From patchwork Thu Aug 27 03:44:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 511163 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id BA7FC1401F0 for ; Thu, 27 Aug 2015 13:45:03 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6ED504B69C; Thu, 27 Aug 2015 05:44:59 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id o5hJWr2MUDYG; Thu, 27 Aug 2015 05:44:58 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7A7394B67C; Thu, 27 Aug 2015 05:44:58 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 108D74B67C for ; Thu, 27 Aug 2015 05:44:55 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id E-JIb43mK3uc for ; Thu, 27 Aug 2015 05:44:54 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from conuserg012-v.nifty.com (conuserg012.nifty.com [202.248.44.38]) by theia.denx.de (Postfix) with ESMTPS id 478904B676 for ; Thu, 27 Aug 2015 05:44:50 +0200 (CEST) Received: from beagle.diag.org (KD119104020144.au-net.ne.jp [119.104.20.144]) (authenticated) by conuserg012-v.nifty.com with ESMTP id t7R3iRh4025369; Thu, 27 Aug 2015 12:44:34 +0900 X-Nifty-SrcIP: [119.104.20.144] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Thu, 27 Aug 2015 12:44:28 +0900 Message-Id: <1440647073-10977-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440647073-10977-1-git-send-email-yamada.masahiro@socionext.com> References: <1440647073-10977-1-git-send-email-yamada.masahiro@socionext.com> Cc: Tom Rini Subject: [U-Boot] [PATCH v5 1/3] dm: core: allow device_bind() to not return a device pointer X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This is useful when we want to bind a device, but do not need the pointer to the device. Signed-off-by: Masahiro Yamada Acked-by: Simon Glass --- Changes in v5: None Changes in v4: - Change the subject as suggested by Simon - Update the function comments for device_bind() and some other functions that call it. drivers/core/device.c | 6 ++++-- include/dm/device-internal.h | 4 ++-- include/dm/lists.h | 4 ++-- 3 files changed, 8 insertions(+), 6 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; diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index 04884f1..322d35a 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -31,7 +31,7 @@ struct udevice; * devices which use device tree. * @of_offset: Offset of device tree node for this device. This is -1 for * devices which don't use device tree. - * @devp: Returns a pointer to the bound device + * @devp: if non-NULL, returns a pointer to the bound device * @return 0 if OK, -ve on error */ int device_bind(struct udevice *parent, const struct driver *drv, @@ -48,7 +48,7 @@ int device_bind(struct udevice *parent, const struct driver *drv, * @pre_reloc_only: If true, bind the driver only if its DM_INIT_F flag is set. * If false bind the driver always. * @info: Name and platdata for this device - * @devp: Returns a pointer to the bound device + * @devp: if non-NULL, returns a pointer to the bound device * @return 0 if OK, -ve on error */ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only, diff --git a/include/dm/lists.h b/include/dm/lists.h index 61610e6..4513d6a 100644 --- a/include/dm/lists.h +++ b/include/dm/lists.h @@ -68,7 +68,7 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset, * @parent: Parent device * @drv_name: Name of driver to attach to this parent * @dev_name: Name of the new device thus created - * @devp: Returns the newly bound device + * @devp: If non-NULL, returns the newly bound device */ int device_bind_driver(struct udevice *parent, const char *drv_name, const char *dev_name, struct udevice **devp); @@ -83,7 +83,7 @@ int device_bind_driver(struct udevice *parent, const char *drv_name, * @drv_name: Name of driver to attach to this parent * @dev_name: Name of the new device thus created * @node: Device tree node - * @devp: Returns the newly bound device + * @devp: If non-NULL, returns the newly bound device */ int device_bind_driver_to_node(struct udevice *parent, const char *drv_name, const char *dev_name, int node,