From patchwork Fri Sep 28 13:38:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Blaess X-Patchwork-Id: 976361 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=logilin.fr Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42MF763VQSz9s3Z for ; Sat, 29 Sep 2018 00:53:54 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726934AbeI1VSB (ORCPT ); Fri, 28 Sep 2018 17:18:01 -0400 Received: from 13.mo3.mail-out.ovh.net ([188.165.33.202]:34560 "EHLO 13.mo3.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726867AbeI1VSB (ORCPT ); Fri, 28 Sep 2018 17:18:01 -0400 X-Greylist: delayed 4218 seconds by postgrey-1.27 at vger.kernel.org; Fri, 28 Sep 2018 17:18:01 EDT Received: from player696.ha.ovh.net (unknown [10.109.160.226]) by mo3.mail-out.ovh.net (Postfix) with ESMTP id 271A71D090F for ; Fri, 28 Sep 2018 15:38:52 +0200 (CEST) Received: from localhost.localdomain (91-160-139-170.subs.proxad.net [91.160.139.170]) (Authenticated sender: christophe@blaess.fr) by player696.ha.ovh.net (Postfix) with ESMTPSA id AA2623C00C0; Fri, 28 Sep 2018 15:38:48 +0200 (CEST) From: Christophe Blaess To: linus.walleij@linaro.org Cc: linux-gpio@vger.kernel.org, Christophe Blaess , Patrick Boettcher Subject: [PATCH] Accept partial 'gpio-line-names' property. Date: Fri, 28 Sep 2018 15:38:43 +0200 Message-Id: <1538141923-6480-1-git-send-email-christophe.blaess@logilin.fr> X-Mailer: git-send-email 2.7.4 X-Ovh-Tracer-Id: 3380795945520158172 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtjedruddtledgieejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenuc Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Documentation/devicetree/bindings/gpio/gpio.txt says: "The names are assigned starting from line offset 0 from left to right from the passed array. An incomplete array (where the number of passed named are less than ngpios) will still be used up until the last provided valid line index". This patch makes it actually work this way. Signed-off-by: Christophe Blaess Signed-off-by: Patrick Boettcher --- drivers/gpio/gpiolib-devprop.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/gpio/gpiolib-devprop.c b/drivers/gpio/gpiolib-devprop.c index f748aa3..34bfcf7 100644 --- a/drivers/gpio/gpiolib-devprop.c +++ b/drivers/gpio/gpiolib-devprop.c @@ -32,32 +32,29 @@ void devprop_gpiochip_set_names(struct gpio_chip *chip, struct gpio_device *gdev = chip->gpiodev; const char **names; int ret, i; + int count; - ret = fwnode_property_read_string_array(fwnode, "gpio-line-names", - NULL, 0); - if (ret < 0) + count = fwnode_property_read_string_array(fwnode, "gpio-line-names", + NULL, 0); + if (count < 0) return; - if (ret != gdev->ngpio) { - dev_warn(&gdev->dev, - "names %d do not match number of GPIOs %d\n", ret, - gdev->ngpio); - return; - } + if (count > gdev->ngpio) + count = gdev->ngpio; - names = kcalloc(gdev->ngpio, sizeof(*names), GFP_KERNEL); + names = kcalloc(count, sizeof(*names), GFP_KERNEL); if (!names) return; ret = fwnode_property_read_string_array(fwnode, "gpio-line-names", - names, gdev->ngpio); + names, count); if (ret < 0) { dev_warn(&gdev->dev, "failed to read GPIO line names\n"); kfree(names); return; } - for (i = 0; i < gdev->ngpio; i++) + for (i = 0; i < count; i++) gdev->descs[i].name = names[i]; kfree(names);