[PATCH v3 net-next 8/8] mfd: zl3073x: Register DPLL sub-device during init

Ivan Vecera posted 10 patches 9 months, 4 weeks ago
Only 8 patches received!
There is a newer version of this series
[PATCH v3 net-next 8/8] mfd: zl3073x: Register DPLL sub-device during init
Posted by Ivan Vecera 9 months, 4 weeks ago
Register DPLL sub-devices to expose this functionality provided
by ZL3073x chip family. Each sub-device represents one of the provided
DPLL channels.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/mfd/zl3073x-core.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/mfd/zl3073x-core.c b/drivers/mfd/zl3073x-core.c
index 0bd31591245a2..fda77724a8452 100644
--- a/drivers/mfd/zl3073x-core.c
+++ b/drivers/mfd/zl3073x-core.c
@@ -6,6 +6,7 @@
 #include <linux/device.h>
 #include <linux/export.h>
 #include <linux/math64.h>
+#include <linux/mfd/core.h>
 #include <linux/mfd/zl3073x.h>
 #include <linux/mfd/zl3073x_regs.h>
 #include <linux/module.h>
@@ -774,6 +775,20 @@ int zl3073x_dev_probe(struct zl3073x_dev *zldev,
 	if (rc)
 		return rc;
 
+	/* Add DPLL sub-device cell for each DPLL channel */
+	for (i = 0; i < chip_info->num_channels; i++) {
+		struct mfd_cell dpll_dev = MFD_CELL_BASIC("zl3073x-dpll", NULL,
+							  NULL, 0, i);
+
+		rc = devm_mfd_add_devices(zldev->dev, PLATFORM_DEVID_AUTO,
+					  &dpll_dev, 1, NULL, 0, NULL);
+		if (rc) {
+			dev_err_probe(zldev->dev, rc,
+				      "Failed to add DPLL sub-device\n");
+			return rc;
+		}
+	}
+
 	/* Register the device as devlink device */
 	devlink = priv_to_devlink(zldev);
 	devlink_register(devlink);
-- 
2.48.1
Re: [PATCH v3 net-next 8/8] mfd: zl3073x: Register DPLL sub-device during init
Posted by Lee Jones 9 months, 3 weeks ago
On Wed, 16 Apr 2025, Ivan Vecera wrote:

> Register DPLL sub-devices to expose this functionality provided
> by ZL3073x chip family. Each sub-device represents one of the provided
> DPLL channels.
> 
> Signed-off-by: Ivan Vecera <ivecera@redhat.com>
> ---
>  drivers/mfd/zl3073x-core.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/mfd/zl3073x-core.c b/drivers/mfd/zl3073x-core.c
> index 0bd31591245a2..fda77724a8452 100644
> --- a/drivers/mfd/zl3073x-core.c
> +++ b/drivers/mfd/zl3073x-core.c
> @@ -6,6 +6,7 @@
>  #include <linux/device.h>
>  #include <linux/export.h>
>  #include <linux/math64.h>
> +#include <linux/mfd/core.h>
>  #include <linux/mfd/zl3073x.h>
>  #include <linux/mfd/zl3073x_regs.h>
>  #include <linux/module.h>
> @@ -774,6 +775,20 @@ int zl3073x_dev_probe(struct zl3073x_dev *zldev,
>  	if (rc)
>  		return rc;
>  
> +	/* Add DPLL sub-device cell for each DPLL channel */
> +	for (i = 0; i < chip_info->num_channels; i++) {
> +		struct mfd_cell dpll_dev = MFD_CELL_BASIC("zl3073x-dpll", NULL,
> +							  NULL, 0, i);

Create a static one of these with the maximum amount of channels.

> +
> +		rc = devm_mfd_add_devices(zldev->dev, PLATFORM_DEVID_AUTO,
> +					  &dpll_dev, 1, NULL, 0, NULL);

Then pass chip_info->num_channels as the 4th argument.

> +		if (rc) {
> +			dev_err_probe(zldev->dev, rc,
> +				      "Failed to add DPLL sub-device\n");
> +			return rc;
> +		}
> +	}
> +
>  	/* Register the device as devlink device */
>  	devlink = priv_to_devlink(zldev);
>  	devlink_register(devlink);
> -- 
> 2.48.1
> 

-- 
Lee Jones [李琼斯]
Re: [PATCH v3 net-next 8/8] mfd: zl3073x: Register DPLL sub-device during init
Posted by Ivan Vecera 9 months, 3 weeks ago

On 17. 04. 25 6:20 odp., Lee Jones wrote:
> On Wed, 16 Apr 2025, Ivan Vecera wrote:
> 
>> Register DPLL sub-devices to expose this functionality provided
>> by ZL3073x chip family. Each sub-device represents one of the provided
>> DPLL channels.
>>
>> Signed-off-by: Ivan Vecera <ivecera@redhat.com>
>> ---
>>   drivers/mfd/zl3073x-core.c | 15 +++++++++++++++
>>   1 file changed, 15 insertions(+)
>>
>> diff --git a/drivers/mfd/zl3073x-core.c b/drivers/mfd/zl3073x-core.c
>> index 0bd31591245a2..fda77724a8452 100644
>> --- a/drivers/mfd/zl3073x-core.c
>> +++ b/drivers/mfd/zl3073x-core.c
>> @@ -6,6 +6,7 @@
>>   #include <linux/device.h>
>>   #include <linux/export.h>
>>   #include <linux/math64.h>
>> +#include <linux/mfd/core.h>
>>   #include <linux/mfd/zl3073x.h>
>>   #include <linux/mfd/zl3073x_regs.h>
>>   #include <linux/module.h>
>> @@ -774,6 +775,20 @@ int zl3073x_dev_probe(struct zl3073x_dev *zldev,
>>   	if (rc)
>>   		return rc;
>>   
>> +	/* Add DPLL sub-device cell for each DPLL channel */
>> +	for (i = 0; i < chip_info->num_channels; i++) {
>> +		struct mfd_cell dpll_dev = MFD_CELL_BASIC("zl3073x-dpll", NULL,
>> +							  NULL, 0, i);
> 
> Create a static one of these with the maximum amount of channels.

Like this?

static const struct mfd_cell dpll_cells[] = {
	MFD_CELL_BASIC("zl3073x-dpll", NULL, NULL, 0, 1),
	MFD_CELL_BASIC("zl3073x-dpll", NULL, NULL, 0, 2),
	MFD_CELL_BASIC("zl3073x-dpll", NULL, NULL, 0, 3),
	MFD_CELL_BASIC("zl3073x-dpll", NULL, NULL, 0, 4),
	MFD_CELL_BASIC("zl3073x-dpll", NULL, NULL, 0, 5),
};

rc = devm_mfd_add_devices(zldev->dev, PLATFORM_DEVID_AUTO, dpll_cells,
                           chip_info->num_channels, NULL, 0, NULL);

Ivan
> 
>> +
>> +		rc = devm_mfd_add_devices(zldev->dev, PLATFORM_DEVID_AUTO,
>> +					  &dpll_dev, 1, NULL, 0, NULL);
> 
> Then pass chip_info->num_channels as the 4th argument.
> 
>> +		if (rc) {
>> +			dev_err_probe(zldev->dev, rc,
>> +				      "Failed to add DPLL sub-device\n");
>> +			return rc;
>> +		}
>> +	}
>> +
>>   	/* Register the device as devlink device */
>>   	devlink = priv_to_devlink(zldev);
>>   	devlink_register(devlink);
>> -- 
>> 2.48.1
>>
>
Re: [PATCH v3 net-next 8/8] mfd: zl3073x: Register DPLL sub-device during init
Posted by Lee Jones 9 months, 2 weeks ago
On Thu, 17 Apr 2025, Ivan Vecera wrote:

> 
> 
> On 17. 04. 25 6:20 odp., Lee Jones wrote:
> > On Wed, 16 Apr 2025, Ivan Vecera wrote:
> > 
> > > Register DPLL sub-devices to expose this functionality provided
> > > by ZL3073x chip family. Each sub-device represents one of the provided
> > > DPLL channels.
> > > 
> > > Signed-off-by: Ivan Vecera <ivecera@redhat.com>
> > > ---
> > >   drivers/mfd/zl3073x-core.c | 15 +++++++++++++++
> > >   1 file changed, 15 insertions(+)
> > > 
> > > diff --git a/drivers/mfd/zl3073x-core.c b/drivers/mfd/zl3073x-core.c
> > > index 0bd31591245a2..fda77724a8452 100644
> > > --- a/drivers/mfd/zl3073x-core.c
> > > +++ b/drivers/mfd/zl3073x-core.c
> > > @@ -6,6 +6,7 @@
> > >   #include <linux/device.h>
> > >   #include <linux/export.h>
> > >   #include <linux/math64.h>
> > > +#include <linux/mfd/core.h>
> > >   #include <linux/mfd/zl3073x.h>
> > >   #include <linux/mfd/zl3073x_regs.h>
> > >   #include <linux/module.h>
> > > @@ -774,6 +775,20 @@ int zl3073x_dev_probe(struct zl3073x_dev *zldev,
> > >   	if (rc)
> > >   		return rc;
> > > +	/* Add DPLL sub-device cell for each DPLL channel */
> > > +	for (i = 0; i < chip_info->num_channels; i++) {
> > > +		struct mfd_cell dpll_dev = MFD_CELL_BASIC("zl3073x-dpll", NULL,
> > > +							  NULL, 0, i);
> > 
> > Create a static one of these with the maximum amount of channels.
> 
> Like this?
> 
> static const struct mfd_cell dpll_cells[] = {
> 	MFD_CELL_BASIC("zl3073x-dpll", NULL, NULL, 0, 1),
> 	MFD_CELL_BASIC("zl3073x-dpll", NULL, NULL, 0, 2),
> 	MFD_CELL_BASIC("zl3073x-dpll", NULL, NULL, 0, 3),
> 	MFD_CELL_BASIC("zl3073x-dpll", NULL, NULL, 0, 4),
> 	MFD_CELL_BASIC("zl3073x-dpll", NULL, NULL, 0, 5),
> };
> 
> rc = devm_mfd_add_devices(zldev->dev, PLATFORM_DEVID_AUTO, dpll_cells,
>                           chip_info->num_channels, NULL, 0, NULL);

Yes, looks better, thank you.

-- 
Lee Jones [李琼斯]
Re: [PATCH v3 net-next 8/8] mfd: zl3073x: Register DPLL sub-device during init
Posted by Lee Jones 9 months, 2 weeks ago
On Thu, 24 Apr 2025, Lee Jones wrote:

> On Thu, 17 Apr 2025, Ivan Vecera wrote:
> 
> > 
> > 
> > On 17. 04. 25 6:20 odp., Lee Jones wrote:
> > > On Wed, 16 Apr 2025, Ivan Vecera wrote:
> > > 
> > > > Register DPLL sub-devices to expose this functionality provided
> > > > by ZL3073x chip family. Each sub-device represents one of the provided
> > > > DPLL channels.
> > > > 
> > > > Signed-off-by: Ivan Vecera <ivecera@redhat.com>
> > > > ---
> > > >   drivers/mfd/zl3073x-core.c | 15 +++++++++++++++
> > > >   1 file changed, 15 insertions(+)
> > > > 
> > > > diff --git a/drivers/mfd/zl3073x-core.c b/drivers/mfd/zl3073x-core.c
> > > > index 0bd31591245a2..fda77724a8452 100644
> > > > --- a/drivers/mfd/zl3073x-core.c
> > > > +++ b/drivers/mfd/zl3073x-core.c
> > > > @@ -6,6 +6,7 @@
> > > >   #include <linux/device.h>
> > > >   #include <linux/export.h>
> > > >   #include <linux/math64.h>
> > > > +#include <linux/mfd/core.h>
> > > >   #include <linux/mfd/zl3073x.h>
> > > >   #include <linux/mfd/zl3073x_regs.h>
> > > >   #include <linux/module.h>
> > > > @@ -774,6 +775,20 @@ int zl3073x_dev_probe(struct zl3073x_dev *zldev,
> > > >   	if (rc)
> > > >   		return rc;
> > > > +	/* Add DPLL sub-device cell for each DPLL channel */
> > > > +	for (i = 0; i < chip_info->num_channels; i++) {
> > > > +		struct mfd_cell dpll_dev = MFD_CELL_BASIC("zl3073x-dpll", NULL,
> > > > +							  NULL, 0, i);
> > > 
> > > Create a static one of these with the maximum amount of channels.
> > 
> > Like this?
> > 
> > static const struct mfd_cell dpll_cells[] = {
> > 	MFD_CELL_BASIC("zl3073x-dpll", NULL, NULL, 0, 1),
> > 	MFD_CELL_BASIC("zl3073x-dpll", NULL, NULL, 0, 2),
> > 	MFD_CELL_BASIC("zl3073x-dpll", NULL, NULL, 0, 3),
> > 	MFD_CELL_BASIC("zl3073x-dpll", NULL, NULL, 0, 4),
> > 	MFD_CELL_BASIC("zl3073x-dpll", NULL, NULL, 0, 5),
> > };
> > 
> > rc = devm_mfd_add_devices(zldev->dev, PLATFORM_DEVID_AUTO, dpll_cells,
> >                           chip_info->num_channels, NULL, 0, NULL);
> 
> Yes, looks better, thank you.

Sorry, just a thought.  Since this is non-standard, please make it easy
on the reader by providing a comment to say that this call will register
a variable number of devices depending on the value of num_channels.

-- 
Lee Jones [李琼斯]