diff mbox

[U-Boot,RFC,v3,1/4] dm: do not return pointer if NULL is given to devp of device_bind()

Message ID 1439222732-28983-2-git-send-email-yamada.masahiro@socionext.com
State Superseded
Delegated to: Simon Glass
Headers show

Commit Message

Masahiro Yamada Aug. 10, 2015, 4:05 p.m. UTC
This is useful when we want to bind a device, but do not need the
device pointer.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/core/device.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Simon Glass Aug. 12, 2015, 2:15 p.m. UTC | #1
Hi Masahiro,

On 10 August 2015 at 10:05, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> This is useful when we want to bind a device, but do not need the
> device pointer.

Could adjust the subject to something shorter, like "dm: core: Allow
device_bind() to not return the device"

>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  drivers/core/device.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/core/device.c b/drivers/core/device.c
> index e23a872..634070c 100644
> --- a/drivers/core/device.c
> +++ b/drivers/core/device.c
> @@ -32,7 +32,8 @@ int device_bind(struct udevice *parent, const struct driver *drv,
>         struct uclass *uc;
>         int size, ret = 0;
>
> -       *devp = NULL;
> +       if (devp)
> +               *devp = NULL;
>         if (!name)
>                 return -EINVAL;
>
> @@ -133,7 +134,8 @@ int device_bind(struct udevice *parent, const struct driver *drv,
>
>         if (parent)
>                 dm_dbg("Bound device %s to %s\n", dev->name, parent->name);
> -       *devp = dev;
> +       if (devp)
> +               *devp = dev;
>
>         dev->flags |= DM_FLAG_BOUND;
>
> --
> 1.9.1
>

Please can you update the function comments for device_bind()?

Regards,
Simon
Masahiro Yamada Aug. 25, 2015, 6:41 a.m. UTC | #2
Hi Simon,

2015-08-12 23:15 GMT+09:00 Simon Glass <sjg@chromium.org>:
> Hi Masahiro,
>
> On 10 August 2015 at 10:05, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
>> This is useful when we want to bind a device, but do not need the
>> device pointer.
>
> Could adjust the subject to something shorter, like "dm: core: Allow
> device_bind() to not return the device"

Done. Thanks.


eturn -EINVAL;
>>
>> @@ -133,7 +134,8 @@ int device_bind(struct udevice *parent, const struct driver *drv,
>>
>>         if (parent)
>>                 dm_dbg("Bound device %s to %s\n", dev->name, parent->name);
>> -       *devp = dev;
>> +       if (devp)
>> +               *devp = dev;
>>
>>         dev->flags |= DM_FLAG_BOUND;
>>
>> --
>> 1.9.1
>>
>
> Please can you update the function comments for device_bind()?


Done for device_bind() and others.
diff mbox

Patch

diff --git a/drivers/core/device.c b/drivers/core/device.c
index e23a872..634070c 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -32,7 +32,8 @@  int device_bind(struct udevice *parent, const struct driver *drv,
 	struct uclass *uc;
 	int size, ret = 0;
 
-	*devp = NULL;
+	if (devp)
+		*devp = NULL;
 	if (!name)
 		return -EINVAL;
 
@@ -133,7 +134,8 @@  int device_bind(struct udevice *parent, const struct driver *drv,
 
 	if (parent)
 		dm_dbg("Bound device %s to %s\n", dev->name, parent->name);
-	*devp = dev;
+	if (devp)
+		*devp = dev;
 
 	dev->flags |= DM_FLAG_BOUND;