diff mbox

[U-Boot,v2,05/15] dm: ahci: Correct uclass private data

Message ID 20170704193133.87092-6-sjg@chromium.org
State Accepted
Delegated to: Jaehoon Chung
Headers show

Commit Message

Simon Glass July 4, 2017, 7:31 p.m. UTC
This is expected to be attached to the uclass and the code operates that
way, but the uclass has not been updated. Fix it to avoid using memory at
address 0.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 47fc61a (dm: ahci: Drop use of probe_ent)
---

Changes in v2: None

 drivers/ata/ahci-uclass.c | 2 ++
 drivers/ata/ahci.c        | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/ata/ahci-uclass.c b/drivers/ata/ahci-uclass.c
index 7b8c32699f..71600fed68 100644
--- a/drivers/ata/ahci-uclass.c
+++ b/drivers/ata/ahci-uclass.c
@@ -6,9 +6,11 @@ 
  */
 
 #include <common.h>
+#include <ahci.h>
 #include <dm.h>
 
 UCLASS_DRIVER(ahci) = {
 	.id		= UCLASS_AHCI,
 	.name		= "ahci",
+	.per_device_auto_alloc_size = sizeof(struct ahci_uc_priv),
 };
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 035db85b45..066524758a 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -935,7 +935,7 @@  static int ahci_scsi_exec(struct udevice *dev, struct scsi_cmd *pccb)
 {
 	struct ahci_uc_priv *uc_priv;
 #ifdef CONFIG_DM_SCSI
-	uc_priv = dev_get_uclass_priv(dev);
+	uc_priv = dev_get_uclass_priv(dev->parent);
 #else
 	uc_priv = probe_ent;
 #endif