public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] scsi: Make use of bus callbacks
@ 2025-12-09 20:45 Uwe Kleine-König
  2025-12-09 20:45 ` [PATCH 1/8] scsi: Pass a struct scsi_driver to scsi_{,un}register_driver() Uwe Kleine-König
                   ` (7 more replies)
  0 siblings, 8 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2025-12-09 20:45 UTC (permalink / raw)
  To: James E.J. Bottomley
  Cc: Martin K. Petersen, Kai Mäkisara, Alim Akhtar, Avri Altman,
	Bart Van Assche, Peter Wang, Bean Huo, Adrian Hunter,
	Bao D. Nguyen, Can Guo, Manivannan Sadhasivam, linux-scsi

Hello,

there are currently two mechanisms to bind a device to a driver: struct
device_driver::probe() and struct bus_type::probe(). The latter is the
newer and preferred variant. This series converts the scsi subsystem to
use the bus_type variant with the eventual goal to drop the
device_driver variant (after all other subsystems are converted as
well).

This passed an allmodconfig buildtest on amd64 and arm64. The intention
is that nothing changes for users of the scsi subsystems. 

Best regards
Uwe

Uwe Kleine-König (8):
  scsi: Pass a struct scsi_driver to scsi_{,un}register_driver()
  scsi: Make use of bus callbacks
  scsi: ch: Convert to scsi bus methods
  scsi: sd: Convert to scsi bus methods
  scsi: ses: Convert to scsi bus methods
  scsi: sr: Convert to scsi bus methods
  scsi: st: Convert to scsi bus methods
  scsi: ufs: Convert to scsi bus methods

 drivers/scsi/ch.c          | 18 ++++-----
 drivers/scsi/scsi_sysfs.c  | 77 ++++++++++++++++++++++++++++++++++++--
 drivers/scsi/sd.c          | 25 +++++++------
 drivers/scsi/ses.c         | 15 ++------
 drivers/scsi/sr.c          | 21 +++++------
 drivers/scsi/st.c          | 22 +++++------
 drivers/ufs/core/ufshcd.c  | 22 +++++------
 include/scsi/scsi_driver.h |  7 +++-
 8 files changed, 137 insertions(+), 70 deletions(-)


base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449
-- 
2.47.3


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

* [PATCH 1/8] scsi: Pass a struct scsi_driver to scsi_{,un}register_driver()
  2025-12-09 20:45 [PATCH 0/8] scsi: Make use of bus callbacks Uwe Kleine-König
@ 2025-12-09 20:45 ` Uwe Kleine-König
  2025-12-10 13:14   ` Peter Wang (王信友)
  2025-12-09 20:45 ` [PATCH 2/8] scsi: Make use of bus callbacks Uwe Kleine-König
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 22+ messages in thread
From: Uwe Kleine-König @ 2025-12-09 20:45 UTC (permalink / raw)
  To: James E.J. Bottomley
  Cc: Martin K. Petersen, Kai Mäkisara, Alim Akhtar, Avri Altman,
	Bart Van Assche, Peter Wang, Bean Huo, Adrian Hunter,
	Bao D. Nguyen, Can Guo, Manivannan Sadhasivam, linux-scsi

This aligns with what other subsystems do, reduces boilerplate a bit for
device drivers and is less error prone.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
 drivers/scsi/ch.c          | 4 ++--
 drivers/scsi/scsi_sysfs.c  | 4 +++-
 drivers/scsi/sd.c          | 4 ++--
 drivers/scsi/ses.c         | 4 ++--
 drivers/scsi/sr.c          | 4 ++--
 drivers/scsi/st.c          | 4 ++--
 drivers/ufs/core/ufshcd.c  | 4 ++--
 include/scsi/scsi_driver.h | 4 ++--
 8 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index fa07a6f54003..f2b63e4b9b99 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -1014,7 +1014,7 @@ static int __init init_ch_module(void)
 		       SCSI_CHANGER_MAJOR);
 		goto fail1;
 	}
-	rc = scsi_register_driver(&ch_template.gendrv);
+	rc = scsi_register_driver(&ch_template);
 	if (rc < 0)
 		goto fail2;
 	return 0;
@@ -1028,7 +1028,7 @@ static int __init init_ch_module(void)
 
 static void __exit exit_ch_module(void)
 {
-	scsi_unregister_driver(&ch_template.gendrv);
+	scsi_unregister_driver(&ch_template);
 	unregister_chrdev(SCSI_CHANGER_MAJOR, "ch");
 	class_unregister(&ch_sysfs_class);
 	idr_destroy(&ch_index_idr);
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 15ba493d2138..f2d62f71c8af 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1609,8 +1609,10 @@ void scsi_remove_target(struct device *dev)
 }
 EXPORT_SYMBOL(scsi_remove_target);
 
-int __scsi_register_driver(struct device_driver *drv, struct module *owner)
+int __scsi_register_driver(struct scsi_driver *sdrv, struct module *owner)
 {
+	struct device_driver *drv = &sdrv->gendrv;
+
 	drv->bus = &scsi_bus_type;
 	drv->owner = owner;
 
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 0252d3f6bed1..da927c030ecc 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -4375,7 +4375,7 @@ static int __init init_sd(void)
 		goto err_out_class;
 	}
 
-	err = scsi_register_driver(&sd_template.gendrv);
+	err = scsi_register_driver(&sd_template);
 	if (err)
 		goto err_out_driver;
 
@@ -4402,7 +4402,7 @@ static void __exit exit_sd(void)
 
 	SCSI_LOG_HLQUEUE(3, printk("exit_sd: exiting sd driver\n"));
 
-	scsi_unregister_driver(&sd_template.gendrv);
+	scsi_unregister_driver(&sd_template);
 	mempool_destroy(sd_page_pool);
 
 	class_unregister(&sd_disk_class);
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index 2c61624cb4b0..f8f5164f3de2 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -921,7 +921,7 @@ static int __init ses_init(void)
 	if (err)
 		return err;
 
-	err = scsi_register_driver(&ses_template.gendrv);
+	err = scsi_register_driver(&ses_template);
 	if (err)
 		goto out_unreg;
 
@@ -934,7 +934,7 @@ static int __init ses_init(void)
 
 static void __exit ses_exit(void)
 {
-	scsi_unregister_driver(&ses_template.gendrv);
+	scsi_unregister_driver(&ses_template);
 	scsi_unregister_interface(&ses_interface);
 }
 
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index add13e306898..2f6bb6355186 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -1001,7 +1001,7 @@ static int __init init_sr(void)
 	rc = register_blkdev(SCSI_CDROM_MAJOR, "sr");
 	if (rc)
 		return rc;
-	rc = scsi_register_driver(&sr_template.gendrv);
+	rc = scsi_register_driver(&sr_template);
 	if (rc)
 		unregister_blkdev(SCSI_CDROM_MAJOR, "sr");
 
@@ -1010,7 +1010,7 @@ static int __init init_sr(void)
 
 static void __exit exit_sr(void)
 {
-	scsi_unregister_driver(&sr_template.gendrv);
+	scsi_unregister_driver(&sr_template);
 	unregister_blkdev(SCSI_CDROM_MAJOR, "sr");
 }
 
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 74a6830b7ed8..83140b60f3fb 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4533,7 +4533,7 @@ static int __init init_st(void)
 		goto err_class;
 	}
 
-	err = scsi_register_driver(&st_template.gendrv);
+	err = scsi_register_driver(&st_template);
 	if (err)
 		goto err_chrdev;
 
@@ -4549,7 +4549,7 @@ static int __init init_st(void)
 
 static void __exit exit_st(void)
 {
-	scsi_unregister_driver(&st_template.gendrv);
+	scsi_unregister_driver(&st_template);
 	unregister_chrdev_region(MKDEV(SCSI_TAPE_MAJOR, 0),
 				 ST_MAX_TAPE_ENTRIES);
 	class_unregister(&st_sysfs_class);
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index d6a060a72461..98a3aec81ade 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -11088,7 +11088,7 @@ static int __init ufshcd_core_init(void)
 
 	ufs_debugfs_init();
 
-	ret = scsi_register_driver(&ufs_dev_wlun_template.gendrv);
+	ret = scsi_register_driver(&ufs_dev_wlun_template);
 	if (ret)
 		ufs_debugfs_exit();
 	return ret;
@@ -11097,7 +11097,7 @@ static int __init ufshcd_core_init(void)
 static void __exit ufshcd_core_exit(void)
 {
 	ufs_debugfs_exit();
-	scsi_unregister_driver(&ufs_dev_wlun_template.gendrv);
+	scsi_unregister_driver(&ufs_dev_wlun_template);
 }
 
 module_init(ufshcd_core_init);
diff --git a/include/scsi/scsi_driver.h b/include/scsi/scsi_driver.h
index c0e89996bdb3..40aba9a9349a 100644
--- a/include/scsi/scsi_driver.h
+++ b/include/scsi/scsi_driver.h
@@ -25,9 +25,9 @@ struct scsi_driver {
 
 #define scsi_register_driver(drv) \
 	__scsi_register_driver(drv, THIS_MODULE)
-int __scsi_register_driver(struct device_driver *, struct module *);
+int __scsi_register_driver(struct scsi_driver *, struct module *);
 #define scsi_unregister_driver(drv) \
-	driver_unregister(drv);
+	driver_unregister(&(drv)->gendrv);
 
 extern int scsi_register_interface(struct class_interface *);
 #define scsi_unregister_interface(intf) \
-- 
2.47.3


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

* [PATCH 2/8] scsi: Make use of bus callbacks
  2025-12-09 20:45 [PATCH 0/8] scsi: Make use of bus callbacks Uwe Kleine-König
  2025-12-09 20:45 ` [PATCH 1/8] scsi: Pass a struct scsi_driver to scsi_{,un}register_driver() Uwe Kleine-König
@ 2025-12-09 20:45 ` Uwe Kleine-König
  2025-12-09 20:59   ` Bart Van Assche
  2025-12-09 21:00   ` Bart Van Assche
  2025-12-09 20:45 ` [PATCH 3/8] scsi: ch: Convert to scsi bus methods Uwe Kleine-König
                   ` (5 subsequent siblings)
  7 siblings, 2 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2025-12-09 20:45 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Martin K. Petersen, linux-scsi

Introduce a bus specific probe, remove and shutdown function. For now
this only allows to get rid of a cast of the generic device to an scsi
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_driver callbacks
.probe(), .remove() and .shutdown() to eventually remove these. Until
all scsi 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. The in-tree drivers are fixed by the following
commits.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
 drivers/scsi/scsi_sysfs.c  | 73 ++++++++++++++++++++++++++++++++++++--
 include/scsi/scsi_driver.h |  3 ++
 2 files changed, 74 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index f2d62f71c8af..343c1f9098af 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -554,10 +554,48 @@ static int scsi_bus_uevent(const struct device *dev, struct kobj_uevent_env *env
 	return 0;
 }
 
+static int scsi_bus_probe(struct device *dev)
+{
+	struct scsi_device *sdp = to_scsi_device(dev);
+	struct scsi_driver *drv = to_scsi_driver(dev->driver);
+
+	if (drv->probe)
+		return drv->probe(sdp);
+	else
+		return 0;
+}
+
+static void scsi_bus_remove(struct device *dev)
+{
+	struct scsi_device *sdp = to_scsi_device(dev);
+	struct scsi_driver *drv = to_scsi_driver(dev->driver);
+
+	if (drv->remove)
+		drv->remove(sdp);
+}
+
+static void scsi_bus_shutdown(struct device *dev)
+{
+	struct scsi_device *sdp = to_scsi_device(dev);
+	struct scsi_driver *drv;
+
+	if (!dev->driver)
+		return;
+
+	drv = to_scsi_driver(dev->driver);
+
+	if (drv->shutdown)
+		drv->shutdown(sdp);
+}
+
+
 const struct bus_type scsi_bus_type = {
-        .name		= "scsi",
-        .match		= scsi_bus_match,
+	.name		= "scsi",
+	.match		= scsi_bus_match,
 	.uevent		= scsi_bus_uevent,
+	.probe		= scsi_bus_probe,
+	.remove		= scsi_bus_remove,
+	.shutdown	= scsi_bus_shutdown,
 #ifdef CONFIG_PM
 	.pm		= &scsi_bus_pm_ops,
 #endif
@@ -1609,6 +1647,30 @@ void scsi_remove_target(struct device *dev)
 }
 EXPORT_SYMBOL(scsi_remove_target);
 
+static int scsi_legacy_probe(struct scsi_device *sdp)
+{
+	struct device *dev = &sdp->sdev_gendev;
+	struct device_driver *driver = dev->driver;
+
+	return driver->probe(dev);
+}
+
+static void scsi_legacy_remove(struct scsi_device *sdp)
+{
+	struct device *dev = &sdp->sdev_gendev;
+	struct device_driver *driver = dev->driver;
+
+	driver->remove(dev);
+}
+
+static void scsi_legacy_shutdown(struct scsi_device *sdp)
+{
+	struct device *dev = &sdp->sdev_gendev;
+	struct device_driver *driver = dev->driver;
+
+	driver->shutdown(dev);
+}
+
 int __scsi_register_driver(struct scsi_driver *sdrv, struct module *owner)
 {
 	struct device_driver *drv = &sdrv->gendrv;
@@ -1616,6 +1678,13 @@ int __scsi_register_driver(struct scsi_driver *sdrv, struct module *owner)
 	drv->bus = &scsi_bus_type;
 	drv->owner = owner;
 
+	if (!sdrv->probe && drv->probe)
+		sdrv->probe = scsi_legacy_probe;
+	if (!sdrv->remove && drv->remove)
+		sdrv->remove = scsi_legacy_remove;
+	if (!sdrv->shutdown && drv->shutdown)
+		sdrv->shutdown = scsi_legacy_shutdown;
+
 	return driver_register(drv);
 }
 EXPORT_SYMBOL(__scsi_register_driver);
diff --git a/include/scsi/scsi_driver.h b/include/scsi/scsi_driver.h
index 40aba9a9349a..249cea724abd 100644
--- a/include/scsi/scsi_driver.h
+++ b/include/scsi/scsi_driver.h
@@ -12,6 +12,9 @@ struct request;
 struct scsi_driver {
 	struct device_driver	gendrv;
 
+	int (*probe)(struct scsi_device *);
+	void (*remove)(struct scsi_device *);
+	void (*shutdown)(struct scsi_device *);
 	int (*resume)(struct device *);
 	void (*rescan)(struct device *);
 	blk_status_t (*init_command)(struct scsi_cmnd *);
-- 
2.47.3


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

* [PATCH 3/8] scsi: ch: Convert to scsi bus methods
  2025-12-09 20:45 [PATCH 0/8] scsi: Make use of bus callbacks Uwe Kleine-König
  2025-12-09 20:45 ` [PATCH 1/8] scsi: Pass a struct scsi_driver to scsi_{,un}register_driver() Uwe Kleine-König
  2025-12-09 20:45 ` [PATCH 2/8] scsi: Make use of bus callbacks Uwe Kleine-König
@ 2025-12-09 20:45 ` Uwe Kleine-König
  2025-12-09 20:45 ` [PATCH 4/8] scsi: sd: " Uwe Kleine-König
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2025-12-09 20:45 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Martin K. Petersen, linux-scsi

The scsi bus got dedicated callbacks for probe, remove and shutdown.
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 <u.kleine-koenig@baylibre.com>
---
 drivers/scsi/ch.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index f2b63e4b9b99..91318e110901 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -894,9 +894,9 @@ static long ch_ioctl(struct file *file,
 
 /* ------------------------------------------------------------------------ */
 
-static int ch_probe(struct device *dev)
+static int ch_probe(struct scsi_device *sd)
 {
-	struct scsi_device *sd = to_scsi_device(dev);
+	struct device *dev = &sd->sdev_gendev;
 	struct device *class_dev;
 	int ret;
 	scsi_changer *ch;
@@ -967,8 +967,9 @@ static int ch_probe(struct device *dev)
 	return ret;
 }
 
-static int ch_remove(struct device *dev)
+static void ch_remove(struct scsi_device *sdev)
 {
+	struct device *dev = &sdev->sdev_gendev;
 	scsi_changer *ch = dev_get_drvdata(dev);
 
 	spin_lock(&ch_index_lock);
@@ -979,15 +980,14 @@ static int ch_remove(struct device *dev)
 	device_destroy(&ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR, ch->minor));
 	scsi_device_put(ch->device);
 	kref_put(&ch->ref, ch_destroy);
-	return 0;
 }
 
 static struct scsi_driver ch_template = {
-	.gendrv     	= {
+	.probe = ch_probe,
+	.remove = ch_remove,
+	.gendrv = {
 		.name	= "ch",
 		.owner	= THIS_MODULE,
-		.probe  = ch_probe,
-		.remove = ch_remove,
 	},
 };
 
-- 
2.47.3


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

* [PATCH 4/8] scsi: sd: Convert to scsi bus methods
  2025-12-09 20:45 [PATCH 0/8] scsi: Make use of bus callbacks Uwe Kleine-König
                   ` (2 preceding siblings ...)
  2025-12-09 20:45 ` [PATCH 3/8] scsi: ch: Convert to scsi bus methods Uwe Kleine-König
@ 2025-12-09 20:45 ` Uwe Kleine-König
  2025-12-10  9:20   ` kernel test robot
  2025-12-15  4:10   ` kernel test robot
  2025-12-09 20:45 ` [PATCH 5/8] scsi: ses: " Uwe Kleine-König
                   ` (3 subsequent siblings)
  7 siblings, 2 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2025-12-09 20:45 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Martin K. Petersen, linux-scsi

The scsi bus got dedicated callbacks for probe, remove and shutdown.
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 <u.kleine-koenig@baylibre.com>
---
 drivers/scsi/sd.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index da927c030ecc..afed915eb158 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -108,7 +108,7 @@ static void sd_config_write_same(struct scsi_disk *sdkp,
 		struct queue_limits *lim);
 static void  sd_revalidate_disk(struct gendisk *);
 static void sd_unlock_native_capacity(struct gendisk *disk);
-static void sd_shutdown(struct device *);
+static void sd_shutdown(struct scsi_device *);
 static void scsi_disk_release(struct device *cdev);
 
 static DEFINE_IDA(sd_index_ida);
@@ -3909,9 +3909,9 @@ static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen)
  *	Assume sd_probe is not re-entrant (for time being)
  *	Also think about sd_probe() and sd_remove() running coincidentally.
  **/
-static int sd_probe(struct device *dev)
+static int sd_probe(struct scsi_device *sdp)
 {
-	struct scsi_device *sdp = to_scsi_device(dev);
+	struct device *dev = &sdp->sdev_gendev;
 	struct scsi_disk *sdkp;
 	struct gendisk *gd;
 	int index;
@@ -4058,8 +4058,9 @@ static int sd_probe(struct device *dev)
  *	that could be re-used by a subsequent sd_probe().
  *	This function is not called when the built-in sd driver is "exit-ed".
  **/
-static int sd_remove(struct device *dev)
+static void sd_remove(struct scsi_device *sd)
 {
+	struct device *dev = &sd->sdev_gendev;
 	struct scsi_disk *sdkp = dev_get_drvdata(dev);
 
 	scsi_autopm_get_device(sdkp->device);
@@ -4067,10 +4068,9 @@ static int sd_remove(struct device *dev)
 	device_del(&sdkp->disk_dev);
 	del_gendisk(sdkp->disk);
 	if (!sdkp->suspended)
-		sd_shutdown(dev);
+		sd_shutdown(sd);
 
 	put_disk(sdkp->disk);
-	return 0;
 }
 
 static void scsi_disk_release(struct device *dev)
@@ -4157,8 +4157,9 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
  * the normal SCSI command structure.  Wait for the command to
  * complete.
  */
-static void sd_shutdown(struct device *dev)
+static void sd_shutdown(struct scsi_device *sd)
 {
+	struct device *dev = &sd->sdev_gendev;
 	struct scsi_disk *sdkp = dev_get_drvdata(dev);
 
 	if (!sdkp)
@@ -4326,12 +4327,12 @@ static const struct dev_pm_ops sd_pm_ops = {
 };
 
 static struct scsi_driver sd_template = {
+	.probe = sd_probe,
+	.remove = sd_remove,
+	.shutdown = sd_shutdown,
 	.gendrv = {
 		.name		= "sd",
-		.probe		= sd_probe,
 		.probe_type	= PROBE_PREFER_ASYNCHRONOUS,
-		.remove		= sd_remove,
-		.shutdown	= sd_shutdown,
 		.pm		= &sd_pm_ops,
 	},
 	.rescan			= sd_rescan,
-- 
2.47.3


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

* [PATCH 5/8] scsi: ses: Convert to scsi bus methods
  2025-12-09 20:45 [PATCH 0/8] scsi: Make use of bus callbacks Uwe Kleine-König
                   ` (3 preceding siblings ...)
  2025-12-09 20:45 ` [PATCH 4/8] scsi: sd: " Uwe Kleine-König
@ 2025-12-09 20:45 ` Uwe Kleine-König
  2025-12-09 20:45 ` [PATCH 6/8] scsi: sr: " Uwe Kleine-König
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2025-12-09 20:45 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Martin K. Petersen, linux-scsi

The scsi bus got dedicated callbacks for probe, remove and shutdown.
Make use of that. This fixes a runtime warning about the driver needing
to be converted to the bus probe method.

There is no need for an empty remove callback, no remove callback has
the same semantics. So instead of converting the remove callback, drop
it.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
 drivers/scsi/ses.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index f8f5164f3de2..789b170da652 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -42,9 +42,8 @@ static bool ses_page2_supported(struct enclosure_device *edev)
 	return (ses_dev->page2 != NULL);
 }
 
-static int ses_probe(struct device *dev)
+static int ses_probe(struct scsi_device *sdev)
 {
-	struct scsi_device *sdev = to_scsi_device(dev);
 	int err = -ENODEV;
 
 	if (sdev->type != TYPE_ENCLOSURE)
@@ -847,11 +846,6 @@ static int ses_intf_add(struct device *cdev)
 	return err;
 }
 
-static int ses_remove(struct device *dev)
-{
-	return 0;
-}
-
 static void ses_intf_remove_component(struct scsi_device *sdev)
 {
 	struct enclosure_device *edev, *prev = NULL;
@@ -906,10 +900,9 @@ static struct class_interface ses_interface = {
 };
 
 static struct scsi_driver ses_template = {
+	.probe = ses_probe,
 	.gendrv = {
 		.name		= "ses",
-		.probe		= ses_probe,
-		.remove		= ses_remove,
 	},
 };
 
-- 
2.47.3


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

* [PATCH 6/8] scsi: sr: Convert to scsi bus methods
  2025-12-09 20:45 [PATCH 0/8] scsi: Make use of bus callbacks Uwe Kleine-König
                   ` (4 preceding siblings ...)
  2025-12-09 20:45 ` [PATCH 5/8] scsi: ses: " Uwe Kleine-König
@ 2025-12-09 20:45 ` Uwe Kleine-König
  2025-12-09 20:45 ` [PATCH 7/8] scsi: st: " Uwe Kleine-König
  2025-12-09 20:45 ` [PATCH 8/8] scsi: ufs: " Uwe Kleine-König
  7 siblings, 0 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2025-12-09 20:45 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Martin K. Petersen, linux-scsi

The scsi bus got dedicated callbacks for probe, remove and shutdown.
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 <u.kleine-koenig@baylibre.com>
---
 drivers/scsi/sr.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 2f6bb6355186..1fb85f548955 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -82,8 +82,8 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_WORM);
 	 CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \
 	 CDC_MRW|CDC_MRW_W|CDC_RAM)
 
-static int sr_probe(struct device *);
-static int sr_remove(struct device *);
+static int sr_probe(struct scsi_device *);
+static void sr_remove(struct scsi_device *);
 static blk_status_t sr_init_command(struct scsi_cmnd *SCpnt);
 static int sr_done(struct scsi_cmnd *);
 static int sr_runtime_suspend(struct device *dev);
@@ -93,10 +93,10 @@ static const struct dev_pm_ops sr_pm_ops = {
 };
 
 static struct scsi_driver sr_template = {
+	.probe = sr_probe,
+	.remove = sr_remove,
 	.gendrv = {
 		.name   	= "sr",
-		.probe		= sr_probe,
-		.remove		= sr_remove,
 		.pm		= &sr_pm_ops,
 	},
 	.init_command		= sr_init_command,
@@ -616,9 +616,9 @@ static void sr_release(struct cdrom_device_info *cdi)
 {
 }
 
-static int sr_probe(struct device *dev)
+static int sr_probe(struct scsi_device *sdev)
 {
-	struct scsi_device *sdev = to_scsi_device(dev);
+	struct device *dev = &sdev->sdev_gendev;
 	struct gendisk *disk;
 	struct scsi_cd *cd;
 	int minor, error;
@@ -982,16 +982,15 @@ static int sr_read_cdda_bpc(struct cdrom_device_info *cdi, void __user *ubuf,
 	return ret;
 }
 
-static int sr_remove(struct device *dev)
+static void sr_remove(struct scsi_device *sdev)
 {
+	struct device *dev = &sdev->sdev_gendev;
 	struct scsi_cd *cd = dev_get_drvdata(dev);
 
 	scsi_autopm_get_device(cd->device);
 
 	del_gendisk(cd->disk);
 	put_disk(cd->disk);
-
-	return 0;
 }
 
 static int __init init_sr(void)
-- 
2.47.3


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

* [PATCH 7/8] scsi: st: Convert to scsi bus methods
  2025-12-09 20:45 [PATCH 0/8] scsi: Make use of bus callbacks Uwe Kleine-König
                   ` (5 preceding siblings ...)
  2025-12-09 20:45 ` [PATCH 6/8] scsi: sr: " Uwe Kleine-König
@ 2025-12-09 20:45 ` Uwe Kleine-König
  2025-12-09 20:45 ` [PATCH 8/8] scsi: ufs: " Uwe Kleine-König
  7 siblings, 0 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2025-12-09 20:45 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Kai Mäkisara, Martin K. Petersen, linux-scsi

The scsi bus got dedicated callbacks for probe, remove and shutdown.
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 <u.kleine-koenig@baylibre.com>
---
 drivers/scsi/st.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 83140b60f3fb..06f03fde9637 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -202,14 +202,14 @@ static int sgl_map_user_pages(struct st_buffer *, const unsigned int,
 			      unsigned long, size_t, int);
 static int sgl_unmap_user_pages(struct st_buffer *, const unsigned int, int);
 
-static int st_probe(struct device *);
-static int st_remove(struct device *);
+static int st_probe(struct scsi_device *);
+static void st_remove(struct scsi_device *);
 
 static struct scsi_driver st_template = {
+	.probe = st_probe,
+	.remove = st_remove,
 	.gendrv = {
 		.name		= "st",
-		.probe		= st_probe,
-		.remove		= st_remove,
 		.groups		= st_drv_groups,
 	},
 };
@@ -4299,9 +4299,9 @@ static void remove_cdevs(struct scsi_tape *tape)
 	}
 }
 
-static int st_probe(struct device *dev)
+static int st_probe(struct scsi_device *SDp)
 {
-	struct scsi_device *SDp = to_scsi_device(dev);
+	struct device *dev = &SDp->sdev_gendev;
 	struct scsi_tape *tpnt = NULL;
 	struct st_modedef *STm;
 	struct st_partstat *STps;
@@ -4456,12 +4456,13 @@ static int st_probe(struct device *dev)
 };
 
 
-static int st_remove(struct device *dev)
+static void st_remove(struct scsi_device *SDp)
 {
+	struct device *dev = &SDp->sdev_gendev;
 	struct scsi_tape *tpnt = dev_get_drvdata(dev);
 	int index = tpnt->index;
 
-	scsi_autopm_get_device(to_scsi_device(dev));
+	scsi_autopm_get_device(SDp);
 	remove_cdevs(tpnt);
 
 	mutex_lock(&st_ref_mutex);
@@ -4470,7 +4471,6 @@ static int st_remove(struct device *dev)
 	spin_lock(&st_index_lock);
 	idr_remove(&st_index_idr, index);
 	spin_unlock(&st_index_lock);
-	return 0;
 }
 
 /**
-- 
2.47.3


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

* [PATCH 8/8] scsi: ufs: Convert to scsi bus methods
  2025-12-09 20:45 [PATCH 0/8] scsi: Make use of bus callbacks Uwe Kleine-König
                   ` (6 preceding siblings ...)
  2025-12-09 20:45 ` [PATCH 7/8] scsi: st: " Uwe Kleine-König
@ 2025-12-09 20:45 ` Uwe Kleine-König
  2025-12-10 13:14   ` Peter Wang (王信友)
  7 siblings, 1 reply; 22+ messages in thread
From: Uwe Kleine-König @ 2025-12-09 20:45 UTC (permalink / raw)
  To: James E.J. Bottomley
  Cc: Alim Akhtar, Avri Altman, Bart Van Assche, Martin K. Petersen,
	Peter Wang, Bean Huo, Adrian Hunter, Bao D. Nguyen, Can Guo,
	Manivannan Sadhasivam, linux-scsi

The scsi bus got dedicated callbacks for probe, remove and shutdown.
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 <u.kleine-koenig@baylibre.com>
---
 drivers/ufs/core/ufshcd.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 98a3aec81ade..84db44c7a583 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -10386,9 +10386,8 @@ int ufshcd_runtime_resume(struct device *dev)
 EXPORT_SYMBOL(ufshcd_runtime_resume);
 #endif /* CONFIG_PM */
 
-static void ufshcd_wl_shutdown(struct device *dev)
+static void ufshcd_wl_shutdown(struct scsi_device *sdev)
 {
-	struct scsi_device *sdev = to_scsi_device(dev);
 	struct ufs_hba *hba = shost_priv(sdev->host);
 
 	down(&hba->host_sem);
@@ -10981,9 +10980,9 @@ static int ufshcd_wl_poweroff(struct device *dev)
 }
 #endif
 
-static int ufshcd_wl_probe(struct device *dev)
+static int ufshcd_wl_probe(struct scsi_device *sdev)
 {
-	struct scsi_device *sdev = to_scsi_device(dev);
+	struct device *dev = &sdev->sdev_gendev;
 
 	if (!is_device_wlun(sdev))
 		return -ENODEV;
@@ -10995,10 +10994,11 @@ static int ufshcd_wl_probe(struct device *dev)
 	return  0;
 }
 
-static int ufshcd_wl_remove(struct device *dev)
+static void ufshcd_wl_remove(struct scsi_device *sdev)
 {
+	struct device *dev = &sdev->sdev_gendev;
+
 	pm_runtime_forbid(dev);
-	return 0;
 }
 
 static const struct dev_pm_ops ufshcd_wl_pm_ops = {
@@ -11071,12 +11071,12 @@ static void ufshcd_check_header_layout(void)
  * Hence register a scsi driver for ufs wluns only.
  */
 static struct scsi_driver ufs_dev_wlun_template = {
+	.probe = ufshcd_wl_probe,
+	.remove = ufshcd_wl_remove,
+	.shutdown = ufshcd_wl_shutdown,
 	.gendrv = {
 		.name = "ufs_device_wlun",
-		.probe = ufshcd_wl_probe,
-		.remove = ufshcd_wl_remove,
 		.pm = &ufshcd_wl_pm_ops,
-		.shutdown = ufshcd_wl_shutdown,
 	},
 };
 
-- 
2.47.3


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

* Re: [PATCH 2/8] scsi: Make use of bus callbacks
  2025-12-09 20:45 ` [PATCH 2/8] scsi: Make use of bus callbacks Uwe Kleine-König
@ 2025-12-09 20:59   ` Bart Van Assche
  2025-12-09 21:22     ` Uwe Kleine-König
  2025-12-09 21:00   ` Bart Van Assche
  1 sibling, 1 reply; 22+ messages in thread
From: Bart Van Assche @ 2025-12-09 20:59 UTC (permalink / raw)
  To: Uwe Kleine-König, James E.J. Bottomley
  Cc: Martin K. Petersen, linux-scsi

On 12/9/25 12:45 PM, Uwe Kleine-König wrote:
> +static int scsi_legacy_probe(struct scsi_device *sdp)
> +{
> +	struct device *dev = &sdp->sdev_gendev;
> +	struct device_driver *driver = dev->driver;
> +
> +	return driver->probe(dev);
> +}
> +
> +static void scsi_legacy_remove(struct scsi_device *sdp)
> +{
> +	struct device *dev = &sdp->sdev_gendev;
> +	struct device_driver *driver = dev->driver;
> +
> +	driver->remove(dev);
> +}
> +
> +static void scsi_legacy_shutdown(struct scsi_device *sdp)
> +{
> +	struct device *dev = &sdp->sdev_gendev;
> +	struct device_driver *driver = dev->driver;
> +
> +	driver->shutdown(dev);
> +}
Does this patch series convert all SCSI drivers that trigger calls to
the above functions? If so, shouldn't there be a patch at the end of
this series that removes the above functions again?

Thanks,

Bart.

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

* Re: [PATCH 2/8] scsi: Make use of bus callbacks
  2025-12-09 20:45 ` [PATCH 2/8] scsi: Make use of bus callbacks Uwe Kleine-König
  2025-12-09 20:59   ` Bart Van Assche
@ 2025-12-09 21:00   ` Bart Van Assche
  2025-12-09 21:26     ` Uwe Kleine-König
  1 sibling, 1 reply; 22+ messages in thread
From: Bart Van Assche @ 2025-12-09 21:00 UTC (permalink / raw)
  To: Uwe Kleine-König, James E.J. Bottomley
  Cc: Martin K. Petersen, linux-scsi

On 12/9/25 12:45 PM, Uwe Kleine-König wrote:
> The objective is to get rid of users of struct device_driver callbacks
> .probe(), .remove() and .shutdown() to eventually remove these. Until
> all scsi 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. The in-tree drivers are fixed by the following
> commits.
Which runtime warning? Has that runtime warning perhaps been introduced
by a patch series that has not yet been merged?

Thanks,

Bart.

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

* Re: [PATCH 2/8] scsi: Make use of bus callbacks
  2025-12-09 20:59   ` Bart Van Assche
@ 2025-12-09 21:22     ` Uwe Kleine-König
  2025-12-10  5:26       ` Christoph Hellwig
  0 siblings, 1 reply; 22+ messages in thread
From: Uwe Kleine-König @ 2025-12-09 21:22 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi

[-- Attachment #1: Type: text/plain, Size: 1326 bytes --]

On Tue, Dec 09, 2025 at 12:59:08PM -0800, Bart Van Assche wrote:
> On 12/9/25 12:45 PM, Uwe Kleine-König wrote:
> > +static int scsi_legacy_probe(struct scsi_device *sdp)
> > +{
> > +	struct device *dev = &sdp->sdev_gendev;
> > +	struct device_driver *driver = dev->driver;
> > +
> > +	return driver->probe(dev);
> > +}
> > +
> > +static void scsi_legacy_remove(struct scsi_device *sdp)
> > +{
> > +	struct device *dev = &sdp->sdev_gendev;
> > +	struct device_driver *driver = dev->driver;
> > +
> > +	driver->remove(dev);
> > +}
> > +
> > +static void scsi_legacy_shutdown(struct scsi_device *sdp)
> > +{
> > +	struct device *dev = &sdp->sdev_gendev;
> > +	struct device_driver *driver = dev->driver;
> > +
> > +	driver->shutdown(dev);
> > +}
> Does this patch series convert all SCSI drivers that trigger calls to
> the above functions? If so, shouldn't there be a patch at the end of
> this series that removes the above functions again?

I decided not to do that as part of this patch set. In case I missed a
driver and for oot drivers I think it's nice and fair to not break them
immediately and give its users/developers a chance to see the warning
and act on it.

Before the callbacks can be removed from struct device_driver these
obviously have to be dropped.

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 2/8] scsi: Make use of bus callbacks
  2025-12-09 21:00   ` Bart Van Assche
@ 2025-12-09 21:26     ` Uwe Kleine-König
  0 siblings, 0 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2025-12-09 21:26 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi

[-- Attachment #1: Type: text/plain, Size: 1127 bytes --]

Hello Bart,

On Tue, Dec 09, 2025 at 01:00:03PM -0800, Bart Van Assche wrote:
> On 12/9/25 12:45 PM, Uwe Kleine-König wrote:
> > The objective is to get rid of users of struct device_driver callbacks
> > .probe(), .remove() and .shutdown() to eventually remove these. Until
> > all scsi 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. The in-tree drivers are fixed by the following
> > commits.
> Which runtime warning? Has that runtime warning perhaps been introduced
> by a patch series that has not yet been merged?

the warning is in driver_register() (drivers/base/driver.c):

        if ((drv->bus->probe && drv->probe) ||
            (drv->bus->remove && drv->remove) ||
            (drv->bus->shutdown && drv->shutdown))
                pr_warn("Driver '%s' needs updating - please use "
                        "bus_type methods\n", drv->name);

since commit 594c8281f905 ("[PATCH] Add bus_type probe, remove, shutdown
methods.") which is in v2.6.16-rc1.

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 2/8] scsi: Make use of bus callbacks
  2025-12-09 21:22     ` Uwe Kleine-König
@ 2025-12-10  5:26       ` Christoph Hellwig
  2025-12-10  6:56         ` Uwe Kleine-König
  0 siblings, 1 reply; 22+ messages in thread
From: Christoph Hellwig @ 2025-12-10  5:26 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Bart Van Assche, James E.J. Bottomley, Martin K. Petersen,
	linux-scsi

On Tue, Dec 09, 2025 at 10:22:54PM +0100, Uwe Kleine-König wrote:
> I decided not to do that as part of this patch set. In case I missed a
> driver and for oot drivers I think it's nice and fair to not break them
> immediately and give its users/developers a chance to see the warning
> and act on it.

No one should care about out of tree drivers.  On the other hand
unfinished transitions are really annoying and have a tendency to
go stale.  So please go the final steps and finish it.


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

* Re: [PATCH 2/8] scsi: Make use of bus callbacks
  2025-12-10  5:26       ` Christoph Hellwig
@ 2025-12-10  6:56         ` Uwe Kleine-König
  2025-12-10  7:04           ` Christoph Hellwig
  0 siblings, 1 reply; 22+ messages in thread
From: Uwe Kleine-König @ 2025-12-10  6:56 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Bart Van Assche, James E.J. Bottomley, Martin K. Petersen,
	linux-scsi

[-- Attachment #1: Type: text/plain, Size: 967 bytes --]

On Tue, Dec 09, 2025 at 09:26:40PM -0800, Christoph Hellwig wrote:
> On Tue, Dec 09, 2025 at 10:22:54PM +0100, Uwe Kleine-König wrote:
> > I decided not to do that as part of this patch set. In case I missed a
> > driver and for oot drivers I think it's nice and fair to not break them
> > immediately and give its users/developers a chance to see the warning
> > and act on it.
> 
> No one should care about out of tree drivers.  On the other hand
> unfinished transitions are really annoying and have a tendency to
> go stale.  So please go the final steps and finish it.

Given that the whole quest to remove the device_driver callbacks will go
on for a few kernel releases and completing the transition for scsi
yields to broken drivers without compile time issues if something is
missed, I think it's sensible to keep them in the "working with warning"
state for a release cycle (or even until the driver callbacks go away).

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 2/8] scsi: Make use of bus callbacks
  2025-12-10  6:56         ` Uwe Kleine-König
@ 2025-12-10  7:04           ` Christoph Hellwig
  2025-12-10 10:34             ` Uwe Kleine-König
  0 siblings, 1 reply; 22+ messages in thread
From: Christoph Hellwig @ 2025-12-10  7:04 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Christoph Hellwig, Bart Van Assche, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi

On Wed, Dec 10, 2025 at 07:56:10AM +0100, Uwe Kleine-König wrote:
> On Tue, Dec 09, 2025 at 09:26:40PM -0800, Christoph Hellwig wrote:
> > On Tue, Dec 09, 2025 at 10:22:54PM +0100, Uwe Kleine-König wrote:
> > > I decided not to do that as part of this patch set. In case I missed a
> > > driver and for oot drivers I think it's nice and fair to not break them
> > > immediately and give its users/developers a chance to see the warning
> > > and act on it.
> > 
> > No one should care about out of tree drivers.  On the other hand
> > unfinished transitions are really annoying and have a tendency to
> > go stale.  So please go the final steps and finish it.
> 
> Given that the whole quest to remove the device_driver callbacks will go
> on for a few kernel releases and completing the transition for scsi
> yields to broken drivers without compile time issues if something is
> missed, I think it's sensible to keep them in the "working with warning"
> state for a release cycle (or even until the driver callbacks go away).

You will notice very quickly when they break.  And it's not like there's
a lot of them to start with.  Please just finish up the conversion
instead of leaving it lingering.


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

* Re: [PATCH 4/8] scsi: sd: Convert to scsi bus methods
  2025-12-09 20:45 ` [PATCH 4/8] scsi: sd: " Uwe Kleine-König
@ 2025-12-10  9:20   ` kernel test robot
  2025-12-10  9:50     ` Uwe Kleine-König
  2025-12-15  4:10   ` kernel test robot
  1 sibling, 1 reply; 22+ messages in thread
From: kernel test robot @ 2025-12-10  9:20 UTC (permalink / raw)
  To: Uwe Kleine-König, James E.J. Bottomley
  Cc: oe-kbuild-all, Martin K. Petersen, linux-scsi

Hi Uwe,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 7d0a66e4bb9081d75c82ec4957c50034cb0ea449]

url:    https://github.com/intel-lab-lkp/linux/commits/Uwe-Kleine-K-nig/scsi-Pass-a-struct-scsi_driver-to-scsi_-un-register_driver/20251210-044843
base:   7d0a66e4bb9081d75c82ec4957c50034cb0ea449
patch link:    https://lore.kernel.org/r/1931ec5bbe8d0ad82b6fbc77939d43bf5a4f177f.1765312062.git.u.kleine-koenig%40baylibre.com
patch subject: [PATCH 4/8] scsi: sd: Convert to scsi bus methods
config: parisc-defconfig (https://download.01.org/0day-ci/archive/20251210/202512101723.HHskrJpy-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251210/202512101723.HHskrJpy-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512101723.HHskrJpy-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> Warning: drivers/scsi/sd.c:3912 function parameter 'sdp' not described in 'sd_probe'
>> Warning: drivers/scsi/sd.c:4061 function parameter 'sd' not described in 'sd_remove'

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH 4/8] scsi: sd: Convert to scsi bus methods
  2025-12-10  9:20   ` kernel test robot
@ 2025-12-10  9:50     ` Uwe Kleine-König
  0 siblings, 0 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2025-12-10  9:50 UTC (permalink / raw)
  To: kernel test robot
  Cc: James E.J. Bottomley, oe-kbuild-all, Martin K. Petersen,
	linux-scsi

[-- Attachment #1: Type: text/plain, Size: 2757 bytes --]

On Wed, Dec 10, 2025 at 05:20:24PM +0800, kernel test robot wrote:
> Hi Uwe,
> 
> kernel test robot noticed the following build warnings:
> 
> [auto build test WARNING on 7d0a66e4bb9081d75c82ec4957c50034cb0ea449]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Uwe-Kleine-K-nig/scsi-Pass-a-struct-scsi_driver-to-scsi_-un-register_driver/20251210-044843
> base:   7d0a66e4bb9081d75c82ec4957c50034cb0ea449
> patch link:    https://lore.kernel.org/r/1931ec5bbe8d0ad82b6fbc77939d43bf5a4f177f.1765312062.git.u.kleine-koenig%40baylibre.com
> patch subject: [PATCH 4/8] scsi: sd: Convert to scsi bus methods
> config: parisc-defconfig (https://download.01.org/0day-ci/archive/20251210/202512101723.HHskrJpy-lkp@intel.com/config)
> compiler: hppa-linux-gcc (GCC) 15.1.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251210/202512101723.HHskrJpy-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202512101723.HHskrJpy-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
> >> Warning: drivers/scsi/sd.c:3912 function parameter 'sdp' not described in 'sd_probe'
> >> Warning: drivers/scsi/sd.c:4061 function parameter 'sd' not described in 'sd_remove'

Oh, this needs:

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index afed915eb158..99a55bc026b4 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3895,7 +3895,7 @@ static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen)
  *	sd_probe - called during driver initialization and whenever a
  *	new scsi device is attached to the system. It is called once
  *	for each scsi device (not just disks) present.
- *	@dev: pointer to device object
+ *	@sdp: pointer to scsi device object
  *
  *	Returns 0 if successful (or not interested in this scsi device 
  *	(e.g. scanner)); 1 when there is an error.
@@ -4051,7 +4051,7 @@ static int sd_probe(struct scsi_device *sdp)
  *	sd_remove - called whenever a scsi disk (previously recognized by
  *	sd_probe) is detached from the system. It is called (potentially
  *	multiple times) during sd module unload.
- *	@dev: pointer to device object
+ *	@sd: pointer to scsi device object
  *
  *	Note: this function is invoked from the scsi mid-level.
  *	This function potentially frees up a device name (e.g. /dev/sdc)

I added that to my local tree, so if I send out a v2 this will be
included. But I'm also open for someone picking up this version and
squashing the above changes into patch #4. :-)

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 2/8] scsi: Make use of bus callbacks
  2025-12-10  7:04           ` Christoph Hellwig
@ 2025-12-10 10:34             ` Uwe Kleine-König
  0 siblings, 0 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2025-12-10 10:34 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Bart Van Assche, James E.J. Bottomley, Martin K. Petersen,
	linux-scsi

[-- Attachment #1: Type: text/plain, Size: 2039 bytes --]

Hello Christoph,

On Tue, Dec 09, 2025 at 11:04:40PM -0800, Christoph Hellwig wrote:
> You will notice very quickly when they break.  And it's not like there's
> a lot of them to start with.  Please just finish up the conversion
> instead of leaving it lingering.

I somewhat understand your position here. But with my Debian kernel team
member hat on I really appreciate if for conversions like this there is
a major kernel version that emits warnings, so users hitting problems
can find hints by just bisecting over kernel releases (that are packaged
and so don't need kernel compilation skills). The bigger picture is this
conversion affects a good dozen of busses. The todo item to convert the
scsi bus dates back to commit v2.6.16-rc1~164^2~32 = 594c8281f905
("[PATCH] Add bus_type probe, remove, shutdown methods.") from 2006. 

Also my impression is that scsi isn't very healthy anyhow. One thing I
spotted is that there are error paths e.g. in scsi_alloc_sdev() when
scsi_realloc_sdev_budget_map() fails that free devices that had
device_initialize() called (here: scsi_sysfs_device_initialize() called
device_initialize(&sdev->sdev_gendev);) So I think there are bugs and
cleanup opportunities in drivers/scsi for someone who cares about scsi,
that make me wonder about the effort you put into making me cleanup the
comparably small issue of three trivial functions for legacy handling
that scsi used for > 18 years now.

Call me conservative, but I really prefer keeping these three little
functions and thus be sure to not silently break a driver that I might
have missed.

And yes, I intend to complete the conversion, just group the remaining
bits that affect scsi to the final cleanup of struct device_driver to
minimize the time window for silent breakage (even though I'm reasonably
sure that I didn't break an scsi driver). The quest will consist of ~
100 patches in sum, each patch that has a safety net until the quest is
done, is a good idea from where I stand.

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 1/8] scsi: Pass a struct scsi_driver to scsi_{,un}register_driver()
  2025-12-09 20:45 ` [PATCH 1/8] scsi: Pass a struct scsi_driver to scsi_{,un}register_driver() Uwe Kleine-König
@ 2025-12-10 13:14   ` Peter Wang (王信友)
  0 siblings, 0 replies; 22+ messages in thread
From: Peter Wang (王信友) @ 2025-12-10 13:14 UTC (permalink / raw)
  To: Uwe Kleine, James.Bottomley@HansenPartnership.com
  Cc: beanhuo@micron.com, avri.altman@wdc.com, Kai.Makisara@kolumbus.fi,
	quic_cang@quicinc.com, quic_nguyenb@quicinc.com,
	linux-scsi@vger.kernel.org, bvanassche@acm.org,
	alim.akhtar@samsung.com, adrian.hunter@intel.com,
	martin.petersen@oracle.com, mani@kernel.org

On Tue, 2025-12-09 at 21:45 +0100, Uwe Kleine-König wrote:
> This aligns with what other subsystems do, reduces boilerplate a bit
> for
> device drivers and is less error prone.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> ---

Reviewed-by: Peter Wang <peter.wang@mediatek.com>


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

* Re: [PATCH 8/8] scsi: ufs: Convert to scsi bus methods
  2025-12-09 20:45 ` [PATCH 8/8] scsi: ufs: " Uwe Kleine-König
@ 2025-12-10 13:14   ` Peter Wang (王信友)
  0 siblings, 0 replies; 22+ messages in thread
From: Peter Wang (王信友) @ 2025-12-10 13:14 UTC (permalink / raw)
  To: Uwe Kleine, James.Bottomley@HansenPartnership.com
  Cc: beanhuo@micron.com, avri.altman@wdc.com, quic_cang@quicinc.com,
	quic_nguyenb@quicinc.com, linux-scsi@vger.kernel.org,
	bvanassche@acm.org, adrian.hunter@intel.com,
	alim.akhtar@samsung.com, martin.petersen@oracle.com,
	mani@kernel.org

On Tue, 2025-12-09 at 21:45 +0100, Uwe Kleine-König wrote:
> The scsi bus got dedicated callbacks for probe, remove and shutdown.
> 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 <u.kleine-koenig@baylibre.com>

Reviewed-by: Peter Wang <peter.wang@mediatek.com>



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

* Re: [PATCH 4/8] scsi: sd: Convert to scsi bus methods
  2025-12-09 20:45 ` [PATCH 4/8] scsi: sd: " Uwe Kleine-König
  2025-12-10  9:20   ` kernel test robot
@ 2025-12-15  4:10   ` kernel test robot
  1 sibling, 0 replies; 22+ messages in thread
From: kernel test robot @ 2025-12-15  4:10 UTC (permalink / raw)
  To: Uwe Kleine-König, James E.J. Bottomley
  Cc: oe-kbuild-all, Martin K. Petersen, linux-scsi

Hi Uwe,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 7d0a66e4bb9081d75c82ec4957c50034cb0ea449]

url:    https://github.com/intel-lab-lkp/linux/commits/Uwe-Kleine-K-nig/scsi-Pass-a-struct-scsi_driver-to-scsi_-un-register_driver/20251210-044843
base:   7d0a66e4bb9081d75c82ec4957c50034cb0ea449
patch link:    https://lore.kernel.org/r/1931ec5bbe8d0ad82b6fbc77939d43bf5a4f177f.1765312062.git.u.kleine-koenig%40baylibre.com
patch subject: [PATCH 4/8] scsi: sd: Convert to scsi bus methods
config: x86_64-rhel-9.4-ltp (https://download.01.org/0day-ci/archive/20251215/202512150543.RnycrOo1-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251215/202512150543.RnycrOo1-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512150543.RnycrOo1-lkp@intel.com/

All warnings (new ones prefixed by >>):

   Warning: drivers/scsi/sd.c:3912 function parameter 'sdp' not described in 'sd_probe'
>> Warning: drivers/scsi/sd.c:4061 function parameter 'sd' not described in 'sd_remove'

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2025-12-15  4:10 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-09 20:45 [PATCH 0/8] scsi: Make use of bus callbacks Uwe Kleine-König
2025-12-09 20:45 ` [PATCH 1/8] scsi: Pass a struct scsi_driver to scsi_{,un}register_driver() Uwe Kleine-König
2025-12-10 13:14   ` Peter Wang (王信友)
2025-12-09 20:45 ` [PATCH 2/8] scsi: Make use of bus callbacks Uwe Kleine-König
2025-12-09 20:59   ` Bart Van Assche
2025-12-09 21:22     ` Uwe Kleine-König
2025-12-10  5:26       ` Christoph Hellwig
2025-12-10  6:56         ` Uwe Kleine-König
2025-12-10  7:04           ` Christoph Hellwig
2025-12-10 10:34             ` Uwe Kleine-König
2025-12-09 21:00   ` Bart Van Assche
2025-12-09 21:26     ` Uwe Kleine-König
2025-12-09 20:45 ` [PATCH 3/8] scsi: ch: Convert to scsi bus methods Uwe Kleine-König
2025-12-09 20:45 ` [PATCH 4/8] scsi: sd: " Uwe Kleine-König
2025-12-10  9:20   ` kernel test robot
2025-12-10  9:50     ` Uwe Kleine-König
2025-12-15  4:10   ` kernel test robot
2025-12-09 20:45 ` [PATCH 5/8] scsi: ses: " Uwe Kleine-König
2025-12-09 20:45 ` [PATCH 6/8] scsi: sr: " Uwe Kleine-König
2025-12-09 20:45 ` [PATCH 7/8] scsi: st: " Uwe Kleine-König
2025-12-09 20:45 ` [PATCH 8/8] scsi: ufs: " Uwe Kleine-König
2025-12-10 13:14   ` Peter Wang (王信友)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox