Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp880485rdg; Wed, 11 Oct 2023 08:03:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzTJVINmhkpS99qvhlHBtdm1SmwttzU/ttxeZsDIn9XGqp5rKmMNTwylHTmTcQP0+/g3kf X-Received: by 2002:a05:6358:1e:b0:164:8225:83ad with SMTP id 30-20020a056358001e00b00164822583admr10860176rww.0.1697036623382; Wed, 11 Oct 2023 08:03:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697036623; cv=none; d=google.com; s=arc-20160816; b=mj6Vm7uhXLVuC2ZaqahK8udUoIVvv82NsCBwm4dwFPmVb+B4CJvvLCTEYdrkycB330 I26omc7AdHJ5Awlxp34860/wrtxPi9nSgWudljZ2Tv34l1kJc6VikVnOBF7rBrmk4yZy vrroJo7hM7aDs63JQe8ZT96N6b+8cKV16TKn16P5ZdGgEoEm9j1Q9nj+/uzx9DNiJ9cs LtiKFRN2QSx4FqFj0CG5uxo+2mBwx1fppYi6TOCCjCLPtkeAmNNFlh2A0yzBVx75w7+R mmlpmpFljqQuEB0rM2iCCnhefTBfj9SIerkUUWwPO35UDryzddKOCS1UI80yHp4+jza9 vMag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=iZGr0MjOwhvBq00ZZaLYaw8OqVHhMeRw+nvEkoYm3dw=; fh=c5ldh+3mAmyXtp8JRrYYGvklCFoU+0ExgWrilWEcaYc=; b=elck7bX+tbwz47PxleUpd02Rh7XvSZxFF/s2HrOAVeuEJNmV54cAylWka3Ie0WTrWX BP3flZrPxlcXXSpEVKnlJmVj2C3K2YGzfSDmpmfg8VvpCjkZW2MTqcawVy6xR83Bt56i RlHDPf3G7oZHdguVamSBd1JHdmJI1UG8YKZ2v1wbhBN3JNa3ozbHistv4HD05SIodHw6 1GkZ7Be4YrPcDAYOPeap5s1DD2NNS1iJzM0yU1UmFh8IV5mXeQ+4+2D+g45/jRv8OKEy kkxn7AWhy6L2TBv+MYSZ0t/tmwPb5oW9gXgkMFXwF3vx1E4EjqXCbkrGpxLOMLtEKr8A 2ekQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=jT1Uqvjn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id i62-20020a638741000000b00569561773a6si1689056pge.549.2023.10.11.08.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 08:03:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=jT1Uqvjn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 731B2817168D; Wed, 11 Oct 2023 08:03:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346731AbjJKPDZ (ORCPT + 99 others); Wed, 11 Oct 2023 11:03:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232628AbjJKPDY (ORCPT ); Wed, 11 Oct 2023 11:03:24 -0400 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3898A94 for ; Wed, 11 Oct 2023 08:03:22 -0700 (PDT) Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3ae1916ba69so4743678b6e.2 for ; Wed, 11 Oct 2023 08:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697036601; x=1697641401; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=iZGr0MjOwhvBq00ZZaLYaw8OqVHhMeRw+nvEkoYm3dw=; b=jT1Uqvjn4Y0+Y9TJ5OXUQ86dMhzra/ZhrwE9bZ3mVTej1bsm4N5C6F82UQHkU5AOkn Z1FGjohOPpKIYfiBPBVO+nhRUHVbCNe4JW44cyBy6+sG3ab+FYRv8ECkOr0fI66Ge+mN axCimuBD2KMYqtTC5gqImgEGK388dBvsgJ1PiYG/y3gHdIg7ngbG1K0NyPbNIY5WV//O V/Krs7rRnmvZayO648invweprpcuDVZk/Hx7R6Yspx9wt0auaF697sCiL5ByegfXDFoo cbN5h6aYqjgq3HiLF9N/T7J7cXO85nAcJowGagREmMrzgZ9O9+oeGjzwyitxYEPfc+ec 9SYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697036601; x=1697641401; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iZGr0MjOwhvBq00ZZaLYaw8OqVHhMeRw+nvEkoYm3dw=; b=IH3fkQgPWHbSQXneqd2o1ItFMOHQKPpRuWSQ6wfdq07aPPZq7+/HW2AymuVaHL4iVi Ld2Lp6Fk5sv1aQjuvCEQ0O9rT3s+wagA2uWyrvGdKpeZkAqDg8hcahzCuI9NMmTvyM5E RUW9Fgdh2tBAZSTtulzPLldSrDvhEjGwr+D1U0fvsDT3gn3HzTBPT/byWKiPKB88nalm tJPKAItojvELDOnwLjIJuxgTYbMSt1+Wu/LKP1Nwud/igq5O6oKqozlFB1IprvRrGpM5 aNIpTAE5wIcwD3i4Ra1l8Hs/6n7dXCrgXUsyGxQ70YEwXNuFEGzqBGdbcZiFLh8kQq/t k8+g== X-Gm-Message-State: AOJu0Yz58ogNhlVL7h5qKQtEXOziovVoseJBFNmepMnurmnnJPOx0yfK yliPKZGimUkMUhMlIAb+atsPMUX/N950dNOIpnWEeg== X-Received: by 2002:a05:6808:144d:b0:3a4:35bb:edae with SMTP id x13-20020a056808144d00b003a435bbedaemr27888321oiv.29.1697036601486; Wed, 11 Oct 2023 08:03:21 -0700 (PDT) MIME-Version: 1.0 References: <20231011130204.52265-1-brgl@bgdev.pl> <20231011130204.52265-4-brgl@bgdev.pl> In-Reply-To: From: Bartosz Golaszewski Date: Wed, 11 Oct 2023 17:03:10 +0200 Message-ID: Subject: Re: [PATCH 3/3] i2c: mux: gpio: don't fiddle with GPIOLIB internals To: Peter Rosin Cc: Linus Walleij , Andy Shevchenko , Peter Korsgaard , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 11 Oct 2023 08:03:40 -0700 (PDT) X-Spam-Level: ** On Wed, Oct 11, 2023 at 4:59=E2=80=AFPM Peter Rosin wrote= : > > Hi! > > 2023-10-11 at 15:02, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski > > > > Use the relevant API functions to retrieve the address of the > > underlying struct device instead of accessing GPIOLIB private structure= s > > manually. > > > > Signed-off-by: Bartosz Golaszewski > > --- > > 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-m= ux-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 > > #include > > #include > > -/* FIXME: stop poking around inside gpiolib */ > > -#include "../../gpio/gpiolib.h" > > +#include > > > > struct gpiomux { > > struct i2c_mux_gpio_platform_data data; > > @@ -176,7 +175,8 @@ static int i2c_mux_gpio_probe(struct platform_devic= e *pdev) > > } > > > > for (i =3D 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_devic= e *pdev) > > if (!muxc->mux_locked) > > continue; > > > > - /* FIXME: find a proper way to access the GPIO device */ > > - gpio_dev =3D &gpiod->gdev->dev; > > - muxc->mux_locked =3D i2c_root_adapter(gpio_dev) =3D=3D ro= ot; > > + gdev =3D gpiod_to_gpio_device(gpiod); > > + dev =3D gpio_device_to_device(gdev); > > + muxc->mux_locked =3D i2c_root_adapter(dev) =3D=3D 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 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