linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eddie James <eajames@linux.ibm.com>
To: linux-leds@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	robh+dt@kernel.org, pavel@ucw.cz,
	Eddie James <eajames@linux.ibm.com>
Subject: [PATCH v2 7/7] leds: pca955x: Switch to i2c probe_new
Date: Fri, 16 Jul 2021 17:03:31 -0500	[thread overview]
Message-ID: <20210716220331.49303-8-eajames@linux.ibm.com> (raw)
In-Reply-To: <20210716220331.49303-1-eajames@linux.ibm.com>

The deprecated i2c probe functionality doesn't work with OF
compatible strings, as it only checks for the i2c device id. Switch
to the new way of probing and grab the match data to select the
chip type.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
 drivers/leds/leds-pca955x.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
index a6aa4b9abde8..a6b5699aeae4 100644
--- a/drivers/leds/leds-pca955x.c
+++ b/drivers/leds/leds-pca955x.c
@@ -479,8 +479,7 @@ static const struct of_device_id of_pca955x_match[] = {
 };
 MODULE_DEVICE_TABLE(of, of_pca955x_match);
 
-static int pca955x_probe(struct i2c_client *client,
-			 const struct i2c_device_id *id)
+static int pca955x_probe(struct i2c_client *client)
 {
 	struct pca955x *pca955x;
 	struct pca955x_led *pca955x_led;
@@ -494,8 +493,24 @@ 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);
 
-	chip = &pca955x_chipdefs[id->driver_data];
+	if (md) {
+		chip_type = (enum pca955x_type)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];
 	adapter = client->adapter;
 	pdata = dev_get_platdata(&client->dev);
 	if (!pdata) {
@@ -670,7 +685,7 @@ static struct i2c_driver pca955x_driver = {
 		.name	= "leds-pca955x",
 		.of_match_table = of_pca955x_match,
 	},
-	.probe	= pca955x_probe,
+	.probe_new = pca955x_probe,
 	.id_table = pca955x_id,
 };
 
-- 
2.27.0


  parent reply	other threads:[~2021-07-16 22:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-16 22:03 [PATCH v2 0/7] leds: Support retaining state for the PCA955x Eddie James
2021-07-16 22:03 ` [PATCH v2 1/7] dt-bindings: leds: Add retain-state-shutdown boolean Eddie James
2021-07-16 22:03 ` [PATCH v2 2/7] leds: leds-core: Implement the retain-state-shutdown property Eddie James
2021-07-16 22:03 ` [PATCH v2 3/7] leds: pca955x: Clean up code formatting Eddie James
2021-07-16 22:03 ` [PATCH v2 4/7] leds: pca955x: Add brightness_get function Eddie James
2021-07-16 22:03 ` [PATCH v2 5/7] leds: pca955x: Implement the default-state property Eddie James
2021-07-16 22:03 ` [PATCH v2 6/7] leds: pca955x: Let the core process the fwnode Eddie James
2021-08-20  9:02   ` Pavel Machek
2021-07-16 22:03 ` Eddie James [this message]
2021-08-20  9:00 ` [PATCH v2 0/7] leds: Support retaining state for the PCA955x Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210716220331.49303-8-eajames@linux.ibm.com \
    --to=eajames@linux.ibm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).