From b56346ddbd82f674db02453ecce60dd91f97b78c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Thu, 30 Dec 2021 16:02:38 +0100 Subject: [PATCH] counter: Use container_of instead of drvdata to track counter_device MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The counter core uses drvdata to find a struct counter_device from a struct device. However as the device is a member of struct counter_device, the lookup can be done faster (and a bit type safe) using container_of. There are no other users of drvdata, so the call to dev_set_drvdata can go away, too. Reviewed-by: Jonathan Cameron Acked-by: William Breathitt Gray Signed-off-by: Uwe Kleine-König Link: https://lore.kernel.org/r/20211230150300.72196-2-u.kleine-koenig@pengutronix.de Signed-off-by: Greg Kroah-Hartman --- drivers/counter/counter-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/counter/counter-core.c b/drivers/counter/counter-core.c index 5acc54539623..f053a43c6c04 100644 --- a/drivers/counter/counter-core.c +++ b/drivers/counter/counter-core.c @@ -26,7 +26,8 @@ static DEFINE_IDA(counter_ida); static void counter_device_release(struct device *dev) { - struct counter_device *const counter = dev_get_drvdata(dev); + struct counter_device *const counter = + container_of(dev, struct counter_device, dev); counter_chrdev_remove(counter); ida_free(&counter_ida, dev->id); @@ -78,7 +79,6 @@ int counter_register(struct counter_device *const counter) dev->of_node = counter->parent->of_node; } device_initialize(dev); - dev_set_drvdata(dev, counter); err = counter_sysfs_add(counter); if (err < 0) -- 2.25.1