Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4767924pxv; Tue, 27 Jul 2021 16:16:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz80ua0M09g7QxeZXzFmrrIlZDUQsz8RFveAf7812IbI62CyD85HyTHUFEDyVZnA7w3+K3w X-Received: by 2002:a05:6638:3a12:: with SMTP id j18mr23890182jaj.75.1627427810340; Tue, 27 Jul 2021 16:16:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627427810; cv=none; d=google.com; s=arc-20160816; b=l67DyXzSzeY8GFk0yUxeO2eRGqSo2ia9C9b/oEcho8NEBMyxcQIYyRZ3atI22PlhIn c+PiIRY+3a2g4gtytgAgPhydh1/q2FwOZSKGI21MarHLt4b6BaSzqO4W4gzHy/EdI+qo I/4fhY1e3J0RDGtp9djIhJfjnDuHJUDRbgrK3qWjt5j3rJm/gQ59BFITcfLLokmYAEyn keldH4z0dRDqLZGk0Wk9XN3+GqN/NDaOTVm+jpY6uPo3MjXGTGz3O4XtvPOegyXbWKAu pvIrqu6lm0mPwjUopT6M4ff5mHvACKqg8y0RiHD2vAYZmqAeQ7+RQi9z5QX5uHmGKsgq rX5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=mIJ+KVW6QLPkxmUFt/vZs8q/s59o5S/PRGcj+YzDTD4=; b=gNjoBCj8QhiFvoBje6VYgKg0I8hl9nBCQZgCFCXle5MxE1XO0MmUfi7G3YOJCfAeNW FnyD6cRP1p2VJOcIZCqk0IHUKi7hvDd59wUV5dSRaphjMuhrV1+EKM6F0ruGLtOnwppr zTsmAUrEAtzfV1fPjmB40eL7zsRQyDPuOTCtgKZJa/saC3PHyKDcAZ7Wj/iM2xX2K8kU RzRFw8aSpXc0tjTurTxCXuEebReo41MCRXgPHUmwNKtTkgy08bAbyRDCejeHASKYf8kQ MOxybH23+zRVj5jJx0fnUsN+imsY2VebJXNzCerLmOh/XACC2sHSL7HwZDwioD/TSo5D Cmhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i7vLKT+b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y17si6437389iov.62.2021.07.27.16.16.37; Tue, 27 Jul 2021 16:16:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@gmail.com header.s=20161025 header.b=i7vLKT+b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232992AbhG0XPj (ORCPT + 99 others); Tue, 27 Jul 2021 19:15:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232314AbhG0XPj (ORCPT ); Tue, 27 Jul 2021 19:15:39 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67916C061757; Tue, 27 Jul 2021 16:15:38 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id r17so387328lfe.2; Tue, 27 Jul 2021 16:15:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mIJ+KVW6QLPkxmUFt/vZs8q/s59o5S/PRGcj+YzDTD4=; b=i7vLKT+bGLiW5/vMeJSuk+5BuC5Wy3gGVWVslg2gQprrd5cNyu+nke3FF64WmGNUlE M+fkn7hdPFXHY7XKxqfyb4xHvj37licW7zfkh6QJoa6+kRWp1tYqOnuPyOL86/LBMf9i Pn6K7N+gWN8kk3JgZgVwrQrx7gUyWpxkZ8yK2VFYK5TwF40wr4UlVVOheDzKpnH+lMdM wVcmTlZfi5Pl8gyK3dMs5F4802pY+YzKYyb8vtA7pYUbLBDfHM4Zo0xOD5JVWbyokUfs Pq0bz0E+RpLdnUnufgpIqDOW/pEdf1OUSSm0MXEMr/jXU9F4rNv4PbWlJvd8pA6CZGU2 hALw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mIJ+KVW6QLPkxmUFt/vZs8q/s59o5S/PRGcj+YzDTD4=; b=bi8tUDYmrLWDsr0iyMRC4WONPidUILcHhFrtKQTTDgQCYwVZAIjwC+pao3q0VpRtNN VPV07Jl4ZKT/gw43bea+08/L4SPVkBhNwhPPmQvK2VOz0G9zv+FqtsL6bAA0y8RRk+2k 9PWIJmhnkmv2nQj21cdSNEngvgCk1yki1pBw/sdjPuDYUw/lJtJ6ZM/naocTgyZppino V0x46TwEfC0MqrlH6vRKxqRljg3YebkcWrMZUIfeQGyEv++/WQX3R23Kzwr3/ldIzQri MG/7HmOtJDZsu0WxBT2Z+3RuczMaBKys0E6hn/cPuSTliOudnj/jZ9ijfW0zdxA5qxVT ngng== X-Gm-Message-State: AOAM531+whTSA8yao+k7imE+XhIUQhkkX6qQmlt6WCnzYW4+rVXAIDls CwPMYncAxZbNjMo1yGF8xwFwGX8krPDiYrv2at4= X-Received: by 2002:a05:6512:400b:: with SMTP id br11mr18195956lfb.36.1627427736772; Tue, 27 Jul 2021 16:15:36 -0700 (PDT) MIME-Version: 1.0 References: <20210727152026.31019-1-sergio.paracuellos@gmail.com> <20210727152026.31019-2-sergio.paracuellos@gmail.com> In-Reply-To: <20210727152026.31019-2-sergio.paracuellos@gmail.com> From: Gregory Fong Date: Tue, 27 Jul 2021 16:15:06 -0700 Message-ID: Subject: Re: [PATCH v3 1/3] gpiolib: convert 'devprop_gpiochip_set_names' to support multiple gpiochip banks per device To: Sergio Paracuellos Cc: linux-gpio@vger.kernel.org, Linus Walleij , Bartosz Golaszewski , f.fainelli@gmail.com, matthias.bgg@gmail.com, opensource@vdorst.com, andy.shevchenko@gmail.com, git@johnthomson.fastmail.com.au, neil@brown.name, hofrat@osadl.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 27, 2021 at 8:20 AM Sergio Paracuellos wrote: > > The default gpiolib-of implementation does not work with the multiple > gpiochip banks per device structure used for example by the gpio-mt7621 > and gpio-brcmstb drivers. To fix these kind of situations driver code > is forced to fill the names to avoid the gpiolib code to set names > repeated along the banks. Instead of continue with that antipattern > fix the gpiolib core function to get expected behaviour for every > single situation adding a field 'offset' in the gpiochip structure. > Doing in this way, we can assume this offset will be zero for normal > driver code where only one gpiochip bank per device is used but > can be set explicitly in those drivers that really need more than > one gpiochip. > > Reviewed-by: Andy Shevchenko One minor comment below, then this looks great: Reviewed-by: Gregory Fong > Signed-off-by: Sergio Paracuellos > --- > drivers/gpio/gpiolib.c | 32 +++++++++++++++++++++++++++----- > include/linux/gpio/driver.h | 4 ++++ > 2 files changed, 31 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > index 27c07108496d..84ed4b73fa3e 100644 > --- a/drivers/gpio/gpiolib.c > +++ b/drivers/gpio/gpiolib.c > @@ -382,10 +382,18 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip) > if (count < 0) > return 0; > > - if (count > gdev->ngpio) { > - dev_warn(&gdev->dev, "gpio-line-names is length %d but should be at most length %d", > - count, gdev->ngpio); > - count = gdev->ngpio; > + /* > + * When offset is set in the driver side we assume the driver internally > + * is using more than one gpiochip per the same device. We have to stop > + * setting friendly names if the specified ones with 'gpio-line-names' > + * are less than the offset in the device itself. This means all the > + * lines are not present for every single pin within all the internal > + * gpiochips. > + */ > + if (count <= chip->offset) { > + dev_warn(&gdev->dev, "gpio-line-names too short (length %d) cannot map names for the gpiochip at offset %u\n", nit: there should be some punctuation after "(length %d)", otherwise with parentheticals removed it reads as "gpio-line-names too short cannot map names ..." but we need to provide a space between these thoughts for clarity. A comma should be ok: "gpio-line-names too short (length %d), cannot map names ..." Best regards, Gregory