* [PATCH v2 1/7] driver core: auxiliary bus: add device creation helper
@ 2025-02-11 17:27 ` Jerome Brunet
0 siblings, 0 replies; 13+ messages in thread
From: Jerome Brunet @ 2025-02-06 18:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann
Cc: Jerome Brunet, linux-kernel
Add a function helper to create a device on the auxiliary bus.
This is meant for fairly simple usage of the auxiliary bus, to avoid having
the same code repeated in the different drivers.
Suggested-by: Stephen Boyd <sboyd@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/base/auxiliary.c | 88 +++++++++++++++++++++++++++++++++++++++++++
include/linux/auxiliary_bus.h | 6 +++
2 files changed, 94 insertions(+)
diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
index afa4df4c5a3f371b91d8dd8c4325495d32ad1291..2594ec9a2d6f1696e064989b2bd5145a73beb159 100644
--- a/drivers/base/auxiliary.c
+++ b/drivers/base/auxiliary.c
@@ -385,6 +385,94 @@ void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv)
}
EXPORT_SYMBOL_GPL(auxiliary_driver_unregister);
+static void auxiliary_device_release(struct device *dev)
+{
+ struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
+
+ kfree(auxdev);
+}
+
+static struct auxiliary_device *auxiliary_device_create(struct device *dev,
+ const char *modname,
+ const char *devname,
+ void *platform_data,
+ int id)
+{
+ struct auxiliary_device *auxdev;
+ int ret;
+
+ auxdev = kzalloc(sizeof(*auxdev), GFP_KERNEL);
+ if (!auxdev)
+ return ERR_PTR(-ENOMEM);
+
+ auxdev->id = id;
+ auxdev->name = devname;
+ auxdev->dev.parent = dev;
+ auxdev->dev.platform_data = platform_data;
+ auxdev->dev.release = auxiliary_device_release;
+ device_set_of_node_from_dev(&auxdev->dev, dev);
+
+ ret = auxiliary_device_init(auxdev);
+ if (ret) {
+ kfree(auxdev);
+ return ERR_PTR(ret);
+ }
+
+ ret = __auxiliary_device_add(auxdev, modname);
+ if (ret) {
+ /*
+ * NOTE: It may look odd but auxdev should not be freed
+ * here. auxiliary_device_uninit() calls device_put()
+ * which call the device release function, freeing auxdev.
+ */
+ auxiliary_device_uninit(auxdev);
+ return ERR_PTR(ret);
+ }
+
+ return auxdev;
+}
+
+static void auxiliary_device_destroy(void *_auxdev)
+{
+ struct auxiliary_device *auxdev = _auxdev;
+
+ auxiliary_device_delete(auxdev);
+ auxiliary_device_uninit(auxdev);
+}
+
+/**
+ * devm_auxiliary_device_create - create a device on the auxiliary bus
+ * @dev: parent device
+ * @modname: module name used to create the auxiliary driver name.
+ * @devname: auxiliary bus device name
+ * @platform_data: auxiliary bus device platform data
+ * @id: auxiliary bus device id
+ *
+ * Device managed helper to create an auxiliary bus device.
+ * The device create matches driver 'modname.devname' on the auxiliary bus.
+ */
+struct auxiliary_device *devm_auxiliary_device_create(struct device *dev,
+ const char *modname,
+ const char *devname,
+ void *platform_data,
+ int id)
+{
+ struct auxiliary_device *auxdev;
+ int ret;
+
+ auxdev = auxiliary_device_create(dev, modname, devname, platform_data, id);
+ if (IS_ERR(auxdev))
+ return auxdev;
+
+ ret = devm_add_action_or_reset(dev, auxiliary_device_destroy,
+ auxdev);
+ if (ret)
+ return ERR_PTR(ret);
+
+ return auxdev;
+}
+EXPORT_SYMBOL_GPL(devm_auxiliary_device_create);
+
void __init auxiliary_bus_init(void)
{
WARN_ON(bus_register(&auxiliary_bus_type));
diff --git a/include/linux/auxiliary_bus.h b/include/linux/auxiliary_bus.h
index 65dd7f15437474468acf0e28f6932a7ff2cfff2c..c9ba8e718304c0ce27e16cdf53b18d81a290e4da 100644
--- a/include/linux/auxiliary_bus.h
+++ b/include/linux/auxiliary_bus.h
@@ -254,6 +254,12 @@ int __auxiliary_driver_register(struct auxiliary_driver *auxdrv, struct module *
void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv);
+struct auxiliary_device *devm_auxiliary_device_create(struct device *dev,
+ const char *modname,
+ const char *devname,
+ void *platform_data,
+ int id);
+
/**
* module_auxiliary_driver() - Helper macro for registering an auxiliary driver
* @__auxiliary_driver: auxiliary driver struct
--
2.45.2
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v2 1/7] driver core: auxiliary bus: add device creation helper
@ 2025-02-11 17:27 ` Jerome Brunet
0 siblings, 0 replies; 13+ messages in thread
From: Jerome Brunet @ 2025-02-11 17:27 UTC (permalink / raw)
To: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann
Cc: Jerome Brunet, linux-kernel
Add a function helper to create a device on the auxiliary bus.
This is meant for fairly simple usage of the auxiliary bus, to avoid having
the same code repeated in the different drivers.
Suggested-by: Stephen Boyd <sboyd@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/base/auxiliary.c | 88 +++++++++++++++++++++++++++++++++++++++++++
include/linux/auxiliary_bus.h | 6 +++
2 files changed, 94 insertions(+)
diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
index afa4df4c5a3f371b91d8dd8c4325495d32ad1291..2594ec9a2d6f1696e064989b2bd5145a73beb159 100644
--- a/drivers/base/auxiliary.c
+++ b/drivers/base/auxiliary.c
@@ -385,6 +385,94 @@ void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv)
}
EXPORT_SYMBOL_GPL(auxiliary_driver_unregister);
+static void auxiliary_device_release(struct device *dev)
+{
+ struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
+
+ kfree(auxdev);
+}
+
+static struct auxiliary_device *auxiliary_device_create(struct device *dev,
+ const char *modname,
+ const char *devname,
+ void *platform_data,
+ int id)
+{
+ struct auxiliary_device *auxdev;
+ int ret;
+
+ auxdev = kzalloc(sizeof(*auxdev), GFP_KERNEL);
+ if (!auxdev)
+ return ERR_PTR(-ENOMEM);
+
+ auxdev->id = id;
+ auxdev->name = devname;
+ auxdev->dev.parent = dev;
+ auxdev->dev.platform_data = platform_data;
+ auxdev->dev.release = auxiliary_device_release;
+ device_set_of_node_from_dev(&auxdev->dev, dev);
+
+ ret = auxiliary_device_init(auxdev);
+ if (ret) {
+ kfree(auxdev);
+ return ERR_PTR(ret);
+ }
+
+ ret = __auxiliary_device_add(auxdev, modname);
+ if (ret) {
+ /*
+ * NOTE: It may look odd but auxdev should not be freed
+ * here. auxiliary_device_uninit() calls device_put()
+ * which call the device release function, freeing auxdev.
+ */
+ auxiliary_device_uninit(auxdev);
+ return ERR_PTR(ret);
+ }
+
+ return auxdev;
+}
+
+static void auxiliary_device_destroy(void *_auxdev)
+{
+ struct auxiliary_device *auxdev = _auxdev;
+
+ auxiliary_device_delete(auxdev);
+ auxiliary_device_uninit(auxdev);
+}
+
+/**
+ * devm_auxiliary_device_create - create a device on the auxiliary bus
+ * @dev: parent device
+ * @modname: module name used to create the auxiliary driver name.
+ * @devname: auxiliary bus device name
+ * @platform_data: auxiliary bus device platform data
+ * @id: auxiliary bus device id
+ *
+ * Device managed helper to create an auxiliary bus device.
+ * The device create matches driver 'modname.devname' on the auxiliary bus.
+ */
+struct auxiliary_device *devm_auxiliary_device_create(struct device *dev,
+ const char *modname,
+ const char *devname,
+ void *platform_data,
+ int id)
+{
+ struct auxiliary_device *auxdev;
+ int ret;
+
+ auxdev = auxiliary_device_create(dev, modname, devname, platform_data, id);
+ if (IS_ERR(auxdev))
+ return auxdev;
+
+ ret = devm_add_action_or_reset(dev, auxiliary_device_destroy,
+ auxdev);
+ if (ret)
+ return ERR_PTR(ret);
+
+ return auxdev;
+}
+EXPORT_SYMBOL_GPL(devm_auxiliary_device_create);
+
void __init auxiliary_bus_init(void)
{
WARN_ON(bus_register(&auxiliary_bus_type));
diff --git a/include/linux/auxiliary_bus.h b/include/linux/auxiliary_bus.h
index 65dd7f15437474468acf0e28f6932a7ff2cfff2c..c9ba8e718304c0ce27e16cdf53b18d81a290e4da 100644
--- a/include/linux/auxiliary_bus.h
+++ b/include/linux/auxiliary_bus.h
@@ -254,6 +254,12 @@ int __auxiliary_driver_register(struct auxiliary_driver *auxdrv, struct module *
void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv);
+struct auxiliary_device *devm_auxiliary_device_create(struct device *dev,
+ const char *modname,
+ const char *devname,
+ void *platform_data,
+ int id);
+
/**
* module_auxiliary_driver() - Helper macro for registering an auxiliary driver
* @__auxiliary_driver: auxiliary driver struct
--
2.45.2
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v2 1/7] driver core: auxiliary bus: add device creation helper
2025-02-11 17:27 ` Jerome Brunet
(?)
@ 2025-02-07 2:32 ` Ira Weiny
-1 siblings, 0 replies; 13+ messages in thread
From: Ira Weiny @ 2025-02-07 2:32 UTC (permalink / raw)
To: Jerome Brunet, Greg Kroah-Hartman, Dave Ertman, Ira Weiny,
Rafael J. Wysocki, Stephen Boyd, Arnd Bergmann
Cc: Jerome Brunet, linux-kernel
Jerome Brunet wrote:
[snip]
Overall this seems like a net benefit!
9 files changed, 160 insertions(+), 348 deletions(-)
1 suggestion I can see though.
> +
> +/**
> + * devm_auxiliary_device_create - create a device on the auxiliary bus
> + * @dev: parent device
> + * @modname: module name used to create the auxiliary driver name.
> + * @devname: auxiliary bus device name
> + * @platform_data: auxiliary bus device platform data
> + * @id: auxiliary bus device id
> + *
> + * Device managed helper to create an auxiliary bus device.
> + * The device create matches driver 'modname.devname' on the auxiliary bus.
> + */
> +struct auxiliary_device *devm_auxiliary_device_create(struct device *dev,
> + const char *modname,
> + const char *devname,
> + void *platform_data,
> + int id)
Almost all of the devm_auxiliary_device_create() calls use KBUILD_MODNAME
as the modname. It seems cleaner to wrap this in a macro like
auxiliary_device_add/__auxiliary_device_add.
Then use __devm_auxiliary_device_create() with the modname for the one
special case.
Ira
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 2/7] reset: mpfs: use the auxiliary device creation helper
2025-02-06 18:23 [PATCH v2 0/7] driver core: auxiliary bus: add device creation helper Jerome Brunet
2025-02-11 17:27 ` Jerome Brunet
@ 2025-02-06 18:23 ` Jerome Brunet
2025-02-06 18:23 ` [PATCH v2 3/7] drm/bridge: ti-sn65dsi86: " Jerome Brunet
` (5 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Jerome Brunet @ 2025-02-06 18:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann
Cc: Jerome Brunet, linux-kernel
The auxiliary device creation of this driver is simple enough to
use the available auxiliary device creation helper.
Use it and remove some boilerplate code.
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/reset/reset-mpfs.c | 53 ++++------------------------------------------
1 file changed, 4 insertions(+), 49 deletions(-)
diff --git a/drivers/reset/reset-mpfs.c b/drivers/reset/reset-mpfs.c
index 574e59db83a4fcf30b60cb5f638607a2ec7b0580..61b8eb42faed809cbffd944f21927236833b2c0e 100644
--- a/drivers/reset/reset-mpfs.c
+++ b/drivers/reset/reset-mpfs.c
@@ -155,62 +155,17 @@ static int mpfs_reset_probe(struct auxiliary_device *adev,
return devm_reset_controller_register(dev, rcdev);
}
-static void mpfs_reset_unregister_adev(void *_adev)
-{
- struct auxiliary_device *adev = _adev;
-
- auxiliary_device_delete(adev);
- auxiliary_device_uninit(adev);
-}
-
-static void mpfs_reset_adev_release(struct device *dev)
-{
- struct auxiliary_device *adev = to_auxiliary_dev(dev);
-
- kfree(adev);
-}
-
-static struct auxiliary_device *mpfs_reset_adev_alloc(struct device *clk_dev)
-{
- struct auxiliary_device *adev;
- int ret;
-
- adev = kzalloc(sizeof(*adev), GFP_KERNEL);
- if (!adev)
- return ERR_PTR(-ENOMEM);
-
- adev->name = "reset-mpfs";
- adev->dev.parent = clk_dev;
- adev->dev.release = mpfs_reset_adev_release;
- adev->id = 666u;
-
- ret = auxiliary_device_init(adev);
- if (ret) {
- kfree(adev);
- return ERR_PTR(ret);
- }
-
- return adev;
-}
-
int mpfs_reset_controller_register(struct device *clk_dev, void __iomem *base)
{
struct auxiliary_device *adev;
- int ret;
- adev = mpfs_reset_adev_alloc(clk_dev);
+ adev = devm_auxiliary_device_create(clk_dev, KBUILD_MODNAME,
+ "reset-mpfs", (__force void *)base,
+ 666u);
if (IS_ERR(adev))
return PTR_ERR(adev);
- ret = auxiliary_device_add(adev);
- if (ret) {
- auxiliary_device_uninit(adev);
- return ret;
- }
-
- adev->dev.platform_data = (__force void *)base;
-
- return devm_add_action_or_reset(clk_dev, mpfs_reset_unregister_adev, adev);
+ return 0;
}
EXPORT_SYMBOL_NS_GPL(mpfs_reset_controller_register, "MCHP_CLK_MPFS");
--
2.45.2
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v2 3/7] drm/bridge: ti-sn65dsi86: use the auxiliary device creation helper
2025-02-06 18:23 [PATCH v2 0/7] driver core: auxiliary bus: add device creation helper Jerome Brunet
2025-02-11 17:27 ` Jerome Brunet
2025-02-06 18:23 ` [PATCH v2 2/7] reset: mpfs: use the auxiliary " Jerome Brunet
@ 2025-02-06 18:23 ` Jerome Brunet
2025-02-06 18:23 ` [PATCH v2 4/7] platform: arm64: lenovo-yoga-c630: " Jerome Brunet
` (4 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Jerome Brunet @ 2025-02-06 18:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann
Cc: Jerome Brunet, linux-kernel
The auxiliary device creation of this driver is simple enough to
use the available auxiliary device creation helper.
Use it and remove some boilerplate code.
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/gpu/drm/bridge/ti-sn65dsi86.c | 88 ++++++++++-------------------------
1 file changed, 24 insertions(+), 64 deletions(-)
diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
index e4d9006b59f1b975cf63e26b221e985206caf867..bd618f497a3f0e1d08e46e98deea3de7d7db8bd5 100644
--- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c
+++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
@@ -454,62 +454,6 @@ static void ti_sn65dsi86_debugfs_init(struct ti_sn65dsi86 *pdata)
debugfs_create_file("status", 0600, debugfs, pdata, &status_fops);
}
-/* -----------------------------------------------------------------------------
- * Auxiliary Devices (*not* AUX)
- */
-
-static void ti_sn65dsi86_uninit_aux(void *data)
-{
- auxiliary_device_uninit(data);
-}
-
-static void ti_sn65dsi86_delete_aux(void *data)
-{
- auxiliary_device_delete(data);
-}
-
-static void ti_sn65dsi86_aux_device_release(struct device *dev)
-{
- struct auxiliary_device *aux = container_of(dev, struct auxiliary_device, dev);
-
- kfree(aux);
-}
-
-static int ti_sn65dsi86_add_aux_device(struct ti_sn65dsi86 *pdata,
- struct auxiliary_device **aux_out,
- const char *name)
-{
- struct device *dev = pdata->dev;
- struct auxiliary_device *aux;
- int ret;
-
- aux = kzalloc(sizeof(*aux), GFP_KERNEL);
- if (!aux)
- return -ENOMEM;
-
- aux->name = name;
- aux->dev.parent = dev;
- aux->dev.release = ti_sn65dsi86_aux_device_release;
- device_set_of_node_from_dev(&aux->dev, dev);
- ret = auxiliary_device_init(aux);
- if (ret) {
- kfree(aux);
- return ret;
- }
- ret = devm_add_action_or_reset(dev, ti_sn65dsi86_uninit_aux, aux);
- if (ret)
- return ret;
-
- ret = auxiliary_device_add(aux);
- if (ret)
- return ret;
- ret = devm_add_action_or_reset(dev, ti_sn65dsi86_delete_aux, aux);
- if (!ret)
- *aux_out = aux;
-
- return ret;
-}
-
/* -----------------------------------------------------------------------------
* AUX Adapter
*/
@@ -671,7 +615,13 @@ static int ti_sn_aux_probe(struct auxiliary_device *adev,
* The eDP to MIPI bridge parts don't work until the AUX channel is
* setup so we don't add it in the main driver probe, we add it now.
*/
- return ti_sn65dsi86_add_aux_device(pdata, &pdata->bridge_aux, "bridge");
+ pdata->bridge_aux = devm_auxiliary_device_create(pdata->dev,
+ KBUILD_MODNAME,
+ "bridge", NULL, 0);
+ if (IS_ERR(pdata->bridge_aux))
+ return PTR_ERR(pdata->bridge_aux);
+
+ return 0;
}
static const struct auxiliary_device_id ti_sn_aux_id_table[] = {
@@ -1950,15 +1900,19 @@ static int ti_sn65dsi86_probe(struct i2c_client *client)
*/
if (IS_ENABLED(CONFIG_OF_GPIO)) {
- ret = ti_sn65dsi86_add_aux_device(pdata, &pdata->gpio_aux, "gpio");
- if (ret)
- return ret;
+ pdata->gpio_aux = devm_auxiliary_device_create(pdata->dev,
+ KBUILD_MODNAME,
+ "gpio", NULL, 0);
+ if (IS_ERR(pdata->gpio_aux))
+ return PTR_ERR(pdata->gpio_aux);
}
if (IS_ENABLED(CONFIG_PWM)) {
- ret = ti_sn65dsi86_add_aux_device(pdata, &pdata->pwm_aux, "pwm");
- if (ret)
- return ret;
+ pdata->pwm_aux = devm_auxiliary_device_create(pdata->dev,
+ KBUILD_MODNAME,
+ "pwm", NULL, 0);
+ if (IS_ERR(pdata->pwm_aux))
+ return PTR_ERR(pdata->pwm_aux);
}
/*
@@ -1967,7 +1921,13 @@ static int ti_sn65dsi86_probe(struct i2c_client *client)
* AUX channel is there and this is a very simple solution to the
* dependency problem.
*/
- return ti_sn65dsi86_add_aux_device(pdata, &pdata->aux_aux, "aux");
+ pdata->aux_aux = devm_auxiliary_device_create(pdata->dev,
+ KBUILD_MODNAME,
+ "aux", NULL, 0);
+ if (IS_ERR(pdata->aux_aux))
+ return PTR_ERR(pdata->aux_aux);
+
+ return 0;
}
static const struct i2c_device_id ti_sn65dsi86_id[] = {
--
2.45.2
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v2 4/7] platform: arm64: lenovo-yoga-c630: use the auxiliary device creation helper
2025-02-06 18:23 [PATCH v2 0/7] driver core: auxiliary bus: add device creation helper Jerome Brunet
` (2 preceding siblings ...)
2025-02-06 18:23 ` [PATCH v2 3/7] drm/bridge: ti-sn65dsi86: " Jerome Brunet
@ 2025-02-06 18:23 ` Jerome Brunet
2025-02-06 18:23 ` [PATCH v2 5/7] clk: eyeq: " Jerome Brunet
` (3 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Jerome Brunet @ 2025-02-06 18:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann
Cc: Jerome Brunet, linux-kernel
The auxiliary device creation of this driver is simple enough to
use the available auxiliary device creation helper.
Use it and remove some boilerplate code.
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/platform/arm64/lenovo-yoga-c630.c | 43 ++++---------------------------
1 file changed, 5 insertions(+), 38 deletions(-)
diff --git a/drivers/platform/arm64/lenovo-yoga-c630.c b/drivers/platform/arm64/lenovo-yoga-c630.c
index 1f05c9a6a89d5ee146144062f5d2e36795c56639..b17b728f6a30eff301ce3f903f7a6e4bea2bbfcc 100644
--- a/drivers/platform/arm64/lenovo-yoga-c630.c
+++ b/drivers/platform/arm64/lenovo-yoga-c630.c
@@ -191,50 +191,17 @@ void yoga_c630_ec_unregister_notify(struct yoga_c630_ec *ec, struct notifier_blo
}
EXPORT_SYMBOL_GPL(yoga_c630_ec_unregister_notify);
-static void yoga_c630_aux_release(struct device *dev)
-{
- struct auxiliary_device *adev = to_auxiliary_dev(dev);
-
- kfree(adev);
-}
-
-static void yoga_c630_aux_remove(void *data)
-{
- struct auxiliary_device *adev = data;
-
- auxiliary_device_delete(adev);
- auxiliary_device_uninit(adev);
-}
-
static int yoga_c630_aux_init(struct device *parent, const char *name,
struct yoga_c630_ec *ec)
{
struct auxiliary_device *adev;
- int ret;
-
- adev = kzalloc(sizeof(*adev), GFP_KERNEL);
- if (!adev)
- return -ENOMEM;
-
- adev->name = name;
- adev->id = 0;
- adev->dev.parent = parent;
- adev->dev.release = yoga_c630_aux_release;
- adev->dev.platform_data = ec;
- ret = auxiliary_device_init(adev);
- if (ret) {
- kfree(adev);
- return ret;
- }
-
- ret = auxiliary_device_add(adev);
- if (ret) {
- auxiliary_device_uninit(adev);
- return ret;
- }
+ adev = devm_auxiliary_device_create(parent, KBUILD_MODNAME,
+ name, ec, 0);
+ if (IS_ERR(adev))
+ return PTR_ERR(adev);
- return devm_add_action_or_reset(parent, yoga_c630_aux_remove, adev);
+ return 0;
}
static int yoga_c630_ec_probe(struct i2c_client *client)
--
2.45.2
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v2 5/7] clk: eyeq: use the auxiliary device creation helper
2025-02-06 18:23 [PATCH v2 0/7] driver core: auxiliary bus: add device creation helper Jerome Brunet
` (3 preceding siblings ...)
2025-02-06 18:23 ` [PATCH v2 4/7] platform: arm64: lenovo-yoga-c630: " Jerome Brunet
@ 2025-02-06 18:23 ` Jerome Brunet
2025-02-06 18:23 ` [PATCH v2 6/7] clk: clk-imx8mp-audiomix: " Jerome Brunet
` (2 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Jerome Brunet @ 2025-02-06 18:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann
Cc: Jerome Brunet, linux-kernel
The auxiliary device creation of this driver is simple enough to
use the available auxiliary device creation helper.
Use it and remove some boilerplate code.
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/clk/clk-eyeq.c | 57 +++++++++++---------------------------------------
1 file changed, 12 insertions(+), 45 deletions(-)
diff --git a/drivers/clk/clk-eyeq.c b/drivers/clk/clk-eyeq.c
index 640c25788487f8cf6fb4431ed6fb612cf099f114..e5d030abd61f05813d4df35189f046dbd4f4b185 100644
--- a/drivers/clk/clk-eyeq.c
+++ b/drivers/clk/clk-eyeq.c
@@ -322,38 +322,18 @@ static void eqc_probe_init_fixed_factors(struct device *dev,
}
}
-static void eqc_auxdev_release(struct device *dev)
-{
- struct auxiliary_device *adev = to_auxiliary_dev(dev);
-
- kfree(adev);
-}
-
-static int eqc_auxdev_create(struct device *dev, void __iomem *base,
- const char *name, u32 id)
+static void eqc_auxdev_create_optional(struct device *dev, void __iomem *base,
+ const char *name)
{
struct auxiliary_device *adev;
- int ret;
-
- adev = kzalloc(sizeof(*adev), GFP_KERNEL);
- if (!adev)
- return -ENOMEM;
-
- adev->name = name;
- adev->dev.parent = dev;
- adev->dev.platform_data = (void __force *)base;
- adev->dev.release = eqc_auxdev_release;
- adev->id = id;
- ret = auxiliary_device_init(adev);
- if (ret)
- return ret;
-
- ret = auxiliary_device_add(adev);
- if (ret)
- auxiliary_device_uninit(adev);
-
- return ret;
+ if (name) {
+ adev = devm_auxiliary_device_create(dev, KBUILD_MODNAME,
+ name, (void __force *)base, 0);
+ if (IS_ERR(adev))
+ dev_warn(dev, "failed creating auxiliary device %s.%s: %ld\n",
+ KBUILD_MODNAME, name, PTR_ERR(adev));
+ }
}
static int eqc_probe(struct platform_device *pdev)
@@ -365,7 +345,6 @@ static int eqc_probe(struct platform_device *pdev)
unsigned int i, clk_count;
struct resource *res;
void __iomem *base;
- int ret;
data = device_get_match_data(dev);
if (!data)
@@ -379,21 +358,9 @@ static int eqc_probe(struct platform_device *pdev)
if (!base)
return -ENOMEM;
- /* Init optional reset auxiliary device. */
- if (data->reset_auxdev_name) {
- ret = eqc_auxdev_create(dev, base, data->reset_auxdev_name, 0);
- if (ret)
- dev_warn(dev, "failed creating auxiliary device %s.%s: %d\n",
- KBUILD_MODNAME, data->reset_auxdev_name, ret);
- }
-
- /* Init optional pinctrl auxiliary device. */
- if (data->pinctrl_auxdev_name) {
- ret = eqc_auxdev_create(dev, base, data->pinctrl_auxdev_name, 0);
- if (ret)
- dev_warn(dev, "failed creating auxiliary device %s.%s: %d\n",
- KBUILD_MODNAME, data->pinctrl_auxdev_name, ret);
- }
+ /* Init optional auxiliary devices. */
+ eqc_auxdev_create_optional(dev, base, data->reset_auxdev_name);
+ eqc_auxdev_create_optional(dev, base, data->pinctrl_auxdev_name);
if (data->pll_count + data->div_count + data->fixed_factor_count == 0)
return 0; /* Zero clocks, we are done. */
--
2.45.2
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v2 6/7] clk: clk-imx8mp-audiomix: use the auxiliary device creation helper
2025-02-06 18:23 [PATCH v2 0/7] driver core: auxiliary bus: add device creation helper Jerome Brunet
` (4 preceding siblings ...)
2025-02-06 18:23 ` [PATCH v2 5/7] clk: eyeq: " Jerome Brunet
@ 2025-02-06 18:23 ` Jerome Brunet
2025-02-12 7:26 ` Dan Carpenter
2025-02-06 18:23 ` [PATCH v2 7/7] clk: amlogic: axg-audio: use the auxiliary reset driver - take 2 Jerome Brunet
2025-02-06 18:32 ` [PATCH v2 0/7] driver core: auxiliary bus: add device creation helper Jerome Brunet
7 siblings, 1 reply; 13+ messages in thread
From: Jerome Brunet @ 2025-02-06 18:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann
Cc: Jerome Brunet, linux-kernel
The auxiliary device creation of this driver is simple enough to
use the available auxiliary device creation helper.
Use it and remove some boilerplate code.
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
drivers/clk/imx/clk-imx8mp-audiomix.c | 57 +++++------------------------------
1 file changed, 7 insertions(+), 50 deletions(-)
diff --git a/drivers/clk/imx/clk-imx8mp-audiomix.c b/drivers/clk/imx/clk-imx8mp-audiomix.c
index c409fc7e061869988f83c7df3ef7860500426323..90e69e253ad5a30cd2a3cb3b63ebe85be1e6b059 100644
--- a/drivers/clk/imx/clk-imx8mp-audiomix.c
+++ b/drivers/clk/imx/clk-imx8mp-audiomix.c
@@ -228,64 +228,21 @@ struct clk_imx8mp_audiomix_priv {
struct clk_hw_onecell_data clk_data;
};
-#if IS_ENABLED(CONFIG_RESET_CONTROLLER)
-
-static void clk_imx8mp_audiomix_reset_unregister_adev(void *_adev)
-{
- struct auxiliary_device *adev = _adev;
-
- auxiliary_device_delete(adev);
- auxiliary_device_uninit(adev);
-}
-
-static void clk_imx8mp_audiomix_reset_adev_release(struct device *dev)
+static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev)
{
- struct auxiliary_device *adev = to_auxiliary_dev(dev);
-
- kfree(adev);
-}
-
-static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev,
- struct clk_imx8mp_audiomix_priv *priv)
-{
- struct auxiliary_device *adev __free(kfree) = NULL;
- int ret;
+ struct auxiliary_device *adev;
if (!of_property_present(dev->of_node, "#reset-cells"))
return 0;
- adev = kzalloc(sizeof(*adev), GFP_KERNEL);
- if (!adev)
- return -ENOMEM;
-
- adev->name = "reset";
- adev->dev.parent = dev;
- adev->dev.release = clk_imx8mp_audiomix_reset_adev_release;
-
- ret = auxiliary_device_init(adev);
- if (ret)
- return ret;
-
- ret = auxiliary_device_add(adev);
- if (ret) {
- auxiliary_device_uninit(adev);
- return ret;
- }
-
- return devm_add_action_or_reset(dev, clk_imx8mp_audiomix_reset_unregister_adev,
- no_free_ptr(adev));
-}
-
-#else /* !CONFIG_RESET_CONTROLLER */
+ adev = devm_auxiliary_device_create(dev, KBUILD_MODNAME,
+ "reset", NULL, 0);
+ if (IS_ERR_OR_NULL(adev))
+ return PTR_ERR(adev);
-static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev,
- struct clk_imx8mp_audiomix_priv *priv)
-{
return 0;
}
-#endif /* !CONFIG_RESET_CONTROLLER */
-
static void clk_imx8mp_audiomix_save_restore(struct device *dev, bool save)
{
struct clk_imx8mp_audiomix_priv *priv = dev_get_drvdata(dev);
@@ -408,7 +365,7 @@ static int clk_imx8mp_audiomix_probe(struct platform_device *pdev)
if (ret)
goto err_clk_register;
- ret = clk_imx8mp_audiomix_reset_controller_register(dev, priv);
+ ret = clk_imx8mp_audiomix_reset_controller_register(dev);
if (ret)
goto err_clk_register;
--
2.45.2
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v2 6/7] clk: clk-imx8mp-audiomix: use the auxiliary device creation helper
2025-02-06 18:23 ` [PATCH v2 6/7] clk: clk-imx8mp-audiomix: " Jerome Brunet
@ 2025-02-12 7:26 ` Dan Carpenter
2025-02-12 10:16 ` Jerome Brunet
0 siblings, 1 reply; 13+ messages in thread
From: Dan Carpenter @ 2025-02-12 7:26 UTC (permalink / raw)
To: oe-kbuild, Jerome Brunet, Greg Kroah-Hartman, Dave Ertman,
Ira Weiny, Rafael J. Wysocki, Stephen Boyd, Arnd Bergmann
Cc: lkp, oe-kbuild-all, Jerome Brunet, linux-kernel
Hi Jerome,
kernel test robot noticed the following build warnings:
url: https://github.com/intel-lab-lkp/linux/commits/Jerome-Brunet/driver-core-auxiliary-bus-add-device-creation-helper/20250207-023433
base: 2014c95afecee3e76ca4a56956a936e23283f05b
patch link: https://lore.kernel.org/r/20250206-aux-device-create-helper-v2-6-fa6a0f326527%40baylibre.com
patch subject: [PATCH v2 6/7] clk: clk-imx8mp-audiomix: use the auxiliary device creation helper
config: xtensa-randconfig-r071-20250208 (https://download.01.org/0day-ci/archive/20250208/202502081655.FlCrxpYN-lkp@intel.com/config)
compiler: xtensa-linux-gcc (GCC) 14.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202502081655.FlCrxpYN-lkp@intel.com/
smatch warnings:
drivers/clk/imx/clk-imx8mp-audiomix.c:241 clk_imx8mp_audiomix_reset_controller_register() warn: passing zero to 'PTR_ERR'
vim +/PTR_ERR +241 drivers/clk/imx/clk-imx8mp-audiomix.c
c350f4c434316c Jerome Brunet 2025-02-06 231 static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev)
6f0e817175c5b2 Shengjiu Wang 2024-06-14 232 {
c350f4c434316c Jerome Brunet 2025-02-06 233 struct auxiliary_device *adev;
6f0e817175c5b2 Shengjiu Wang 2024-06-14 234
6f0e817175c5b2 Shengjiu Wang 2024-06-14 235 if (!of_property_present(dev->of_node, "#reset-cells"))
6f0e817175c5b2 Shengjiu Wang 2024-06-14 236 return 0;
6f0e817175c5b2 Shengjiu Wang 2024-06-14 237
c350f4c434316c Jerome Brunet 2025-02-06 238 adev = devm_auxiliary_device_create(dev, KBUILD_MODNAME,
c350f4c434316c Jerome Brunet 2025-02-06 239 "reset", NULL, 0);
c350f4c434316c Jerome Brunet 2025-02-06 240 if (IS_ERR_OR_NULL(adev))
c350f4c434316c Jerome Brunet 2025-02-06 @241 return PTR_ERR(adev);
If devm_auxiliary_device_create() could return NULL then that would count
as success. But devm_auxiliary_device_create() can't return NULL. It
only makes sense to return NULL if the auxiliary device is optional.
https://staticthinking.wordpress.com/2022/08/01/mixing-error-pointers-and-null/
6f0e817175c5b2 Shengjiu Wang 2024-06-14 242
6f0e817175c5b2 Shengjiu Wang 2024-06-14 243 return 0;
6f0e817175c5b2 Shengjiu Wang 2024-06-14 244 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v2 6/7] clk: clk-imx8mp-audiomix: use the auxiliary device creation helper
2025-02-12 7:26 ` Dan Carpenter
@ 2025-02-12 10:16 ` Jerome Brunet
0 siblings, 0 replies; 13+ messages in thread
From: Jerome Brunet @ 2025-02-12 10:16 UTC (permalink / raw)
To: Dan Carpenter
Cc: oe-kbuild, Greg Kroah-Hartman, Dave Ertman, Ira Weiny,
Rafael J. Wysocki, Stephen Boyd, Arnd Bergmann, lkp,
oe-kbuild-all, linux-kernel
On Wed 12 Feb 2025 at 10:26, Dan Carpenter <dan.carpenter@linaro.org> wrote:
> Hi Jerome,
>
> kernel test robot noticed the following build warnings:
>
> url:
> https://github.com/intel-lab-lkp/linux/commits/Jerome-Brunet/driver-core-auxiliary-bus-add-device-creation-helper/20250207-023433
> base: 2014c95afecee3e76ca4a56956a936e23283f05b
> patch link: https://lore.kernel.org/r/20250206-aux-device-create-helper-v2-6-fa6a0f326527%40baylibre.com
> patch subject: [PATCH v2 6/7] clk: clk-imx8mp-audiomix: use the auxiliary device creation helper
> config: xtensa-randconfig-r071-20250208
> (https://download.01.org/0day-ci/archive/20250208/202502081655.FlCrxpYN-lkp@intel.com/config)
> compiler: xtensa-linux-gcc (GCC) 14.2.0
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> | Closes: https://lore.kernel.org/r/202502081655.FlCrxpYN-lkp@intel.com/
>
> smatch warnings:
> drivers/clk/imx/clk-imx8mp-audiomix.c:241
> clk_imx8mp_audiomix_reset_controller_register() warn: passing zero to
> 'PTR_ERR'
>
> vim +/PTR_ERR +241 drivers/clk/imx/clk-imx8mp-audiomix.c
>
> c350f4c434316c Jerome Brunet 2025-02-06 231 static int
> clk_imx8mp_audiomix_reset_controller_register(struct device *dev)
> 6f0e817175c5b2 Shengjiu Wang 2024-06-14 232 {
> c350f4c434316c Jerome Brunet 2025-02-06 233 struct auxiliary_device *adev;
> 6f0e817175c5b2 Shengjiu Wang 2024-06-14 234
> 6f0e817175c5b2 Shengjiu Wang 2024-06-14 235 if (!of_property_present(dev->of_node, "#reset-cells"))
> 6f0e817175c5b2 Shengjiu Wang 2024-06-14 236 return 0;
> 6f0e817175c5b2 Shengjiu Wang 2024-06-14 237
> c350f4c434316c Jerome Brunet 2025-02-06 238 adev = devm_auxiliary_device_create(dev, KBUILD_MODNAME,
> c350f4c434316c Jerome Brunet 2025-02-06 239 "reset", NULL, 0);
> c350f4c434316c Jerome Brunet 2025-02-06 240 if (IS_ERR_OR_NULL(adev))
> c350f4c434316c Jerome Brunet 2025-02-06 @241 return PTR_ERR(adev);
>
> If devm_auxiliary_device_create() could return NULL then that would count
> as success. But devm_auxiliary_device_create() can't return NULL. It
> only makes sense to return NULL if the auxiliary device is optional.
Hi Dan,
It should have been IS_ERR() there. It is something I've noticed and
fixed in the other changes before submitting the v2 but, somehow, this
one slipped through. Thanks for catching this. This is obviously still
present in the v3 I've sent yesterday but will be fixed on the next
version. I'm waiting for feedback on the core part before making another
one.
Cheers
>
> https://staticthinking.wordpress.com/2022/08/01/mixing-error-pointers-and-null/
>
> 6f0e817175c5b2 Shengjiu Wang 2024-06-14 242
> 6f0e817175c5b2 Shengjiu Wang 2024-06-14 243 return 0;
> 6f0e817175c5b2 Shengjiu Wang 2024-06-14 244 }
--
Jerome
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 7/7] clk: amlogic: axg-audio: use the auxiliary reset driver - take 2
2025-02-06 18:23 [PATCH v2 0/7] driver core: auxiliary bus: add device creation helper Jerome Brunet
` (5 preceding siblings ...)
2025-02-06 18:23 ` [PATCH v2 6/7] clk: clk-imx8mp-audiomix: " Jerome Brunet
@ 2025-02-06 18:23 ` Jerome Brunet
2025-02-06 18:32 ` [PATCH v2 0/7] driver core: auxiliary bus: add device creation helper Jerome Brunet
7 siblings, 0 replies; 13+ messages in thread
From: Jerome Brunet @ 2025-02-06 18:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann
Cc: Jerome Brunet, linux-kernel
Remove the implementation of the reset driver in axg audio
clock driver and migrate to the one provided by reset framework
on the auxiliary bus.
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
There has been a discussion about the use on imply here.
After re-reading the documentation I've decided to stick with
imply in this version:
> This is useful e.g. with multiple drivers that want to indicate their
> ability to hook into a secondary subsystem while allowing the user to
> configure that subsystem out without also having to unset these drivers.
IMO, this is a pretty accurate description of the use case in this change.
The pitfall mentioned in the doc does not apply as there is not link error
regardless of the config of RESET_MESON_AUX.
I also think this is more readeable and maintainable than a bunch of
'default CONFIG_FOO if CONFIG_FOO' for CONFIG_RESET_MESON_AUX. This approach
also would have several pitfall, such as picking the value of the first config
set or the config of RESET_MESON_AUX staying to 'n' if CONFIG_FOO is turned on
with menuconfig.
drivers/clk/meson/Kconfig | 2 +-
drivers/clk/meson/axg-audio.c | 114 +++++-------------------------------------
2 files changed, 14 insertions(+), 102 deletions(-)
diff --git a/drivers/clk/meson/Kconfig b/drivers/clk/meson/Kconfig
index be2e3a5f83363b07cdcec2601acf15780ff24892..7cb21fc223b063cb93812643f02f192343981ed8 100644
--- a/drivers/clk/meson/Kconfig
+++ b/drivers/clk/meson/Kconfig
@@ -106,7 +106,7 @@ config COMMON_CLK_AXG_AUDIO
select COMMON_CLK_MESON_SCLK_DIV
select COMMON_CLK_MESON_CLKC_UTILS
select REGMAP_MMIO
- select RESET_CONTROLLER
+ imply RESET_MESON_AUX
help
Support for the audio clock controller on AmLogic A113D devices,
aka axg, Say Y if you want audio subsystem to work.
diff --git a/drivers/clk/meson/axg-audio.c b/drivers/clk/meson/axg-audio.c
index 9df627b142f89788966ede0262aaaf39e13f0b49..172d3e8157d2e9a6f3cdc4ed7bea89791824493a 100644
--- a/drivers/clk/meson/axg-audio.c
+++ b/drivers/clk/meson/axg-audio.c
@@ -4,6 +4,7 @@
* Author: Jerome Brunet <jbrunet@baylibre.com>
*/
+#include <linux/auxiliary_bus.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/init.h>
@@ -12,7 +13,6 @@
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/reset.h>
-#include <linux/reset-controller.h>
#include <linux/slab.h>
#include "meson-clkc-utils.h"
@@ -1678,84 +1678,6 @@ static struct clk_regmap *const sm1_clk_regmaps[] = {
&sm1_earcrx_dmac_clk,
};
-struct axg_audio_reset_data {
- struct reset_controller_dev rstc;
- struct regmap *map;
- unsigned int offset;
-};
-
-static void axg_audio_reset_reg_and_bit(struct axg_audio_reset_data *rst,
- unsigned long id,
- unsigned int *reg,
- unsigned int *bit)
-{
- unsigned int stride = regmap_get_reg_stride(rst->map);
-
- *reg = (id / (stride * BITS_PER_BYTE)) * stride;
- *reg += rst->offset;
- *bit = id % (stride * BITS_PER_BYTE);
-}
-
-static int axg_audio_reset_update(struct reset_controller_dev *rcdev,
- unsigned long id, bool assert)
-{
- struct axg_audio_reset_data *rst =
- container_of(rcdev, struct axg_audio_reset_data, rstc);
- unsigned int offset, bit;
-
- axg_audio_reset_reg_and_bit(rst, id, &offset, &bit);
-
- regmap_update_bits(rst->map, offset, BIT(bit),
- assert ? BIT(bit) : 0);
-
- return 0;
-}
-
-static int axg_audio_reset_status(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- struct axg_audio_reset_data *rst =
- container_of(rcdev, struct axg_audio_reset_data, rstc);
- unsigned int val, offset, bit;
-
- axg_audio_reset_reg_and_bit(rst, id, &offset, &bit);
-
- regmap_read(rst->map, offset, &val);
-
- return !!(val & BIT(bit));
-}
-
-static int axg_audio_reset_assert(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- return axg_audio_reset_update(rcdev, id, true);
-}
-
-static int axg_audio_reset_deassert(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- return axg_audio_reset_update(rcdev, id, false);
-}
-
-static int axg_audio_reset_toggle(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- int ret;
-
- ret = axg_audio_reset_assert(rcdev, id);
- if (ret)
- return ret;
-
- return axg_audio_reset_deassert(rcdev, id);
-}
-
-static const struct reset_control_ops axg_audio_rstc_ops = {
- .assert = axg_audio_reset_assert,
- .deassert = axg_audio_reset_deassert,
- .reset = axg_audio_reset_toggle,
- .status = axg_audio_reset_status,
-};
-
static struct regmap_config axg_audio_regmap_cfg = {
.reg_bits = 32,
.val_bits = 32,
@@ -1766,8 +1688,7 @@ struct audioclk_data {
struct clk_regmap *const *regmap_clks;
unsigned int regmap_clk_num;
struct meson_clk_hw_data hw_clks;
- unsigned int reset_offset;
- unsigned int reset_num;
+ const char *rst_drvname;
unsigned int max_register;
};
@@ -1775,7 +1696,7 @@ static int axg_audio_clkc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
const struct audioclk_data *data;
- struct axg_audio_reset_data *rst;
+ struct auxiliary_device *auxdev;
struct regmap *map;
void __iomem *regs;
struct clk_hw *hw;
@@ -1834,22 +1755,15 @@ static int axg_audio_clkc_probe(struct platform_device *pdev)
if (ret)
return ret;
- /* Stop here if there is no reset */
- if (!data->reset_num)
- return 0;
-
- rst = devm_kzalloc(dev, sizeof(*rst), GFP_KERNEL);
- if (!rst)
- return -ENOMEM;
-
- rst->map = map;
- rst->offset = data->reset_offset;
- rst->rstc.nr_resets = data->reset_num;
- rst->rstc.ops = &axg_audio_rstc_ops;
- rst->rstc.of_node = dev->of_node;
- rst->rstc.owner = THIS_MODULE;
+ /* Register auxiliary reset driver when applicable */
+ if (data->rst_drvname) {
+ auxdev = devm_auxiliary_device_create(dev, dev->driver->name,
+ data->rst_drvname, NULL, 0);
+ if (IS_ERR(auxdev))
+ return PTR_ERR(auxdev);
+ }
- return devm_reset_controller_register(dev, &rst->rstc);
+ return 0;
}
static const struct audioclk_data axg_audioclk_data = {
@@ -1869,8 +1783,7 @@ static const struct audioclk_data g12a_audioclk_data = {
.hws = g12a_audio_hw_clks,
.num = ARRAY_SIZE(g12a_audio_hw_clks),
},
- .reset_offset = AUDIO_SW_RESET,
- .reset_num = 26,
+ .rst_drvname = "rst-g12a",
.max_register = AUDIO_CLK_SPDIFOUT_B_CTRL,
};
@@ -1881,8 +1794,7 @@ static const struct audioclk_data sm1_audioclk_data = {
.hws = sm1_audio_hw_clks,
.num = ARRAY_SIZE(sm1_audio_hw_clks),
},
- .reset_offset = AUDIO_SM1_SW_RESET0,
- .reset_num = 39,
+ .rst_drvname = "rst-sm1",
.max_register = AUDIO_EARCRX_DMAC_CLK_CTRL,
};
--
2.45.2
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v2 0/7] driver core: auxiliary bus: add device creation helper
2025-02-06 18:23 [PATCH v2 0/7] driver core: auxiliary bus: add device creation helper Jerome Brunet
` (6 preceding siblings ...)
2025-02-06 18:23 ` [PATCH v2 7/7] clk: amlogic: axg-audio: use the auxiliary reset driver - take 2 Jerome Brunet
@ 2025-02-06 18:32 ` Jerome Brunet
7 siblings, 0 replies; 13+ messages in thread
From: Jerome Brunet @ 2025-02-06 18:32 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Dave Ertman, Ira Weiny, Rafael J. Wysocki, Stephen Boyd,
Arnd Bergmann, linux-kernel
On Thu 06 Feb 2025 at 19:23, Jerome Brunet <jbrunet@baylibre.com> wrote:
> The suggestion for this change was initially discussed here: [1]
>
> This patchset adds and use a helper to create a simple auxiliary device.
> The goal is to remove boilerplate code that tends to get repeated for
> simple cases.
>
> Only the last change was tested on actual HW. The other usage of the helper
> have only been compile tested with x64_64 allmodconfig. There are many other
> simple cases of auxiliary device creation but those tend to use the
> 'container_of' trick to allocate the auxiliary device. It is possible to
> convert these drivers to use the provided helper but the conversion is
> slightly more complex.
>
> [1]: https://lore.kernel.org/linux-clk/df0a53ee859e450d84e81547099f5f36.sboyd@kernel.org
Hi Greg,
Since the examples of usage touch several subsystems, this should have
spamed a lot of people. I took the liberty to send this v2 to the same
people as the v1 only, to collect feedback on the core helper and get
this right first.
If you are fine with the change, I'll resend, spamming all the necessary
people.
>
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> ---
> Changes in v2:
> - Add usage examples, as requested.
> - Add 'id' as function parameter: Adding the example usage showed that
> handling IDA allocation was not appropriate and making the usage more
> complex for simple use case.
> - Also add 'modname' as parameter: Most driver have been using
> KBUILD_MODNAME and this actually rarely align with the driver name.
> - Link to v1: https://lore.kernel.org/r/20241210-aux-device-create-helper-v1-1-5887f4d89308@baylibre.com
>
> ---
> Jerome Brunet (7):
> driver core: auxiliary bus: add device creation helper
> reset: mpfs: use the auxiliary device creation helper
> drm/bridge: ti-sn65dsi86: use the auxiliary device creation helper
> platform: arm64: lenovo-yoga-c630: use the auxiliary device creation helper
> clk: eyeq: use the auxiliary device creation helper
> clk: clk-imx8mp-audiomix: use the auxiliary device creation helper
> clk: amlogic: axg-audio: use the auxiliary reset driver - take 2
>
> drivers/base/auxiliary.c | 88 +++++++++++++++++++++++
> drivers/clk/clk-eyeq.c | 57 ++++-----------
> drivers/clk/imx/clk-imx8mp-audiomix.c | 57 ++-------------
> drivers/clk/meson/Kconfig | 2 +-
> drivers/clk/meson/axg-audio.c | 114 ++++--------------------------
> drivers/gpu/drm/bridge/ti-sn65dsi86.c | 88 +++++++----------------
> drivers/platform/arm64/lenovo-yoga-c630.c | 43 ++---------
> drivers/reset/reset-mpfs.c | 53 ++------------
> include/linux/auxiliary_bus.h | 6 ++
> 9 files changed, 160 insertions(+), 348 deletions(-)
> ---
> base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b
> change-id: 20241210-aux-device-create-helper-93141524e523
>
> Best regards,
--
Jerome
^ permalink raw reply [flat|nested] 13+ messages in thread