Message ID | 20231204093509.19225-3-brgl@bgdev.pl |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2647465vqy; Mon, 4 Dec 2023 01:36:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXOi7l6StAAZ5pg3wPxzWWj4MAX8bZ2czl5T1fTpgrWGTshAVb73oI0p6kdgp5l3GUNwcJ X-Received: by 2002:a17:903:25c6:b0:1d0:6ffd:6101 with SMTP id jc6-20020a17090325c600b001d06ffd6101mr3985441plb.35.1701682565419; Mon, 04 Dec 2023 01:36:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701682565; cv=none; d=google.com; s=arc-20160816; b=ozCmKGnQdTw6g42JFNMh5QCrfercsCjDD4E2BueMzgwVB5C8aN0Ze+e6Vz1yJsVkSW FanEZ3tpgoeV6jwDyD+VrouoRsBT84zzA0CYLkqP82f3jPePr56pomfgEup/+/juqBmi TimDWbYbwhx1ihWbrduQvlEL5pkaWVqjvq30Ygm7oSIo7/NKAPbrtZrA88RG1s7ezd9Q BuSTAmq2kgooonQPYPRYQyP3bVuXifnLcdVh9cicwUKxa0Fb90+yXfYjelwv8KYVzJAm jjLXrI5FebdRDRTkeFe1zDWlHrbeCYxGeXUUA91aAEkA4IVUEPMTsOXV+v6VJDAYDZd6 zCsw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5Sv99NjQCF32QfqStrxQNV++EDXzWOND44xPhDEPFwA=; fh=fw6biwzn34ngIUS3OuPB+D+TvAzoz1YwnvitHxA+Jyw=; b=lh1l/Q+Q7wldclbZ5ftwqBxOJxywfDqLq6cP8m4392eXc/3MrmxwFKkDfjgqFmPY1q 3FrgxMwxSQnsndCwU50Xji8D4wOJkEeina3X+Rk9pb3hNCPl5ytkweNKnW0Lk3rrOewV bsRtfJURU+ujgV9VeU8Gr4kZvUvPoeZ7QCzjIdOISjygHXV6kzgxJwiYQfpB+OfKr1Zw 3ClKlO6Htv+Kndb3gzraj2xc2QCzkRPckocAe/nwM0ggcLdSgJt+nEURuJIjZHoKVG1H Qky8gZyocgDVdWaXOvmijs5i62QIkXSYzjd/BJ2hwB3U7yGv8/j4VRuSI5eNy777CTzj uJLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=i95wUyLN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id n6-20020a170903110600b001d08fadf1b4si2175249plh.338.2023.12.04.01.36.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:36:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=i95wUyLN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id D90DA807D0E7; Mon, 4 Dec 2023 01:35:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234815AbjLDJfT (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Mon, 4 Dec 2023 04:35:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234818AbjLDJfM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 4 Dec 2023 04:35:12 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0CD0124 for <linux-kernel@vger.kernel.org>; Mon, 4 Dec 2023 01:35:16 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3333224c7b9so2279244f8f.1 for <linux-kernel@vger.kernel.org>; Mon, 04 Dec 2023 01:35:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701682515; x=1702287315; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5Sv99NjQCF32QfqStrxQNV++EDXzWOND44xPhDEPFwA=; b=i95wUyLNLZz5CTbGL8et8CKZjeP/avgInNMQvRUmE2P7Q5VDwnQvS675+d82tsyeBb PNl1qqSMK/Ev0BJbfhMauF3cOLd+m9dGGIzFca/BImEP0u5tTAeWP1e1XO/was82QZOl jLpSvp/fF0Xup/1p8u9SV2Aa4fiTMPC049o5gwM7+M3NyVpR62gldJCFnXGvXZOy0g6G Ywqlh22KyGpALjvdp0q7VjFR5E1XZI5hqK8vYii/U/j5uMxGphy/kCwhh1I5VCj7P19L b9K3gZWXcm4LzAUmubW38meDcSM0s02wj1XgszPx9BJlHMar4+u4A4nj6vI825qRutkt wOZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701682515; x=1702287315; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5Sv99NjQCF32QfqStrxQNV++EDXzWOND44xPhDEPFwA=; b=ZYsoZlHeGSWFzllYunJr5eaqsIAyyv+V367QdH+yiCbLIw2/ZNhAkHa59FjsTVOmbc YFBuiCtGXKANaanuSTVkO+TM+dPxFYIEmEXvhLaNVrT/0W0zWKg6EZRYPBPBdGIjAReI JmRvF9XF0mMuGbICHN4wdijC7EyfI3hdyC4ypoa+E+0moI+wlvYVC+neFZJfh5g+fvMM X/b08HPu0W+wtgmLydeLMvmN78ammx+VR1o42FYWlTOHnHffcfZZqqglp2VowsGCoA53 sHv1XDhuxNCJFqRZ+J4oF4sTcia0JD5iL5A0jOEV5CtRQx+LV8JEg+fZJTCmBHuzYobV RMOg== X-Gm-Message-State: AOJu0YzkX09nxVjlVrcDcuPVMUhMkYYKe2DcoSkiJM5bG3p5xjp797fU ZJNSdkzTFnT4SnoPKNSY9H4CTQ== X-Received: by 2002:a7b:ca49:0:b0:40b:5e21:e276 with SMTP id m9-20020a7bca49000000b0040b5e21e276mr2343776wml.99.1701682514585; Mon, 04 Dec 2023 01:35:14 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4cb1:229e:8c33:122a]) by smtp.gmail.com with ESMTPSA id fs16-20020a05600c3f9000b0040b48690c49sm14266219wmb.6.2023.12.04.01.35.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:35:13 -0800 (PST) From: Bartosz Golaszewski <brgl@bgdev.pl> To: Linus Walleij <linus.walleij@linaro.org>, Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Subject: [PATCH v3 02/10] gpio: wm831x: use gpiochip_dup_line_label() Date: Mon, 4 Dec 2023 10:35:01 +0100 Message-Id: <20231204093509.19225-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231204093509.19225-1-brgl@bgdev.pl> References: <20231204093509.19225-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 04 Dec 2023 01:35:43 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784343497820442240 X-GMAIL-MSGID: 1784343497820442240 |
Series |
gpio/pinctrl: replace gpiochip_is_requested() with a safer interface
|
|
Commit Message
Bartosz Golaszewski
Dec. 4, 2023, 9:35 a.m. UTC
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Use the new gpiochip_dup_line_label() helper to safely retrieve the descriptor label. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> --- drivers/gpio/gpio-wm831x.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
Comments
On Mon, Dec 04, 2023 at 10:35:01AM +0100, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > > Use the new gpiochip_dup_line_label() helper to safely retrieve the > descriptor label. ... > for (i = 0; i < chip->ngpio; i++) { > int gpio = i + chip->base; > int reg; > - const char *label, *pull, *powerdomain; > + const char *pull, *powerdomain; Make it reversed xmas tree?
On Mon, Dec 4, 2023 at 2:16 PM Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > > On Mon, Dec 04, 2023 at 10:35:01AM +0100, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > > > > Use the new gpiochip_dup_line_label() helper to safely retrieve the > > descriptor label. > > ... > > > for (i = 0; i < chip->ngpio; i++) { > > int gpio = i + chip->base; > > int reg; > > - const char *label, *pull, *powerdomain; > > + const char *pull, *powerdomain; > > Make it reversed xmas tree? > Bikeshedding again. :) But I plan on making all local variables across the core GPIOLIB code consistent (no tabs and reverse xmas tree) closer to the end of the release cycle. Bart
diff --git a/drivers/gpio/gpio-wm831x.c b/drivers/gpio/gpio-wm831x.c index 7eaf8a28638c..f7d5120ff8f1 100644 --- a/drivers/gpio/gpio-wm831x.c +++ b/drivers/gpio/gpio-wm831x.c @@ -8,6 +8,7 @@ * */ +#include <linux/cleanup.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/module.h> @@ -160,18 +161,21 @@ static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) for (i = 0; i < chip->ngpio; i++) { int gpio = i + chip->base; int reg; - const char *label, *pull, *powerdomain; + const char *pull, *powerdomain; /* We report the GPIO even if it's not requested since * we're also reporting things like alternate * functions which apply even when the GPIO is not in * use as a GPIO. */ - label = gpiochip_is_requested(chip, i); - if (!label) - label = "Unrequested"; + char *label __free(kfree) = gpiochip_dup_line_label(chip, i); + if (IS_ERR(label)) { + dev_err(wm831x->dev, "Failed to duplicate label\n"); + continue; + } - seq_printf(s, " gpio-%-3d (%-20.20s) ", gpio, label); + seq_printf(s, " gpio-%-3d (%-20.20s) ", + gpio, label ?: "Unrequested"); reg = wm831x_reg_read(wm831x, WM831X_GPIO1_CONTROL + i); if (reg < 0) {