On Thu, 14 Dec 2023 22:25:27 -0700
Vishal Verma <vishal.l.ve...@intel.com> wrote:

> Use the guard(device) macro to lock a 'struct device', and unlock it
> automatically when going out of scope using Scope Based Resource
> Management semantics. A lot of the sysfs attribute writes in
> drivers/dax/bus.c benefit from a cleanup using these, so change these
> where applicable.
> 
> Cc: Joao Martins <joao.m.mart...@oracle.com>
> Cc: Dan Williams <dan.j.willi...@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>
Hi Vishal,

A few really minor suggestions inline if you happen to be doing a v7.
Either way
Reviewed-by: Jonathan Cameron <jonathan.came...@huawei.com>

>  
> @@ -481,12 +466,9 @@ static int __free_dev_dax_id(struct dev_dax *dev_dax)
>  static int free_dev_dax_id(struct dev_dax *dev_dax)
>  {
>       struct device *dev = &dev_dax->dev;
> -     int rc;
>  
> -     device_lock(dev);
> -     rc = __free_dev_dax_id(dev_dax);
> -     device_unlock(dev);
> -     return rc;
> +     guard(device)(dev);

        guard(device)(&dev_dax->dev); /* Only one user now */
        
> +     return __free_dev_dax_id(dev_dax);
>  }
>  
>  static int alloc_dev_dax_id(struct dev_dax *dev_dax)
> @@ -908,9 +890,8 @@ static ssize_t size_show(struct device *dev,
>       struct dev_dax *dev_dax = to_dev_dax(dev);
>       unsigned long long size;
>  
> -     device_lock(dev);
> +     guard(device)(dev);
>       size = dev_dax_size(dev_dax);
> -     device_unlock(dev);
>  
>       return sprintf(buf, "%llu\n", size);
Might as well make this

        guard(device)(dev);
        return sprintf(buf, "%llu\n", dev_dax_size(to_dev_dax(dev));

>  }





Reply via email to