fsi: Convert to bus probe mechanism
Subsystems (5)
cover fsi: Convert to bus probe mechanism
Hello,
for the quest to drop .probe(), .remove() and .shutdown() from struct device_driver, convert the fsi subsystem to make use of the respective bus methods. Some cleanups are also included, I noticed those while working on the conversion.
Regarding how to merge this series: There are two drivers touched that are not in drivers/fsi, namely drivers/i2c/busses/i2c-fsi.c and drivers/spi/spi-fsi.c. The easiest would be to merge this series through a single tree because the i2c and spi driver changes depend on some fsi core patches and fsi_bus_type can only made private when these are applied. I tried to quickly resort the series to only need three steps when merged separately, but this wasn't trivially possible, so I hope Andi and Mark give their acks to merge their driver changes together with the fsi core changes in one go.
Note this series is only compile tested as I don't have a machine using the fsi subsystem.
All the calls to get_device() I found in these drivers look a bit suspicious and I think there are some issues with lifetime tracking. But I didn't try to address these, so I'm just mentioning that here.
Best regards
Uwe
Uwe Kleine-König (12):
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: 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 | 1 - drivers/i2c/busses/i2c-fsi.c | 16 +++--- drivers/spi/spi-fsi.c | 7 +-- include/linux/fsi.h | 13 ++++- 8 files changed, 125 insertions(+), 97 deletions(-)
base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
Signature · 1 line
2.47.3
PATCH 1/12 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
@@ -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
@@ -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
PATCH 2/12 fsi: Assign driver's bus in fsi_driver_register()
In reply to Uwe Kleine-KönigInstead 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 3/12 fsi: Provide thin wrappers around dev_[gs]et_data() for fsi devices
In reply to Uwe Kleine-KönigSimilar 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
@@ -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
PATCH 4/12 i2c: fsi: Drop assigning fsi bus
In reply to Uwe Kleine-KönigSince 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
@@ -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
Re: [PATCH 04/12] i2c: fsi: Drop assigning fsi bus
Hi Uwe,
Quoted 1 line · Uwe Kleine-König
Since commit FIXME ("fsi: Assign driver's bus in
fsi_driver_register()")
whoever is going to apply the series needs to remember to replace this FIXME.
Quoted 4 lines
module_fsi_driver()cares about assigning the driver's bus member. Drop the explicit driver specific assignment.Signed-off-by Uwe Kleine-König <[email protected]>
Thanks,
Andi
Re: [PATCH 04/12] i2c: fsi: Drop assigning fsi bus
Hello Andi,
Quoted 5 lines · Andi Shyti
Quoted 1 line · Uwe Kleine-König
Since commit FIXME ("fsi: Assign driver's bus in
fsi_driver_register()")whoever is going to apply the series needs to remember to replace this FIXME.
Ah right, when I wrote the commit log I made a mental note to point that out in the cover letter, but then I forgot. Thanks for the reminder.
Best regards
Uwe
PATCH 5/12 spi: fsi: Drop assigning fsi bus
In reply to Uwe Kleine-KönigSince 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
@@ -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
Re: [PATCH 05/12] 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.
PATCH 6/12 fsi: Make fsi_bus_type a private variable to the core
In reply to Uwe Kleine-KönigThere 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
@@ -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
@@ -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
PATCH 7/12 fsi: Create bus specific probe and remove functions
In reply to Uwe Kleine-KönigIntroduce 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
@@ -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
@@ -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
PATCH 8/12 fsi: master: Convert to fsi bus probe mechanism
In reply to Uwe Kleine-KönigThe 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
@@ -192,9 +192,9 @@ static int hub_master_init(struct fsi_master_hub *hub)return fsi_device_write (dev,FSI_MRESB0 , ®,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
PATCH 9/12 fsi: sbefifo: Convert to fsi bus probe mechanism
In reply to Uwe Kleine-KönigThe 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
@@ -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
PATCH 10/12 fsi: scom: Convert to fsi bus probe mechanism
In reply to Uwe Kleine-KönigThe 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
@@ -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
PATCH 11/12 i2c: fsi: Convert to fsi bus probe mechanism
In reply to Uwe Kleine-KönigThe 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
@@ -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
Re: [PATCH 11/12] i2c: fsi: Convert to fsi bus probe mechanism
Hi Uwe,
Quoted 5 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.
Signed-off-by Uwe Kleine-König <[email protected]>
looks all right:
Andi
PATCH 12/12 spi: fsi: Convert to fsi bus probe mechanism
In reply to Uwe Kleine-KönigThe 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
@@ -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
Re: [PATCH 12/12] 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.
Hello,
Quoted 15 lines · Uwe Kleine-König
for the quest to drop .probe(), .remove() and .shutdown() from struct
device_driver, convert the fsi subsystem to make use of the respective bus methods. Some cleanups are also included, I noticed those while working on the conversion.Regarding how to merge this series: There are two drivers touched that are not in
drivers/fsi, namelydrivers/i2c/busses/i2c-fsi.canddrivers/spi/spi-fsi.c. The easiest would be to merge this series through a single tree because the i2c and spi driver changes depend on some fsi core patches andfsi_bus_typecan only made private when these are applied. I tried to quickly resort the series to only need three steps when merged separately, but this wasn't trivially possible, so I hope Andi and Mark give their acks to merge their driver changes together with the fsi core changes in one go.
Quoted 6 lines
Note this series is only compile tested as I don't have a machine using the fsi subsystem.
All the calls to
get_device()I found in these drivers look a bit suspicious and I think there are some issues with lifetime tracking. But I didn't try to address these, so I'm just mentioning that here.
While working on more such patches (for other subsystems) I found a problem in this patch set. Please don't apply it yet, I will prepare a v2 (and then also explain the things that need to be done).
Thanks
Uwe