From patchwork Thu Oct 4 20:17:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brandon Maier X-Patchwork-Id: 979151 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=rockwellcollins.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42R4FT2Yt8z9s9m for ; Fri, 5 Oct 2018 06:27:41 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727511AbeJEDWd (ORCPT ); Thu, 4 Oct 2018 23:22:33 -0400 Received: from ch3vs04.rockwellcollins.com ([205.175.226.52]:49036 "EHLO ch3vs04.rockwellcollins.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727354AbeJEDWd (ORCPT ); Thu, 4 Oct 2018 23:22:33 -0400 X-Greylist: delayed 573 seconds by postgrey-1.27 at vger.kernel.org; Thu, 04 Oct 2018 23:22:33 EDT Received: from ofwch3n02.rockwellcollins.com (HELO ciulimr01.rockwellcollins.com) ([205.175.226.14]) by ch3vs04.rockwellcollins.com with ESMTP; 04 Oct 2018 15:18:09 -0500 X-Received: from righttwix.rockwellcollins.com (righttwix.rockwellcollins.com [192.168.141.218]) by ciulimr01.rockwellcollins.com (Postfix) with ESMTP id 11E826013F; Thu, 4 Oct 2018 15:18:09 -0500 (CDT) From: Brandon Maier To: linux-gpio@vger.kernel.org Cc: linus.walleij@linaro.org, Brandon Maier Subject: [PATCH] gpio: Ignore gpio names with empty strings Date: Thu, 4 Oct 2018 15:17:47 -0500 Message-Id: <20181004201747.56861-1-brandon.maier@rockwellcollins.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org If a gpiochip sets it's gpio_chip->names, it must give every gpio a unique name. However we may not need to name all gpios, for example if they are unused. gpio-line-names allows this by ignoring gpios with empty names. But gpiochip_set_desc_names() will yell at us, as the empty name will collide with other empty names. Fix this by skipping empty strings, so that they look like unnamed gpios. Signed-off-by: Brandon Maier --- drivers/gpio/gpiolib-devprop.c | 3 ++- drivers/gpio/gpiolib.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpiolib-devprop.c b/drivers/gpio/gpiolib-devprop.c index dd517098ab95..2c56a0acd98b 100644 --- a/drivers/gpio/gpiolib-devprop.c +++ b/drivers/gpio/gpiolib-devprop.c @@ -52,7 +52,8 @@ void devprop_gpiochip_set_names(struct gpio_chip *chip, } for (i = 0; i < count; i++) - gdev->descs[i].name = names[i]; + if (names[i] && names[i][0]) + gdev->descs[i].name = names[i]; kfree(names); } diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 86c147b3f4af..7d359e560d81 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -341,7 +341,8 @@ static int gpiochip_set_desc_names(struct gpio_chip *gc) /* Then add all names to the GPIO descriptors */ for (i = 0; i != gc->ngpio; ++i) - gdev->descs[i].name = gc->names[i]; + if (gc->names[i] && gc->names[i][0]) + gdev->descs[i].name = gc->names[i]; return 0; }