* [PATCH v3 1/7] driver core: auxiliary bus: add device creation helpers
2025-02-11 17:27 [PATCH v3 0/7] driver core: auxiliary bus: add device creation helper Jerome Brunet
@ 2025-02-11 17:27 ` Jerome Brunet
2025-02-14 16:33 ` Greg Kroah-Hartman
2025-02-11 17:27 ` [PATCH v3 2/7] reset: mpfs: use the auxiliary device creation helper Jerome Brunet
` (5 subsequent siblings)
6 siblings, 1 reply; 29+ 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, Danilo Krummrich, Conor Dooley,
Daire McNamara, Philipp Zabel, Douglas Anderson, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Hans de Goede,
Ilpo Järvinen, Bryan O'Donoghue, Vladimir Kondratiev,
Gregory CLEMENT, Théo Lebrun, Michael Turquette, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Kevin Hilman, Martin Blumenstingl
Cc: Jerome Brunet, linux-kernel, linux-riscv, dri-devel,
platform-driver-x86, linux-mips, linux-clk, imx, linux-arm-kernel,
linux-amlogic
Add helper functions 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 | 10 +++++
2 files changed, 98 insertions(+)
diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
index afa4df4c5a3f371b91d8dd8c4325495d32ad1291..0f697c9c243dc9a50498a52362806db594345faf 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..c098568eeed2a518b055afbf1f1e68623a2c109a 100644
--- a/include/linux/auxiliary_bus.h
+++ b/include/linux/auxiliary_bus.h
@@ -254,6 +254,16 @@ 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);
+
+#define devm_auxiliary_device_create(dev, devname, platform_data, id) \
+ __devm_auxiliary_device_create(dev, KBUILD_MODNAME, devname, \
+ platform_data, 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] 29+ messages in thread
* Re: [PATCH v3 1/7] driver core: auxiliary bus: add device creation helpers
2025-02-11 17:27 ` [PATCH v3 1/7] driver core: auxiliary bus: add device creation helpers Jerome Brunet
@ 2025-02-14 16:33 ` Greg Kroah-Hartman
2025-02-14 18:16 ` Jerome Brunet
0 siblings, 1 reply; 29+ messages in thread
From: Greg Kroah-Hartman @ 2025-02-14 16:33 UTC (permalink / raw)
To: Jerome Brunet
Cc: Dave Ertman, Ira Weiny, Rafael J. Wysocki, Stephen Boyd,
Arnd Bergmann, Danilo Krummrich, Conor Dooley, Daire McNamara,
Philipp Zabel, Douglas Anderson, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Hans de Goede, Ilpo Järvinen,
Bryan O'Donoghue, Vladimir Kondratiev, Gregory CLEMENT,
Théo Lebrun, Michael Turquette, Abel Vesa, Peng Fan,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Kevin Hilman, Martin Blumenstingl, linux-kernel, linux-riscv,
dri-devel, platform-driver-x86, linux-mips, linux-clk, imx,
linux-arm-kernel, linux-amlogic
On Tue, Feb 11, 2025 at 06:27:58PM +0100, Jerome Brunet wrote:
> Add helper functions 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 | 10 +++++
> 2 files changed, 98 insertions(+)
I like the idea, see much the same of what I recently did for the "faux"
bus here:
https://lore.kernel.org/all/2025021023-sandstorm-precise-9f5d@gregkh/
Some review comments:
> diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
> index afa4df4c5a3f371b91d8dd8c4325495d32ad1291..0f697c9c243dc9a50498a52362806db594345faf 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,
Can you have the caller set the platform_data if they need/want it after
the device is created? Or do you need that in the probe callback?
And can't this be a global function too for those that don't want to
deal with devm stuff?
> + int id)
> +{
> + struct auxiliary_device *auxdev;
> + int ret;
> +
> + auxdev = kzalloc(sizeof(*auxdev), GFP_KERNEL);
> + if (!auxdev)
> + return ERR_PTR(-ENOMEM);
Ick, who cares what the error value really is? Why not just do NULL or
a valid pointer? That makes the caller much simpler to handle, right?
> +
> + 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);
Only way this will fail is if you forgot to set parent or a valid name.
So why not check for devname being non-NULL above this?
> + 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);
Yes it is odd, are you SURE you should be calling device_del() on the
device if this fails? auxiliary_device_uninit(), makes sense so why not
just call that here?
> + 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);
Oh this is going to be messy, but I trust that callers know what they
are doing here. Good luck! :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v3 1/7] driver core: auxiliary bus: add device creation helpers
2025-02-14 16:33 ` Greg Kroah-Hartman
@ 2025-02-14 18:16 ` Jerome Brunet
2025-02-15 6:53 ` Greg Kroah-Hartman
0 siblings, 1 reply; 29+ messages in thread
From: Jerome Brunet @ 2025-02-14 18:16 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Dave Ertman, Ira Weiny, Rafael J. Wysocki, Stephen Boyd,
Arnd Bergmann, Danilo Krummrich, Conor Dooley, Daire McNamara,
Philipp Zabel, Douglas Anderson, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Hans de Goede, Ilpo Järvinen,
Bryan O'Donoghue, Vladimir Kondratiev, Gregory CLEMENT,
Théo Lebrun, Michael Turquette, Abel Vesa, Peng Fan,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Kevin Hilman, Martin Blumenstingl, linux-kernel, linux-riscv,
dri-devel, platform-driver-x86, linux-mips, linux-clk, imx,
linux-arm-kernel, linux-amlogic
On Fri 14 Feb 2025 at 17:33, Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
> On Tue, Feb 11, 2025 at 06:27:58PM +0100, Jerome Brunet wrote:
>> Add helper functions 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 | 10 +++++
>> 2 files changed, 98 insertions(+)
>
> I like the idea, see much the same of what I recently did for the "faux"
> bus here:
> https://lore.kernel.org/all/2025021023-sandstorm-precise-9f5d@gregkh/
Reading this, I'm getting the feeling that some (most?) simple auxiliary
driver might be better off migrating to "faux", instead of what I'm
proposing here ? Is this what you are suggesting ?
Few Q:
Is there some sort of 'platform_data' (sorry for the lack of a better
term, no provocation intended ;) ) ... it there a
simple way to pass an arbitrary struct to the created device with 'faux' ?
The difference between aux and faux I'm seeing it that aux seems to
decouple things a bit more. The only thing aux needs is a module name to
pop something up, while faux needs a reference to the ops instead.
I can see the appeal to use aux for maintainers trying to decouple
different subsystems.
>
> Some review comments:
>
>> diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
>> index afa4df4c5a3f371b91d8dd8c4325495d32ad1291..0f697c9c243dc9a50498a52362806db594345faf 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,
>
> Can you have the caller set the platform_data if they need/want it after
> the device is created? Or do you need that in the probe callback?
My assumption was that it is needed in probe, but I guess that entirely
depends on the driver. If that was ever needed, it could be added later
I think.
>
> And can't this be a global function too for those that don't want to
> deal with devm stuff?
There was a note about that in the cover-letter of the v1 but I did not
repeat it after.
It can be exported but I had no use for it so I thought It was better not
export it until it was actually needed. I really do not have a strong
preference over this.
>
>> + int id)
>> +{
>> + struct auxiliary_device *auxdev;
>> + int ret;
>> +
>> + auxdev = kzalloc(sizeof(*auxdev), GFP_KERNEL);
>> + if (!auxdev)
>> + return ERR_PTR(-ENOMEM);
>
> Ick, who cares what the error value really is? Why not just do NULL or
> a valid pointer? That makes the caller much simpler to handle, right?
>
Sure why not
>> +
>> + 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);
>
> Only way this will fail is if you forgot to set parent or a valid name.
> So why not check for devname being non-NULL above this?
If auxiliary_device_init() ever changes it would be easy to forget to
update that and lead to something nasty to debug, don't you think ?
If you are OK with this, I could update in this direction.
>
>> + 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);
>
> Yes it is odd, are you SURE you should be calling device_del() on the
> device if this fails? auxiliary_device_uninit(), makes sense so why not
> just call that here?
I'm confused ... I am call auxiliary_device_uninit() here. What do you
mean ?
>
>> + 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);
>
> Oh this is going to be messy, but I trust that callers know what they
> are doing here. Good luck! :)
>
> thanks,
>
> greg k-h
--
Jerome
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v3 1/7] driver core: auxiliary bus: add device creation helpers
2025-02-14 18:16 ` Jerome Brunet
@ 2025-02-15 6:53 ` Greg Kroah-Hartman
2025-02-17 18:10 ` Jerome Brunet
0 siblings, 1 reply; 29+ messages in thread
From: Greg Kroah-Hartman @ 2025-02-15 6:53 UTC (permalink / raw)
To: Jerome Brunet
Cc: Dave Ertman, Ira Weiny, Rafael J. Wysocki, Stephen Boyd,
Arnd Bergmann, Danilo Krummrich, Conor Dooley, Daire McNamara,
Philipp Zabel, Douglas Anderson, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Hans de Goede, Ilpo Järvinen,
Bryan O'Donoghue, Vladimir Kondratiev, Gregory CLEMENT,
Théo Lebrun, Michael Turquette, Abel Vesa, Peng Fan,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Kevin Hilman, Martin Blumenstingl, linux-kernel, linux-riscv,
dri-devel, platform-driver-x86, linux-mips, linux-clk, imx,
linux-arm-kernel, linux-amlogic
On Fri, Feb 14, 2025 at 07:16:30PM +0100, Jerome Brunet wrote:
> On Fri 14 Feb 2025 at 17:33, Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
>
> > On Tue, Feb 11, 2025 at 06:27:58PM +0100, Jerome Brunet wrote:
> >> Add helper functions 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 | 10 +++++
> >> 2 files changed, 98 insertions(+)
> >
> > I like the idea, see much the same of what I recently did for the "faux"
> > bus here:
> > https://lore.kernel.org/all/2025021023-sandstorm-precise-9f5d@gregkh/
>
> Reading this, I'm getting the feeling that some (most?) simple auxiliary
> driver might be better off migrating to "faux", instead of what I'm
> proposing here ? Is this what you are suggesting ?
For any that do not actually talk to any real hardware (i.e. they are
NOT sharing resources with a parent device), then yes, they should. I
was also trying to point out that "simple" apis like what you created
here are a good thing in my opinion, I like it!
> Few Q:
> Is there some sort of 'platform_data' (sorry for the lack of a better
> term, no provocation intended ;) ) ... it there a
> simple way to pass an arbitrary struct to the created device with 'faux' ?
There are at least 2 ways to do this:
- embed a faux_device inside a larger structure and then do a
container_of() in any sysfs callback to get to your real structure
- in a provided probe() callback, set the driverdata field with a call
to faux_device_set_drvdata()
> The difference between aux and faux I'm seeing it that aux seems to
> decouple things a bit more. The only thing aux needs is a module name to
> pop something up, while faux needs a reference to the ops instead.
aux is needed for when you want multiple drivers to be bound to the same
hardware resource and need some way to share all of that. faux is used
for "fake" devices where you just need a struct device in the /sys/ tree
to be used for "something" or as a parent device for something else.
See the examples in the above patch series where I convert many
different types of drivers over to use faux.
> I can see the appeal to use aux for maintainers trying to decouple
> different subsystems.
Again aux is needed for "sharing" a real device. faux is there for fake
ones that people previously were using platform devices for.
> > Some review comments:
> >
> >> diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
> >> index afa4df4c5a3f371b91d8dd8c4325495d32ad1291..0f697c9c243dc9a50498a52362806db594345faf 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,
> >
> > Can you have the caller set the platform_data if they need/want it after
> > the device is created? Or do you need that in the probe callback?
>
> My assumption was that it is needed in probe, but I guess that entirely
> depends on the driver. If that was ever needed, it could be added later
> I think.
>
> >
> > And can't this be a global function too for those that don't want to
> > deal with devm stuff?
>
> There was a note about that in the cover-letter of the v1 but I did not
> repeat it after.
>
> It can be exported but I had no use for it so I thought It was better not
> export it until it was actually needed. I really do not have a strong
> preference over this.
>
> >
> >> + int id)
> >> +{
> >> + struct auxiliary_device *auxdev;
> >> + int ret;
> >> +
> >> + auxdev = kzalloc(sizeof(*auxdev), GFP_KERNEL);
> >> + if (!auxdev)
> >> + return ERR_PTR(-ENOMEM);
> >
> > Ick, who cares what the error value really is? Why not just do NULL or
> > a valid pointer? That makes the caller much simpler to handle, right?
> >
>
> Sure why not
>
> >> +
> >> + 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);
> >
> > Only way this will fail is if you forgot to set parent or a valid name.
> > So why not check for devname being non-NULL above this?
>
> If auxiliary_device_init() ever changes it would be easy to forget to
> update that and lead to something nasty to debug, don't you think ?
Yes, this is being more defensive, I take back my objection, thanks.
> >> + 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);
> >
> > Yes it is odd, are you SURE you should be calling device_del() on the
> > device if this fails? auxiliary_device_uninit(), makes sense so why not
> > just call that here?
>
> I'm confused ... I am call auxiliary_device_uninit() here. What do you
> mean ?
Oh wow, I got this wrong, sorry, I was thinking you were calling
auxiliary_device_destroy(). Nevermind, ugh, it was a long day...
thanks,
greg k-h
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v3 1/7] driver core: auxiliary bus: add device creation helpers
2025-02-15 6:53 ` Greg Kroah-Hartman
@ 2025-02-17 18:10 ` Jerome Brunet
2025-02-18 8:14 ` Greg Kroah-Hartman
0 siblings, 1 reply; 29+ messages in thread
From: Jerome Brunet @ 2025-02-17 18:10 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Dave Ertman, Ira Weiny, Rafael J. Wysocki, Stephen Boyd,
Arnd Bergmann, Danilo Krummrich, Conor Dooley, Daire McNamara,
Philipp Zabel, Douglas Anderson, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Hans de Goede, Ilpo Järvinen,
Bryan O'Donoghue, Vladimir Kondratiev, Gregory CLEMENT,
Théo Lebrun, Michael Turquette, Abel Vesa, Peng Fan,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Kevin Hilman, Martin Blumenstingl, linux-kernel, linux-riscv,
dri-devel, platform-driver-x86, linux-mips, linux-clk, imx,
linux-arm-kernel, linux-amlogic
On Sat 15 Feb 2025 at 07:53, Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
[...]
>>
>> >
>> >> + int id)
>> >> +{
>> >> + struct auxiliary_device *auxdev;
>> >> + int ret;
>> >> +
>> >> + auxdev = kzalloc(sizeof(*auxdev), GFP_KERNEL);
>> >> + if (!auxdev)
>> >> + return ERR_PTR(-ENOMEM);
>> >
>> > Ick, who cares what the error value really is? Why not just do NULL or
>> > a valid pointer? That makes the caller much simpler to handle, right?
>> >
>>
>> Sure why not
I have tried the 'NULL or valid' approach. In the consumers,
which mostly return an integer from their various init function, I got
this weird to come up with one from NULL. EINVAL, ENOMEM, etc ... can't
really pick one.
It is actually easier to pass something along.
>>
>> >> +
>> >> + 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);
>> >
>> > Only way this will fail is if you forgot to set parent or a valid name.
>> > So why not check for devname being non-NULL above this?
>>
>> If auxiliary_device_init() ever changes it would be easy to forget to
>> update that and lead to something nasty to debug, don't you think ?
>
> Yes, this is being more defensive, I take back my objection, thanks.
>
>> >> + 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);
>> >
>> > Yes it is odd, are you SURE you should be calling device_del() on the
>> > device if this fails? auxiliary_device_uninit(), makes sense so why not
>> > just call that here?
>>
>> I'm confused ... I am call auxiliary_device_uninit() here. What do you
>> mean ?
>
> Oh wow, I got this wrong, sorry, I was thinking you were calling
> auxiliary_device_destroy(). Nevermind, ugh, it was a long day...
>
No worries
> thanks,
>
> greg k-h
--
Jerome
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v3 1/7] driver core: auxiliary bus: add device creation helpers
2025-02-17 18:10 ` Jerome Brunet
@ 2025-02-18 8:14 ` Greg Kroah-Hartman
0 siblings, 0 replies; 29+ messages in thread
From: Greg Kroah-Hartman @ 2025-02-18 8:14 UTC (permalink / raw)
To: Jerome Brunet
Cc: Dave Ertman, Ira Weiny, Rafael J. Wysocki, Stephen Boyd,
Arnd Bergmann, Danilo Krummrich, Conor Dooley, Daire McNamara,
Philipp Zabel, Douglas Anderson, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Hans de Goede, Ilpo Järvinen,
Bryan O'Donoghue, Vladimir Kondratiev, Gregory CLEMENT,
Théo Lebrun, Michael Turquette, Abel Vesa, Peng Fan,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Kevin Hilman, Martin Blumenstingl, linux-kernel, linux-riscv,
dri-devel, platform-driver-x86, linux-mips, linux-clk, imx,
linux-arm-kernel, linux-amlogic
On Mon, Feb 17, 2025 at 07:10:54PM +0100, Jerome Brunet wrote:
> On Sat 15 Feb 2025 at 07:53, Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
>
> [...]
>
> >>
> >> >
> >> >> + int id)
> >> >> +{
> >> >> + struct auxiliary_device *auxdev;
> >> >> + int ret;
> >> >> +
> >> >> + auxdev = kzalloc(sizeof(*auxdev), GFP_KERNEL);
> >> >> + if (!auxdev)
> >> >> + return ERR_PTR(-ENOMEM);
> >> >
> >> > Ick, who cares what the error value really is? Why not just do NULL or
> >> > a valid pointer? That makes the caller much simpler to handle, right?
> >> >
> >>
> >> Sure why not
>
> I have tried the 'NULL or valid' approach. In the consumers,
> which mostly return an integer from their various init function, I got
> this weird to come up with one from NULL. EINVAL, ENOMEM, etc ... can't
> really pick one.
>
> It is actually easier to pass something along.
Ok, fair enough, thanks for trying. But I would have returned just
-ENODEV in all cases, as that's what the end result was :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v3 2/7] reset: mpfs: use the auxiliary device creation helper
2025-02-11 17:27 [PATCH v3 0/7] driver core: auxiliary bus: add device creation helper Jerome Brunet
2025-02-11 17:27 ` [PATCH v3 1/7] driver core: auxiliary bus: add device creation helpers Jerome Brunet
@ 2025-02-11 17:27 ` Jerome Brunet
2025-02-13 17:59 ` Conor Dooley
2025-02-11 17:28 ` [PATCH v3 3/7] drm/bridge: ti-sn65dsi86: " Jerome Brunet
` (4 subsequent siblings)
6 siblings, 1 reply; 29+ 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, Danilo Krummrich, Conor Dooley,
Daire McNamara, Philipp Zabel, Douglas Anderson, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Hans de Goede,
Ilpo Järvinen, Bryan O'Donoghue, Vladimir Kondratiev,
Gregory CLEMENT, Théo Lebrun, Michael Turquette, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Kevin Hilman, Martin Blumenstingl
Cc: Jerome Brunet, linux-kernel, linux-riscv, dri-devel,
platform-driver-x86, linux-mips, linux-clk, imx, linux-arm-kernel,
linux-amlogic
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 | 52 +++-------------------------------------------
1 file changed, 3 insertions(+), 49 deletions(-)
diff --git a/drivers/reset/reset-mpfs.c b/drivers/reset/reset-mpfs.c
index 574e59db83a4fcf30b60cb5f638607a2ec7b0580..bbea64862181877eb7ae51fdaa9e50ffac17c908 100644
--- a/drivers/reset/reset-mpfs.c
+++ b/drivers/reset/reset-mpfs.c
@@ -155,62 +155,16 @@ 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, "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] 29+ messages in thread
* Re: [PATCH v3 2/7] reset: mpfs: use the auxiliary device creation helper
2025-02-11 17:27 ` [PATCH v3 2/7] reset: mpfs: use the auxiliary device creation helper Jerome Brunet
@ 2025-02-13 17:59 ` Conor Dooley
2025-02-14 8:59 ` Jerome Brunet
0 siblings, 1 reply; 29+ messages in thread
From: Conor Dooley @ 2025-02-13 17:59 UTC (permalink / raw)
To: Jerome Brunet
Cc: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann, Danilo Krummrich, Conor Dooley,
Daire McNamara, Philipp Zabel, Douglas Anderson, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Hans de Goede,
Ilpo Järvinen, Bryan O'Donoghue, Vladimir Kondratiev,
Gregory CLEMENT, Théo Lebrun, Michael Turquette, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Kevin Hilman, Martin Blumenstingl, linux-kernel,
linux-riscv, dri-devel, platform-driver-x86, linux-mips,
linux-clk, imx, linux-arm-kernel, linux-amlogic
[-- Attachment #1: Type: text/plain, Size: 2802 bytes --]
On Tue, Feb 11, 2025 at 06:27:59PM +0100, Jerome Brunet wrote:
> 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 | 52 +++-------------------------------------------
> 1 file changed, 3 insertions(+), 49 deletions(-)
>
> diff --git a/drivers/reset/reset-mpfs.c b/drivers/reset/reset-mpfs.c
> index 574e59db83a4fcf30b60cb5f638607a2ec7b0580..bbea64862181877eb7ae51fdaa9e50ffac17c908 100644
> --- a/drivers/reset/reset-mpfs.c
> +++ b/drivers/reset/reset-mpfs.c
> @@ -155,62 +155,16 @@ 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, "reset-mpfs",
> + (__force void *)base, 666u);
Moving the boilerplate into a helper makes sense:
Acked-by: Conor Dooley <conor.dooley@microchip.com>
One think that's always felt a bit meh to me is this id number stuff,
I just threw in 666 for meme value. The whole thing seems super
arbitrary, do any of the users of this helper actually put meaningful
values into the id parameter?
> 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
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v3 2/7] reset: mpfs: use the auxiliary device creation helper
2025-02-13 17:59 ` Conor Dooley
@ 2025-02-14 8:59 ` Jerome Brunet
2025-02-14 15:25 ` Doug Anderson
0 siblings, 1 reply; 29+ messages in thread
From: Jerome Brunet @ 2025-02-14 8:59 UTC (permalink / raw)
To: Conor Dooley
Cc: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann, Danilo Krummrich, Conor Dooley,
Daire McNamara, Philipp Zabel, Douglas Anderson, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Hans de Goede,
Ilpo Järvinen, Bryan O'Donoghue, Vladimir Kondratiev,
Gregory CLEMENT, Théo Lebrun, Michael Turquette, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Kevin Hilman, Martin Blumenstingl, linux-kernel,
linux-riscv, dri-devel, platform-driver-x86, linux-mips,
linux-clk, imx, linux-arm-kernel, linux-amlogic
On Thu 13 Feb 2025 at 17:59, Conor Dooley <conor@kernel.org> wrote:
> On Tue, Feb 11, 2025 at 06:27:59PM +0100, Jerome Brunet wrote:
>> 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 | 52 +++-------------------------------------------
>> 1 file changed, 3 insertions(+), 49 deletions(-)
>>
>> diff --git a/drivers/reset/reset-mpfs.c b/drivers/reset/reset-mpfs.c
>> index 574e59db83a4fcf30b60cb5f638607a2ec7b0580..bbea64862181877eb7ae51fdaa9e50ffac17c908 100644
>> --- a/drivers/reset/reset-mpfs.c
>> +++ b/drivers/reset/reset-mpfs.c
>> @@ -155,62 +155,16 @@ 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, "reset-mpfs",
>> + (__force void *)base, 666u);
>
> Moving the boilerplate into a helper makes sense:
> Acked-by: Conor Dooley <conor.dooley@microchip.com>
>
> One think that's always felt a bit meh to me is this id number stuff,
> I just threw in 666 for meme value.
:)
> The whole thing seems super
> arbitrary, do any of the users of this helper actually put meaningful
> values into the id parameter?
In example changes I've sent, no.
In other simple usages (those using container_of()) of the auxiliary
bus, I think there are a few that uses 0 and 1 for 2 instances.
I guess your question is "do we really need this parameter here ?"
We could remove it and still address 90% of the original target.
Keeping it leaves the door open in case the figure above does not hold
and it is pretty cheap to do. It could also enable drivers requiring an
IDA to use the helper, possibly.
>
>> 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
>>
--
Jerome
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v3 2/7] reset: mpfs: use the auxiliary device creation helper
2025-02-14 8:59 ` Jerome Brunet
@ 2025-02-14 15:25 ` Doug Anderson
2025-02-15 12:50 ` Conor Dooley
0 siblings, 1 reply; 29+ messages in thread
From: Doug Anderson @ 2025-02-14 15:25 UTC (permalink / raw)
To: Jerome Brunet
Cc: Conor Dooley, Greg Kroah-Hartman, Dave Ertman, Ira Weiny,
Rafael J. Wysocki, Stephen Boyd, Arnd Bergmann, Danilo Krummrich,
Conor Dooley, Daire McNamara, Philipp Zabel, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Hans de Goede,
Ilpo Järvinen, Bryan O'Donoghue, Vladimir Kondratiev,
Gregory CLEMENT, Théo Lebrun, Michael Turquette, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Kevin Hilman, Martin Blumenstingl, linux-kernel,
linux-riscv, dri-devel, platform-driver-x86, linux-mips,
linux-clk, imx, linux-arm-kernel, linux-amlogic
Hi,
On Fri, Feb 14, 2025 at 12:59 AM Jerome Brunet <jbrunet@baylibre.com> wrote:
>
> > One think that's always felt a bit meh to me is this id number stuff,
> > I just threw in 666 for meme value.
>
> :)
>
> > The whole thing seems super
> > arbitrary, do any of the users of this helper actually put meaningful
> > values into the id parameter?
>
> In example changes I've sent, no.
>
> In other simple usages (those using container_of()) of the auxiliary
> bus, I think there are a few that uses 0 and 1 for 2 instances.
>
> I guess your question is "do we really need this parameter here ?"
>
> We could remove it and still address 90% of the original target.
>
> Keeping it leaves the door open in case the figure above does not hold
> and it is pretty cheap to do. It could also enable drivers requiring an
> IDA to use the helper, possibly.
FWIW, once you resolve the conflicts in drm-misc with ti-sn65dsi86
you'll need the ID value. ;-)
There was a big-ol' discussion here:
https://lore.kernel.org/r/8c2df6a903f87d4932586b25f1d3bd548fe8e6d1.1729180470.git.geert+renesas@glider.be
I eventually pushed v2 of the patch:
https://lore.kernel.org/r/7a68a0e3f927e26edca6040067fb653eb06efb79.1733840089.git.geert+renesas@glider.be
-Doug
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v3 2/7] reset: mpfs: use the auxiliary device creation helper
2025-02-14 15:25 ` Doug Anderson
@ 2025-02-15 12:50 ` Conor Dooley
0 siblings, 0 replies; 29+ messages in thread
From: Conor Dooley @ 2025-02-15 12:50 UTC (permalink / raw)
To: Doug Anderson
Cc: Jerome Brunet, Greg Kroah-Hartman, Dave Ertman, Ira Weiny,
Rafael J. Wysocki, Stephen Boyd, Arnd Bergmann, Danilo Krummrich,
Conor Dooley, Daire McNamara, Philipp Zabel, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Hans de Goede,
Ilpo Järvinen, Bryan O'Donoghue, Vladimir Kondratiev,
Gregory CLEMENT, Théo Lebrun, Michael Turquette, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Kevin Hilman, Martin Blumenstingl, linux-kernel,
linux-riscv, dri-devel, platform-driver-x86, linux-mips,
linux-clk, imx, linux-arm-kernel, linux-amlogic
[-- Attachment #1: Type: text/plain, Size: 1577 bytes --]
On Fri, Feb 14, 2025 at 07:25:59AM -0800, Doug Anderson wrote:
> Hi,
>
> On Fri, Feb 14, 2025 at 12:59 AM Jerome Brunet <jbrunet@baylibre.com> wrote:
> >
> > > One think that's always felt a bit meh to me is this id number stuff,
> > > I just threw in 666 for meme value.
> >
> > :)
> >
> > > The whole thing seems super
> > > arbitrary, do any of the users of this helper actually put meaningful
> > > values into the id parameter?
> >
> > In example changes I've sent, no.
> >
> > In other simple usages (those using container_of()) of the auxiliary
> > bus, I think there are a few that uses 0 and 1 for 2 instances.
> >
> > I guess your question is "do we really need this parameter here ?"
> >
> > We could remove it and still address 90% of the original target.
> >
> > Keeping it leaves the door open in case the figure above does not hold
> > and it is pretty cheap to do. It could also enable drivers requiring an
> > IDA to use the helper, possibly.
>
> FWIW, once you resolve the conflicts in drm-misc with ti-sn65dsi86
> you'll need the ID value. ;-)
>
> There was a big-ol' discussion here:
>
> https://lore.kernel.org/r/8c2df6a903f87d4932586b25f1d3bd548fe8e6d1.1729180470.git.geert+renesas@glider.be
>
> I eventually pushed v2 of the patch:
>
> https://lore.kernel.org/r/7a68a0e3f927e26edca6040067fb653eb06efb79.1733840089.git.geert+renesas@glider.be
Think it makes sense to have a "simplified" wrapper for the cases where
the id has no meaning then? Not really a fan of the drivers coming up with
magic numbers.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v3 3/7] drm/bridge: ti-sn65dsi86: use the auxiliary device creation helper
2025-02-11 17:27 [PATCH v3 0/7] driver core: auxiliary bus: add device creation helper Jerome Brunet
2025-02-11 17:27 ` [PATCH v3 1/7] driver core: auxiliary bus: add device creation helpers Jerome Brunet
2025-02-11 17:27 ` [PATCH v3 2/7] reset: mpfs: use the auxiliary device creation helper Jerome Brunet
@ 2025-02-11 17:28 ` Jerome Brunet
2025-02-12 16:38 ` Doug Anderson
2025-02-11 17:28 ` [PATCH v3 4/7] platform: arm64: lenovo-yoga-c630: " Jerome Brunet
` (3 subsequent siblings)
6 siblings, 1 reply; 29+ messages in thread
From: Jerome Brunet @ 2025-02-11 17:28 UTC (permalink / raw)
To: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann, Danilo Krummrich, Conor Dooley,
Daire McNamara, Philipp Zabel, Douglas Anderson, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Hans de Goede,
Ilpo Järvinen, Bryan O'Donoghue, Vladimir Kondratiev,
Gregory CLEMENT, Théo Lebrun, Michael Turquette, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Kevin Hilman, Martin Blumenstingl
Cc: Jerome Brunet, linux-kernel, linux-riscv, dri-devel,
platform-driver-x86, linux-mips, linux-clk, imx, linux-arm-kernel,
linux-amlogic
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 | 84 +++++++++--------------------------
1 file changed, 20 insertions(+), 64 deletions(-)
diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
index e4d9006b59f1b975cf63e26b221e985206caf867..e583b8ba1fd4f27d98e03d4382e0417bbd50436f 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,12 @@ 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, "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 +1899,17 @@ 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, "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, "pwm",
+ NULL, 0);
+ if (IS_ERR(pdata->pwm_aux))
+ return PTR_ERR(pdata->pwm_aux);
}
/*
@@ -1967,7 +1918,12 @@ 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, "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] 29+ messages in thread
* Re: [PATCH v3 3/7] drm/bridge: ti-sn65dsi86: use the auxiliary device creation helper
2025-02-11 17:28 ` [PATCH v3 3/7] drm/bridge: ti-sn65dsi86: " Jerome Brunet
@ 2025-02-12 16:38 ` Doug Anderson
2025-02-13 10:10 ` Jerome Brunet
0 siblings, 1 reply; 29+ messages in thread
From: Doug Anderson @ 2025-02-12 16:38 UTC (permalink / raw)
To: Jerome Brunet
Cc: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann, Danilo Krummrich, Conor Dooley,
Daire McNamara, Philipp Zabel, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Hans de Goede, Ilpo Järvinen,
Bryan O'Donoghue, Vladimir Kondratiev, Gregory CLEMENT,
Théo Lebrun, Michael Turquette, Abel Vesa, Peng Fan,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Kevin Hilman, Martin Blumenstingl, linux-kernel, linux-riscv,
dri-devel, platform-driver-x86, linux-mips, linux-clk, imx,
linux-arm-kernel, linux-amlogic
Hi,
On Tue, Feb 11, 2025 at 9:28 AM Jerome Brunet <jbrunet@baylibre.com> wrote:
>
> 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 | 84 +++++++++--------------------------
> 1 file changed, 20 insertions(+), 64 deletions(-)
Thanks for creating the helpers and getting rid of some boilerplate!
This conflicts with commit 574f5ee2c85a ("drm/bridge: ti-sn65dsi86:
Fix multiple instances") which is in drm-next, though. Please resolve.
Since nothing here is urgent, I would assume patch #1 would land and
then we'd just wait until it made it to mainline before landing the
other patches in their respective trees?
> -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;
I notice that your new code has one fewer devm_add_action_or_reset()
than the code here which you're replacing. That means it needs to call
"uninit" explicitly in one extra place. It still seems clean enough,
though, so I don't have any real objections to the way you're doing it
there. ;-)
-Doug
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v3 3/7] drm/bridge: ti-sn65dsi86: use the auxiliary device creation helper
2025-02-12 16:38 ` Doug Anderson
@ 2025-02-13 10:10 ` Jerome Brunet
0 siblings, 0 replies; 29+ messages in thread
From: Jerome Brunet @ 2025-02-13 10:10 UTC (permalink / raw)
To: Doug Anderson
Cc: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann, Danilo Krummrich, Conor Dooley,
Daire McNamara, Philipp Zabel, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Hans de Goede, Ilpo Järvinen,
Bryan O'Donoghue, Vladimir Kondratiev, Gregory CLEMENT,
Théo Lebrun, Michael Turquette, Abel Vesa, Peng Fan,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Kevin Hilman, Martin Blumenstingl, linux-kernel, linux-riscv,
dri-devel, platform-driver-x86, linux-mips, linux-clk, imx,
linux-arm-kernel, linux-amlogic
On Wed 12 Feb 2025 at 08:38, Doug Anderson <dianders@chromium.org> wrote:
> Hi,
>
> On Tue, Feb 11, 2025 at 9:28 AM Jerome Brunet <jbrunet@baylibre.com> wrote:
>>
>> 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 | 84 +++++++++--------------------------
>> 1 file changed, 20 insertions(+), 64 deletions(-)
>
> Thanks for creating the helpers and getting rid of some boilerplate!
> This conflicts with commit 574f5ee2c85a ("drm/bridge: ti-sn65dsi86:
> Fix multiple instances") which is in drm-next, though. Please resolve.
Noted. this is based on v6.14-rc1 ATM
>
> Since nothing here is urgent, I would assume patch #1 would land and
> then we'd just wait until it made it to mainline before landing the
> other patches in their respective trees?
That would simplest way to handle it I think. No rush.
I'll rebase when the time comes.
>
>
>> -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;
>
> I notice that your new code has one fewer devm_add_action_or_reset()
> than the code here which you're replacing. That means it needs to call
> "uninit" explicitly in one extra place.
... but it needs one memory allocation less ;)
> It still seems clean enough,
> though, so I don't have any real objections to the way you're doing it
> there. ;-)
Both ways are valid indeed. Just a matter of personal taste I guess.
>
> -Doug
--
Jerome
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v3 4/7] platform: arm64: lenovo-yoga-c630: use the auxiliary device creation helper
2025-02-11 17:27 [PATCH v3 0/7] driver core: auxiliary bus: add device creation helper Jerome Brunet
` (2 preceding siblings ...)
2025-02-11 17:28 ` [PATCH v3 3/7] drm/bridge: ti-sn65dsi86: " Jerome Brunet
@ 2025-02-11 17:28 ` Jerome Brunet
2025-02-13 12:56 ` Ilpo Järvinen
2025-02-11 17:28 ` [PATCH v3 5/7] clk: eyeq: " Jerome Brunet
` (2 subsequent siblings)
6 siblings, 1 reply; 29+ messages in thread
From: Jerome Brunet @ 2025-02-11 17:28 UTC (permalink / raw)
To: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann, Danilo Krummrich, Conor Dooley,
Daire McNamara, Philipp Zabel, Douglas Anderson, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Hans de Goede,
Ilpo Järvinen, Bryan O'Donoghue, Vladimir Kondratiev,
Gregory CLEMENT, Théo Lebrun, Michael Turquette, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Kevin Hilman, Martin Blumenstingl
Cc: Jerome Brunet, linux-kernel, linux-riscv, dri-devel,
platform-driver-x86, linux-mips, linux-clk, imx, linux-arm-kernel,
linux-amlogic
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 | 42 +++----------------------------
1 file changed, 4 insertions(+), 38 deletions(-)
diff --git a/drivers/platform/arm64/lenovo-yoga-c630.c b/drivers/platform/arm64/lenovo-yoga-c630.c
index 1f05c9a6a89d5ee146144062f5d2e36795c56639..921a93d4ea39ac54344cc964e2805e974cc7e808 100644
--- a/drivers/platform/arm64/lenovo-yoga-c630.c
+++ b/drivers/platform/arm64/lenovo-yoga-c630.c
@@ -191,50 +191,16 @@ 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, 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] 29+ messages in thread
* Re: [PATCH v3 4/7] platform: arm64: lenovo-yoga-c630: use the auxiliary device creation helper
2025-02-11 17:28 ` [PATCH v3 4/7] platform: arm64: lenovo-yoga-c630: " Jerome Brunet
@ 2025-02-13 12:56 ` Ilpo Järvinen
0 siblings, 0 replies; 29+ messages in thread
From: Ilpo Järvinen @ 2025-02-13 12:56 UTC (permalink / raw)
To: Jerome Brunet
Cc: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann, Danilo Krummrich, Conor Dooley,
Daire McNamara, Philipp Zabel, Douglas Anderson, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Hans de Goede,
Bryan O'Donoghue, Vladimir Kondratiev, Gregory CLEMENT,
Théo Lebrun, Michael Turquette, Abel Vesa, Peng Fan,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Kevin Hilman, Martin Blumenstingl, LKML, linux-riscv, dri-devel,
platform-driver-x86, linux-mips, linux-clk, imx, linux-arm-kernel,
linux-amlogic
On Tue, 11 Feb 2025, Jerome Brunet wrote:
> 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 | 42 +++----------------------------
> 1 file changed, 4 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/platform/arm64/lenovo-yoga-c630.c b/drivers/platform/arm64/lenovo-yoga-c630.c
> index 1f05c9a6a89d5ee146144062f5d2e36795c56639..921a93d4ea39ac54344cc964e2805e974cc7e808 100644
> --- a/drivers/platform/arm64/lenovo-yoga-c630.c
> +++ b/drivers/platform/arm64/lenovo-yoga-c630.c
> @@ -191,50 +191,16 @@ 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, 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;
return PTR_ERR_OR_ZERO()
> }
>
> static int yoga_c630_ec_probe(struct i2c_client *client)
>
>
--
i.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v3 5/7] clk: eyeq: use the auxiliary device creation helper
2025-02-11 17:27 [PATCH v3 0/7] driver core: auxiliary bus: add device creation helper Jerome Brunet
` (3 preceding siblings ...)
2025-02-11 17:28 ` [PATCH v3 4/7] platform: arm64: lenovo-yoga-c630: " Jerome Brunet
@ 2025-02-11 17:28 ` Jerome Brunet
2025-02-12 14:41 ` [PATCH] reset: eyeq: drop device_set_of_node_from_dev() done by parent Théo Lebrun
2025-02-12 14:51 ` [PATCH v3 5/7] clk: eyeq: use the auxiliary device creation helper Théo Lebrun
2025-02-11 17:28 ` [PATCH v3 6/7] clk: clk-imx8mp-audiomix: " Jerome Brunet
2025-02-11 17:28 ` [PATCH v3 7/7] clk: amlogic: axg-audio: use the auxiliary reset driver - take 2 Jerome Brunet
6 siblings, 2 replies; 29+ messages in thread
From: Jerome Brunet @ 2025-02-11 17:28 UTC (permalink / raw)
To: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann, Danilo Krummrich, Conor Dooley,
Daire McNamara, Philipp Zabel, Douglas Anderson, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Hans de Goede,
Ilpo Järvinen, Bryan O'Donoghue, Vladimir Kondratiev,
Gregory CLEMENT, Théo Lebrun, Michael Turquette, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Kevin Hilman, Martin Blumenstingl
Cc: Jerome Brunet, linux-kernel, linux-riscv, dri-devel,
platform-driver-x86, linux-mips, linux-clk, imx, linux-arm-kernel,
linux-amlogic
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..37e76ad3fbe95ee2dea7df8f6b02d28f19f1d5ef 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, 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] 29+ messages in thread
* [PATCH] reset: eyeq: drop device_set_of_node_from_dev() done by parent
2025-02-11 17:28 ` [PATCH v3 5/7] clk: eyeq: " Jerome Brunet
@ 2025-02-12 14:41 ` Théo Lebrun
2025-02-12 14:51 ` [PATCH v3 5/7] clk: eyeq: use the auxiliary device creation helper Théo Lebrun
1 sibling, 0 replies; 29+ messages in thread
From: Théo Lebrun @ 2025-02-12 14:41 UTC (permalink / raw)
To: jbrunet
Cc: Laurent.pinchart, abelvesa, airlied, andrzej.hajda, arnd,
bryan.odonoghue, conor.dooley, daire.mcnamara, dakr,
david.m.ertman, dianders, dri-devel, festevam, gregkh,
gregory.clement, hdegoede, ilpo.jarvinen, imx, ira.weiny,
jernej.skrabec, jonas, kernel, khilman, linux-amlogic,
linux-arm-kernel, linux-clk, linux-kernel, linux-mips,
linux-riscv, maarten.lankhorst, martin.blumenstingl, mripard,
mturquette, neil.armstrong, p.zabel, peng.fan,
platform-driver-x86, rafael, rfoss, s.hauer, sboyd, shawnguo,
simona, theo.lebrun, tzimmermann, vladimir.kondratiev
Our parent driver (clk-eyeq) now does the
device_set_of_node_from_dev(dev, dev->parent)
call through the newly introduced devm_auxiliary_device_create() helper.
Doing it again in the reset-eyeq probe would be redundant.
Drop both the WARN_ON() and the device_set_of_node_from_dev() call.
Also fix the following comment that talks about "our newfound OF node".
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
drivers/reset/reset-eyeq.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/drivers/reset/reset-eyeq.c b/drivers/reset/reset-eyeq.c
index 02d50041048b..8018fa895427 100644
--- a/drivers/reset/reset-eyeq.c
+++ b/drivers/reset/reset-eyeq.c
@@ -420,17 +420,8 @@ static int eqr_probe(struct auxiliary_device *adev,
int ret;
/*
- * We are an auxiliary device of clk-eyeq. We do not have an OF node by
- * default; let's reuse our parent's OF node.
- */
- WARN_ON(dev->of_node);
- device_set_of_node_from_dev(dev, dev->parent);
- if (!dev->of_node)
- return -ENODEV;
-
- /*
- * Using our newfound OF node, we can get match data. We cannot use
- * device_get_match_data() because it does not match reused OF nodes.
+ * Get match data. We cannot use device_get_match_data() because it does
+ * not accept reused OF nodes; see device_set_of_node_from_dev().
*/
match = of_match_node(dev->driver->of_match_table, dev->of_node);
if (!match || !match->data)
--
2.48.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH v3 5/7] clk: eyeq: use the auxiliary device creation helper
2025-02-11 17:28 ` [PATCH v3 5/7] clk: eyeq: " Jerome Brunet
2025-02-12 14:41 ` [PATCH] reset: eyeq: drop device_set_of_node_from_dev() done by parent Théo Lebrun
@ 2025-02-12 14:51 ` Théo Lebrun
1 sibling, 0 replies; 29+ messages in thread
From: Théo Lebrun @ 2025-02-12 14:51 UTC (permalink / raw)
To: Jerome Brunet, Greg Kroah-Hartman, Dave Ertman, Ira Weiny,
Rafael J. Wysocki, Stephen Boyd, Arnd Bergmann, Danilo Krummrich,
Conor Dooley, Daire McNamara, Philipp Zabel, Douglas Anderson,
Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Hans de Goede,
Ilpo Järvinen, Bryan O'Donoghue, Vladimir Kondratiev,
Gregory CLEMENT, Michael Turquette, Abel Vesa, Peng Fan,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Kevin Hilman, Martin Blumenstingl
Cc: linux-kernel, linux-riscv, dri-devel, platform-driver-x86,
linux-mips, linux-clk, imx, linux-arm-kernel, linux-amlogic,
Philipp Zabel
Hello Jerome,
On Tue Feb 11, 2025 at 6:28 PM CET, Jerome Brunet wrote:
> 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>
Tested the series, it works. However:
- The newly introduced helper does a
device_set_of_node_from_dev(child_device, parent_device) call which
used to be done by our reset-eyeq child.
- reset-eyeq also did a WARN_ON(dev->of_node) to validate it didn't
have an OF node at probe (checking its assumptions).
- We can remove both. See patch that got sent as a reply.
With that additional patch:
Tested-by: Théo Lebrun <theo.lebrun@bootlin.com> # On Mobileye EyeQ5
Note: Philipp Zabel has been CCed on the patch and this email as the
reset maintainer.
Thanks,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v3 6/7] clk: clk-imx8mp-audiomix: use the auxiliary device creation helper
2025-02-11 17:27 [PATCH v3 0/7] driver core: auxiliary bus: add device creation helper Jerome Brunet
` (4 preceding siblings ...)
2025-02-11 17:28 ` [PATCH v3 5/7] clk: eyeq: " Jerome Brunet
@ 2025-02-11 17:28 ` Jerome Brunet
2025-02-14 16:15 ` Ira Weiny
2025-02-11 17:28 ` [PATCH v3 7/7] clk: amlogic: axg-audio: use the auxiliary reset driver - take 2 Jerome Brunet
6 siblings, 1 reply; 29+ messages in thread
From: Jerome Brunet @ 2025-02-11 17:28 UTC (permalink / raw)
To: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann, Danilo Krummrich, Conor Dooley,
Daire McNamara, Philipp Zabel, Douglas Anderson, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Hans de Goede,
Ilpo Järvinen, Bryan O'Donoghue, Vladimir Kondratiev,
Gregory CLEMENT, Théo Lebrun, Michael Turquette, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Kevin Hilman, Martin Blumenstingl
Cc: Jerome Brunet, linux-kernel, linux-riscv, dri-devel,
platform-driver-x86, linux-mips, linux-clk, imx, linux-arm-kernel,
linux-amlogic
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 | 56 ++++-------------------------------
1 file changed, 6 insertions(+), 50 deletions(-)
diff --git a/drivers/clk/imx/clk-imx8mp-audiomix.c b/drivers/clk/imx/clk-imx8mp-audiomix.c
index c409fc7e061869988f83c7df3ef7860500426323..988a5fffeb4e0e481ec57038d9d1f1b43432fc98 100644
--- a/drivers/clk/imx/clk-imx8mp-audiomix.c
+++ b/drivers/clk/imx/clk-imx8mp-audiomix.c
@@ -228,64 +228,20 @@ 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, "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 +364,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] 29+ messages in thread
* Re: [PATCH v3 6/7] clk: clk-imx8mp-audiomix: use the auxiliary device creation helper
2025-02-11 17:28 ` [PATCH v3 6/7] clk: clk-imx8mp-audiomix: " Jerome Brunet
@ 2025-02-14 16:15 ` Ira Weiny
2025-02-14 18:20 ` Jerome Brunet
0 siblings, 1 reply; 29+ messages in thread
From: Ira Weiny @ 2025-02-14 16:15 UTC (permalink / raw)
To: Jerome Brunet, Greg Kroah-Hartman, Dave Ertman, Ira Weiny,
Rafael J. Wysocki, Stephen Boyd, Arnd Bergmann, Danilo Krummrich,
Conor Dooley, Daire McNamara, Philipp Zabel, Douglas Anderson,
Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Hans de Goede,
Ilpo Järvinen, Bryan O'Donoghue, Vladimir Kondratiev,
Gregory CLEMENT, Théo Lebrun, Michael Turquette, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Kevin Hilman, Martin Blumenstingl
Cc: Jerome Brunet, linux-kernel, linux-riscv, dri-devel,
platform-driver-x86, linux-mips, linux-clk, imx, linux-arm-kernel,
linux-amlogic
Jerome Brunet wrote:
> 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 | 56 ++++-------------------------------
> 1 file changed, 6 insertions(+), 50 deletions(-)
>
> diff --git a/drivers/clk/imx/clk-imx8mp-audiomix.c b/drivers/clk/imx/clk-imx8mp-audiomix.c
> index c409fc7e061869988f83c7df3ef7860500426323..988a5fffeb4e0e481ec57038d9d1f1b43432fc98 100644
> --- a/drivers/clk/imx/clk-imx8mp-audiomix.c
> +++ b/drivers/clk/imx/clk-imx8mp-audiomix.c
> @@ -228,64 +228,20 @@ struct clk_imx8mp_audiomix_priv {
> struct clk_hw_onecell_data clk_data;
> };
>
> -#if IS_ENABLED(CONFIG_RESET_CONTROLLER)
I see the Kconfig ...
select AUXILIARY_BUS if RESET_CONTROLLER
But I don't see how this code is omitted without AUXILIARY_BUS. Is this
kconfig check safe to remove?
Ira
> -
> -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, "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 +364,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 [flat|nested] 29+ messages in thread
* Re: [PATCH v3 6/7] clk: clk-imx8mp-audiomix: use the auxiliary device creation helper
2025-02-14 16:15 ` Ira Weiny
@ 2025-02-14 18:20 ` Jerome Brunet
2025-02-14 22:03 ` Ira Weiny
0 siblings, 1 reply; 29+ messages in thread
From: Jerome Brunet @ 2025-02-14 18:20 UTC (permalink / raw)
To: Ira Weiny
Cc: Greg Kroah-Hartman, Dave Ertman, Rafael J. Wysocki, Stephen Boyd,
Arnd Bergmann, Danilo Krummrich, Conor Dooley, Daire McNamara,
Philipp Zabel, Douglas Anderson, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Hans de Goede, Ilpo Järvinen,
Bryan O'Donoghue, Vladimir Kondratiev, Gregory CLEMENT,
Théo Lebrun, Michael Turquette, Abel Vesa, Peng Fan,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Kevin Hilman, Martin Blumenstingl, linux-kernel, linux-riscv,
dri-devel, platform-driver-x86, linux-mips, linux-clk, imx,
linux-arm-kernel, linux-amlogic
On Fri 14 Feb 2025 at 10:15, Ira Weiny <ira.weiny@intel.com> wrote:
> Jerome Brunet wrote:
>> 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 | 56 ++++-------------------------------
>> 1 file changed, 6 insertions(+), 50 deletions(-)
>>
>> diff --git a/drivers/clk/imx/clk-imx8mp-audiomix.c b/drivers/clk/imx/clk-imx8mp-audiomix.c
>> index c409fc7e061869988f83c7df3ef7860500426323..988a5fffeb4e0e481ec57038d9d1f1b43432fc98 100644
>> --- a/drivers/clk/imx/clk-imx8mp-audiomix.c
>> +++ b/drivers/clk/imx/clk-imx8mp-audiomix.c
>> @@ -228,64 +228,20 @@ struct clk_imx8mp_audiomix_priv {
>> struct clk_hw_onecell_data clk_data;
>> };
>>
>> -#if IS_ENABLED(CONFIG_RESET_CONTROLLER)
>
> I see the Kconfig ...
>
> select AUXILIARY_BUS if RESET_CONTROLLER
>
> But I don't see how this code is omitted without AUXILIARY_BUS. Is this
> kconfig check safe to remove?
Ahhh that's what this directive was for.
I thought it was really odd to have an #if on RESET while auxialiary
device was supposed to properly decouple the clock and reset part.
To keep things as they were I'll add an #if on CONFIG_AUXILIARY_BUS I
wonder if this driver should select CONFIG_AUXILIARY_BUS instead ?
>
> Ira
>
>> -
>> -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, "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 +364,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
>>
--
Jerome
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v3 6/7] clk: clk-imx8mp-audiomix: use the auxiliary device creation helper
2025-02-14 18:20 ` Jerome Brunet
@ 2025-02-14 22:03 ` Ira Weiny
0 siblings, 0 replies; 29+ messages in thread
From: Ira Weiny @ 2025-02-14 22:03 UTC (permalink / raw)
To: Jerome Brunet, Ira Weiny
Cc: Greg Kroah-Hartman, Dave Ertman, Rafael J. Wysocki, Stephen Boyd,
Arnd Bergmann, Danilo Krummrich, Conor Dooley, Daire McNamara,
Philipp Zabel, Douglas Anderson, Andrzej Hajda, Neil Armstrong,
Robert Foss, Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Hans de Goede, Ilpo Järvinen,
Bryan O'Donoghue, Vladimir Kondratiev, Gregory CLEMENT,
Théo Lebrun, Michael Turquette, Abel Vesa, Peng Fan,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Kevin Hilman, Martin Blumenstingl, linux-kernel, linux-riscv,
dri-devel, platform-driver-x86, linux-mips, linux-clk, imx,
linux-arm-kernel, linux-amlogic
Jerome Brunet wrote:
> On Fri 14 Feb 2025 at 10:15, Ira Weiny <ira.weiny@intel.com> wrote:
>
> > Jerome Brunet wrote:
> >> 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 | 56 ++++-------------------------------
> >> 1 file changed, 6 insertions(+), 50 deletions(-)
> >>
> >> diff --git a/drivers/clk/imx/clk-imx8mp-audiomix.c b/drivers/clk/imx/clk-imx8mp-audiomix.c
> >> index c409fc7e061869988f83c7df3ef7860500426323..988a5fffeb4e0e481ec57038d9d1f1b43432fc98 100644
> >> --- a/drivers/clk/imx/clk-imx8mp-audiomix.c
> >> +++ b/drivers/clk/imx/clk-imx8mp-audiomix.c
> >> @@ -228,64 +228,20 @@ struct clk_imx8mp_audiomix_priv {
> >> struct clk_hw_onecell_data clk_data;
> >> };
> >>
> >> -#if IS_ENABLED(CONFIG_RESET_CONTROLLER)
> >
> > I see the Kconfig ...
> >
> > select AUXILIARY_BUS if RESET_CONTROLLER
> >
> > But I don't see how this code is omitted without AUXILIARY_BUS. Is this
> > kconfig check safe to remove?
>
> Ahhh that's what this directive was for.
>
> I thought it was really odd to have an #if on RESET while auxialiary
> device was supposed to properly decouple the clock and reset part.
>
> To keep things as they were I'll add an #if on CONFIG_AUXILIARY_BUS I
> wonder if this driver should select CONFIG_AUXILIARY_BUS instead ?
I wonder if .../imx/clk-imx8mp-audiomix.c should be conditionally compiled
based off of AUXILIARY_BUS? That is what I expected to see when I dug
into the Kconfig/Makefile but it is not there AFAICS.
I think for this patch it is best to leave the kconfig as it was. But it
seems this is a place which could be cleaned up by the folks who work on
this driver?
Ira
>
> >
> > Ira
> >
> >> -
> >> -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, "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 +364,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
> >>
>
> --
> Jerome
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH v3 7/7] clk: amlogic: axg-audio: use the auxiliary reset driver - take 2
2025-02-11 17:27 [PATCH v3 0/7] driver core: auxiliary bus: add device creation helper Jerome Brunet
` (5 preceding siblings ...)
2025-02-11 17:28 ` [PATCH v3 6/7] clk: clk-imx8mp-audiomix: " Jerome Brunet
@ 2025-02-11 17:28 ` Jerome Brunet
2025-02-12 14:53 ` Théo Lebrun
2025-02-13 12:26 ` Arnd Bergmann
6 siblings, 2 replies; 29+ messages in thread
From: Jerome Brunet @ 2025-02-11 17:28 UTC (permalink / raw)
To: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann, Danilo Krummrich, Conor Dooley,
Daire McNamara, Philipp Zabel, Douglas Anderson, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Hans de Goede,
Ilpo Järvinen, Bryan O'Donoghue, Vladimir Kondratiev,
Gregory CLEMENT, Théo Lebrun, Michael Turquette, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Kevin Hilman, Martin Blumenstingl
Cc: Jerome Brunet, linux-kernel, linux-riscv, dri-devel,
platform-driver-x86, linux-mips, linux-clk, imx, linux-arm-kernel,
linux-amlogic
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 sticked 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..6d798705c5fd1e6190192294783c955fc9be1e21 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] 29+ messages in thread
* Re: [PATCH v3 7/7] clk: amlogic: axg-audio: use the auxiliary reset driver - take 2
2025-02-11 17:28 ` [PATCH v3 7/7] clk: amlogic: axg-audio: use the auxiliary reset driver - take 2 Jerome Brunet
@ 2025-02-12 14:53 ` Théo Lebrun
2025-02-13 10:16 ` Jerome Brunet
2025-02-13 12:26 ` Arnd Bergmann
1 sibling, 1 reply; 29+ messages in thread
From: Théo Lebrun @ 2025-02-12 14:53 UTC (permalink / raw)
To: Jerome Brunet, Greg Kroah-Hartman, Dave Ertman, Ira Weiny,
Rafael J. Wysocki, Stephen Boyd, Arnd Bergmann, Danilo Krummrich,
Conor Dooley, Daire McNamara, Philipp Zabel, Douglas Anderson,
Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Hans de Goede,
Ilpo Järvinen, Bryan O'Donoghue, Vladimir Kondratiev,
Gregory CLEMENT, Michael Turquette, Abel Vesa, Peng Fan,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Kevin Hilman, Martin Blumenstingl
Cc: linux-kernel, linux-riscv, dri-devel, platform-driver-x86,
linux-mips, linux-clk, imx, linux-arm-kernel, linux-amlogic
Hello Jerome,
Why the " - take 2" in the commit first line?
Thanks,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v3 7/7] clk: amlogic: axg-audio: use the auxiliary reset driver - take 2
2025-02-12 14:53 ` Théo Lebrun
@ 2025-02-13 10:16 ` Jerome Brunet
0 siblings, 0 replies; 29+ messages in thread
From: Jerome Brunet @ 2025-02-13 10:16 UTC (permalink / raw)
To: Théo Lebrun
Cc: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
Stephen Boyd, Arnd Bergmann, Danilo Krummrich, Conor Dooley,
Daire McNamara, Philipp Zabel, Douglas Anderson, Andrzej Hajda,
Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Hans de Goede,
Ilpo Järvinen, Bryan O'Donoghue, Vladimir Kondratiev,
Gregory CLEMENT, Michael Turquette, Abel Vesa, Peng Fan,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Kevin Hilman, Martin Blumenstingl, linux-kernel, linux-riscv,
dri-devel, platform-driver-x86, linux-mips, linux-clk, imx,
linux-arm-kernel, linux-amlogic
On Wed 12 Feb 2025 at 15:53, Théo Lebrun <theo.lebrun@bootlin.com> wrote:
> Hello Jerome,
>
> Why the " - take 2" in the commit first line?
Because, at the origin of the dicussion for this patchet, there was
another change doing the same thing [1]. The change was reverted do
perform some rework and now it is back. It was another series entirely
so v2, v3, etc ... did not really apply well.
Just giving a change to people using google or lore to distinguish the
two, that's all.
[1]: https://lore.kernel.org/lkml/f9fc8247-331e-4cdb-992e-bc2f196aa12c@linaro.org/T/#m9ab35b541a31b25bdd812082ed70f9dac087096e
>
> Thanks,
--
Jerome
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v3 7/7] clk: amlogic: axg-audio: use the auxiliary reset driver - take 2
2025-02-11 17:28 ` [PATCH v3 7/7] clk: amlogic: axg-audio: use the auxiliary reset driver - take 2 Jerome Brunet
2025-02-12 14:53 ` Théo Lebrun
@ 2025-02-13 12:26 ` Arnd Bergmann
2025-02-13 13:35 ` Jerome Brunet
1 sibling, 1 reply; 29+ messages in thread
From: Arnd Bergmann @ 2025-02-13 12:26 UTC (permalink / raw)
To: Jerome Brunet, Greg Kroah-Hartman, Dave Ertman, Ira Weiny,
Rafael J . Wysocki, Stephen Boyd, Danilo Krummrich, Conor.Dooley,
Daire McNamara, Philipp Zabel, Doug Anderson, Andrzej Hajda,
Neil Armstrong, Robert Foss, laurent.pinchart, Jonas Karlman,
Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, Dave Airlie, Simona Vetter, Hans de Goede,
Ilpo Järvinen, Bryan O'Donoghue, Vladimir Kondratiev,
Gregory Clement, Théo Lebrun, Michael Turquette, Abel Vesa,
Peng Fan, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Kevin Hilman, Martin Blumenstingl
Cc: linux-kernel, linux-riscv, dri-devel, platform-driver-x86,
linux-mips, linux-clk, imx, linux-arm-kernel, linux-amlogic
On Tue, Feb 11, 2025, at 18:28, Jerome Brunet wrote:
>
> 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.
I still think you should just drop the 'imply' line, all it does it
force reviewers to double-check that you didn't make a mistake
here, so it's a waste of time.
Arnd
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH v3 7/7] clk: amlogic: axg-audio: use the auxiliary reset driver - take 2
2025-02-13 12:26 ` Arnd Bergmann
@ 2025-02-13 13:35 ` Jerome Brunet
0 siblings, 0 replies; 29+ messages in thread
From: Jerome Brunet @ 2025-02-13 13:35 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J . Wysocki,
Stephen Boyd, Danilo Krummrich, Conor.Dooley, Daire McNamara,
Philipp Zabel, Doug Anderson, Andrzej Hajda, Neil Armstrong,
Robert Foss, laurent.pinchart, Jonas Karlman, Jernej Skrabec,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Dave Airlie,
Simona Vetter, Hans de Goede, Ilpo Järvinen,
Bryan O'Donoghue, Vladimir Kondratiev, Gregory Clement,
Théo Lebrun, Michael Turquette, Abel Vesa, Peng Fan,
Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Kevin Hilman, Martin Blumenstingl, linux-kernel, linux-riscv,
dri-devel, platform-driver-x86, linux-mips, linux-clk, imx,
linux-arm-kernel, linux-amlogic
On Thu 13 Feb 2025 at 13:26, "Arnd Bergmann" <arnd@arndb.de> wrote:
> On Tue, Feb 11, 2025, at 18:28, Jerome Brunet wrote:
>>
>> 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.
>
> I still think you should just drop the 'imply' line, all it does it
> force reviewers to double-check that you didn't make a mistake
> here, so it's a waste of time.
Arnd, you've made you preference clear and this note has been added
specifically for this reason, and transparency.
I've exposed a technical reason for my choice. Going with the 'default'
approach makes things more difficult in the long run for those
maintaining this platform, me included.
The trouble of having to coordinate changes in 2 different subsystems to
have an appropriate configuration and the pitfalls of using 'default'
outweigh the extra review trouble of using 'imply' ... especially when
the pitfall mentioned in documentation is explicitly addressed in the
description.
If there something wrong with 'imply' existing and being used, maybe the
Documentation should be updated to reflect this, or the support be
removed entirely.
ATM, it exists and it makes things a lot easier for me to support and
maintain this device.
This all started with a maintainer request to move some resets away
from clock. More requests have been added along the way, making things
more generic. I'm more than happy to have contributed my effort and
time on this and I don't think anybody's time has been wasted so far.
>
> Arnd
--
Jerome
^ permalink raw reply [flat|nested] 29+ messages in thread