[U-Boot] [PATCH v2 12/29] dm: scsi: Use the uclass platform data

Simon Glass sjg at chromium.org
Thu Jun 15 03:28:31 UTC 2017


At present the two driver-model SCSI drivers use device platform data to
store information that relates to the uclass. It is better to use uclass
platform data in this situation. Update the code to do this.

Signed-off-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
---

Changes in v2: None

 drivers/ata/ahci.c         | 2 +-
 drivers/ata/dwc_ahci.c     | 3 +--
 drivers/ata/sata_ceva.c    | 5 ++---
 drivers/scsi/scsi-uclass.c | 1 +
 drivers/scsi/scsi.c        | 2 +-
 5 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 29835f06d3..2cc604b3f4 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -479,7 +479,7 @@ static int ahci_init_one(pci_dev_t dev)
 		pci_write_config_byte(dev, 0x41, 0xa1);
 #endif
 #else
-	struct scsi_platdata *plat = dev_get_platdata(dev);
+	struct scsi_platdata *plat = dev_get_uclass_platdata(dev);
 	probe_ent->mmio_base = (void *)plat->base;
 #endif
 
diff --git a/drivers/ata/dwc_ahci.c b/drivers/ata/dwc_ahci.c
index 3f839bf987..e634df5e3c 100644
--- a/drivers/ata/dwc_ahci.c
+++ b/drivers/ata/dwc_ahci.c
@@ -28,7 +28,7 @@ struct dwc_ahci_priv {
 static int dwc_ahci_ofdata_to_platdata(struct udevice *dev)
 {
 	struct dwc_ahci_priv *priv = dev_get_priv(dev);
-	struct scsi_platdata *plat = dev_get_platdata(dev);
+	struct scsi_platdata *plat = dev_get_uclass_platdata(dev);
 	fdt_addr_t addr;
 
 	plat->max_id = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
@@ -96,6 +96,5 @@ U_BOOT_DRIVER(dwc_ahci) = {
 	.ofdata_to_platdata = dwc_ahci_ofdata_to_platdata,
 	.probe	= dwc_ahci_probe,
 	.priv_auto_alloc_size = sizeof(struct dwc_ahci_priv),
-	.platdata_auto_alloc_size = sizeof(struct scsi_platdata),
 	.flags = DM_FLAG_ALLOC_PRIV_DMA,
 };
diff --git a/drivers/ata/sata_ceva.c b/drivers/ata/sata_ceva.c
index 65a4bb2099..01f48810f3 100644
--- a/drivers/ata/sata_ceva.c
+++ b/drivers/ata/sata_ceva.c
@@ -114,7 +114,7 @@ static int ceva_init_sata(ulong mmio)
 
 static int sata_ceva_probe(struct udevice *dev)
 {
-	struct scsi_platdata *plat = dev_get_platdata(dev);
+	struct scsi_platdata *plat = dev_get_uclass_platdata(dev);
 
 	ceva_init_sata(plat->base);
 	return 0;
@@ -127,7 +127,7 @@ static const struct udevice_id sata_ceva_ids[] = {
 
 static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
 {
-	struct scsi_platdata *plat = dev_get_platdata(dev);
+	struct scsi_platdata *plat = dev_get_uclass_platdata(dev);
 
 	plat->base = devfdt_get_addr(dev);
 	if (plat->base == FDT_ADDR_T_NONE)
@@ -146,5 +146,4 @@ U_BOOT_DRIVER(ceva_host_blk) = {
 	.of_match = sata_ceva_ids,
 	.probe = sata_ceva_probe,
 	.ofdata_to_platdata = sata_ceva_ofdata_to_platdata,
-	.platdata_auto_alloc_size = sizeof(struct scsi_platdata),
 };
diff --git a/drivers/scsi/scsi-uclass.c b/drivers/scsi/scsi-uclass.c
index 05da6cdeab..e4ee44bb4c 100644
--- a/drivers/scsi/scsi-uclass.c
+++ b/drivers/scsi/scsi-uclass.c
@@ -24,4 +24,5 @@ UCLASS_DRIVER(scsi) = {
 	.id		= UCLASS_SCSI,
 	.name		= "scsi",
 	.post_probe	 = scsi_post_probe,
+	.per_device_platdata_auto_alloc_size = sizeof(struct scsi_platdata),
 };
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 5f5652b9e0..2d0f81ad1f 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -619,7 +619,7 @@ int scsi_scan(int mode)
 			return ret;
 
 		/* Get controller platdata */
-		plat = dev_get_platdata(dev);
+		plat = dev_get_uclass_platdata(dev);
 
 		for (i = 0; i < plat->max_id; i++)
 			for (lun = 0; lun < plat->max_lun; lun++)
-- 
2.13.1.518.g3df882009-goog



More information about the U-Boot mailing list