All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Match data improvements for pca955x driver
@ 2023-09-30 17:56 Biju Das
  2023-09-30 17:56 ` [PATCH v3 1/2] leds: pca955x: Convert enum->pointer for data in the match tables Biju Das
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Biju Das @ 2023-09-30 17:56 UTC (permalink / raw)
  To: Pavel Machek, Lee Jones
  Cc: Biju Das, linux-leds, linux-kernel, Biju Das, Andy Shevchenko

This patch series aims to add match data improvements for pca955x driver.

This patch series is only compile tested.

v2->v3:
 * Added Rb tag from Andy.
 * Dropped tabs from struct pca955x.
v1->v2:
 * Added Rb tag from Lee Jones for patch#1.
 * Adeed patch#2 for cleanup of OF/ID table terminators.

Biju Das (2):
  leds: pca955x: Convert enum->pointer for data in the match tables
  leds: pca955x: Cleanup OF/ID table terminators

 drivers/leds/leds-pca955x.c | 71 +++++++++++++++----------------------
 1 file changed, 29 insertions(+), 42 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 1/2] leds: pca955x: Convert enum->pointer for data in the match tables
  2023-09-30 17:56 [PATCH v3 0/2] Match data improvements for pca955x driver Biju Das
@ 2023-09-30 17:56 ` Biju Das
  2023-09-30 17:56 ` [PATCH v3 2/2] leds: pca955x: Cleanup OF/ID table terminators Biju Das
  2023-10-05 13:11 ` [PATCH v3 0/2] Match data improvements for pca955x driver Lee Jones
  2 siblings, 0 replies; 7+ messages in thread
From: Biju Das @ 2023-09-30 17:56 UTC (permalink / raw)
  To: Pavel Machek, Lee Jones
  Cc: Biju Das, linux-leds, linux-kernel, Biju Das, Andy Shevchenko

Convert enum->pointer for data in the match tables, so that
device_get_match_data() can do match against OF/ACPI/I2C tables, once i2c
bus type match support added to it.

Replace enum->struct *pca955x_chipdefs for data in the match table.
Simplify the probe() by replacing device_get_match_data() and ID lookup
for retrieving data by i2c_get_match_data().

While at it, add const definition to pca955x_chipdefs[] and drop tabs
from struct pca955x.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Lee Jones <lee@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2->v3:
 * Added Rb tag from Andy
 * Dropped tabs from struct pca955x.
v1->v2:
 * Rebased to leds-next.
 * Added Rb tag from Lee Jones.
---
 drivers/leds/leds-pca955x.c | 51 ++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 32 deletions(-)

diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
index 1d7fa0cd97bf..7a83e84be6db 100644
--- a/drivers/leds/leds-pca955x.c
+++ b/drivers/leds/leds-pca955x.c
@@ -76,7 +76,7 @@ struct pca955x_chipdef {
 	int			slv_addr_shift;	/* Number of bits to ignore */
 };
 
-static struct pca955x_chipdef pca955x_chipdefs[] = {
+static const struct pca955x_chipdef pca955x_chipdefs[] = {
 	[pca9550] = {
 		.bits		= 2,
 		.slv_addr	= /* 110000x */ 0x60,
@@ -105,11 +105,11 @@ static struct pca955x_chipdef pca955x_chipdefs[] = {
 };
 
 static const struct i2c_device_id pca955x_id[] = {
-	{ "pca9550", pca9550 },
-	{ "pca9551", pca9551 },
-	{ "pca9552", pca9552 },
-	{ "ibm-pca9552", ibm_pca9552 },
-	{ "pca9553", pca9553 },
+	{ "pca9550", (kernel_ulong_t)&pca955x_chipdefs[pca9550] },
+	{ "pca9551", (kernel_ulong_t)&pca955x_chipdefs[pca9551] },
+	{ "pca9552", (kernel_ulong_t)&pca955x_chipdefs[pca9552] },
+	{ "ibm-pca9552", (kernel_ulong_t)&pca955x_chipdefs[ibm_pca9552] },
+	{ "pca9553", (kernel_ulong_t)&pca955x_chipdefs[pca9553] },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, pca955x_id);
@@ -117,8 +117,8 @@ MODULE_DEVICE_TABLE(i2c, pca955x_id);
 struct pca955x {
 	struct mutex lock;
 	struct pca955x_led *leds;
-	struct pca955x_chipdef	*chipdef;
-	struct i2c_client	*client;
+	const struct pca955x_chipdef *chipdef;
+	struct i2c_client *client;
 	unsigned long active_pins;
 #ifdef CONFIG_LEDS_PCA955X_GPIO
 	struct gpio_chip gpio;
@@ -415,7 +415,7 @@ static int pca955x_gpio_direction_output(struct gpio_chip *gc,
 #endif /* CONFIG_LEDS_PCA955X_GPIO */
 
 static struct pca955x_platform_data *
-pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip)
+pca955x_get_pdata(struct i2c_client *client, const struct pca955x_chipdef *chip)
 {
 	struct pca955x_platform_data *pdata;
 	struct pca955x_led *led;
@@ -458,11 +458,11 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip)
 }
 
 static const struct of_device_id of_pca955x_match[] = {
-	{ .compatible = "nxp,pca9550", .data = (void *)pca9550 },
-	{ .compatible = "nxp,pca9551", .data = (void *)pca9551 },
-	{ .compatible = "nxp,pca9552", .data = (void *)pca9552 },
-	{ .compatible = "ibm,pca9552", .data = (void *)ibm_pca9552 },
-	{ .compatible = "nxp,pca9553", .data = (void *)pca9553 },
+	{ .compatible = "nxp,pca9550", .data = &pca955x_chipdefs[pca9550] },
+	{ .compatible = "nxp,pca9551", .data = &pca955x_chipdefs[pca9551] },
+	{ .compatible = "nxp,pca9552", .data = &pca955x_chipdefs[pca9552] },
+	{ .compatible = "ibm,pca9552", .data = &pca955x_chipdefs[ibm_pca9552] },
+	{ .compatible = "nxp,pca9553", .data = &pca955x_chipdefs[pca9553] },
 	{},
 };
 MODULE_DEVICE_TABLE(of, of_pca955x_match);
@@ -471,7 +471,7 @@ static int pca955x_probe(struct i2c_client *client)
 {
 	struct pca955x *pca955x;
 	struct pca955x_led *pca955x_led;
-	struct pca955x_chipdef *chip;
+	const struct pca955x_chipdef *chip;
 	struct led_classdev *led;
 	struct led_init_data init_data;
 	struct i2c_adapter *adapter;
@@ -480,24 +480,11 @@ static int pca955x_probe(struct i2c_client *client)
 	bool set_default_label = false;
 	bool keep_pwm = false;
 	char default_label[8];
-	enum pca955x_type chip_type;
-	const void *md = device_get_match_data(&client->dev);
-
-	if (md) {
-		chip_type = (enum pca955x_type)(uintptr_t)md;
-	} else {
-		const struct i2c_device_id *id = i2c_match_id(pca955x_id,
-							      client);
-
-		if (id) {
-			chip_type = (enum pca955x_type)id->driver_data;
-		} else {
-			dev_err(&client->dev, "unknown chip\n");
-			return -ENODEV;
-		}
-	}
 
-	chip = &pca955x_chipdefs[chip_type];
+	chip = i2c_get_match_data(client);
+	if (!chip)
+		return dev_err_probe(&client->dev, -ENODEV, "unknown chip\n");
+
 	adapter = client->adapter;
 	pdata = dev_get_platdata(&client->dev);
 	if (!pdata) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 2/2] leds: pca955x: Cleanup OF/ID table terminators
  2023-09-30 17:56 [PATCH v3 0/2] Match data improvements for pca955x driver Biju Das
  2023-09-30 17:56 ` [PATCH v3 1/2] leds: pca955x: Convert enum->pointer for data in the match tables Biju Das
@ 2023-09-30 17:56 ` Biju Das
  2023-10-05 13:11 ` [PATCH v3 0/2] Match data improvements for pca955x driver Lee Jones
  2 siblings, 0 replies; 7+ messages in thread
From: Biju Das @ 2023-09-30 17:56 UTC (permalink / raw)
  To: Pavel Machek, Lee Jones
  Cc: Biju Das, linux-leds, linux-kernel, Biju Das, Andy Shevchenko

Some cleanups:
 * Remove the trailing comma in the terminator entry for the OF
   table making code robust against (theoretical) misrebases or other
   similar things where the new entry goes _after_ the termination without
   the compiler noticing.
 * Drop a space from terminator entry for ID table.

While at it, move OF/ID table near to the user.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2->v3:
 * Added Rb tag from Andy.
v2:
 * New patch.
---
 drivers/leds/leds-pca955x.c | 40 ++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
index 7a83e84be6db..6720e1c7a8d9 100644
--- a/drivers/leds/leds-pca955x.c
+++ b/drivers/leds/leds-pca955x.c
@@ -104,16 +104,6 @@ static const struct pca955x_chipdef pca955x_chipdefs[] = {
 	},
 };
 
-static const struct i2c_device_id pca955x_id[] = {
-	{ "pca9550", (kernel_ulong_t)&pca955x_chipdefs[pca9550] },
-	{ "pca9551", (kernel_ulong_t)&pca955x_chipdefs[pca9551] },
-	{ "pca9552", (kernel_ulong_t)&pca955x_chipdefs[pca9552] },
-	{ "ibm-pca9552", (kernel_ulong_t)&pca955x_chipdefs[ibm_pca9552] },
-	{ "pca9553", (kernel_ulong_t)&pca955x_chipdefs[pca9553] },
-	{ }
-};
-MODULE_DEVICE_TABLE(i2c, pca955x_id);
-
 struct pca955x {
 	struct mutex lock;
 	struct pca955x_led *leds;
@@ -457,16 +447,6 @@ pca955x_get_pdata(struct i2c_client *client, const struct pca955x_chipdef *chip)
 	return pdata;
 }
 
-static const struct of_device_id of_pca955x_match[] = {
-	{ .compatible = "nxp,pca9550", .data = &pca955x_chipdefs[pca9550] },
-	{ .compatible = "nxp,pca9551", .data = &pca955x_chipdefs[pca9551] },
-	{ .compatible = "nxp,pca9552", .data = &pca955x_chipdefs[pca9552] },
-	{ .compatible = "ibm,pca9552", .data = &pca955x_chipdefs[ibm_pca9552] },
-	{ .compatible = "nxp,pca9553", .data = &pca955x_chipdefs[pca9553] },
-	{},
-};
-MODULE_DEVICE_TABLE(of, of_pca955x_match);
-
 static int pca955x_probe(struct i2c_client *client)
 {
 	struct pca955x *pca955x;
@@ -650,6 +630,26 @@ static int pca955x_probe(struct i2c_client *client)
 	return 0;
 }
 
+static const struct i2c_device_id pca955x_id[] = {
+	{ "pca9550", (kernel_ulong_t)&pca955x_chipdefs[pca9550] },
+	{ "pca9551", (kernel_ulong_t)&pca955x_chipdefs[pca9551] },
+	{ "pca9552", (kernel_ulong_t)&pca955x_chipdefs[pca9552] },
+	{ "ibm-pca9552", (kernel_ulong_t)&pca955x_chipdefs[ibm_pca9552] },
+	{ "pca9553", (kernel_ulong_t)&pca955x_chipdefs[pca9553] },
+	{}
+};
+MODULE_DEVICE_TABLE(i2c, pca955x_id);
+
+static const struct of_device_id of_pca955x_match[] = {
+	{ .compatible = "nxp,pca9550", .data = &pca955x_chipdefs[pca9550] },
+	{ .compatible = "nxp,pca9551", .data = &pca955x_chipdefs[pca9551] },
+	{ .compatible = "nxp,pca9552", .data = &pca955x_chipdefs[pca9552] },
+	{ .compatible = "ibm,pca9552", .data = &pca955x_chipdefs[ibm_pca9552] },
+	{ .compatible = "nxp,pca9553", .data = &pca955x_chipdefs[pca9553] },
+	{}
+};
+MODULE_DEVICE_TABLE(of, of_pca955x_match);
+
 static struct i2c_driver pca955x_driver = {
 	.driver = {
 		.name	= "leds-pca955x",
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 0/2] Match data improvements for pca955x driver
  2023-09-30 17:56 [PATCH v3 0/2] Match data improvements for pca955x driver Biju Das
  2023-09-30 17:56 ` [PATCH v3 1/2] leds: pca955x: Convert enum->pointer for data in the match tables Biju Das
  2023-09-30 17:56 ` [PATCH v3 2/2] leds: pca955x: Cleanup OF/ID table terminators Biju Das
@ 2023-10-05 13:11 ` Lee Jones
  2023-10-05 15:48   ` Biju Das
  2 siblings, 1 reply; 7+ messages in thread
From: Lee Jones @ 2023-10-05 13:11 UTC (permalink / raw)
  To: Biju Das
  Cc: Pavel Machek, linux-leds, linux-kernel, Biju Das, Andy Shevchenko

On Sat, 30 Sep 2023, Biju Das wrote:

> This patch series aims to add match data improvements for pca955x driver.
> 
> This patch series is only compile tested.
> 
> v2->v3:
>  * Added Rb tag from Andy.
>  * Dropped tabs from struct pca955x.
> v1->v2:
>  * Added Rb tag from Lee Jones for patch#1.
>  * Adeed patch#2 for cleanup of OF/ID table terminators.
> 
> Biju Das (2):
>   leds: pca955x: Convert enum->pointer for data in the match tables
>   leds: pca955x: Cleanup OF/ID table terminators
> 
>  drivers/leds/leds-pca955x.c | 71 +++++++++++++++----------------------
>  1 file changed, 29 insertions(+), 42 deletions(-)

These no longer apply.

Please rebase and submit a [RESEND] so I can apply them.

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH v3 0/2] Match data improvements for pca955x driver
  2023-10-05 13:11 ` [PATCH v3 0/2] Match data improvements for pca955x driver Lee Jones
@ 2023-10-05 15:48   ` Biju Das
  2023-10-05 15:53     ` Lee Jones
  0 siblings, 1 reply; 7+ messages in thread
From: Biju Das @ 2023-10-05 15:48 UTC (permalink / raw)
  To: Lee Jones
  Cc: Pavel Machek, linux-leds@vger.kernel.org,
	linux-kernel@vger.kernel.org, Biju Das, Andy Shevchenko

Hi Lee Jones,

> -----Original Message-----
> From: Lee Jones <lee@kernel.org>
> Sent: Thursday, October 5, 2023 2:12 PM
> To: Biju Das <biju.das.jz@bp.renesas.com>
> Cc: Pavel Machek <pavel@ucw.cz>; linux-leds@vger.kernel.org; linux-
> kernel@vger.kernel.org; Biju Das <biju.das.au@gmail.com>; Andy Shevchenko
> <andriy.shevchenko@linux.intel.com>
> Subject: Re: [PATCH v3 0/2] Match data improvements for pca955x driver
> 
> On Sat, 30 Sep 2023, Biju Das wrote:
> 
> > This patch series aims to add match data improvements for pca955x driver.
> >
> > This patch series is only compile tested.
> >
> > v2->v3:
> >  * Added Rb tag from Andy.
> >  * Dropped tabs from struct pca955x.
> > v1->v2:
> >  * Added Rb tag from Lee Jones for patch#1.
> >  * Adeed patch#2 for cleanup of OF/ID table terminators.
> >
> > Biju Das (2):
> >   leds: pca955x: Convert enum->pointer for data in the match tables
> >   leds: pca955x: Cleanup OF/ID table terminators
> >
> >  drivers/leds/leds-pca955x.c | 71 +++++++++++++++----------------------
> >  1 file changed, 29 insertions(+), 42 deletions(-)
> 
> These no longer apply.
> 
> Please rebase and submit a [RESEND] so I can apply them.

Can you please point me to the tree I need to rebase?

I believe previously I have rebased with [1], Please confirm.

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/lee/leds.git?h=for-leds-next

Cheers,
Biju


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 0/2] Match data improvements for pca955x driver
  2023-10-05 15:48   ` Biju Das
@ 2023-10-05 15:53     ` Lee Jones
  2023-10-05 15:54       ` Biju Das
  0 siblings, 1 reply; 7+ messages in thread
From: Lee Jones @ 2023-10-05 15:53 UTC (permalink / raw)
  To: Biju Das
  Cc: Pavel Machek, linux-leds@vger.kernel.org,
	linux-kernel@vger.kernel.org, Biju Das, Andy Shevchenko

On Thu, 05 Oct 2023, Biju Das wrote:

> Hi Lee Jones,
> 
> > -----Original Message-----
> > From: Lee Jones <lee@kernel.org>
> > Sent: Thursday, October 5, 2023 2:12 PM
> > To: Biju Das <biju.das.jz@bp.renesas.com>
> > Cc: Pavel Machek <pavel@ucw.cz>; linux-leds@vger.kernel.org; linux-
> > kernel@vger.kernel.org; Biju Das <biju.das.au@gmail.com>; Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com>
> > Subject: Re: [PATCH v3 0/2] Match data improvements for pca955x driver
> > 
> > On Sat, 30 Sep 2023, Biju Das wrote:
> > 
> > > This patch series aims to add match data improvements for pca955x driver.
> > >
> > > This patch series is only compile tested.
> > >
> > > v2->v3:
> > >  * Added Rb tag from Andy.
> > >  * Dropped tabs from struct pca955x.
> > > v1->v2:
> > >  * Added Rb tag from Lee Jones for patch#1.
> > >  * Adeed patch#2 for cleanup of OF/ID table terminators.
> > >
> > > Biju Das (2):
> > >   leds: pca955x: Convert enum->pointer for data in the match tables
> > >   leds: pca955x: Cleanup OF/ID table terminators
> > >
> > >  drivers/leds/leds-pca955x.c | 71 +++++++++++++++----------------------
> > >  1 file changed, 29 insertions(+), 42 deletions(-)
> > 
> > These no longer apply.
> > 
> > Please rebase and submit a [RESEND] so I can apply them.
> 
> Can you please point me to the tree I need to rebase?
> 
> I believe previously I have rebased with [1], Please confirm.
> 
> [1]
> https://git.kernel.org/pub/scm/linux/kernel/git/lee/leds.git?h=for-leds-next

Yes, that'll do.  Or if you're prepared to wait for the overnight-sync
you can use Linux Next tomorrow.

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH v3 0/2] Match data improvements for pca955x driver
  2023-10-05 15:53     ` Lee Jones
@ 2023-10-05 15:54       ` Biju Das
  0 siblings, 0 replies; 7+ messages in thread
From: Biju Das @ 2023-10-05 15:54 UTC (permalink / raw)
  To: Lee Jones
  Cc: Pavel Machek, linux-leds@vger.kernel.org,
	linux-kernel@vger.kernel.org, Biju Das, Andy Shevchenko

> Subject: Re: [PATCH v3 0/2] Match data improvements for pca955x driver
> 
> On Thu, 05 Oct 2023, Biju Das wrote:
> 
> > Hi Lee Jones,
> >
> > > -----Original Message-----
> > > From: Lee Jones <lee@kernel.org>
> > > Sent: Thursday, October 5, 2023 2:12 PM
> > > To: Biju Das <biju.das.jz@bp.renesas.com>
> > > Cc: Pavel Machek <pavel@ucw.cz>; linux-leds@vger.kernel.org; linux-
> > > kernel@vger.kernel.org; Biju Das <biju.das.au@gmail.com>; Andy
> > > Shevchenko <andriy.shevchenko@linux.intel.com>
> > > Subject: Re: [PATCH v3 0/2] Match data improvements for pca955x
> > > driver
> > >
> > > On Sat, 30 Sep 2023, Biju Das wrote:
> > >
> > > > This patch series aims to add match data improvements for pca955x
> driver.
> > > >
> > > > This patch series is only compile tested.
> > > >
> > > > v2->v3:
> > > >  * Added Rb tag from Andy.
> > > >  * Dropped tabs from struct pca955x.
> > > > v1->v2:
> > > >  * Added Rb tag from Lee Jones for patch#1.
> > > >  * Adeed patch#2 for cleanup of OF/ID table terminators.
> > > >
> > > > Biju Das (2):
> > > >   leds: pca955x: Convert enum->pointer for data in the match tables
> > > >   leds: pca955x: Cleanup OF/ID table terminators
> > > >
> > > >  drivers/leds/leds-pca955x.c | 71
> > > > +++++++++++++++----------------------
> > > >  1 file changed, 29 insertions(+), 42 deletions(-)
> > >
> > > These no longer apply.
> > >
> > > Please rebase and submit a [RESEND] so I can apply them.
> >
> > Can you please point me to the tree I need to rebase?
> >
> > I believe previously I have rebased with [1], Please confirm.
> >
> > [1]
> 
> Yes, that'll do.  Or if you're prepared to wait for the overnight-sync you
> can use Linux Next tomorrow.

OK, will wait for Linux Next.

Cheers,
Biju

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-10-05 16:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-30 17:56 [PATCH v3 0/2] Match data improvements for pca955x driver Biju Das
2023-09-30 17:56 ` [PATCH v3 1/2] leds: pca955x: Convert enum->pointer for data in the match tables Biju Das
2023-09-30 17:56 ` [PATCH v3 2/2] leds: pca955x: Cleanup OF/ID table terminators Biju Das
2023-10-05 13:11 ` [PATCH v3 0/2] Match data improvements for pca955x driver Lee Jones
2023-10-05 15:48   ` Biju Das
2023-10-05 15:53     ` Lee Jones
2023-10-05 15:54       ` Biju Das

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.