From patchwork Tue Dec 15 12:37:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 343981 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3876226jai; Tue, 15 Dec 2020 04:41:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxlPYeEPlY2usjqUCcz7pRxqNO0P0Vgt6djGj08Rs7HZ015IpbxKHfesrcJ9md82FQsz91 X-Received: by 2002:a17:906:890:: with SMTP id n16mr11230299eje.463.1608036116681; Tue, 15 Dec 2020 04:41:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608036116; cv=none; d=google.com; s=arc-20160816; b=YNQcXiwelIsaz1oQe9yb9Rfpq+hDoyiQYEbdCJFllQASdJMtrRH2XeGBSCafma75YH FMETSrvYQ44ZgE6H3qRFI9gr+Mse2mSk6vNvNTkSWsP+HajvPoe66BATaA+/rsAh9GR/ HaksxxNBz1oo+rOYvIgU7Oscs6AEs+07BEa1APr+RQyfg2ouGkRnYApsTXcDJ9MDCC+j EmyQBmKFOo4VXdVhM1RCv7sbmvszNuWvSkm3Hx37r8wNjvkYXqvNCw5vhyIbMo7DdsVS S/ca8ALbxXV75F5gOVYzJNaNNbyKs5ZufYZUYTra43nm8bE/+KMKbANWHiwNMPeG8BTg JrWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=2u+g101SrX2cbAexKAHiTmYjfJwI9XfuubnmRIODs2o=; b=Nd6vZmyq8Cqxwvj6MnYUBZoABkEPI8JAbto8Fyhx20Ww9lmHG5JJUw4TOzdPvp51nP jq6QNUP8jQ4eaKbW8d/B7OCZjeqKwy6aGYDXfdA5NByh4d/SI/sEPoHaH2/6R6PHumbi Aq6ASeV5Kdt5U1lZYsCCrhOCHJ2IV/Ca+W5AIEsoURcBY7xJHEKjJbI0MHH7CqkUo8Nj oa2XQzzy43D+kAvsIJzw+XUrUrUoB//xmAtTQsBVPfmhanufzce2FuVWRYnBmW4U1Suu GqSOmVhD1TnTsv1dhxJOADgiWPjx/2Y3vFnf1Uxhu5UprAgJ5oPHazMXXzQ8li1nu149 zFOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A6DUYu1K; spf=pass (google.com: domain of linux-gpio-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q16si858086ejy.572.2020.12.15.04.41.56; Tue, 15 Dec 2020 04:41:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-gpio-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A6DUYu1K; spf=pass (google.com: domain of linux-gpio-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726156AbgLOMkk (ORCPT + 3 others); Tue, 15 Dec 2020 07:40:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725535AbgLOMkk (ORCPT ); Tue, 15 Dec 2020 07:40:40 -0500 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7E16C06179C for ; Tue, 15 Dec 2020 04:39:59 -0800 (PST) Received: by mail-lf1-x143.google.com with SMTP id o19so13293758lfo.1 for ; Tue, 15 Dec 2020 04:39:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2u+g101SrX2cbAexKAHiTmYjfJwI9XfuubnmRIODs2o=; b=A6DUYu1KA4eS/fJx/o82Aq9L85RD5+0wgKBCCNrWsNcQszcQHP/sD6uM1gBgHOU7D4 Mj1kcTkqdL++H0LI2I0zXJoKBypOEJJns2XqnTprwSBfBvK7ktrRaWkU05RiKEQCOTFg jl1LYXK4KUqfOxuHsrw3YwJGfSS/YRPy0aJTbUXte3qTS3ldyGQGB0GqeR2ytnO5R8SR nRxKEE5rwBv0uuG6MYRT4llSTF0/lht3n8HvcdDnhc3CwiA+7BmgW14tCuemW/67vHrE VinQ6LugDB6mNYYp6iPVkhUIblm0tpXt/nrf/FgfTTn6JZhGSiYJuvM6OJKBxgru2PGa XtRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2u+g101SrX2cbAexKAHiTmYjfJwI9XfuubnmRIODs2o=; b=LiEesdEW6NHz3yjLpwaoMrja90U5MAJZg6fT2dZQFzqf0JvVsM72rZb1n6RyY9w0jl HuuFSSWqdnAOWr8nTqEAIpd7jXLrsaIPf/2H89aSyeufuvV16LNt20lnsWZqy+3Tu2Mn NeZQcw9GBdDZzSDLsv80PxypL+frcTVhSIrgvCznTi0mW3Zs+9z/CmVfInKgSncL0m1c nIm0LQbKYqm7+UcTWLseeeh86ftMeaMI1cGeTby81kd3UlhltE6Eu+cuY6QghdaRwVeD l+sdG4xLH3IMwQtlZcWc0lbMSdRYz1odHsPvHZfXnSv9SxCAr6P1c/iJ5QLBDKmtYeoE /hDA== X-Gm-Message-State: AOAM5316wyl7mbC0+FvjQ6XGs3zaCuMvQOa25fY0vjqWqPSSU+Q/HUJP /DZXBJ7+foOCjgtUk0u9lzImwAfeXFO3ynNm X-Received: by 2002:a2e:7212:: with SMTP id n18mr8704169ljc.399.1608035997937; Tue, 15 Dec 2020 04:39:57 -0800 (PST) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id t28sm1918036ljo.45.2020.12.15.04.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 04:39:57 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org Cc: Bartosz Golaszewski , Linus Walleij , Guillaume Tucker Subject: [PATCH] gpio: Skip over NULL and (empty string) line names Date: Tue, 15 Dec 2020 13:37:55 +0100 Message-Id: <20201215123755.438369-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The core will warn if we try to assign the name '' (empty string) to two lines. Actively ignore NULL and empty string in the name assignment loop. Reported-by: Guillaume Tucker Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) -- 2.28.0 diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 26c75499d549..d07da3ffd140 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -343,6 +343,10 @@ static int gpiochip_set_desc_names(struct gpio_chip *gc) for (i = 0; i != gc->ngpio; ++i) { struct gpio_desc *gpiod; + /* Skip NULL or '(empty string)' names */ + if (!gc->names[i] || !strlen(gc->names[i])) + continue; + gpiod = gpio_name_to_desc(gc->names[i]); if (gpiod && (gpiod->gdev == gdev)) { dev_err(&gdev->dev, @@ -352,8 +356,12 @@ 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) + for (i = 0; i != gc->ngpio; ++i) { + /* Skip NULL or '(empty string)' names */ + if (!gc->names[i] || !strlen(gc->names[i])) + continue; gdev->descs[i].name = gc->names[i]; + } return 0; } @@ -404,6 +412,9 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip) for (i = 0; i < count; i++) { struct gpio_desc *gpiod; + /* Skip NULL or '(empty string)' names */ + if (!names[i] || !strlen(names[i])) + continue; gpiod = gpio_name_to_desc(names[i]); if (gpiod && (gpiod->gdev == gdev)) { dev_err(&gdev->dev,