From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YgNLo-0002dq-81 for barebox@lists.infradead.org; Fri, 10 Apr 2015 01:03:17 +0000 Received: by wizk4 with SMTP id k4so111420269wiz.1 for ; Thu, 09 Apr 2015 18:02:53 -0700 (PDT) From: Sebastian Hesselbarth Date: Fri, 10 Apr 2015 03:02:44 +0200 Message-Id: <1428627766-17178-3-git-send-email-sebastian.hesselbarth@gmail.com> In-Reply-To: <1428627766-17178-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <1428627766-17178-1-git-send-email-sebastian.hesselbarth@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 2/4] gpio: Return -EPROBE_DEFER on gpio_get_num() To: Sebastian Hesselbarth Cc: barebox@lists.infradead.org GPIO drivers can be registered quite late in registration process causing dependant devices to fail probing. If we know gpio_get_num will be called with a non-NULL device, return -EPROBE_DEFER instead of -ENODEV to allow re-probing later. Signed-off-by: Sebastian Hesselbarth --- Cc: barebox@lists.infradead.org --- drivers/gpio/gpiolib.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 611e41ea5606..1f57c76ec16d 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -292,12 +292,15 @@ int gpio_get_num(struct device_d *dev, int gpio) { struct gpio_chip *chip; + if (!dev) + return -ENODEV; + list_for_each_entry(chip, &chip_list, list) { if (chip->dev == dev) return chip->base + gpio; } - return -ENODEV; + return -EPROBE_DEFER; } #ifdef CONFIG_CMD_GPIO -- 2.1.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox