Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp771229rdg; Thu, 12 Oct 2023 23:51:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGWsXIY1yzLx5i1hOGO57Zp5Xil8fI3jbrWYaFo1iXNNclpJoRsmz8MrbUtvNtcgOk6wwMe X-Received: by 2002:a05:6808:1146:b0:3a4:316c:8eeb with SMTP id u6-20020a056808114600b003a4316c8eebmr41033624oiu.40.1697179865552; Thu, 12 Oct 2023 23:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697179865; cv=none; d=google.com; s=arc-20160816; b=zjsGGI+rYXBzdLSlyBnO/2WmuEO60pydaObpTLZ7WJj6DgyLzvr7O7WXrvYE6vvdnw XAEbT7iYvIbL2plC3DC7Nrcw+eol3dF7y0fdg6Q9RJZjBxzMFLil/aiZqGDyMFfT5zvq yuDUuTsrjM8J0qX1bmrTTgJV2lLvcuIF5fQtucTld92nW98bCvi0da2hO6I/RHaikVcw HjQYkOonUgkfNBQoYNRTKE9R8e9xo9t7dQrTUYy0Pop1Y2xBwisO4etoY12rVnGBuT6o OeyYxEAepRQQ4Za5n5VDn8QkrBo2SHqcMwe51cFGiKOWQoBKi0m9VTMpnBrh4UtR1Wtq FpVQ== 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=+21d47K5pMKUUp+ZZCwfOqG7e0i0/Qbr9a+Z9J91e90=; fh=YP/ZZen/fLhGMMezUuWB0b3Qyqd3gueBWEsOMCN9gx4=; b=htC2xTfr/c9CvEOoIluismB/Wm4SSTF4OwSt3XJd8eL9CCgw9rjMrRYi8SPw8gCmPi XmvlrCmCD3OB2zZPhLS/NE2bZpkAXVwlJnc9kZb2aMH5aMmBdhnAsryjwQ7DDzrJ39wp HRIhjX6uOxh6FnYzvXcbfPkZ6aUlsNrNbYyVNjSIc2im6+1VoLRFwt+Gs49X+gnyUV2w 7+jPZeFh+mePW9nys+9zgaZF3oN0Nl1lUJE2ZcdUjOvd6PunfWxh8fGTGQxT+Virvpam ofelWnWrZ5RiE+GaRxxtuD+woJ3A4po7nywNCNMS4A/4Yk/zbAm5NLZ8nhU+Kr1ihsSI QyMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b="1gD/aYlm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id k6-20020a634b46000000b00565d88203c8si1330787pgl.535.2023.10.12.23.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 23:51:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b="1gD/aYlm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 15FAF8100DA4; Thu, 12 Oct 2023 23:51:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229867AbjJMGux (ORCPT + 99 others); Fri, 13 Oct 2023 02:50:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229809AbjJMGuv (ORCPT ); Fri, 13 Oct 2023 02:50:51 -0400 Received: from mail-ua1-x92c.google.com (mail-ua1-x92c.google.com [IPv6:2607:f8b0:4864:20::92c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DE95E1 for ; Thu, 12 Oct 2023 23:50:49 -0700 (PDT) Received: by mail-ua1-x92c.google.com with SMTP id a1e0cc1a2514c-7b2ca45d5cfso902006241.1 for ; Thu, 12 Oct 2023 23:50:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697179848; x=1697784648; 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=+21d47K5pMKUUp+ZZCwfOqG7e0i0/Qbr9a+Z9J91e90=; b=1gD/aYlmA5tguC/7wZbdgXm6yj6Jkt1on3VVnC3meMX0Mt6OFGpGWakVr3vheUBbCb VRDXBzd2fUzO06/ul8kuSyUg/2ozbnQVm8o2CAjz404b4aEx/iMfpri+Y+/rEHMr1Gko TaWpJ5zAd5h0nNQWETAhuL6aLCnOx5sBR7ypH4HAHE0XI/Ld8QdoDNT+3cZjjP5Kdlyu MSWSmUJzp3vr9VVKfM9r4pQYjgyvA/9mHDSGA43uYOYaVEC6XCBXWbIulyjuvfpHT7PQ QOgLFlGWQvWrsdC+zhMfo8uAabjKJ9npT0OfSM1mrj/ffGUNbszOp6A5WNSm1r6PaFFx l+9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697179848; x=1697784648; 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=+21d47K5pMKUUp+ZZCwfOqG7e0i0/Qbr9a+Z9J91e90=; b=RyQRvbMFNR5Uzh5fGmIYTuL8as8hQw+fUMEYJXkAdB1gLS8z7eEtkA/1ludgFLk8Hw twIRo2jVGL9XeMYiRtis2jLgu2hM9J6U0xg4zrofBtnp9tpcbLrs5jx2trr9L097Ynv2 WYQwLg0t+bZKRkkZCveMiDMCUwPEAsIlPFvSDe14oY5peat9T/6ybs1RJETgCIYfoPwn KGZduR/0mUKRtHiGvlgHc7I23obrjiYpM5MXKnHkxjtFCT8Nr6N5hKKah6g4J4F6sBf7 r+X4QCO6hOwwbcQe+in3KB9nxyx41/sYppsZSvrLcW4jWV8pQACrGOKjnqrbv1wLvoDb zVhA== X-Gm-Message-State: AOJu0YwouocZKs9QXPE41vLGSaJURI38IcFBkN0ABYOy6bQKkWm30nXZ I0ln3z4CaAyZ3hb67npa6ton/RORqP4YgeAFOq4fYZhAoisvap65 X-Received: by 2002:a1f:e2c3:0:b0:49c:37a1:2358 with SMTP id z186-20020a1fe2c3000000b0049c37a12358mr21402810vkg.14.1697179848192; Thu, 12 Oct 2023 23:50:48 -0700 (PDT) MIME-Version: 1.0 References: <20231011130204.52265-1-brgl@bgdev.pl> In-Reply-To: <20231011130204.52265-1-brgl@bgdev.pl> From: Bartosz Golaszewski Date: Fri, 13 Oct 2023 08:50:37 +0200 Message-ID: Subject: Re: [PATCH 0/3] i2c: mux: don't access GPIOLIB internal structures To: Linus Walleij , Andy Shevchenko , Peter Korsgaard , Peter Rosin Cc: 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=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Thu, 12 Oct 2023 23:51:03 -0700 (PDT) On Wed, Oct 11, 2023 at 3:02=E2=80=AFPM Bartosz Golaszewski = wrote: > > From: Bartosz Golaszewski > > The backstory for this short series is that we are identyfing and > removing all unauthorized uses of GPIOLIB structures across the kernel. > > For example: there are many users that access struct gpio_chip when the > only user allowed to safely do this is the provider of that chip. > > We are very close to removing gpiochip_find(). Another function that > poses a similar problem is gpiod_to_chip() which also returns the > address of the underlying gpio_chip without assuring that it will not go > away e.g. due to a hot-unplug event or a device unbind. > > We'll need to replace it with gpiod_to_gpio_device() across the entire > tree. Let's start by actually providing it and adding the first user: > the i2c-mux-gpio driver which dereferences the otherwise opaque struct > gpio_desc. > > Let's also add a helper that allows to retrieve the address of the > struct device backing the GPIO device as this is another valid use-case. > > Finally, let's un-include the GPIO private header and fix the code to > access the device in a safe way. > > As the change is pretty minor, it would be best if patch 3/3 could be > acked by the I2C mux maintainers and went through the GPIO tree. > Otherwise, I can apply patches 1 and 2 and provide an immutable branch. > > Bartosz Golaszewski (3): > gpiolib: provide gpio_device_to_device() > gpiolib: provide gpiod_to_gpio_device() > i2c: mux: gpio: don't fiddle with GPIOLIB internals > > drivers/gpio/gpiolib.c | 38 ++++++++++++++++++++++++++++++++ > drivers/i2c/muxes/i2c-mux-gpio.c | 12 +++++----- > include/linux/gpio/driver.h | 3 +++ > 3 files changed, 47 insertions(+), 6 deletions(-) > > -- > 2.39.2 > Queued for v6.7. Bart