counter: Provide a wrapper to access device private data
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thu, 30 Dec 2021 15:02:41 +0000 (16:02 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Dec 2021 16:44:06 +0000 (17:44 +0100)
For now this just wraps accessing struct counter_device::priv. However
this is about to change and converting drivers to this helper
individually makes fixing device lifetime issues result in easier to
review patches.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20211230150300.72196-5-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/counter/counter-core.c
include/linux/counter.h

index f053a43c6c04a9d3353fe4b58ab3600dab5e5bf7..00c41f28c1011ba489e21846fc415200bb1d0263 100644 (file)
@@ -45,6 +45,18 @@ static struct bus_type counter_bus_type = {
 
 static dev_t counter_devt;
 
+/**
+ * counter_priv - access counter device private data
+ * @counter: counter device
+ *
+ * Get the counter device private data
+ */
+void *counter_priv(const struct counter_device *const counter)
+{
+       return counter->priv;
+}
+EXPORT_SYMBOL_GPL(counter_priv);
+
 /**
  * counter_register - register Counter to the system
  * @counter:   pointer to Counter to register
index dfbde2808998d8b5f126e372e5070bcbd44393d8..627f1757f6bbc528eee4eca2bee2d5f96ac6c0d3 100644 (file)
@@ -329,6 +329,8 @@ struct counter_device {
        struct mutex ops_exist_lock;
 };
 
+void *counter_priv(const struct counter_device *const counter);
+
 int counter_register(struct counter_device *const counter);
 void counter_unregister(struct counter_device *const counter);
 int devm_counter_register(struct device *dev,