Skip to contentSkip to conversation

fsi: Convert to bus probe mechanism

PATCH In review Uwe Kleine-König 2 participants 29 messages Dec 9, 2025 – Jan 27

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 cover fsi: Convert to bus probe mechanism

Hello,

this is the 2nd installment of the series converting the fsi bus to use bus methods for .probe and .remove. The changes since the first iteration---that can be found at
https://lore.kernel.org/lkml/[email protected]/
--- are:

- (trivially) rebase to v6.18
- add tags by Andi (for the i2c parts) and Mark Brown (for the spi parts)
- Add a patch converting drivers/fsi/i2cr-scom.c (#8)

In the earlier thread I thought I made a mistake for (implicit) v1, but I confused fsi with fsl and the problem doesn't apply here as it doesn't touch the shutdown callback.

This series is not urgent, but it would be great to get this into v6.19-rc1. With Mark's Acks and Andi's tags (though they are not an Ack) this should be fine to be picked up in one go by Eddie.

As before there are two commit refs that should refer to the commit for patch #2 ("fsi: Assign driver's bus in fsi_driver_register()"). As I cannot know the commit hash yet, I wrote "FIXME" and these need updating when the series is picked up.

Thanks
Uwe

Uwe Kleine-König (13):
fsi: Make use of module_fsi_driver()
fsi: Assign driver's bus in fsi_driver_register()
fsi: Provide thin wrappers around dev_[gs]et_data() for fsi devices
i2c: fsi: Drop assigning fsi bus
spi: fsi: Drop assigning fsi bus
fsi: Make fsi_bus_type a private variable to the core
fsi: Create bus specific probe and remove functions
fsi: i2cr-scom: Convert to fsi bus probe mechanism
fsi: master: Convert to fsi bus probe mechanism
fsi: sbefifo: Convert to fsi bus probe mechanism
fsi: scom: Convert to fsi bus probe mechanism
i2c: fsi: Convert to fsi bus probe mechanism
spi: fsi: Convert to fsi bus probe mechanism

 drivers/fsi/fsi-core.c       | 107 ++++++++++++++++++++++++++---------
 drivers/fsi/fsi-master-hub.c |  17 +++---
 drivers/fsi/fsi-sbefifo.c    |  31 +++-------
 drivers/fsi/fsi-scom.c       |  30 +++-------
 drivers/fsi/i2cr-scom.c      |  15 ++---
 drivers/i2c/busses/i2c-fsi.c |  16 +++---
 drivers/spi/spi-fsi.c        |   7 +--
 include/linux/fsi.h          |  13 ++++-
 8 files changed, 131 insertions(+), 105 deletions(-)

base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449

Signature · 1 line
2.47.3
#1 lore raw

PATCH v2 1/13 fsi: Make use of module_fsi_driver()

All other fsi drivers already use this helper to reduce boilerplate. Catch up for the last two remaining ones.

---
 drivers/fsi/fsi-sbefifo.c | 13 +------------
 drivers/fsi/fsi-scom.c    | 13 +------------
 2 files changed, 2 insertions(+), 24 deletions(-)
drivers/fsi/fsi-sbefifo.c +1 -12
index 0a98517f3959..5a08423d0c7e 100644
@@ -1139,18 +1139,7 @@ static struct fsi_driver sbefifo_drv = {
 	}
 };
 
-static int sbefifo_init(void)
-{
-	return fsi_driver_register(&sbefifo_drv);
-}
-
-static void sbefifo_exit(void)
-{
-	fsi_driver_unregister(&sbefifo_drv);
-}
-
-module_init(sbefifo_init);
-module_exit(sbefifo_exit);
+module_fsi_driver(sbefifo_drv);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Brad Bishop <[email protected]>");
 MODULE_AUTHOR("Eddie James <[email protected]>");
drivers/fsi/fsi-scom.c +1 -12
index 411ddc018cd8..f533106085ac 100644
@@ -613,17 +613,6 @@ static struct fsi_driver scom_drv = {
 	}
 };
 
-static int scom_init(void)
-{
-	return fsi_driver_register(&scom_drv);
-}
-
-static void scom_exit(void)
-{
-	fsi_driver_unregister(&scom_drv);
-}
-
-module_init(scom_init);
-module_exit(scom_exit);
+module_fsi_driver(scom_drv);
 MODULE_DESCRIPTION("SCOM FSI Client device driver");
 MODULE_LICENSE("GPL");
Signature · 1 line
2.47.3
maintainer Acked-by on v2 1/13
#2 lore raw

Re: [PATCH v2 01/13] fsi: Make use of module_fsi_driver()

Quoted 2 lines · Uwe Kleine-König

All other fsi drivers already use this helper to reduce boilerplate. Catch up for the last two remaining ones.

Quoted 54 lines
---
  drivers/fsi/fsi-sbefifo.c | 13 +------------
  drivers/fsi/fsi-scom.c    | 13 +------------
  2 files changed, 2 insertions(+), 24 deletions(-)
drivers/fsi/fsi-sbefifo.c +1 -12
index 0a98517f3959..5a08423d0c7e 100644
@@ -1139,18 +1139,7 @@ static struct fsi_driver sbefifo_drv = {
  	}
  };
 
-static int sbefifo_init(void)
-{
-	return fsi_driver_register(&sbefifo_drv);
-}
-
-static void sbefifo_exit(void)
-{
-	fsi_driver_unregister(&sbefifo_drv);
-}
-
-module_init(sbefifo_init);
-module_exit(sbefifo_exit);
+module_fsi_driver(sbefifo_drv);
  MODULE_LICENSE("GPL");
  MODULE_AUTHOR("Brad Bishop <[email protected]>");
  MODULE_AUTHOR("Eddie James <[email protected]>");
drivers/fsi/fsi-scom.c +1 -12
index 411ddc018cd8..f533106085ac 100644
@@ -613,17 +613,6 @@ static struct fsi_driver scom_drv = {
  	}
  };
 
-static int scom_init(void)
-{
-	return fsi_driver_register(&scom_drv);
-}
-
-static void scom_exit(void)
-{
-	fsi_driver_unregister(&scom_drv);
-}
-
-module_init(scom_init);
-module_exit(scom_exit);
+module_fsi_driver(scom_drv);
  MODULE_DESCRIPTION("SCOM FSI Client device driver");
  MODULE_LICENSE("GPL");
#3 lore raw

PATCH v2 2/13 fsi: Assign driver's bus in fsi_driver_register()

In reply to Uwe Kleine-König

Instead of letting each driver assign the bus, do it once in the fsi driver register function.

Simplify the fsi drivers that are living in drivers/fsi accordingly.

Once all fsi drivers dropped assigning the bus, fsi_bus_type can be made a static variable.

---
 drivers/fsi/fsi-core.c       | 2 ++
 drivers/fsi/fsi-master-hub.c | 1 -
 drivers/fsi/fsi-sbefifo.c    | 1 -
 drivers/fsi/fsi-scom.c       | 1 -
 drivers/fsi/i2cr-scom.c      | 1 -
 5 files changed, 2 insertions(+), 4 deletions(-)
drivers/fsi/fsi-core.c +2 -0
index c6c115993ebc..e1ea1124282e 100644
@@ -1394,6 +1394,8 @@ int fsi_driver_register(struct fsi_driver *fsi_drv)
 	if (!fsi_drv->id_table)
 		return -EINVAL;
 
+	fsi_drv->drv.bus = &fsi_bus_type;
+
 	return driver_register(&fsi_drv->drv);
 }
 EXPORT_SYMBOL_GPL(fsi_driver_register);
drivers/fsi/fsi-master-hub.c +0 -1
index 6568fed7db3c..d389856d18ac 100644
@@ -288,7 +288,6 @@ static struct fsi_driver hub_master_driver = {
 	.id_table = hub_master_ids,
 	.drv = {
 		.name = "fsi-master-hub",
-		.bus = &fsi_bus_type,
 		.probe = hub_master_probe,
 		.remove = hub_master_remove,
 	}
drivers/fsi/fsi-sbefifo.c +0 -1
index 5a08423d0c7e..fde1c34743a0 100644
@@ -1133,7 +1133,6 @@ static struct fsi_driver sbefifo_drv = {
 	.id_table = sbefifo_ids,
 	.drv = {
 		.name = DEVICE_NAME,
-		.bus = &fsi_bus_type,
 		.probe = sbefifo_probe,
 		.remove = sbefifo_remove,
 	}
drivers/fsi/fsi-scom.c +0 -1
index f533106085ac..2eda44451cc1 100644
@@ -606,7 +606,6 @@ static struct fsi_driver scom_drv = {
 	.id_table = scom_ids,
 	.drv = {
 		.name = "scom",
-		.bus = &fsi_bus_type,
 		.of_match_table = scom_of_ids,
 		.probe = scom_probe,
 		.remove = scom_remove,
drivers/fsi/i2cr-scom.c +0 -1
index cb7e02213032..dfdb16afd205 100644
@@ -140,7 +140,6 @@ static struct fsi_driver i2cr_scom_driver = {
 	.id_table = i2cr_scom_ids,
 	.drv = {
 		.name = "i2cr_scom",
-		.bus = &fsi_bus_type,
 		.of_match_table = i2cr_scom_of_ids,
 		.probe = i2cr_scom_probe,
 		.remove = i2cr_scom_remove,
Signature · 1 line
2.47.3
maintainer Acked-by on v2 2/13
#4 lore raw

Re: [PATCH v2 02/13] fsi: Assign driver's bus in fsi_driver_register()

Quoted 7 lines · Uwe Kleine-König

Instead of letting each driver assign the bus, do it once in the fsi driver register function.

Simplify the fsi drivers that are living in drivers/fsi accordingly.

Once all fsi drivers dropped assigning the bus, fsi_bus_type can be made a static variable.

Quoted 71 lines
---
  drivers/fsi/fsi-core.c       | 2 ++
  drivers/fsi/fsi-master-hub.c | 1 -
  drivers/fsi/fsi-sbefifo.c    | 1 -
  drivers/fsi/fsi-scom.c       | 1 -
  drivers/fsi/i2cr-scom.c      | 1 -
  5 files changed, 2 insertions(+), 4 deletions(-)
drivers/fsi/fsi-core.c +2 -0
index c6c115993ebc..e1ea1124282e 100644
@@ -1394,6 +1394,8 @@ int fsi_driver_register(struct fsi_driver *fsi_drv)
  	if (!fsi_drv->id_table)
  		return -EINVAL;
 
+	fsi_drv->drv.bus = &fsi_bus_type;
+
  	return driver_register(&fsi_drv->drv);
  }
  EXPORT_SYMBOL_GPL(fsi_driver_register);
drivers/fsi/fsi-master-hub.c +0 -1
index 6568fed7db3c..d389856d18ac 100644
@@ -288,7 +288,6 @@ static struct fsi_driver hub_master_driver = {
  	.id_table = hub_master_ids,
  	.drv = {
  		.name = "fsi-master-hub",
-		.bus = &fsi_bus_type,
  		.probe = hub_master_probe,
  		.remove = hub_master_remove,
  	}
drivers/fsi/fsi-sbefifo.c +0 -1
index 5a08423d0c7e..fde1c34743a0 100644
@@ -1133,7 +1133,6 @@ static struct fsi_driver sbefifo_drv = {
  	.id_table = sbefifo_ids,
  	.drv = {
  		.name = DEVICE_NAME,
-		.bus = &fsi_bus_type,
  		.probe = sbefifo_probe,
  		.remove = sbefifo_remove,
  	}
drivers/fsi/fsi-scom.c +0 -1
index f533106085ac..2eda44451cc1 100644
@@ -606,7 +606,6 @@ static struct fsi_driver scom_drv = {
  	.id_table = scom_ids,
  	.drv = {
  		.name = "scom",
-		.bus = &fsi_bus_type,
  		.of_match_table = scom_of_ids,
  		.probe = scom_probe,
  		.remove = scom_remove,
drivers/fsi/i2cr-scom.c +0 -1
index cb7e02213032..dfdb16afd205 100644
@@ -140,7 +140,6 @@ static struct fsi_driver i2cr_scom_driver = {
  	.id_table = i2cr_scom_ids,
  	.drv = {
  		.name = "i2cr_scom",
-		.bus = &fsi_bus_type,
  		.of_match_table = i2cr_scom_of_ids,
  		.probe = i2cr_scom_probe,
  		.remove = i2cr_scom_remove,
#5 lore raw

PATCH v2 3/13 fsi: Provide thin wrappers around dev_[gs]et_data() for fsi devices

In reply to Uwe Kleine-König

Similar to wrappers for other subsystems provide inline functions for fsi devices to store driver data.

---
 include/linux/fsi.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
include/linux/fsi.h +10 -0
index adea1b432f2d..05be75869a69 100644
@@ -19,6 +19,16 @@ struct fsi_device {
 	uint32_t		size;
 };
 
+static inline void *fsi_get_drvdata(struct fsi_device *fsi_dev)
+{
+	return dev_get_drvdata(&fsi_dev->dev);
+}
+
+static inline void fsi_set_drvdata(struct fsi_device *fsi_dev, void *data)
+{
+	dev_set_drvdata(&fsi_dev->dev, data);
+}
+
 extern int fsi_device_read(struct fsi_device *dev, uint32_t addr,
 		void *val, size_t size);
 extern int fsi_device_write(struct fsi_device *dev, uint32_t addr,
Signature · 1 line
2.47.3
maintainer Acked-by on v2 3/13
#6 lore raw

Re: [PATCH v2 03/13] fsi: Provide thin wrappers around dev_[gs]et_data() for fsi devices

Quoted 2 lines · Uwe Kleine-König

Similar to wrappers for other subsystems provide inline functions for fsi devices to store driver data.

Quoted 27 lines
---
  include/linux/fsi.h | 10 ++++++++++
  1 file changed, 10 insertions(+)
include/linux/fsi.h +10 -0
index adea1b432f2d..05be75869a69 100644
@@ -19,6 +19,16 @@ struct fsi_device {
  	uint32_t		size;
  };
 
+static inline void *fsi_get_drvdata(struct fsi_device *fsi_dev)
+{
+	return dev_get_drvdata(&fsi_dev->dev);
+}
+
+static inline void fsi_set_drvdata(struct fsi_device *fsi_dev, void *data)
+{
+	dev_set_drvdata(&fsi_dev->dev, data);
+}
+
  extern int fsi_device_read(struct fsi_device *dev, uint32_t addr,
  		void *val, size_t size);
  extern int fsi_device_write(struct fsi_device *dev, uint32_t addr,
#7 lore raw

PATCH v2 4/13 i2c: fsi: Drop assigning fsi bus

In reply to Uwe Kleine-König

Since commit FIXME ("fsi: Assign driver's bus in fsi_driver_register()") module_fsi_driver() cares about assigning the driver's bus member. Drop the explicit driver specific assignment.

---
 drivers/i2c/busses/i2c-fsi.c | 1 -
 1 file changed, 1 deletion(-)
drivers/i2c/busses/i2c-fsi.c +0 -1
index ae016a9431da..e98dd5dcac0f 100644
@@ -763,7 +763,6 @@ static struct fsi_driver fsi_i2c_driver = {
 	.id_table = fsi_i2c_ids,
 	.drv = {
 		.name = "i2c-fsi",
-		.bus = &fsi_bus_type,
 		.probe = fsi_i2c_probe,
 		.remove = fsi_i2c_remove,
 	},
Signature · 1 line
2.47.3
maintainer Acked-by on v2 4/13
#8 lore raw

Re: [PATCH v2 04/13] i2c: fsi: Drop assigning fsi bus

Quoted 3 lines · Uwe Kleine-König

Since commit FIXME ("fsi: Assign driver's bus in fsi_driver_register()") module_fsi_driver() cares about assigning the driver's bus member. Drop the explicit driver specific assignment.

Quoted 19 lines
---
  drivers/i2c/busses/i2c-fsi.c | 1 -
  1 file changed, 1 deletion(-)
drivers/i2c/busses/i2c-fsi.c +0 -1
index ae016a9431da..e98dd5dcac0f 100644
@@ -763,7 +763,6 @@ static struct fsi_driver fsi_i2c_driver = {
  	.id_table = fsi_i2c_ids,
  	.drv = {
  		.name = "i2c-fsi",
-		.bus = &fsi_bus_type,
  		.probe = fsi_i2c_probe,
  		.remove = fsi_i2c_remove,
  	},
#9 lore raw

PATCH v2 5/13 spi: fsi: Drop assigning fsi bus

In reply to Uwe Kleine-König

Since commit FIXME ("fsi: Assign driver's bus in fsi_driver_register()") module_fsi_driver() cares about assigning the driver's bus member. Drop the explicit driver specific assignment.

---
 drivers/spi/spi-fsi.c | 1 -
 1 file changed, 1 deletion(-)
drivers/spi/spi-fsi.c +0 -1
index e01c63d23b64..f9c15b99dba5 100644
@@ -595,7 +595,6 @@ static struct fsi_driver fsi_spi_driver = {
 	.id_table = fsi_spi_ids,
 	.drv = {
 		.name = "spi-fsi",
-		.bus = &fsi_bus_type,
 		.probe = fsi_spi_probe,
 	},
 };
Signature · 1 line
2.47.3
maintainer Acked-by on v2 5/13
#10 lore raw

Re: [PATCH v2 05/13] spi: fsi: Drop assigning fsi bus

Quoted 3 lines · Uwe Kleine-König

Since commit FIXME ("fsi: Assign driver's bus in fsi_driver_register()") module_fsi_driver() cares about assigning the driver's bus member. Drop the explicit driver specific assignment.

Quoted 19 lines
---
  drivers/spi/spi-fsi.c | 1 -
  1 file changed, 1 deletion(-)
drivers/spi/spi-fsi.c +0 -1
index e01c63d23b64..f9c15b99dba5 100644
@@ -595,7 +595,6 @@ static struct fsi_driver fsi_spi_driver = {
  	.id_table = fsi_spi_ids,
  	.drv = {
  		.name = "spi-fsi",
-		.bus = &fsi_bus_type,
  		.probe = fsi_spi_probe,
  	},
  };
#11 lore raw

PATCH v2 6/13 fsi: Make fsi_bus_type a private variable to the core

In reply to Uwe Kleine-König

There are no users of fsi_bus_type outside of fsi-core.c, so make that variable static, don't export it and drop the declaration from the public header file.

As there is a usage of fsi_bus_type in fsi_create_device() the definition of that variable must happen further up in the file to not have to add a local declaration.

---
 drivers/fsi/fsi-core.c | 67 +++++++++++++++++++++---------------------
 include/linux/fsi.h    |  1 -
 2 files changed, 33 insertions(+), 35 deletions(-)
drivers/fsi/fsi-core.c +33 -34
index e1ea1124282e..4e60d4b17c11 100644
@@ -100,6 +100,39 @@ static int fsi_master_write(struct fsi_master *master, int link,
 		uint8_t slave_id, uint32_t addr, const void *val, size_t size);
 static int fsi_master_break(struct fsi_master *master, int link);
 
+/* FSI core & Linux bus type definitions */
+
+static int fsi_bus_match(struct device *dev, const struct device_driver *drv)
+{
+	struct fsi_device *fsi_dev = to_fsi_dev(dev);
+	const struct fsi_driver *fsi_drv = to_fsi_drv(drv);
+	const struct fsi_device_id *id;
+
+	if (!fsi_drv->id_table)
+		return 0;
+
+	for (id = fsi_drv->id_table; id->engine_type; id++) {
+		if (id->engine_type != fsi_dev->engine_type)
+			continue;
+		if (id->version == FSI_VERSION_ANY ||
+		    id->version == fsi_dev->version) {
+			if (drv->of_match_table) {
+				if (of_driver_match_device(dev, drv))
+					return 1;
+			} else {
+				return 1;
+			}
+		}
+	}
+
+	return 0;
+}
+
+static const struct bus_type fsi_bus_type = {
+	.name = "fsi",
+	.match = fsi_bus_match,
+};
+
 /*
  * fsi_device_read() / fsi_device_write() / fsi_device_peek()
  *
@@ -1359,34 +1392,6 @@ void fsi_master_unregister(struct fsi_master *master)
 }
 EXPORT_SYMBOL_GPL(fsi_master_unregister);
 
-/* FSI core & Linux bus type definitions */
-
-static int fsi_bus_match(struct device *dev, const struct device_driver *drv)
-{
-	struct fsi_device *fsi_dev = to_fsi_dev(dev);
-	const struct fsi_driver *fsi_drv = to_fsi_drv(drv);
-	const struct fsi_device_id *id;
-
-	if (!fsi_drv->id_table)
-		return 0;
-
-	for (id = fsi_drv->id_table; id->engine_type; id++) {
-		if (id->engine_type != fsi_dev->engine_type)
-			continue;
-		if (id->version == FSI_VERSION_ANY ||
-		    id->version == fsi_dev->version) {
-			if (drv->of_match_table) {
-				if (of_driver_match_device(dev, drv))
-					return 1;
-			} else {
-				return 1;
-			}
-		}
-	}
-
-	return 0;
-}
-
 int fsi_driver_register(struct fsi_driver *fsi_drv)
 {
 	if (!fsi_drv)
@@ -1406,12 +1411,6 @@ void fsi_driver_unregister(struct fsi_driver *fsi_drv)
 }
 EXPORT_SYMBOL_GPL(fsi_driver_unregister);
 
-const struct bus_type fsi_bus_type = {
-	.name		= "fsi",
-	.match		= fsi_bus_match,
-};
-EXPORT_SYMBOL_GPL(fsi_bus_type);
-
 static int __init fsi_init(void)
 {
 	int rc;
include/linux/fsi.h +0 -1
index 05be75869a69..3e3a8f3adac3 100644
@@ -78,7 +78,6 @@ extern int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
 extern int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
 		const void *val, size_t size);
 
-extern const struct bus_type fsi_bus_type;
 extern const struct device_type fsi_cdev_type;
 
 enum fsi_dev_type {
Signature · 1 line
2.47.3
maintainer Acked-by on v2 6/13
#12 lore raw

Re: [PATCH v2 06/13] fsi: Make fsi_bus_type a private variable to the core

Quoted 7 lines · Uwe Kleine-König

There are no users of fsi_bus_type outside of fsi-core.c, so make that variable static, don't export it and drop the declaration from the public header file.

As there is a usage of fsi_bus_type in fsi_create_device() the definition of that variable must happen further up in the file to not have to add a local declaration.

Quoted 111 lines
---
  drivers/fsi/fsi-core.c | 67 +++++++++++++++++++++---------------------
  include/linux/fsi.h    |  1 -
  2 files changed, 33 insertions(+), 35 deletions(-)
drivers/fsi/fsi-core.c +33 -34
index e1ea1124282e..4e60d4b17c11 100644
@@ -100,6 +100,39 @@ static int fsi_master_write(struct fsi_master *master, int link,
  		uint8_t slave_id, uint32_t addr, const void *val, size_t size);
  static int fsi_master_break(struct fsi_master *master, int link);
 
+/* FSI core & Linux bus type definitions */
+
+static int fsi_bus_match(struct device *dev, const struct device_driver *drv)
+{
+	struct fsi_device *fsi_dev = to_fsi_dev(dev);
+	const struct fsi_driver *fsi_drv = to_fsi_drv(drv);
+	const struct fsi_device_id *id;
+
+	if (!fsi_drv->id_table)
+		return 0;
+
+	for (id = fsi_drv->id_table; id->engine_type; id++) {
+		if (id->engine_type != fsi_dev->engine_type)
+			continue;
+		if (id->version == FSI_VERSION_ANY ||
+		    id->version == fsi_dev->version) {
+			if (drv->of_match_table) {
+				if (of_driver_match_device(dev, drv))
+					return 1;
+			} else {
+				return 1;
+			}
+		}
+	}
+
+	return 0;
+}
+
+static const struct bus_type fsi_bus_type = {
+	.name = "fsi",
+	.match = fsi_bus_match,
+};
+
  /*
   * fsi_device_read() / fsi_device_write() / fsi_device_peek()
   *
@@ -1359,34 +1392,6 @@ void fsi_master_unregister(struct fsi_master *master)
  }
  EXPORT_SYMBOL_GPL(fsi_master_unregister);
 
-/* FSI core & Linux bus type definitions */
-
-static int fsi_bus_match(struct device *dev, const struct device_driver *drv)
-{
-	struct fsi_device *fsi_dev = to_fsi_dev(dev);
-	const struct fsi_driver *fsi_drv = to_fsi_drv(drv);
-	const struct fsi_device_id *id;
-
-	if (!fsi_drv->id_table)
-		return 0;
-
-	for (id = fsi_drv->id_table; id->engine_type; id++) {
-		if (id->engine_type != fsi_dev->engine_type)
-			continue;
-		if (id->version == FSI_VERSION_ANY ||
-		    id->version == fsi_dev->version) {
-			if (drv->of_match_table) {
-				if (of_driver_match_device(dev, drv))
-					return 1;
-			} else {
-				return 1;
-			}
-		}
-	}
-
-	return 0;
-}
-
  int fsi_driver_register(struct fsi_driver *fsi_drv)
  {
  	if (!fsi_drv)
@@ -1406,12 +1411,6 @@ void fsi_driver_unregister(struct fsi_driver *fsi_drv)
  }
  EXPORT_SYMBOL_GPL(fsi_driver_unregister);
 
-const struct bus_type fsi_bus_type = {
-	.name		= "fsi",
-	.match		= fsi_bus_match,
-};
-EXPORT_SYMBOL_GPL(fsi_bus_type);
-
  static int __init fsi_init(void)
  {
  	int rc;
include/linux/fsi.h +0 -1
index 05be75869a69..3e3a8f3adac3 100644
@@ -78,7 +78,6 @@ extern int fsi_slave_read(struct fsi_slave *slave, uint32_t addr,
  extern int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
  		const void *val, size_t size);
 
-extern const struct bus_type fsi_bus_type;
  extern const struct device_type fsi_cdev_type;
 
  enum fsi_dev_type {
#13 lore raw

PATCH v2 7/13 fsi: Create bus specific probe and remove functions

In reply to Uwe Kleine-König

Introduce a bus specific probe and remove function. For now this only allows to get rid of a cast of the generic device to an fsi device in the drivers and changes the remove prototype to return void---a non-zero return value is ignored anyhow.

The objective is to get rid of users of struct device callbacks .probe(), .remove() and .shutdown() to eventually remove these.

Until all fsi drivers are converted this results in a runtime warning about the drivers needing an update because there is a bus probe function and a driver probe function.

---
 drivers/fsi/fsi-core.c | 50 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/fsi.h    |  2 ++
 2 files changed, 52 insertions(+)
drivers/fsi/fsi-core.c +50 -0
index 4e60d4b17c11..83599a1c548b 100644
@@ -128,9 +128,31 @@ static int fsi_bus_match(struct device *dev, const struct device_driver *drv)
 	return 0;
 }
 
+static int fsi_probe(struct device *dev)
+{
+	struct fsi_device *fsidev = to_fsi_dev(dev);
+	struct fsi_driver *fsidrv = to_fsi_drv(dev->driver);
+
+	if (fsidrv->probe)
+		return fsidrv->probe(fsidev);
+	else
+		return 0;
+}
+
+static void fsi_remove(struct device *dev)
+{
+	struct fsi_device *fsidev = to_fsi_dev(dev);
+	struct fsi_driver *fsidrv = to_fsi_drv(dev->driver);
+
+	if (fsidrv->remove)
+		fsidrv->remove(fsidev);
+}
+
 static const struct bus_type fsi_bus_type = {
 	.name = "fsi",
 	.match = fsi_bus_match,
+	.probe = fsi_probe,
+	.remove = fsi_remove,
 };
 
 /*
@@ -1392,6 +1414,25 @@ void fsi_master_unregister(struct fsi_master *master)
 }
 EXPORT_SYMBOL_GPL(fsi_master_unregister);
 
+static int fsi_legacy_probe(struct fsi_device *fsidev)
+{
+	struct device *dev = &fsidev->dev;
+	struct device_driver *driver = dev->driver;
+
+	return driver->probe(dev);
+}
+
+static void fsi_legacy_remove(struct fsi_device *fsidev)
+{
+	struct device *dev = &fsidev->dev;
+	struct device_driver *driver = dev->driver;
+	int ret;
+
+	ret = driver->remove(dev);
+	if (unlikely(ret))
+		dev_warn(dev, "Ignoring return value of remove callback (%pe)\n", ERR_PTR(ret));
+}
+
 int fsi_driver_register(struct fsi_driver *fsi_drv)
 {
 	if (!fsi_drv)
@@ -1401,6 +1442,15 @@ int fsi_driver_register(struct fsi_driver *fsi_drv)
 
 	fsi_drv->drv.bus = &fsi_bus_type;
 
+	/*
+	 * This driver needs updating. Note that driver_register() warns about
+	 * this, so we're not adding another warning here.
+	 */
+	if (!fsi_drv->probe && fsi_drv->drv.probe)
+		fsi_drv->probe = fsi_legacy_probe;
+	if (!fsi_drv->remove && fsi_drv->drv.remove)
+		fsi_drv->remove = fsi_legacy_remove;
+
 	return driver_register(&fsi_drv->drv);
 }
 EXPORT_SYMBOL_GPL(fsi_driver_register);
include/linux/fsi.h +2 -0
index 3e3a8f3adac3..9c67c43f9e6c 100644
@@ -49,6 +49,8 @@ struct fsi_device_id {
 	.engine_type = (t), .version = (v),
 
 struct fsi_driver {
+	int (*probe)(struct fsi_device *fsidev);
+	void (*remove)(struct fsi_device *fsidev);
 	struct device_driver		drv;
 	const struct fsi_device_id	*id_table;
 };
Signature · 1 line
2.47.3
maintainer Acked-by on v2 7/13
#14 lore raw

Re: [PATCH v2 07/13] fsi: Create bus specific probe and remove functions

Quoted 11 lines · Uwe Kleine-König

Introduce a bus specific probe and remove function. For now this only allows to get rid of a cast of the generic device to an fsi device in the drivers and changes the remove prototype to return void---a non-zero return value is ignored anyhow.

The objective is to get rid of users of struct device callbacks .probe(), .remove() and .shutdown() to eventually remove these.

Until all fsi drivers are converted this results in a runtime warning about the drivers needing an update because there is a bus probe function and a driver probe function.

Quoted 98 lines
---
  drivers/fsi/fsi-core.c | 50 ++++++++++++++++++++++++++++++++++++++++++
  include/linux/fsi.h    |  2 ++
  2 files changed, 52 insertions(+)
drivers/fsi/fsi-core.c +50 -0
index 4e60d4b17c11..83599a1c548b 100644
@@ -128,9 +128,31 @@ static int fsi_bus_match(struct device *dev, const struct device_driver *drv)
  	return 0;
  }
 
+static int fsi_probe(struct device *dev)
+{
+	struct fsi_device *fsidev = to_fsi_dev(dev);
+	struct fsi_driver *fsidrv = to_fsi_drv(dev->driver);
+
+	if (fsidrv->probe)
+		return fsidrv->probe(fsidev);
+	else
+		return 0;
+}
+
+static void fsi_remove(struct device *dev)
+{
+	struct fsi_device *fsidev = to_fsi_dev(dev);
+	struct fsi_driver *fsidrv = to_fsi_drv(dev->driver);
+
+	if (fsidrv->remove)
+		fsidrv->remove(fsidev);
+}
+
  static const struct bus_type fsi_bus_type = {
  	.name = "fsi",
  	.match = fsi_bus_match,
+	.probe = fsi_probe,
+	.remove = fsi_remove,
  };
 
  /*
@@ -1392,6 +1414,25 @@ void fsi_master_unregister(struct fsi_master *master)
  }
  EXPORT_SYMBOL_GPL(fsi_master_unregister);
 
+static int fsi_legacy_probe(struct fsi_device *fsidev)
+{
+	struct device *dev = &fsidev->dev;
+	struct device_driver *driver = dev->driver;
+
+	return driver->probe(dev);
+}
+
+static void fsi_legacy_remove(struct fsi_device *fsidev)
+{
+	struct device *dev = &fsidev->dev;
+	struct device_driver *driver = dev->driver;
+	int ret;
+
+	ret = driver->remove(dev);
+	if (unlikely(ret))
+		dev_warn(dev, "Ignoring return value of remove callback (%pe)\n", ERR_PTR(ret));
+}
+
  int fsi_driver_register(struct fsi_driver *fsi_drv)
  {
  	if (!fsi_drv)
@@ -1401,6 +1442,15 @@ int fsi_driver_register(struct fsi_driver *fsi_drv)
 
  	fsi_drv->drv.bus = &fsi_bus_type;
 
+	/*
+	 * This driver needs updating. Note that driver_register() warns about
+	 * this, so we're not adding another warning here.
+	 */
+	if (!fsi_drv->probe && fsi_drv->drv.probe)
+		fsi_drv->probe = fsi_legacy_probe;
+	if (!fsi_drv->remove && fsi_drv->drv.remove)
+		fsi_drv->remove = fsi_legacy_remove;
+
  	return driver_register(&fsi_drv->drv);
  }
  EXPORT_SYMBOL_GPL(fsi_driver_register);
include/linux/fsi.h +2 -0
index 3e3a8f3adac3..9c67c43f9e6c 100644
@@ -49,6 +49,8 @@ struct fsi_device_id {
  	.engine_type = (t), .version = (v),
 
  struct fsi_driver {
+	int (*probe)(struct fsi_device *fsidev);
+	void (*remove)(struct fsi_device *fsidev);
  	struct device_driver		drv;
  	const struct fsi_device_id	*id_table;
  };
#15 lore raw

PATCH v2 8/13 fsi: i2cr-scom: Convert to fsi bus probe mechanism

In reply to Uwe Kleine-König

The fsi bus got a dedicated probe and remove callback. Make use of them. This fixes a runtime warning about the driver needing to be converted to the bus methods.

---
 drivers/fsi/i2cr-scom.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/fsi/i2cr-scom.c +6 -8
index dfdb16afd205..3efca2e944bb 100644
@@ -81,9 +81,9 @@ static const struct file_operations i2cr_scom_fops = {
 	.write		= i2cr_scom_write,
 };
 
-static int i2cr_scom_probe(struct device *dev)
+static int i2cr_scom_probe(struct fsi_device *fsi_dev)
 {
-	struct fsi_device *fsi_dev = to_fsi_dev(dev);
+	struct device *dev = &fsi_dev->dev;
 	struct i2cr_scom *scom;
 	int didx;
 	int ret;
@@ -115,14 +115,12 @@ static int i2cr_scom_probe(struct device *dev)
 	return ret;
 }
 
-static int i2cr_scom_remove(struct device *dev)
+static void i2cr_scom_remove(struct fsi_device *fsi_dev)
 {
-	struct i2cr_scom *scom = dev_get_drvdata(dev);
+	struct i2cr_scom *scom = dev_get_drvdata(&fsi_dev->dev);
 
 	cdev_device_del(&scom->cdev, &scom->dev);
 	fsi_free_minor(scom->dev.devt);
-
-	return 0;
 }
 
 static const struct of_device_id i2cr_scom_of_ids[] = {
@@ -137,12 +135,12 @@ static const struct fsi_device_id i2cr_scom_ids[] = {
 };
 
 static struct fsi_driver i2cr_scom_driver = {
+	.probe = i2cr_scom_probe,
+	.remove = i2cr_scom_remove,
 	.id_table = i2cr_scom_ids,
 	.drv = {
 		.name = "i2cr_scom",
 		.of_match_table = i2cr_scom_of_ids,
-		.probe = i2cr_scom_probe,
-		.remove = i2cr_scom_remove,
 	}
 };
 
Signature · 1 line
2.47.3
maintainer Acked-by on v2 8/13
#16 lore raw

Re: [PATCH v2 08/13] fsi: i2cr-scom: Convert to fsi bus probe mechanism

Quoted 3 lines · Uwe Kleine-König

The fsi bus got a dedicated probe and remove callback. Make use of them. This fixes a runtime warning about the driver needing to be converted to the bus methods.

Quoted 54 lines
---
  drivers/fsi/i2cr-scom.c | 14 ++++++--------
  1 file changed, 6 insertions(+), 8 deletions(-)
drivers/fsi/i2cr-scom.c +6 -8
index dfdb16afd205..3efca2e944bb 100644
@@ -81,9 +81,9 @@ static const struct file_operations i2cr_scom_fops = {
  	.write		= i2cr_scom_write,
  };
 
-static int i2cr_scom_probe(struct device *dev)
+static int i2cr_scom_probe(struct fsi_device *fsi_dev)
  {
-	struct fsi_device *fsi_dev = to_fsi_dev(dev);
+	struct device *dev = &fsi_dev->dev;
  	struct i2cr_scom *scom;
  	int didx;
  	int ret;
@@ -115,14 +115,12 @@ static int i2cr_scom_probe(struct device *dev)
  	return ret;
  }
 
-static int i2cr_scom_remove(struct device *dev)
+static void i2cr_scom_remove(struct fsi_device *fsi_dev)
  {
-	struct i2cr_scom *scom = dev_get_drvdata(dev);
+	struct i2cr_scom *scom = dev_get_drvdata(&fsi_dev->dev);
 
  	cdev_device_del(&scom->cdev, &scom->dev);
  	fsi_free_minor(scom->dev.devt);
-
-	return 0;
  }
 
  static const struct of_device_id i2cr_scom_of_ids[] = {
@@ -137,12 +135,12 @@ static const struct fsi_device_id i2cr_scom_ids[] = {
  };
 
  static struct fsi_driver i2cr_scom_driver = {
+	.probe = i2cr_scom_probe,
+	.remove = i2cr_scom_remove,
  	.id_table = i2cr_scom_ids,
  	.drv = {
  		.name = "i2cr_scom",
  		.of_match_table = i2cr_scom_of_ids,
-		.probe = i2cr_scom_probe,
-		.remove = i2cr_scom_remove,
  	}
  };
 
#17 lore raw

PATCH v2 9/13 fsi: master: Convert to fsi bus probe mechanism

In reply to Uwe Kleine-König

The fsi bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.

---
 drivers/fsi/fsi-master-hub.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/fsi/fsi-master-hub.c +7 -9
index d389856d18ac..a84955bb23b1 100644
@@ -192,9 +192,9 @@ static int hub_master_init(struct fsi_master_hub *hub)
 	return fsi_device_write(dev, FSI_MRESB0, &reg, sizeof(reg));
 }
 
-static int hub_master_probe(struct device *dev)
+static int hub_master_probe(struct fsi_device *fsi_dev)
 {
-	struct fsi_device *fsi_dev = to_fsi_dev(dev);
+	struct device *dev = &fsi_dev->dev;
 	struct fsi_master_hub *hub;
 	uint32_t reg, links;
 	__be32 __reg;
@@ -235,7 +235,7 @@ static int hub_master_probe(struct device *dev)
 	hub->master.send_break = hub_master_break;
 	hub->master.link_enable = hub_master_link_enable;
 
-	dev_set_drvdata(dev, hub);
+	fsi_set_drvdata(fsi_dev, hub);
 
 	hub_master_init(hub);
 
@@ -259,9 +259,9 @@ static int hub_master_probe(struct device *dev)
 	return rc;
 }
 
-static int hub_master_remove(struct device *dev)
+static void hub_master_remove(struct fsi_device *fsi_dev)
 {
-	struct fsi_master_hub *hub = dev_get_drvdata(dev);
+	struct fsi_master_hub *hub = fsi_get_drvdata(fsi_dev);
 
 	fsi_master_unregister(&hub->master);
 	fsi_slave_release_range(hub->upstream->slave, hub->addr, hub->size);
@@ -272,8 +272,6 @@ static int hub_master_remove(struct device *dev)
 	 * the hub
 	 */
 	put_device(&hub->master.dev);
-
-	return 0;
 }
 
 static const struct fsi_device_id hub_master_ids[] = {
@@ -286,10 +284,10 @@ static const struct fsi_device_id hub_master_ids[] = {
 
 static struct fsi_driver hub_master_driver = {
 	.id_table = hub_master_ids,
+	.probe = hub_master_probe,
+	.remove = hub_master_remove,
 	.drv = {
 		.name = "fsi-master-hub",
-		.probe = hub_master_probe,
-		.remove = hub_master_remove,
 	}
 };
 
Signature · 1 line
2.47.3
maintainer Acked-by on v2 9/13
#18 lore raw

Re: [PATCH v2 09/13] fsi: master: Convert to fsi bus probe mechanism

Quoted 3 lines · Uwe Kleine-König

The fsi bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.

Quoted 65 lines
---
  drivers/fsi/fsi-master-hub.c | 16 +++++++---------
  1 file changed, 7 insertions(+), 9 deletions(-)
drivers/fsi/fsi-master-hub.c +7 -9
index d389856d18ac..a84955bb23b1 100644
@@ -192,9 +192,9 @@ static int hub_master_init(struct fsi_master_hub *hub)
  	return fsi_device_write(dev, FSI_MRESB0, &reg, sizeof(reg));
  }
 
-static int hub_master_probe(struct device *dev)
+static int hub_master_probe(struct fsi_device *fsi_dev)
  {
-	struct fsi_device *fsi_dev = to_fsi_dev(dev);
+	struct device *dev = &fsi_dev->dev;
  	struct fsi_master_hub *hub;
  	uint32_t reg, links;
  	__be32 __reg;
@@ -235,7 +235,7 @@ static int hub_master_probe(struct device *dev)
  	hub->master.send_break = hub_master_break;
  	hub->master.link_enable = hub_master_link_enable;
 
-	dev_set_drvdata(dev, hub);
+	fsi_set_drvdata(fsi_dev, hub);
 
  	hub_master_init(hub);
 
@@ -259,9 +259,9 @@ static int hub_master_probe(struct device *dev)
  	return rc;
  }
 
-static int hub_master_remove(struct device *dev)
+static void hub_master_remove(struct fsi_device *fsi_dev)
  {
-	struct fsi_master_hub *hub = dev_get_drvdata(dev);
+	struct fsi_master_hub *hub = fsi_get_drvdata(fsi_dev);
 
  	fsi_master_unregister(&hub->master);
  	fsi_slave_release_range(hub->upstream->slave, hub->addr, hub->size);
@@ -272,8 +272,6 @@ static int hub_master_remove(struct device *dev)
  	 * the hub
  	 */
  	put_device(&hub->master.dev);
-
-	return 0;
  }
 
  static const struct fsi_device_id hub_master_ids[] = {
@@ -286,10 +284,10 @@ static const struct fsi_device_id hub_master_ids[] = {
 
  static struct fsi_driver hub_master_driver = {
  	.id_table = hub_master_ids,
+	.probe = hub_master_probe,
+	.remove = hub_master_remove,
  	.drv = {
  		.name = "fsi-master-hub",
-		.probe = hub_master_probe,
-		.remove = hub_master_remove,
  	}
  };
 
#19 lore raw

PATCH v2 10/13 fsi: sbefifo: Convert to fsi bus probe mechanism

In reply to Uwe Kleine-König

The fsi bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.

---
 drivers/fsi/fsi-sbefifo.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/fsi/fsi-sbefifo.c +8 -9
index fde1c34743a0..6ca5817910cd 100644
@@ -1022,9 +1022,9 @@ static void sbefifo_free(struct device *dev)
  * Probe/remove
  */
 
-static int sbefifo_probe(struct device *dev)
+static int sbefifo_probe(struct fsi_device *fsi_dev)
 {
-	struct fsi_device *fsi_dev = to_fsi_dev(dev);
+	struct device *dev = &fsi_dev->dev;
 	struct sbefifo *sbefifo;
 	struct device_node *np;
 	struct platform_device *child;
@@ -1045,7 +1045,7 @@ static int sbefifo_probe(struct device *dev)
 
 	sbefifo->magic = SBEFIFO_MAGIC;
 	sbefifo->fsi_dev = fsi_dev;
-	dev_set_drvdata(dev, sbefifo);
+	fsi_set_drvdata(fsi_dev, sbefifo);
 	mutex_init(&sbefifo->lock);
 	sbefifo->timeout_in_cmd_ms = SBEFIFO_TIMEOUT_IN_CMD;
 	sbefifo->timeout_start_rsp_ms = SBEFIFO_TIMEOUT_START_RSP;
@@ -1101,9 +1101,10 @@ static int sbefifo_unregister_child(struct device *dev, void *data)
 	return 0;
 }
 
-static int sbefifo_remove(struct device *dev)
+static void sbefifo_remove(struct fsi_device *fsi_dev)
 {
-	struct sbefifo *sbefifo = dev_get_drvdata(dev);
+	struct device *dev = &fsi_dev->dev;
+	struct sbefifo *sbefifo = fsi_get_drvdata(fsi_dev);
 
 	dev_dbg(dev, "Removing sbefifo device...\n");
 
@@ -1117,8 +1118,6 @@ static int sbefifo_remove(struct device *dev)
 	fsi_free_minor(sbefifo->dev.devt);
 	device_for_each_child(dev, NULL, sbefifo_unregister_child);
 	put_device(&sbefifo->dev);
-
-	return 0;
 }
 
 static const struct fsi_device_id sbefifo_ids[] = {
@@ -1131,10 +1130,10 @@ static const struct fsi_device_id sbefifo_ids[] = {
 
 static struct fsi_driver sbefifo_drv = {
 	.id_table = sbefifo_ids,
+	.probe = sbefifo_probe,
+	.remove = sbefifo_remove,
 	.drv = {
 		.name = DEVICE_NAME,
-		.probe = sbefifo_probe,
-		.remove = sbefifo_remove,
 	}
 };
 
Signature · 1 line
2.47.3
maintainer Acked-by on v2 10/13
#20 lore raw

Re: [PATCH v2 10/13] fsi: sbefifo: Convert to fsi bus probe mechanism

Quoted 3 lines · Uwe Kleine-König

The fsi bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.

Quoted 66 lines
---
  drivers/fsi/fsi-sbefifo.c | 17 ++++++++---------
  1 file changed, 8 insertions(+), 9 deletions(-)
drivers/fsi/fsi-sbefifo.c +8 -9
index fde1c34743a0..6ca5817910cd 100644
@@ -1022,9 +1022,9 @@ static void sbefifo_free(struct device *dev)
   * Probe/remove
   */
 
-static int sbefifo_probe(struct device *dev)
+static int sbefifo_probe(struct fsi_device *fsi_dev)
  {
-	struct fsi_device *fsi_dev = to_fsi_dev(dev);
+	struct device *dev = &fsi_dev->dev;
  	struct sbefifo *sbefifo;
  	struct device_node *np;
  	struct platform_device *child;
@@ -1045,7 +1045,7 @@ static int sbefifo_probe(struct device *dev)
 
  	sbefifo->magic = SBEFIFO_MAGIC;
  	sbefifo->fsi_dev = fsi_dev;
-	dev_set_drvdata(dev, sbefifo);
+	fsi_set_drvdata(fsi_dev, sbefifo);
  	mutex_init(&sbefifo->lock);
  	sbefifo->timeout_in_cmd_ms = SBEFIFO_TIMEOUT_IN_CMD;
  	sbefifo->timeout_start_rsp_ms = SBEFIFO_TIMEOUT_START_RSP;
@@ -1101,9 +1101,10 @@ static int sbefifo_unregister_child(struct device *dev, void *data)
  	return 0;
  }
 
-static int sbefifo_remove(struct device *dev)
+static void sbefifo_remove(struct fsi_device *fsi_dev)
  {
-	struct sbefifo *sbefifo = dev_get_drvdata(dev);
+	struct device *dev = &fsi_dev->dev;
+	struct sbefifo *sbefifo = fsi_get_drvdata(fsi_dev);
 
  	dev_dbg(dev, "Removing sbefifo device...\n");
 
@@ -1117,8 +1118,6 @@ static int sbefifo_remove(struct device *dev)
  	fsi_free_minor(sbefifo->dev.devt);
  	device_for_each_child(dev, NULL, sbefifo_unregister_child);
  	put_device(&sbefifo->dev);
-
-	return 0;
  }
 
  static const struct fsi_device_id sbefifo_ids[] = {
@@ -1131,10 +1130,10 @@ static const struct fsi_device_id sbefifo_ids[] = {
 
  static struct fsi_driver sbefifo_drv = {
  	.id_table = sbefifo_ids,
+	.probe = sbefifo_probe,
+	.remove = sbefifo_remove,
  	.drv = {
  		.name = DEVICE_NAME,
-		.probe = sbefifo_probe,
-		.remove = sbefifo_remove,
  	}
  };
 
#21 lore raw

PATCH v2 11/13 fsi: scom: Convert to fsi bus probe mechanism

In reply to Uwe Kleine-König

The fsi bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.

---
 drivers/fsi/fsi-scom.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/fsi/fsi-scom.c +7 -9
index 2eda44451cc1..67cd45605fe4 100644
@@ -527,16 +527,16 @@ static void scom_free(struct device *dev)
 	kfree(scom);
 }
 
-static int scom_probe(struct device *dev)
+static int scom_probe(struct fsi_device *fsi_dev)
 {
-	struct fsi_device *fsi_dev = to_fsi_dev(dev);
+	struct device *dev = &fsi_dev->dev;
 	struct scom_device *scom;
 	int rc, didx;
 
 	scom = kzalloc(sizeof(*scom), GFP_KERNEL);
 	if (!scom)
 		return -ENOMEM;
-	dev_set_drvdata(dev, scom);
+	fsi_set_drvdata(fsi_dev, scom);
 	mutex_init(&scom->lock);
 
 	/* Grab a reference to the device (parent of our cdev), we'll drop it later */
@@ -574,9 +574,9 @@ static int scom_probe(struct device *dev)
 	return rc;
 }
 
-static int scom_remove(struct device *dev)
+static void scom_remove(struct fsi_device *fsi_dev)
 {
-	struct scom_device *scom = dev_get_drvdata(dev);
+	struct scom_device *scom = fsi_get_drvdata(fsi_dev);
 
 	mutex_lock(&scom->lock);
 	scom->dead = true;
@@ -584,8 +584,6 @@ static int scom_remove(struct device *dev)
 	cdev_device_del(&scom->cdev, &scom->dev);
 	fsi_free_minor(scom->dev.devt);
 	put_device(&scom->dev);
-
-	return 0;
 }
 
 static const struct of_device_id scom_of_ids[] = {
@@ -604,11 +602,11 @@ static const struct fsi_device_id scom_ids[] = {
 
 static struct fsi_driver scom_drv = {
 	.id_table = scom_ids,
+	.probe = scom_probe,
+	.remove = scom_remove,
 	.drv = {
 		.name = "scom",
 		.of_match_table = scom_of_ids,
-		.probe = scom_probe,
-		.remove = scom_remove,
 	}
 };
 
Signature · 1 line
2.47.3
maintainer Acked-by on v2 11/13
#22 lore raw

Re: [PATCH v2 11/13] fsi: scom: Convert to fsi bus probe mechanism

Quoted 3 lines · Uwe Kleine-König

The fsi bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.

Quoted 65 lines
---
  drivers/fsi/fsi-scom.c | 16 +++++++---------
  1 file changed, 7 insertions(+), 9 deletions(-)
drivers/fsi/fsi-scom.c +7 -9
index 2eda44451cc1..67cd45605fe4 100644
@@ -527,16 +527,16 @@ static void scom_free(struct device *dev)
  	kfree(scom);
  }
 
-static int scom_probe(struct device *dev)
+static int scom_probe(struct fsi_device *fsi_dev)
  {
-	struct fsi_device *fsi_dev = to_fsi_dev(dev);
+	struct device *dev = &fsi_dev->dev;
  	struct scom_device *scom;
  	int rc, didx;
 
  	scom = kzalloc(sizeof(*scom), GFP_KERNEL);
  	if (!scom)
  		return -ENOMEM;
-	dev_set_drvdata(dev, scom);
+	fsi_set_drvdata(fsi_dev, scom);
  	mutex_init(&scom->lock);
 
  	/* Grab a reference to the device (parent of our cdev), we'll drop it later */
@@ -574,9 +574,9 @@ static int scom_probe(struct device *dev)
  	return rc;
  }
 
-static int scom_remove(struct device *dev)
+static void scom_remove(struct fsi_device *fsi_dev)
  {
-	struct scom_device *scom = dev_get_drvdata(dev);
+	struct scom_device *scom = fsi_get_drvdata(fsi_dev);
 
  	mutex_lock(&scom->lock);
  	scom->dead = true;
@@ -584,8 +584,6 @@ static int scom_remove(struct device *dev)
  	cdev_device_del(&scom->cdev, &scom->dev);
  	fsi_free_minor(scom->dev.devt);
  	put_device(&scom->dev);
-
-	return 0;
  }
 
  static const struct of_device_id scom_of_ids[] = {
@@ -604,11 +602,11 @@ static const struct fsi_device_id scom_ids[] = {
 
  static struct fsi_driver scom_drv = {
  	.id_table = scom_ids,
+	.probe = scom_probe,
+	.remove = scom_remove,
  	.drv = {
  		.name = "scom",
  		.of_match_table = scom_of_ids,
-		.probe = scom_probe,
-		.remove = scom_remove,
  	}
  };
 
#23 lore raw

PATCH v2 12/13 i2c: fsi: Convert to fsi bus probe mechanism

In reply to Uwe Kleine-König

The fsi bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.

---
 drivers/i2c/busses/i2c-fsi.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/i2c/busses/i2c-fsi.c +7 -8
index e98dd5dcac0f..3a7e577e6eac 100644
@@ -674,8 +674,9 @@ static struct device_node *fsi_i2c_find_port_of_node(struct device_node *fsi,
 	return NULL;
 }
 
-static int fsi_i2c_probe(struct device *dev)
+static int fsi_i2c_probe(struct fsi_device *fsi_dev)
 {
+	struct device *dev = &fsi_dev->dev;
 	struct fsi_i2c_ctrl *i2c;
 	struct fsi_i2c_port *port;
 	struct device_node *np;
@@ -735,14 +736,14 @@ static int fsi_i2c_probe(struct device *dev)
 		list_add(&port->list, &i2c->ports);
 	}
 
-	dev_set_drvdata(dev, i2c);
+	fsi_set_drvdata(fsi_dev, i2c);
 
 	return 0;
 }
 
-static int fsi_i2c_remove(struct device *dev)
+static void fsi_i2c_remove(struct fsi_device *fsi_dev)
 {
-	struct fsi_i2c_ctrl *i2c = dev_get_drvdata(dev);
+	struct fsi_i2c_ctrl *i2c = fsi_get_drvdata(fsi_dev);
 	struct fsi_i2c_port *port, *tmp;
 
 	list_for_each_entry_safe(port, tmp, &i2c->ports, list) {
@@ -750,8 +751,6 @@ static int fsi_i2c_remove(struct device *dev)
 		i2c_del_adapter(&port->adapter);
 		kfree(port);
 	}
-
-	return 0;
 }
 
 static const struct fsi_device_id fsi_i2c_ids[] = {
@@ -761,10 +760,10 @@ static const struct fsi_device_id fsi_i2c_ids[] = {
 
 static struct fsi_driver fsi_i2c_driver = {
 	.id_table = fsi_i2c_ids,
+	.probe = fsi_i2c_probe,
+	.remove = fsi_i2c_remove,
 	.drv = {
 		.name = "i2c-fsi",
-		.probe = fsi_i2c_probe,
-		.remove = fsi_i2c_remove,
 	},
 };
 
Signature · 1 line
2.47.3
maintainer Acked-by on v2 12/13
#24 lore raw

Re: [PATCH v2 12/13] i2c: fsi: Convert to fsi bus probe mechanism

Quoted 3 lines · Uwe Kleine-König

The fsi bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.

Quoted 62 lines
---
  drivers/i2c/busses/i2c-fsi.c | 15 +++++++--------
  1 file changed, 7 insertions(+), 8 deletions(-)
drivers/i2c/busses/i2c-fsi.c +7 -8
index e98dd5dcac0f..3a7e577e6eac 100644
@@ -674,8 +674,9 @@ static struct device_node *fsi_i2c_find_port_of_node(struct device_node *fsi,
  	return NULL;
  }
 
-static int fsi_i2c_probe(struct device *dev)
+static int fsi_i2c_probe(struct fsi_device *fsi_dev)
  {
+	struct device *dev = &fsi_dev->dev;
  	struct fsi_i2c_ctrl *i2c;
  	struct fsi_i2c_port *port;
  	struct device_node *np;
@@ -735,14 +736,14 @@ static int fsi_i2c_probe(struct device *dev)
  		list_add(&port->list, &i2c->ports);
  	}
 
-	dev_set_drvdata(dev, i2c);
+	fsi_set_drvdata(fsi_dev, i2c);
 
  	return 0;
  }
 
-static int fsi_i2c_remove(struct device *dev)
+static void fsi_i2c_remove(struct fsi_device *fsi_dev)
  {
-	struct fsi_i2c_ctrl *i2c = dev_get_drvdata(dev);
+	struct fsi_i2c_ctrl *i2c = fsi_get_drvdata(fsi_dev);
  	struct fsi_i2c_port *port, *tmp;
 
  	list_for_each_entry_safe(port, tmp, &i2c->ports, list) {
@@ -750,8 +751,6 @@ static int fsi_i2c_remove(struct device *dev)
  		i2c_del_adapter(&port->adapter);
  		kfree(port);
  	}
-
-	return 0;
  }
 
  static const struct fsi_device_id fsi_i2c_ids[] = {
@@ -761,10 +760,10 @@ static const struct fsi_device_id fsi_i2c_ids[] = {
 
  static struct fsi_driver fsi_i2c_driver = {
  	.id_table = fsi_i2c_ids,
+	.probe = fsi_i2c_probe,
+	.remove = fsi_i2c_remove,
  	.drv = {
  		.name = "i2c-fsi",
-		.probe = fsi_i2c_probe,
-		.remove = fsi_i2c_remove,
  	},
  };
 
#25 lore raw

PATCH v2 13/13 spi: fsi: Convert to fsi bus probe mechanism

In reply to Uwe Kleine-König

The fsi bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.

---
 drivers/spi/spi-fsi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/spi-fsi.c +3 -3
index f9c15b99dba5..07dc3d24f2c9 100644
@@ -528,13 +528,13 @@ static size_t fsi_spi_max_transfer_size(struct spi_device *spi)
 	return SPI_FSI_MAX_RX_SIZE;
 }
 
-static int fsi_spi_probe(struct device *dev)
+static int fsi_spi_probe(struct fsi_device *fsi)
 {
 	int rc;
 	struct device_node *np;
 	int num_controllers_registered = 0;
 	struct fsi2spi *bridge;
-	struct fsi_device *fsi = to_fsi_dev(dev);
+	struct device *dev = &fsi->dev;
 
 	rc = fsi_spi_check_mux(fsi, dev);
 	if (rc)
@@ -593,9 +593,9 @@ MODULE_DEVICE_TABLE(fsi, fsi_spi_ids);
 
 static struct fsi_driver fsi_spi_driver = {
 	.id_table = fsi_spi_ids,
+	.probe = fsi_spi_probe,
 	.drv = {
 		.name = "spi-fsi",
-		.probe = fsi_spi_probe,
 	},
 };
 module_fsi_driver(fsi_spi_driver);
Signature · 1 line
2.47.3
maintainer Acked-by on v2 13/13
#26 lore raw

Re: [PATCH v2 13/13] spi: fsi: Convert to fsi bus probe mechanism

Quoted 3 lines · Uwe Kleine-König

The fsi bus got a dedicated probe function. Make use of that. This fixes a runtime warning about the driver needing to be converted to the bus probe method.

Quoted 38 lines
---
  drivers/spi/spi-fsi.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/spi-fsi.c +3 -3
index f9c15b99dba5..07dc3d24f2c9 100644
@@ -528,13 +528,13 @@ static size_t fsi_spi_max_transfer_size(struct spi_device *spi)
  	return SPI_FSI_MAX_RX_SIZE;
  }
 
-static int fsi_spi_probe(struct device *dev)
+static int fsi_spi_probe(struct fsi_device *fsi)
  {
  	int rc;
  	struct device_node *np;
  	int num_controllers_registered = 0;
  	struct fsi2spi *bridge;
-	struct fsi_device *fsi = to_fsi_dev(dev);
+	struct device *dev = &fsi->dev;
 
  	rc = fsi_spi_check_mux(fsi, dev);
  	if (rc)
@@ -593,9 +593,9 @@ MODULE_DEVICE_TABLE(fsi, fsi_spi_ids);
 
  static struct fsi_driver fsi_spi_driver = {
  	.id_table = fsi_spi_ids,
+	.probe = fsi_spi_probe,
  	.drv = {
  		.name = "spi-fsi",
-		.probe = fsi_spi_probe,
  	},
  };
  module_fsi_driver(fsi_spi_driver);
#27 lore raw
In reply to Uwe Kleine-König

Hello Eddie,

Quoted 17 lines · Uwe Kleine-König

Hello,

this is the 2nd installment of the series converting the fsi bus to use bus methods for .probe and .remove. The changes since the first iteration---that can be found at
https://lore.kernel.org/lkml/[email protected]/
--- are:

- (trivially) rebase to v6.18
- add tags by Andi (for the i2c parts) and Mark Brown (for the spi parts)
- Add a patch converting drivers/fsi/i2cr-scom.c (#8)

In the earlier thread I thought I made a mistake for (implicit) v1, but I confused fsi with fsl and the problem doesn't apply here as it doesn't touch the shutdown callback.

Quoted 8 lines

This series is not urgent, but it would be great to get this into v6.19-rc1. With Mark's Acks and Andi's tags (though they are not an Ack) this should be fine to be picked up in one go by Eddie.

As before there are two commit refs that should refer to the commit for patch #2 ("fsi: Assign driver's bus in fsi_driver_register()"). As I cannot know the commit hash yet, I wrote "FIXME" and these need updating when the series is picked up.

gentle ping. While my quest to drop .probe() and .remove() is still in early stages, I'd like to see this series go in before it bitrots. It should have all the acks necessary to merge it.

Alternatively, should I ask Greg (added to Cc:) to merge?

Best regards
Uwe

maintainer
#28 lore raw
Quoted 24 lines · Uwe Kleine-König

Hello Eddie,

Quoted 21 lines · Uwe Kleine-König

Hello,

this is the 2nd installment of the series converting the fsi bus to use bus methods for .probe and .remove. The changes since the first iteration---that can be found at
https://lore.kernel.org/lkml/[email protected]/
--- are:

- (trivially) rebase to v6.18
- add tags by Andi (for the i2c parts) and Mark Brown (for the spi parts)
- Add a patch converting drivers/fsi/i2cr-scom.c (#8)

In the earlier thread I thought I made a mistake for (implicit) v1, but I confused fsi with fsl and the problem doesn't apply here as it doesn't touch the shutdown callback.

This series is not urgent, but it would be great to get this into v6.19-rc1. With Mark's Acks and Andi's tags (though they are not an Ack) this should be fine to be picked up in one go by Eddie.

Quoted 7 lines
Quoted 4 lines

As before there are two commit refs that should refer to the commit for patch #2 ("fsi: Assign driver's bus in fsi_driver_register()"). As I cannot know the commit hash yet, I wrote "FIXME" and these need updating when the series is picked up.

gentle ping. While my quest to drop .probe() and .remove() is still in early stages, I'd like to see this series go in before it bitrots. It should have all the acks necessary to merge it.

So sorry for the delay. Thank you very much for the series! Greg, please merge at your earliest convenience.

Thanks!

Eddie

Quoted 5 lines

Alternatively, should I ask Greg (added to Cc:) to merge?

Best regards
Uwe