diff mbox

[U-Boot,17/18] dm: core: Add device checking to syscon_get_regmap()

Message ID 1436208879-8431-18-git-send-email-sjg@chromium.org
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass July 6, 2015, 6:54 p.m. UTC
This function can only handle a syscon device. It is possible that someone
will make a mistake, so add a check for this.

Also we should return -ENODEV when a device cannot be found, so update the
syscon_get_regmap_by_driver_data() to follow this convention.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/syscon-uclass.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Simon Glass July 17, 2015, 11:59 p.m. UTC | #1
On 6 July 2015 at 12:54, Simon Glass <sjg@chromium.org> wrote:
> This function can only handle a syscon device. It is possible that someone
> will make a mistake, so add a check for this.
>
> Also we should return -ENODEV when a device cannot be found, so update the
> syscon_get_regmap_by_driver_data() to follow this convention.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/core/syscon-uclass.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Applied to u-boot-dm.
diff mbox

Patch

diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c
index 4d66bb5..686c320 100644
--- a/drivers/core/syscon-uclass.c
+++ b/drivers/core/syscon-uclass.c
@@ -17,8 +17,11 @@ 
 
 struct regmap *syscon_get_regmap(struct udevice *dev)
 {
-	struct syscon_uc_info *priv = dev_get_uclass_priv(dev);
+	struct syscon_uc_info *priv;
 
+	if (device_get_uclass_id(dev) != UCLASS_SYSCON)
+		return ERR_PTR(-ENOEXEC);
+	priv = dev_get_uclass_priv(dev);
 	return priv->regmap;
 }
 
@@ -52,7 +55,7 @@  struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data)
 		}
 	}
 
-	return ERR_PTR(-ENOENT);
+	return ERR_PTR(-ENODEV);
 }
 
 void *syscon_get_first_range(ulong driver_data)