Message ID | 20231011130204.52265-4-brgl@bgdev.pl |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp521821vqb; Wed, 11 Oct 2023 06:03:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHlX6dEFpWB9Cs7o0J1a2ve7yNQOqnUtivTmT0UzvRYSEdn36X1G3mLsVeUK2wjdHF84a0x X-Received: by 2002:a05:6a00:3916:b0:68e:2fd4:288a with SMTP id fh22-20020a056a00391600b0068e2fd4288amr23821692pfb.3.1697029388653; Wed, 11 Oct 2023 06:03:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697029388; cv=none; d=google.com; s=arc-20160816; b=nTgj3NAGkanggFthqpyMW10H9cZ45tbqyN71IuZ+67jIGbl3Pfc7DXy/jS828guepD Kk3RpcJJVDwvj5W+W1haAAUqSRzC7W0VGVt7WEmwQhq/zIq15Q3flewgw7KGV4plpF49 Ei9FxY3CoHKfFk/V6olfoATjS5iha4fB67J6TC/wplY5ThFqWkIebOsgnvK3OmzCui4O ChDiVhOmEMqFASy71BkqZBEUtxYfnMkaqftQTwQk7c/mF4jRISj1nEvATKtXa9f21S8m bfs5e5O6s4cmEyQ6pgTVN+IYM3bbH2c4fo+3zwpXQICdM0Sqtb7rtQON1iLruQI7bj9R pzlQ== 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=GOhmKBxnjPWo6ddzFX5PM60asyFhIGEHrRKZVC90wiM=; fh=YP/ZZen/fLhGMMezUuWB0b3Qyqd3gueBWEsOMCN9gx4=; b=PIlyaa2P2+yCQAjjDgwPJQTRb8ehMZYJ8A6P/GYDbAG/+02UfPBaGH9ooggM+R2wUf Ogwp1dex9exnLN+tKPcYuvbVMVL1/+PU6i4X21LIwByE1zAQ6z87JiVXePyoV8NR1DXL l0EHjmwRdvZWnp/Hq1A6Y/wOSofSa2uEAuiLt09zj0hASE1ISU4Q+yNHbYZ44kPMihG0 4QGiC4O0RfsTwaVDQ/PNaDUX9prpbhFmc6BORMRrXvkpCfp1Ofxx6mgidzR5yKhpdrwp Kg0fMh8yFcOluMEdxrtj+87GK3Y+TNCnZYpT6c23xspPazrI564AfThqnKNI+b2T5bek VCSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=gHlFgqI3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id fd17-20020a056a002e9100b006896e2f30f2si12620407pfb.365.2023.10.11.06.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 06:03:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=gHlFgqI3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id EBDFE810CAB9; Wed, 11 Oct 2023 06:02:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346062AbjJKNCX (ORCPT <rfc822;kartikey406@gmail.com> + 18 others); Wed, 11 Oct 2023 09:02:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234884AbjJKNCS (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 11 Oct 2023 09:02:18 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E1EDB0 for <linux-kernel@vger.kernel.org>; Wed, 11 Oct 2023 06:02:15 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-325e9cd483eso6449406f8f.2 for <linux-kernel@vger.kernel.org>; Wed, 11 Oct 2023 06:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697029334; x=1697634134; 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=GOhmKBxnjPWo6ddzFX5PM60asyFhIGEHrRKZVC90wiM=; b=gHlFgqI3ABxAxpZZcg/h8K2970YKKRpIJbmBqDjj8m6GmthEHqePRB8SyiV3V4Jdvt BLiUpOX8y5u543L5X2pQTz3q0ze3DZR/sHttB3nzHOT5ZSKLIpNSkfN2ts+gU8ZcxU12 Zt7OP2RiYo1UbuMyvJY5nVjeL1jGdLcHYtyG1a5I/GKUUon9yGZd/j9kNwhDmuZfX05K kmJHfcx9NiO331BgKqund/NaA2q7KxEGaPGPSjctLjOuhXSaxba6NyuVDo4TgQ5lsamQ POPUvBcvrccg4xRlrGU2AsaPN72QU8Xr2NYVQla52TjHncGRNMwc25nKEeKtPYDkU+Zc sUhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697029334; x=1697634134; 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=GOhmKBxnjPWo6ddzFX5PM60asyFhIGEHrRKZVC90wiM=; b=W8GJXQma5zYvZ9Emk8a1E8V0YU6VqLXKN+L/WIki0+P55Ckg3ATvvhtbWOrZOg9klV dLVQ0fqhoTNrLNLevXSySBSWz5mHB5nLtE9N9msgoNgLTDaGrhKA6vHHg/FPThVCiAyN x9WKKgQdB90zM9ZXXlO3o/RJHptbjLZrcrbvitzwHFRJUkiF07C/zBO5K+fcCMJdZHth jQNVctnQ5KbCqP4IFVxHNl1T8NmB2A0v9BSEmsClcLKgkiTnWiH5+W0ZnxPUIhSEe47Z lzpuItWIzYcHqyzKMSgREr7cO3JEWQPG5bGj4+dK+WGeIpugxqAVNREoR7xbTkKczJYd ZL4w== X-Gm-Message-State: AOJu0YyF0kJPrpoRHQ1YxFToU/Mu5Lf5FG/JSYRIeNTm3LgATVsD49yk slJhgVUnZMlc10voOJ+PZHPtCg== X-Received: by 2002:a5d:4c50:0:b0:31f:dc60:13b5 with SMTP id n16-20020a5d4c50000000b0031fdc6013b5mr18364953wrt.25.1697029333084; Wed, 11 Oct 2023 06:02:13 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:e551:3946:26fc:f94]) by smtp.gmail.com with ESMTPSA id s13-20020adfeccd000000b003198a9d758dsm15455375wro.78.2023.10.11.06.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 06:02:12 -0700 (PDT) From: Bartosz Golaszewski <brgl@bgdev.pl> To: Linus Walleij <linus.walleij@linaro.org>, Andy Shevchenko <andy@kernel.org>, Peter Korsgaard <peter.korsgaard@barco.com>, Peter Rosin <peda@axentia.se> Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Subject: [PATCH 3/3] i2c: mux: gpio: don't fiddle with GPIOLIB internals Date: Wed, 11 Oct 2023 15:02:04 +0200 Message-Id: <20231011130204.52265-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231011130204.52265-1-brgl@bgdev.pl> References: <20231011130204.52265-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Wed, 11 Oct 2023 06:02:42 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779464288305651280 X-GMAIL-MSGID: 1779464288305651280 |
Series |
i2c: mux: don't access GPIOLIB internal structures
|
|
Commit Message
Bartosz Golaszewski
Oct. 11, 2023, 1:02 p.m. UTC
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Use the relevant API functions to retrieve the address of the underlying struct device instead of accessing GPIOLIB private structures manually. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> --- drivers/i2c/muxes/i2c-mux-gpio.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Comments
Hi! 2023-10-11 at 15:02, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > > Use the relevant API functions to retrieve the address of the > underlying struct device instead of accessing GPIOLIB private structures > manually. > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > --- > drivers/i2c/muxes/i2c-mux-gpio.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c > index 5d5cbe0130cd..48a872a8196b 100644 > --- a/drivers/i2c/muxes/i2c-mux-gpio.c > +++ b/drivers/i2c/muxes/i2c-mux-gpio.c > @@ -14,8 +14,7 @@ > #include <linux/slab.h> > #include <linux/bits.h> > #include <linux/gpio/consumer.h> > -/* FIXME: stop poking around inside gpiolib */ > -#include "../../gpio/gpiolib.h" > +#include <linux/gpio/driver.h> > > struct gpiomux { > struct i2c_mux_gpio_platform_data data; > @@ -176,7 +175,8 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev) > } > > for (i = 0; i < ngpios; i++) { > - struct device *gpio_dev; > + struct gpio_device *gdev; > + struct device *dev; > struct gpio_desc *gpiod; > enum gpiod_flags flag; > > @@ -195,9 +195,9 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev) > if (!muxc->mux_locked) > continue; > > - /* FIXME: find a proper way to access the GPIO device */ > - gpio_dev = &gpiod->gdev->dev; > - muxc->mux_locked = i2c_root_adapter(gpio_dev) == root; > + gdev = gpiod_to_gpio_device(gpiod); > + dev = gpio_device_to_device(gdev); > + muxc->mux_locked = i2c_root_adapter(dev) == root; > } > > if (muxc->mux_locked) Very nice to see that wart gone! The only small question I have is if these helpers are needed elsewhere, or if a more "direct" gpiod_to_device() would have been sufficient? That said, I have zero problem with this new code as-is, and that detail is of course squarely in gpio-land. Acked-by: Peter Rosin <peda@axentia.se> Cheers, Peter
On Wed, Oct 11, 2023 at 4:59 PM Peter Rosin <peda@axentia.se> wrote: > > Hi! > > 2023-10-11 at 15:02, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > > > > Use the relevant API functions to retrieve the address of the > > underlying struct device instead of accessing GPIOLIB private structures > > manually. > > > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> > > --- > > drivers/i2c/muxes/i2c-mux-gpio.c | 12 ++++++------ > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c > > index 5d5cbe0130cd..48a872a8196b 100644 > > --- a/drivers/i2c/muxes/i2c-mux-gpio.c > > +++ b/drivers/i2c/muxes/i2c-mux-gpio.c > > @@ -14,8 +14,7 @@ > > #include <linux/slab.h> > > #include <linux/bits.h> > > #include <linux/gpio/consumer.h> > > -/* FIXME: stop poking around inside gpiolib */ > > -#include "../../gpio/gpiolib.h" > > +#include <linux/gpio/driver.h> > > > > struct gpiomux { > > struct i2c_mux_gpio_platform_data data; > > @@ -176,7 +175,8 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev) > > } > > > > for (i = 0; i < ngpios; i++) { > > - struct device *gpio_dev; > > + struct gpio_device *gdev; > > + struct device *dev; > > struct gpio_desc *gpiod; > > enum gpiod_flags flag; > > > > @@ -195,9 +195,9 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev) > > if (!muxc->mux_locked) > > continue; > > > > - /* FIXME: find a proper way to access the GPIO device */ > > - gpio_dev = &gpiod->gdev->dev; > > - muxc->mux_locked = i2c_root_adapter(gpio_dev) == root; > > + gdev = gpiod_to_gpio_device(gpiod); > > + dev = gpio_device_to_device(gdev); > > + muxc->mux_locked = i2c_root_adapter(dev) == root; > > } > > > > if (muxc->mux_locked) > > Very nice to see that wart gone! The only small question I have > is if these helpers are needed elsewhere, or if a more "direct" > gpiod_to_device() would have been sufficient? That said, I have > zero problem with this new code as-is, and that detail is of > course squarely in gpio-land. > > Acked-by: Peter Rosin <peda@axentia.se> gpiod_to_gpio_device() will be used in at least 10 other places. I haven't identified any other potential user for gpio_device_to_device() yet but I haven't looked hard yet either. Bart > > Cheers, > Peter
On Wed, Oct 11, 2023 at 5:59 PM Peter Rosin <peda@axentia.se> wrote: > 2023-10-11 at 15:02, Bartosz Golaszewski wrote: > > Use the relevant API functions to retrieve the address of the > > underlying struct device instead of accessing GPIOLIB private structures > > manually. > Very nice to see that wart gone! The only small question I have > is if these helpers are needed elsewhere, or if a more "direct" > gpiod_to_device() would have been sufficient? Same concern is here. But I'm fine with the code.
Hi Bartosz, > > > -/* FIXME: stop poking around inside gpiolib */ > > > -#include "../../gpio/gpiolib.h" > > > +#include <linux/gpio/driver.h> Hooray! \o/ > gpiod_to_gpio_device() will be used in at least 10 other places. I > haven't identified any other potential user for > gpio_device_to_device() yet but I haven't looked hard yet either. Same here. Looked a little bit, found nothing. Acked-by: Wolfram Sang <wsa@kernel.org>
diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c index 5d5cbe0130cd..48a872a8196b 100644 --- a/drivers/i2c/muxes/i2c-mux-gpio.c +++ b/drivers/i2c/muxes/i2c-mux-gpio.c @@ -14,8 +14,7 @@ #include <linux/slab.h> #include <linux/bits.h> #include <linux/gpio/consumer.h> -/* FIXME: stop poking around inside gpiolib */ -#include "../../gpio/gpiolib.h" +#include <linux/gpio/driver.h> struct gpiomux { struct i2c_mux_gpio_platform_data data; @@ -176,7 +175,8 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev) } for (i = 0; i < ngpios; i++) { - struct device *gpio_dev; + struct gpio_device *gdev; + struct device *dev; struct gpio_desc *gpiod; enum gpiod_flags flag; @@ -195,9 +195,9 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev) if (!muxc->mux_locked) continue; - /* FIXME: find a proper way to access the GPIO device */ - gpio_dev = &gpiod->gdev->dev; - muxc->mux_locked = i2c_root_adapter(gpio_dev) == root; + gdev = gpiod_to_gpio_device(gpiod); + dev = gpio_device_to_device(gdev); + muxc->mux_locked = i2c_root_adapter(dev) == root; } if (muxc->mux_locked)