[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20231219152726.0000228f@Huawei.com>
Date: Tue, 19 Dec 2023 15:27:26 +0000
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
To: Vishal Verma <vishal.l.verma@...el.com>
CC: Dan Williams <dan.j.williams@...el.com>, Dave Jiang
<dave.jiang@...el.com>, Andrew Morton <akpm@...ux-foundation.org>, "Oscar
Salvador" <osalvador@...e.de>, <linux-kernel@...r.kernel.org>,
<nvdimm@...ts.linux.dev>, <linux-cxl@...r.kernel.org>, David Hildenbrand
<david@...hat.com>, Dave Hansen <dave.hansen@...ux.intel.com>, Huang Ying
<ying.huang@...el.com>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
<linux-mm@...ck.org>, Joao Martins <joao.m.martins@...cle.com>
Subject: Re: [PATCH v6 2/4] dax/bus: Use guard(device) in sysfs attribute
helpers
On Thu, 14 Dec 2023 22:25:27 -0700
Vishal Verma <vishal.l.verma@...el.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.martins@...cle.com>
> Cc: Dan Williams <dan.j.williams@...el.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@...el.com>
Hi Vishal,
A few really minor suggestions inline if you happen to be doing a v7.
Either way
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@...wei.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));
> }
Powered by blists - more mailing lists