diff mbox series

[6.1.y-cip,07/13] rtc: isl1208: Make similar I2C and DT-based matching table

Message ID 20230816142458.147476-8-biju.das.jz@bp.renesas.com (mailing list archive)
State Accepted
Headers show
Series Add Renesas PMIC RAA215300 driver and builtin RTC support | expand

Commit Message

Biju Das Aug. 16, 2023, 2:24 p.m. UTC
commit fbc06a53561c64ec6d7f9a1b3bc04597de4cbb2d upstream.

The isl1208_id[].driver_data could store a pointer to the config,
like for DT-based matching, making I2C and DT-based matching
more similar.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20230623140948.384762-8-biju.das.jz@bp.renesas.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/rtc/rtc-isl1208.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Pavel Machek Aug. 17, 2023, 11:11 a.m. UTC | #1
Hi!

> commit fbc06a53561c64ec6d7f9a1b3bc04597de4cbb2d upstream.
> 

> +++ b/drivers/rtc/rtc-isl1208.c
> @@ -90,10 +90,10 @@ static const struct isl1208_config {
>  };
>  
>  static const struct i2c_device_id isl1208_id[] = {
> -	{ "isl1208", TYPE_ISL1208 },
> -	{ "isl1209", TYPE_ISL1209 },
> -	{ "isl1218", TYPE_ISL1218 },
> -	{ "isl1219", TYPE_ISL1219 },
> +	{ "isl1208", .driver_data = (kernel_ulong_t)&isl1208_configs[TYPE_ISL1208] },
> +	{ "isl1209", .driver_data = (kernel_ulong_t)&isl1208_configs[TYPE_ISL1209] },
> +	{ "isl1218", .driver_data = (kernel_ulong_t)&isl1208_configs[TYPE_ISL1218] },
> +	{ "isl1219", .driver_data = (kernel_ulong_t)&isl1208_configs[TYPE_ISL1219] },

I'd expect to see "(unsigned long)" here.

Best regards,
								Pavel
Biju Das Aug. 17, 2023, 11:25 a.m. UTC | #2
Hi Pavel Machek,

Thanks for the feedback.

> Subject: Re: [PATCH 6.1.y-cip 07/13] rtc: isl1208: Make similar I2C and DT-
> based matching table
> 
> Hi!
> 
> > commit fbc06a53561c64ec6d7f9a1b3bc04597de4cbb2d upstream.
> >
> 
> > +++ b/drivers/rtc/rtc-isl1208.c
> > @@ -90,10 +90,10 @@ static const struct isl1208_config {  };
> >
> >  static const struct i2c_device_id isl1208_id[] = {
> > -	{ "isl1208", TYPE_ISL1208 },
> > -	{ "isl1209", TYPE_ISL1209 },
> > -	{ "isl1218", TYPE_ISL1218 },
> > -	{ "isl1219", TYPE_ISL1219 },
> > +	{ "isl1208", .driver_data =
> (kernel_ulong_t)&isl1208_configs[TYPE_ISL1208] },
> > +	{ "isl1209", .driver_data =
> (kernel_ulong_t)&isl1208_configs[TYPE_ISL1209] },
> > +	{ "isl1218", .driver_data =
> (kernel_ulong_t)&isl1208_configs[TYPE_ISL1218] },
> > +	{ "isl1219", .driver_data =
> > +(kernel_ulong_t)&isl1208_configs[TYPE_ISL1219] },
> 
> I'd expect to see "(unsigned long)" here.

Because driver_data is kernel_ulong_t. See below

struct i2c_device_id {
	char name[I2C_NAME_SIZE];
	kernel_ulong_t driver_data;	/* Data private to the driver */
};

Cheers,
Biju
Pavel Machek Aug. 17, 2023, 1:23 p.m. UTC | #3
Hi!

> > > +++ b/drivers/rtc/rtc-isl1208.c
> > > @@ -90,10 +90,10 @@ static const struct isl1208_config {  };
> > >
> > >  static const struct i2c_device_id isl1208_id[] = {
> > > -	{ "isl1208", TYPE_ISL1208 },
> > > -	{ "isl1209", TYPE_ISL1209 },
> > > -	{ "isl1218", TYPE_ISL1218 },
> > > -	{ "isl1219", TYPE_ISL1219 },
> > > +	{ "isl1208", .driver_data =
> > (kernel_ulong_t)&isl1208_configs[TYPE_ISL1208] },
> > > +	{ "isl1209", .driver_data =
> > (kernel_ulong_t)&isl1208_configs[TYPE_ISL1209] },
> > > +	{ "isl1218", .driver_data =
> > (kernel_ulong_t)&isl1208_configs[TYPE_ISL1218] },
> > > +	{ "isl1219", .driver_data =
> > > +(kernel_ulong_t)&isl1208_configs[TYPE_ISL1219] },
> > 
> > I'd expect to see "(unsigned long)" here.
> 
> Because driver_data is kernel_ulong_t. See below
> 
> struct i2c_device_id {
> 	char name[I2C_NAME_SIZE];
> 	kernel_ulong_t driver_data;	/* Data private to the driver */
> };

Aha, ok, that's quite unusual. Sorry for the noise.

Best regards,
								Pavel
diff mbox series

Patch

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 1716c0c3b550..67487a784e58 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -90,10 +90,10 @@  static const struct isl1208_config {
 };
 
 static const struct i2c_device_id isl1208_id[] = {
-	{ "isl1208", TYPE_ISL1208 },
-	{ "isl1209", TYPE_ISL1209 },
-	{ "isl1218", TYPE_ISL1218 },
-	{ "isl1219", TYPE_ISL1219 },
+	{ "isl1208", .driver_data = (kernel_ulong_t)&isl1208_configs[TYPE_ISL1208] },
+	{ "isl1209", .driver_data = (kernel_ulong_t)&isl1208_configs[TYPE_ISL1209] },
+	{ "isl1218", .driver_data = (kernel_ulong_t)&isl1208_configs[TYPE_ISL1218] },
+	{ "isl1219", .driver_data = (kernel_ulong_t)&isl1208_configs[TYPE_ISL1219] },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, isl1208_id);
@@ -820,9 +820,9 @@  isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
 		if (!isl1208->config)
 			return -ENODEV;
 	} else {
-		if (id->driver_data >= ISL_LAST_ID)
+		if (!id)
 			return -ENODEV;
-		isl1208->config = &isl1208_configs[id->driver_data];
+		isl1208->config = (struct isl1208_config *)id->driver_data;
 	}
 
 	isl1208->rtc = devm_rtc_allocate_device(&client->dev);