Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp673257ybh; Wed, 11 Mar 2020 08:33:51 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvwUY/hZjk0KwSLX9V8JyYgdDu/jh9DVVCc6nqw/agyGvXf288ruUj217Cy0aRYuVW4kN7s X-Received: by 2002:a05:6830:20c9:: with SMTP id z9mr2846745otq.44.1583940831274; Wed, 11 Mar 2020 08:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583940831; cv=none; d=google.com; s=arc-20160816; b=g4mSjJ8XaN5bWI6VYcVjORDE2OHs4aPF4yLrGUadZVQYH1OJYsMvfTv4eDoEy1fXUs JihUxbMowVLW06+yMNAbRC+q1RFQ6G0MkA8mmxNrNQt9bCZA6u9Or8feN9ZuvS5Somrc NmcpZ0+6NyVygQMvfJEdP5nYW1p8Vt3DK5n0njlnzLj/LQm80CVDSwsVmAPFrB6KF63T a7MJdElNRec9AcLdlH7d89Jvm+x5DTA+zKqmc9ykWNiVDxQPlNLcWGMtCrbVtDEr4zHd 5ClPcfkD8n0Z6GnszbtErMakY9kHOxBySrCytzhQxyTOvGDSllgJaqiQe/aiRLQHFZPE 3zXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=igM2VI1+T7dAbedLoTNIOOP15/c1U1XVsx0x9BZ/myo=; b=rPrOhP91ymmTDT/z7EAEr8gRvzuOW6RlyJ/CokQV/6cE/kmrEwqVTTQI/tdZ2VJzYk yXZG2uyOq+v3IPk2/QsXGQmAak0ciTAzIPL0SzPfXIlNGqOHEw9VF7Wbim4/tFxaIZnM INDxsv/VkrEGPQXV+eILSRj8NXroDSQFuoib+Fv5Ui/FGKxixV7uoKzSLQU7naSmMDM7 0UgZwD6DvmhCp/yoI9DVOQ6tY3ZOjPvfwMUnZylWWOg4mmzUKt2F/biVHaDvC1Orm2dS OnCzoy8N+R8pIIm7Rb2fP7pWA4Lo5PUcsYcVRuTkYBrkoB20/W2AKL7Y+mfpGqt/xHgC MEwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lqKirzdA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h26si1469697otg.152.2020.03.11.08.33.35; Wed, 11 Mar 2020 08:33:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lqKirzdA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729846AbgCKPcn (ORCPT + 99 others); Wed, 11 Mar 2020 11:32:43 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:45082 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729521AbgCKPcm (ORCPT ); Wed, 11 Mar 2020 11:32:42 -0400 Received: by mail-lf1-f65.google.com with SMTP id b13so2082832lfb.12 for ; Wed, 11 Mar 2020 08:32:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=igM2VI1+T7dAbedLoTNIOOP15/c1U1XVsx0x9BZ/myo=; b=lqKirzdAID+58xNJrnXODfhsEXd+1XT0hsWptXnIiKCSXD1oliJSkWtAwCkpP3KrZf SE6YQSRwhSLJfEbhVMD4MwVd9nNP0tZ52T8Mycl7CZLNWJ3gt0A2U+QyEYclzo2QkdbQ Fve9KCp1rSO0UDKQFJKaatHNck9DLeVRM5AnpkgBgPElw2wSM4IXVuVN2RiSOP4y9GNX nCtP7K7TvgnWifrF9goHJpM8ApwrdpPWJQh2qIJ48+eM+keiYOOVZwb6yVAufb+kdtKz L6otsOtmKHsA61SdlexWzQXwmlKGdBc7RHB0Vz0VERYQi35yGYKHy46esvnWsLWFUL5/ 1XBw== 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=igM2VI1+T7dAbedLoTNIOOP15/c1U1XVsx0x9BZ/myo=; b=eIogoVVXH2CxP2qVgf5qhBv4ADGz6bQfmlAR6joM816SxmS3GualRiUOryaKsr1GI1 9lMDG1nZv8w//KHEOetSbJGfClzoiscHqek/XPwfkOlE0JC5S7pEzrzrIAvIcNrhWjyz clPR3bV/LjnHbSYHBPYNAJ1W1VwbGw3osLC6Ihg/1GNcgdME0HluqGdchBxKZM5Fxbbr JCiNRCVduFEBvuXpDCERKFkwnvqekscGw7YkhQIWUcxHpGmkxFjYPK8wBLb6jFjJJHnA cC5aaN9vbAae/uHl18WKitex/gvYrpwzP4+VDC0WpwsYkEQDfVgzR8lz+9ZYiE46bgGj zQEg== X-Gm-Message-State: ANhLgQ2W2ALjc1MqOeYMiI7OhER0ThNinqcfDLoj1NvT+gR1G2rGKPX5 24w2XUoPICjjZSF+3PZxSkCgv+/fD3KnBvrL4c1ANSUPSY3Q7w== X-Received: by 2002:ac2:4a76:: with SMTP id q22mr2396492lfp.217.1583940760278; Wed, 11 Mar 2020 08:32:40 -0700 (PDT) MIME-Version: 1.0 References: <1583780521-45702-1-git-send-email-opendmb@gmail.com> In-Reply-To: <1583780521-45702-1-git-send-email-opendmb@gmail.com> From: Linus Walleij Date: Wed, 11 Mar 2020 16:32:29 +0100 Message-ID: Subject: Re: [PATCH V2] gpio: brcmstb: support gpio-line-names property To: Doug Berger Cc: Gregory Fong , Bartosz Golaszewski , Florian Fainelli , bcm-kernel-feedback-list , "open list:GPIO SUBSYSTEM" , Linux ARM , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 9, 2020 at 8:02 PM Doug Berger wrote: > The default handling of the gpio-line-names property by the > gpiolib-of implementation does not work with the multiple > gpiochip banks per device structure used by the gpio-brcmstb > driver. > > This commit adds driver level support for the device tree > property so that GPIO lines can be assigned friendly names. > > Signed-off-by: Doug Berger > +static void brcmstb_gpio_set_names(struct device *dev, > + struct brcmstb_gpio_bank *bank) > +{ > + struct device_node *np = dev->of_node; > + const char **names; > + int nstrings, base; I don't understand why that thing is named "base". > + unsigned int i; > + > + base = bank->id * MAX_GPIO_PER_BANK; That would be ngpios or something. But you alread have what you need in bank->gc.ngpio, right? So why calculate it? > + nstrings = of_property_count_strings(np, "gpio-line-names"); > + if (nstrings <= base) > + /* Line names not present */ > + return; > + > + names = devm_kcalloc(dev, MAX_GPIO_PER_BANK, sizeof(*names), > + GFP_KERNEL); > + if (!names) > + return; > + > + /* > + * Make sure to not index beyond the end of the number of descriptors > + * of the GPIO device. > + */ > + for (i = 0; i < bank->width; i++) { > + const char *name; > + int ret; > + > + ret = of_property_read_string_index(np, "gpio-line-names", > + base + i, &name); > + if (ret) { > + if (ret != -ENODATA) > + dev_err(dev, "unable to name line %d: %d\n", > + base + i, ret); > + break; > + } > + if (*name) > + names[i] = name; > + } > + > + bank->gc.names = names; > +} Why can't you just make the function devprop_gpiochip_set_names() public, (line in ) and convert your np to a fwnode and call that &bank->gc ? Yours, Linus Walleij