Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp717927pxb; Fri, 14 Jan 2022 14:54:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvTGtEwd6ibap5tfjwwQB75Y5zAAht2RlIjmppSfjxj3tbCidppFcAXFq07U1zfoDV6JAS X-Received: by 2002:a17:907:7fab:: with SMTP id qk43mr9312827ejc.692.1642200897757; Fri, 14 Jan 2022 14:54:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642200897; cv=none; d=google.com; s=arc-20160816; b=Ml02Dv5A+9OWpMxyKLHk4Am+eiZY5WH7mKKhkN/vQk3DGJxgHsRPwl6wP5MROtIyU0 4bxOyvINGvY1GvS2W13kJfnFcb0W8qg0EDQ6ZC5qdK3Ky4Dtd+GaYB6wo3CHOF0xvn4q 4UqVwpMiBpNJWL6HVrB3DqeOdQ5CeHsuPWpVpP9XLMkV5tdoACESnDpdNNyaibj84JZw FbO4O+Geo2JP70hTC+SPRneOIWjpsMotByQvIGkMGoDXYuMaW0tE4i5jbKVyeA0Ocr0F ZiBmgz4Xis9UBPALXYDQzD6S06cC4/xRgyfd5Y+8JW9WUBqjR8CgowSNeaKH+FIOpCJs 9KBA== 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=oKmCN3yojMQ2wi56P4UR8ruDKIpKUs7zR5mIdUilTLs=; b=SMPAT/BEUeB6ynq8az64EltC4a73pUUXE8t8OqkaUmE32jrUlZ0hNBC3NVxIBSq+ud N7l88ClaJm2cnt1thTqoh/Ki8DWs6X+0yzCAT0+Lum7F3d9bSokpVzGm91of6sz76CW1 kwQReCk1E7FtylKCa/MSEoOZs/9jyMaV0zrIqOEUv/TMPhNe9UHdowkCXEqn1c+xqsMY XGP53W0fDhorcjRyrB8SrnUq8z7hWiDvqKD+zaTS5uJFSgLiNcrT8MAcNUIxX0Caip14 GutF208I5if0csOhR3t9whIAxos0JDXkqoXB4dq/0xFMG6l6MO3w7md0TjsPvOaedEml DiJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="c/em2xkl"; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v7si3976475edb.41.2022.01.14.14.54.28; Fri, 14 Jan 2022 14:54:57 -0800 (PST) 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=@linaro.org header.s=google header.b="c/em2xkl"; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243687AbiANRAx (ORCPT + 99 others); Fri, 14 Jan 2022 12:00:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243672AbiANRAw (ORCPT ); Fri, 14 Jan 2022 12:00:52 -0500 Received: from mail-ua1-x92b.google.com (mail-ua1-x92b.google.com [IPv6:2607:f8b0:4864:20::92b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26652C06173F for ; Fri, 14 Jan 2022 09:00:52 -0800 (PST) Received: by mail-ua1-x92b.google.com with SMTP id y4so18019955uad.1 for ; Fri, 14 Jan 2022 09:00:52 -0800 (PST) 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=oKmCN3yojMQ2wi56P4UR8ruDKIpKUs7zR5mIdUilTLs=; b=c/em2xklv+/oiPVG3wTsLIBI/PYz+iiwoQwDyRu0z2WGsetY8k58VlWYjZ74jknml7 6Km598wDrpzl0CGzCrAAR0yygQgYzQ70RNZmob1m3aoLEx7l4GAI2MsvP59jQoQuy2Ev q4UZ6uROQCaS4wDF1vEQWhZr42h6gvMrUReP4y2T+g/YFirmZyzn1NT0at9oT5nU6Mwz ONVcyHYScnayivUGaX9SjAgUUCbcHcJ27ckCH4T659y6ApgoD7aJZfjZVgfJLKDKLY7m BahChZQZ20cJ2K/Iq7ycKTmXSrs5eMoA4S3dRodPxwbKWs+uKs15irLcXcp0Ub6akDqb BGxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oKmCN3yojMQ2wi56P4UR8ruDKIpKUs7zR5mIdUilTLs=; b=HTruWq1njO5mZbKHsJlyZmb0G9n86ooYfWK2jOPwjv5gPhbT8KbKA8EV0LwUDd2mR/ 45lE7X0MiVZKKi+9XObfQW44EVx/Uk98t+57Nac6wSIpI5OEKEcWGUbkEfAXB3GEd97M kkpmtt54gsNtyPC2+eseswJa27RQjd0BWydyFa6Pswb28ixkjtgL4Nadz1GtBl27hZJi 0v8IfK2Mu6RZQaxp+Ulhl/VW7nu7x8r8h/krVMjCf6fAU3vPysPAxn93UshG9Ahrsffi CtZle9tSg/RGKEssT25TIbg6klHgxHTciTXSZ07TadrHPBq7RPDyQDdfGadNzp0FpGjq i+QA== X-Gm-Message-State: AOAM533fUKfc0RVmdwlQWT4xFW2PWAxliQ9AgL+GUBsEiXxcXwU8vSEV 39RNcjvzch000Ix2Up+qoFFXoNnf38yxVLlbzkZEow== X-Received: by 2002:ab0:5a46:: with SMTP id m6mr4357760uad.104.1642179651179; Fri, 14 Jan 2022 09:00:51 -0800 (PST) MIME-Version: 1.0 References: <20220111201426.326777-1-krzysztof.kozlowski@canonical.com> <20220111201426.326777-3-krzysztof.kozlowski@canonical.com> In-Reply-To: <20220111201426.326777-3-krzysztof.kozlowski@canonical.com> From: Sam Protsenko Date: Fri, 14 Jan 2022 19:00:39 +0200 Message-ID: Subject: Re: [PATCH v2 02/28] pinctrl: samsung: accept GPIO bank nodes with a suffix To: Krzysztof Kozlowski Cc: Tomasz Figa , Sylwester Nawrocki , Linus Walleij , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Szyprowski , Chanho Park , Alim Akhtar Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 11 Jan 2022 at 22:15, Krzysztof Kozlowski wrote: > > Existing dt-bindings expected that each GPIO/pin bank within pin > controller has its own node with name matching the bank (e.g. gpa0, > gpx2) and "gpio-controller" property. The node name is then used for > matching between driver data and DTS. > > Newly introduced dtschema expects to have nodes ending with "-gpio-bank" > suffix, so rewrite bank-devicetree matching to look for old and new > style of naming. > > Signed-off-by: Krzysztof Kozlowski > --- Reviewed-by: Sam Protsenko > drivers/pinctrl/samsung/pinctrl-samsung.c | 57 ++++++++++++++++++----- > 1 file changed, 45 insertions(+), 12 deletions(-) > > diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c > index b19ebc43d886..b3a5bc473841 100644 > --- a/drivers/pinctrl/samsung/pinctrl-samsung.c > +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c > @@ -1012,13 +1012,56 @@ static void samsung_banks_of_node_put(struct samsung_pinctrl_drv_data *d) > of_node_put(bank->of_node); > } > > +/* > + * Iterate over all driver pin banks to find one matching the name of node, > + * skipping optional "-gpio" node suffix. When found, assign node to the bank. > + */ > +static void samsung_banks_of_node_get(struct device *dev, > + struct samsung_pinctrl_drv_data *d, > + struct device_node *node) > +{ > + const char *suffix = "-gpio-bank"; > + struct samsung_pin_bank *bank; > + struct device_node *child; > + /* Pin bank names are up to 4 characters */ > + char node_name[20]; > + unsigned int i; > + size_t len; > + > + bank = d->pin_banks; > + for (i = 0; i < d->nr_banks; ++i, ++bank) { > + strscpy(node_name, bank->name, sizeof(node_name)); > + len = strlcat(node_name, suffix, sizeof(node_name)); > + if (len >= sizeof(node_name)) { > + dev_err(dev, "Too long pin bank name '%s', ignoring\n", > + bank->name); > + continue; > + } > + > + for_each_child_of_node(node, child) { > + if (!of_find_property(child, "gpio-controller", NULL)) > + continue; > + if (of_node_name_eq(child, node_name)) > + break; > + else if (of_node_name_eq(child, bank->name)) > + break; > + } > + > + if (child) > + bank->of_node = child; > + else > + dev_warn(dev, "Missing node for bank %s - invalid DTB\n", > + bank->name); > + /* child reference dropped in samsung_drop_banks_of_node() */ > + } > +} > + > /* retrieve the soc specific data */ > static const struct samsung_pin_ctrl * > samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d, > struct platform_device *pdev) > { > struct device_node *node = pdev->dev.of_node; > - struct device_node *np; > const struct samsung_pin_bank_data *bdata; > const struct samsung_pin_ctrl *ctrl; > struct samsung_pin_bank *bank; > @@ -1082,17 +1125,7 @@ samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d, > */ > d->virt_base = virt_base[0]; > > - for_each_child_of_node(node, np) { > - if (!of_find_property(np, "gpio-controller", NULL)) > - continue; > - bank = d->pin_banks; > - for (i = 0; i < d->nr_banks; ++i, ++bank) { > - if (of_node_name_eq(np, bank->name)) { > - bank->of_node = np; > - break; > - } > - } > - } > + samsung_banks_of_node_get(&pdev->dev, d, node); > > d->pin_base = pin_base; > pin_base += d->nr_pins; > -- > 2.32.0 >