[PATCH 13/23] iio: accel: mma7455: Convert to i2c's .probe_new

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



.probe_new() doesn't get the i2c_device_id * parameter, so determine
that explicitly in .probe(). The device_id array has to move up for that
to work.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
---
Alternatively it would be possible to just pass i2c->name to
mma7455_core_probe(). That's a simpler patch but that changes things
in case id == NULL, so I didn't do that here even though it might be
considered an improvement.
---
 drivers/iio/accel/mma7455_i2c.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/accel/mma7455_i2c.c b/drivers/iio/accel/mma7455_i2c.c
index c63b321b01cd..9518bd81f9e5 100644
--- a/drivers/iio/accel/mma7455_i2c.c
+++ b/drivers/iio/accel/mma7455_i2c.c
@@ -10,9 +10,16 @@
 
 #include "mma7455.h"
 
-static int mma7455_i2c_probe(struct i2c_client *i2c,
-			     const struct i2c_device_id *id)
+static const struct i2c_device_id mma7455_i2c_ids[] = {
+	{ "mma7455", 0 },
+	{ "mma7456", 0 },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, mma7455_i2c_ids);
+
+static int mma7455_i2c_probe(struct i2c_client *i2c)
 {
+	const struct i2c_device_id *id = i2c_match_id(mma7455_i2c_ids, i2c);
 	struct regmap *regmap;
 	const char *name = NULL;
 
@@ -31,13 +38,6 @@ static void mma7455_i2c_remove(struct i2c_client *i2c)
 	mma7455_core_remove(&i2c->dev);
 }
 
-static const struct i2c_device_id mma7455_i2c_ids[] = {
-	{ "mma7455", 0 },
-	{ "mma7456", 0 },
-	{ }
-};
-MODULE_DEVICE_TABLE(i2c, mma7455_i2c_ids);
-
 static const struct of_device_id mma7455_of_match[] = {
 	{ .compatible = "fsl,mma7455" },
 	{ .compatible = "fsl,mma7456" },
@@ -46,7 +46,7 @@ static const struct of_device_id mma7455_of_match[] = {
 MODULE_DEVICE_TABLE(of, mma7455_of_match);
 
 static struct i2c_driver mma7455_i2c_driver = {
-	.probe = mma7455_i2c_probe,
+	.probe_new = mma7455_i2c_probe,
 	.remove = mma7455_i2c_remove,
 	.id_table = mma7455_i2c_ids,
 	.driver = {
-- 
2.37.2




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux