[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241202163451.1442566-4-mschmidt@redhat.com>
Date: Mon, 2 Dec 2024 17:34:48 +0100
From: Michal Schmidt <mschmidt@...hat.com>
To: Rodolfo Giometti <giometti@...eenne.com>
Cc: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Christophe JAILLET <christophe.jaillet@...adoo.fr>,
"Dr. David Alan Gilbert" <linux@...blig.org>,
Ma Ke <make24@...as.ac.cn>,
Andrew Morton <akpm@...ux-foundation.org>,
George Spelvin <linux@...izon.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH 3/6] pps: use scoped_guard for pps_idr_lock
Use the scoped_guard syntax to be more brief.
Signed-off-by: Michal Schmidt <mschmidt@...hat.com>
---
drivers/pps/pps.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c
index 9a631f6d3a1e..92be7815a621 100644
--- a/drivers/pps/pps.c
+++ b/drivers/pps/pps.c
@@ -323,9 +323,8 @@ static void pps_device_destruct(struct device *dev)
/* Now we can release the ID for re-use */
pr_debug("deallocating pps%d\n", pps->id);
- mutex_lock(&pps_idr_lock);
- idr_remove(&pps_idr, pps->id);
- mutex_unlock(&pps_idr_lock);
+ scoped_guard(mutex, &pps_idr_lock)
+ idr_remove(&pps_idr, pps->id);
kfree(dev);
kfree(pps);
@@ -340,9 +339,8 @@ int pps_register_cdev(struct pps_device *pps)
* Get new ID for the new PPS source. After idr_alloc() calling
* the new source will be freely available into the kernel.
*/
- mutex_lock(&pps_idr_lock);
- err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL);
- mutex_unlock(&pps_idr_lock);
+ scoped_guard(mutex, &pps_idr_lock)
+ err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL);
if (err < 0) {
if (err == -ENOSPC) {
pr_err("%s: too many PPS sources in the system\n",
@@ -387,9 +385,8 @@ int pps_register_cdev(struct pps_device *pps)
cdev_del(&pps->cdev);
free_idr:
- mutex_lock(&pps_idr_lock);
- idr_remove(&pps_idr, pps->id);
- mutex_unlock(&pps_idr_lock);
+ scoped_guard(mutex, &pps_idr_lock)
+ idr_remove(&pps_idr, pps->id);
return err;
}
--
2.47.0
Powered by blists - more mailing lists