Skip to contentSkip to conversation

scsi: use platform helper macro and wrapper functions

PATCH In review Kefeng Wang 2 participants 8 messages May 30, 2013 – May 31, 2013 SCSI

lore
Share & tools
lore
#0 lore raw

cover scsi: use platform helper macro and wrapper functions

use module_platform_driver() and paltform{set,get}_drvdata to simpily code, and patch 2/5 delete unnecessery drvdate set to null.

Kefeng Wang (5):
scsi: jazz: use module_platform_driver() and
platform_{set,get}_drvdata
scsi: sun: use module_platform_driver() and platform_{set,get}_drvdata
scsi: qlogicpti: use module_platform_driver() and
platform_{set,get}_drvdata
scsi: sun3x: use module_platform_driver() and
platform_{set,get}_drvdata
scsi: sni: use module_platform_driver() and platform_{set,get}_drvdata

 drivers/scsi/jazz_esp.c   | 17 +++--------------
 drivers/scsi/qlogicpti.c  | 17 +++--------------
 drivers/scsi/sni_53c710.c | 17 +++--------------
 drivers/scsi/sun3x_esp.c  | 16 +++-------------
 drivers/scsi/sun_esp.c    | 19 +++----------------
 5 files changed, 15 insertions(+), 71 deletions(-)
Signature · 1 line
1.8.2.1
#1 lore raw

PATCH 1/5 scsi: jazz: use module_platform_driver() and platform_{set,get}_drvdata

Use helper macro and wrapper functions to simpily code.

---
 drivers/scsi/jazz_esp.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/scsi/jazz_esp.c +3 -14
index 69efbf1..08fa257 100644
@@ -180,7 +180,7 @@ static int esp_jazz_probe(struct platform_device *dev)
 	esp->scsi_id_mask = (1 << esp->scsi_id);
 	esp->cfreq = 40000000;
 
-	dev_set_drvdata(&dev->dev, esp);
+	platform_set_drvdata(dev, esp);
 
 	err = scsi_esp_register(esp, &dev->dev);
 	if (err)
@@ -203,7 +203,7 @@ fail:
 
 static int esp_jazz_remove(struct platform_device *dev)
 {
-	struct esp *esp = dev_get_drvdata(&dev->dev);
+	struct esp *esp = platform_get_drvdata(dev);
 	unsigned int irq = esp->host->irq;
 
 	scsi_esp_unregister(esp);
@@ -230,20 +230,9 @@ static struct platform_driver esp_jazz_driver = {
 	},
 };
 
-static int __init jazz_esp_init(void)
-{
-	return platform_driver_register(&esp_jazz_driver);
-}
-
-static void __exit jazz_esp_exit(void)
-{
-	platform_driver_unregister(&esp_jazz_driver);
-}
+module_platform_driver(esp_jazz_driver);
 
 MODULE_DESCRIPTION("JAZZ ESP SCSI driver");
 MODULE_AUTHOR("Thomas Bogendoerfer ([email protected])");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
-
-module_init(jazz_esp_init);
-module_exit(jazz_esp_exit);
Signature · 1 line
1.8.2.1
#2 lore raw

PATCH 2/5 scsi: sun: use module_platform_driver() and platform_{set,get}_drvdata

In reply to Kefeng Wang

Use helper macro and wrapper functions to simpily code. Meanwhile, remove unnecessary drvdata set to null due to commint 0998d0631 (device-core: Ensure drvdata = NULL when no driver is bound).

---
 drivers/scsi/sun_esp.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)
drivers/scsi/sun_esp.c +3 -16
index f2e6845..b7361a6 100644
@@ -538,7 +538,7 @@ static int esp_sbus_probe_one(struct platform_device *op,
 		dma_write32(val & ~DMA_RST_SCSI, DMA_CSR);
 	}
 
-	dev_set_drvdata(&op->dev, esp);
+	platform_set_drvdata(op, esp);
 
 	err = scsi_esp_register(esp, &op->dev);
 	if (err)
@@ -585,7 +585,7 @@ static int esp_sbus_probe(struct platform_device *op)
 
 static int esp_sbus_remove(struct platform_device *op)
 {
-	struct esp *esp = dev_get_drvdata(&op->dev);
+	struct esp *esp = platform_get_drvdata(op);
 	struct platform_device *dma_of = esp->dma;
 	unsigned int irq = esp->host->irq;
 	bool is_hme;
@@ -611,8 +611,6 @@ static int esp_sbus_remove(struct platform_device *op)
 
 	scsi_host_put(esp->host);
 
-	dev_set_drvdata(&op->dev, NULL);
-
 	return 0;
 }
 
@@ -640,20 +638,9 @@ static struct platform_driver esp_sbus_driver = {
 	.remove		= esp_sbus_remove,
 };
 
-static int __init sunesp_init(void)
-{
-	return platform_driver_register(&esp_sbus_driver);
-}
-
-static void __exit sunesp_exit(void)
-{
-	platform_driver_unregister(&esp_sbus_driver);
-}
+module_platform_driver(esp_sbus_driver);
 
 MODULE_DESCRIPTION("Sun ESP SCSI driver");
 MODULE_AUTHOR("David S. Miller ([email protected])");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
-
-module_init(sunesp_init);
-module_exit(sunesp_exit);
Signature · 1 line
1.8.2.1
#5 lore raw

PATCH 5/5 scsi: sni: use module_platform_driver() and platform_{set,get}_drvdata

In reply to Kefeng Wang

Use helper macro and wrapper functions to simpily code.

---
 drivers/scsi/sni_53c710.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/scsi/sni_53c710.c +3 -14
index 52d54e7..eff84c4 100644
@@ -104,7 +104,7 @@ static int snirm710_probe(struct platform_device *dev)
 		goto out_put_host;
 	}
 
-	dev_set_drvdata(&dev->dev, host);
+	platform_set_drvdata(dev, host);
 	scsi_scan_host(host);
 
 	return 0;
@@ -119,7 +119,7 @@ static int snirm710_probe(struct platform_device *dev)
 
 static int __exit snirm710_driver_remove(struct platform_device *dev)
 {
-	struct Scsi_Host *host = dev_get_drvdata(&dev->dev);
+	struct Scsi_Host *host = platform_get_drvdata(dev);
 	struct NCR_700_Host_Parameters *hostdata =
 		(struct NCR_700_Host_Parameters *)host->hostdata[0];
 
@@ -141,15 +141,4 @@ static struct platform_driver snirm710_driver = {
 	},
 };
 
-static int __init snirm710_init(void)
-{
-	return platform_driver_register(&snirm710_driver);
-}
-
-static void __exit snirm710_exit(void)
-{
-	platform_driver_unregister(&snirm710_driver);
-}
-
-module_init(snirm710_init);
-module_exit(snirm710_exit);
+module_platform_driver(snirm710_driver);
Signature · 1 line
1.8.2.1
#3 lore raw

PATCH 3/5 scsi: qlogicpti: use module_platform_driver() and platform_{set,get}_drvdata

In reply to Kefeng Wang

Use helper macro and wrapper functions to simpily code.

---
 drivers/scsi/qlogicpti.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/scsi/qlogicpti.c +3 -14
index 6d48d30..1349374 100644
@@ -1367,7 +1367,7 @@ static int qpti_sbus_probe(struct platform_device *op)
 		goto fail_unmap_queues;
 	}
 
-	dev_set_drvdata(&op->dev, qpti);
+	platform_set_drvdata(op, qpti);
 
 	qpti_chain_add(qpti);
 
@@ -1404,7 +1404,7 @@ fail_unlink:
 
 static int qpti_sbus_remove(struct platform_device *op)
 {
-	struct qlogicpti *qpti = dev_get_drvdata(&op->dev);
+	struct qlogicpti *qpti = platform_get_drvdata(&op->dev);
 
 	qpti_chain_del(qpti);
 
@@ -1462,21 +1462,10 @@ static struct platform_driver qpti_sbus_driver = {
 	.remove		= qpti_sbus_remove,
 };
 
-static int __init qpti_init(void)
-{
-	return platform_driver_register(&qpti_sbus_driver);
-}
-
-static void __exit qpti_exit(void)
-{
-	platform_driver_unregister(&qpti_sbus_driver);
-}
+module_platform_driver(qpti_sbus_driver);
 
 MODULE_DESCRIPTION("QlogicISP SBUS driver");
 MODULE_AUTHOR("David S. Miller ([email protected])");
 MODULE_LICENSE("GPL");
 MODULE_VERSION("2.1");
 MODULE_FIRMWARE("qlogic/isp1000.bin");
-
-module_init(qpti_init);
-module_exit(qpti_exit);
Signature · 1 line
1.8.2.1
#4 lore raw

PATCH 4/5 scsi: sun3x: use module_platform_driver() and platform_{set,get}_drvdata

In reply to Kefeng Wang

Use helper macro and wrapper functions to simpily code.

---
 drivers/scsi/sun3x_esp.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/scsi/sun3x_esp.c +3 -13
index 534eb96..4c9a2b4 100644
@@ -244,7 +244,7 @@ static int esp_sun3x_probe(struct platform_device *dev)
 	esp->scsi_id_mask = (1 << esp->scsi_id);
 	esp->cfreq = 20000000;
 
-	dev_set_drvdata(&dev->dev, esp);
+	platform_set_drvdata(dev, esp);
 
 	err = scsi_esp_register(esp, &dev->dev);
 	if (err)
@@ -270,7 +270,7 @@ fail:
 
 static int esp_sun3x_remove(struct platform_device *dev)
 {
-	struct esp *esp = dev_get_drvdata(&dev->dev);
+	struct esp *esp = platform_get_drvdata(dev);
 	unsigned int irq = esp->host->irq;
 	u32 val;
 
@@ -299,21 +299,11 @@ static struct platform_driver esp_sun3x_driver = {
 	},
 };
 
-static int __init sun3x_esp_init(void)
-{
-	return platform_driver_register(&esp_sun3x_driver);
-}
-
-static void __exit sun3x_esp_exit(void)
-{
-	platform_driver_unregister(&esp_sun3x_driver);
-}
+module_platform_driver(esp_sun3x_driver);
 
 MODULE_DESCRIPTION("Sun3x ESP SCSI driver");
 MODULE_AUTHOR("Thomas Bogendoerfer ([email protected])");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
 
-module_init(sun3x_esp_init);
-module_exit(sun3x_esp_exit);
 MODULE_ALIAS("platform:sun3x_esp");
Signature · 1 line
1.8.2.1
maintainer
#6 lore raw
In reply to Kefeng Wang
Quoted 13 lines · Kefeng Wang

use module_platform_driver() and paltform{set,get}_drvdata to simpily code, and patch 2/5 delete unnecessery drvdate set to null.

Kefeng Wang (5):
scsi: jazz: use module_platform_driver() and
platform_{set,get}_drvdata
scsi: sun: use module_platform_driver() and platform_{set,get}_drvdata
scsi: qlogicpti: use module_platform_driver() and
platform_{set,get}_drvdata
scsi: sun3x: use module_platform_driver() and
platform_{set,get}_drvdata
scsi: sni: use module_platform_driver() and platform_{set,get}_drvdata

Quoted 6 lines
 drivers/scsi/jazz_esp.c   | 17 +++--------------
 drivers/scsi/qlogicpti.c  | 17 +++--------------
 drivers/scsi/sni_53c710.c | 17 +++--------------
 drivers/scsi/sun3x_esp.c  | 16 +++-------------
 drivers/scsi/sun_esp.c    | 19 +++----------------
 5 files changed, 15 insertions(+), 71 deletions(-)

There doesn't seem to be much point to these patches since either idiom is fine and easily understood. We also try to touch the ancient drivers as little as possible since it can be months before anyone actually tries them out and notices that something got broken, so the rule for them is obvious bug fixes only.

James

#7 lore raw
Quoted 7 lines · James Bottomley

There doesn't seem to be much point to these patches since either idiom is fine and easily understood. We also try to touch the ancient drivers as little as possible since it can be months before anyone actually tries them out and notices that something got broken, so the rule for them is obvious bug fixes only.

James

hi James,
Thanks for remind, I got it.