Message ID | 20221118214036.1269005-1-michael@walle.cc |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp423503wrr; Fri, 18 Nov 2022 13:47:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf6AHXrsLaXG4uRz4igL5cKn/YLOVIRGq5IzHq9JbcFSciNWiptr++B8wlEQHYFu8vwm397/ X-Received: by 2002:a17:906:f88:b0:78d:ff14:63f9 with SMTP id q8-20020a1709060f8800b0078dff1463f9mr7419038ejj.516.1668808038873; Fri, 18 Nov 2022 13:47:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668808038; cv=none; d=google.com; s=arc-20160816; b=QPPEjU6K3yZ7Lmnd21dzVykaZJYLkCCjWen+AzcwZk/wP+QKjpJEUJBvI5iXthNzz+ lNx5voE8t6CBXXAg3Tx8EqLKcIY1NgObbElQntvuKoeuRwZC1GzN+kXICASgicIeVpPb 2f+oB1Rla/+MI93NOcKiBTU0w0rR/8+VHstEM1ecbeimgRU/pFH80adW0w9gSmeO6xKL pO00P+l6GcK6yIgf8c2jkGh4SpNXkTUjiJJO+VX3y0YIAVRE3FIty8EwyxnZ7c7WkwvH +gJhRP5NeYKGnTAHJFNGeiPIDboG6fulBmYwNxrtkui4dvZo/dfcB20SZtUXZKjTLvsj TIVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PCD/6dmFnGBLqWK1cint2zY12NZJUc/wLW+bw2dtkU8=; b=dMR2qXexQvFZ4OTGiodfpOruuP2+Jk52i9AWZdX4DuwtZICcI2FOJABJhBvAT4tw85 SaG/FDaeKu9XR4zEI+qGlRwgdYZb3lxTw78yAcuaarrblKDZX1F7EUxhexbBsi0smwSs gh9Dr50+Bp2F6kcUbJwr/gdCiTwXVhMbHgWYRI6b2SHdbJgxXiqYkUXb7aqd595+k9pa YIPRKF17D22l15N/A5sPNUgMdCNvk/glwHoDTHUtox4h+g859r96OO7OO5aK1a/ahDKv fFFQv2Dtyzqlk4sXuMjxsujI7eK7Cbe96Ifnu6I33Z+0B49sp2TEAiM1JJX02fPSAYKH X6Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=vUKLS4bq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y6-20020a056402358600b004642b0f2357si4403571edc.589.2022.11.18.13.46.55; Fri, 18 Nov 2022 13:47:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=vUKLS4bq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229949AbiKRVk4 (ORCPT <rfc822;kkmonlee@gmail.com> + 99 others); Fri, 18 Nov 2022 16:40:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbiKRVky (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 18 Nov 2022 16:40:54 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AA9F5E9FE; Fri, 18 Nov 2022 13:40:53 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 7DB7D1CF7; Fri, 18 Nov 2022 22:40:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1668807651; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PCD/6dmFnGBLqWK1cint2zY12NZJUc/wLW+bw2dtkU8=; b=vUKLS4bqpaikYXvkQtVYN3r7XeWvcQJkx7QF1r/3prG0WQ2dzbJJx3wreaTe2wVNgT1BQC 3oH7C6JxPRJKTDHo4yWCGQvtFJr5Fu5iPBAFUkQaPcxzsB3TTNshCHkAjoBZ3ubMO07wZE c+t3045n0vUKTTxoUVO6CBSJQUapB81ujl/LjWAucAJaPd7PN11pJQco4HYxw3Rik7eX+9 xNdn0NKfB3HuvtCDgwONTzGhjkpYPoCtoH0Wl496fz1x8FBJ7SAcvforeLYa+2+H3QxDms OFsOaA1sVr3YTZbve7sq5kyKZq5wqh3aarK3M+VXZVhmg8nE12rtmAX1ZMGxtA== From: Michael Walle <michael@walle.cc> To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, Miquel Raynal <miquel.raynal@bootlin.com>, Rob Herring <robh+dt@kernel.org>, Frank Rowand <frowand.list@gmail.com> Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle <michael@walle.cc> Subject: [PATCH] of: property: special #nvmem-cell-cells handling Date: Fri, 18 Nov 2022 22:40:36 +0100 Message-Id: <20221118214036.1269005-1-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <8b976cf546bad3aa159a6f05cd3c15d1@walle.cc> References: <8b976cf546bad3aa159a6f05cd3c15d1@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam: Yes X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749872057758632227?= X-GMAIL-MSGID: =?utf-8?q?1749872057758632227?= |
Series |
of: property: special #nvmem-cell-cells handling
|
|
Commit Message
Michael Walle
Nov. 18, 2022, 9:40 p.m. UTC
Since recently, there is a new #nvmem-cell-cells. To be backwards
compatible this is optional. Therefore, we need special handling and
cannot use DEFINE_SIMPLE_PROP() anymore.
Signed-off-by: Michael Walle <michael@walle.cc>
---
This patch will be part of the following series:
https://lore.kernel.org/linux-arm-kernel/20221118185118.1190044-1-michael@walle.cc/
drivers/of/property.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
Comments
On Fri, Nov 18, 2022 at 3:40 PM Michael Walle <michael@walle.cc> wrote: > > Since recently, there is a new #nvmem-cell-cells. To be backwards > compatible this is optional. Therefore, we need special handling and > cannot use DEFINE_SIMPLE_PROP() anymore. > > Signed-off-by: Michael Walle <michael@walle.cc> > --- > This patch will be part of the following series: > https://lore.kernel.org/linux-arm-kernel/20221118185118.1190044-1-michael@walle.cc/ > > drivers/of/property.c | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/drivers/of/property.c b/drivers/of/property.c > index 967f79b59016..93c0ea662336 100644 > --- a/drivers/of/property.c > +++ b/drivers/of/property.c > @@ -1305,7 +1305,6 @@ DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-cells") > DEFINE_SIMPLE_PROP(power_domains, "power-domains", "#power-domain-cells") > DEFINE_SIMPLE_PROP(hwlocks, "hwlocks", "#hwlock-cells") > DEFINE_SIMPLE_PROP(extcon, "extcon", NULL) > -DEFINE_SIMPLE_PROP(nvmem_cells, "nvmem-cells", NULL) > DEFINE_SIMPLE_PROP(phys, "phys", "#phy-cells") > DEFINE_SIMPLE_PROP(wakeup_parent, "wakeup-parent", NULL) > DEFINE_SIMPLE_PROP(pinctrl0, "pinctrl-0", NULL) > @@ -1381,6 +1380,22 @@ static struct device_node *parse_interrupts(struct device_node *np, > return of_irq_parse_one(np, index, &sup_args) ? NULL : sup_args.np; > } > > +static struct device_node *parse_nvmem_cells(struct device_node *np, > + const char *prop_name, int index) > +{ > + struct of_phandle_args sup_args; > + > + if (strcmp(prop_name, "nvmem-cells")) > + return NULL; > + > + if (of_parse_phandle_with_optional_args(np, prop_name, > + "#nvmem-cell-cells", index, > + &sup_args)) > + return NULL; > + > + return sup_args.np; > +} There's a couple of other cases like that (MSI IIRC), so can we generalize this to work in more than 1 case? Rob
Am 2022-11-18 22:52, schrieb Rob Herring: > On Fri, Nov 18, 2022 at 3:40 PM Michael Walle <michael@walle.cc> wrote: >> >> Since recently, there is a new #nvmem-cell-cells. To be backwards >> compatible this is optional. Therefore, we need special handling and >> cannot use DEFINE_SIMPLE_PROP() anymore. >> >> Signed-off-by: Michael Walle <michael@walle.cc> >> --- >> This patch will be part of the following series: >> https://lore.kernel.org/linux-arm-kernel/20221118185118.1190044-1-michael@walle.cc/ >> >> drivers/of/property.c | 17 ++++++++++++++++- >> 1 file changed, 16 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/of/property.c b/drivers/of/property.c >> index 967f79b59016..93c0ea662336 100644 >> --- a/drivers/of/property.c >> +++ b/drivers/of/property.c >> @@ -1305,7 +1305,6 @@ DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-cells") >> DEFINE_SIMPLE_PROP(power_domains, "power-domains", >> "#power-domain-cells") >> DEFINE_SIMPLE_PROP(hwlocks, "hwlocks", "#hwlock-cells") >> DEFINE_SIMPLE_PROP(extcon, "extcon", NULL) >> -DEFINE_SIMPLE_PROP(nvmem_cells, "nvmem-cells", NULL) >> DEFINE_SIMPLE_PROP(phys, "phys", "#phy-cells") >> DEFINE_SIMPLE_PROP(wakeup_parent, "wakeup-parent", NULL) >> DEFINE_SIMPLE_PROP(pinctrl0, "pinctrl-0", NULL) >> @@ -1381,6 +1380,22 @@ static struct device_node >> *parse_interrupts(struct device_node *np, >> return of_irq_parse_one(np, index, &sup_args) ? NULL : >> sup_args.np; >> } >> >> +static struct device_node *parse_nvmem_cells(struct device_node *np, >> + const char *prop_name, >> int index) >> +{ >> + struct of_phandle_args sup_args; >> + >> + if (strcmp(prop_name, "nvmem-cells")) >> + return NULL; >> + >> + if (of_parse_phandle_with_optional_args(np, prop_name, >> + "#nvmem-cell-cells", >> index, >> + &sup_args)) >> + return NULL; >> + >> + return sup_args.np; >> +} > > There's a couple of other cases like that (MSI IIRC), so can we > generalize this to work in more than 1 case? You mean addding a new DEFINE_SIMPLE_PROP_OPTIONAL_ARGS()? -michael
On Fri, Nov 18, 2022 at 4:03 PM Michael Walle <michael@walle.cc> wrote: > > Am 2022-11-18 22:52, schrieb Rob Herring: > > On Fri, Nov 18, 2022 at 3:40 PM Michael Walle <michael@walle.cc> wrote: > >> > >> Since recently, there is a new #nvmem-cell-cells. To be backwards > >> compatible this is optional. Therefore, we need special handling and > >> cannot use DEFINE_SIMPLE_PROP() anymore. > >> > >> Signed-off-by: Michael Walle <michael@walle.cc> > >> --- > >> This patch will be part of the following series: > >> https://lore.kernel.org/linux-arm-kernel/20221118185118.1190044-1-michael@walle.cc/ > >> > >> drivers/of/property.c | 17 ++++++++++++++++- > >> 1 file changed, 16 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/of/property.c b/drivers/of/property.c > >> index 967f79b59016..93c0ea662336 100644 > >> --- a/drivers/of/property.c > >> +++ b/drivers/of/property.c > >> @@ -1305,7 +1305,6 @@ DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-cells") > >> DEFINE_SIMPLE_PROP(power_domains, "power-domains", > >> "#power-domain-cells") > >> DEFINE_SIMPLE_PROP(hwlocks, "hwlocks", "#hwlock-cells") > >> DEFINE_SIMPLE_PROP(extcon, "extcon", NULL) > >> -DEFINE_SIMPLE_PROP(nvmem_cells, "nvmem-cells", NULL) > >> DEFINE_SIMPLE_PROP(phys, "phys", "#phy-cells") > >> DEFINE_SIMPLE_PROP(wakeup_parent, "wakeup-parent", NULL) > >> DEFINE_SIMPLE_PROP(pinctrl0, "pinctrl-0", NULL) > >> @@ -1381,6 +1380,22 @@ static struct device_node > >> *parse_interrupts(struct device_node *np, > >> return of_irq_parse_one(np, index, &sup_args) ? NULL : > >> sup_args.np; > >> } > >> > >> +static struct device_node *parse_nvmem_cells(struct device_node *np, > >> + const char *prop_name, > >> int index) > >> +{ > >> + struct of_phandle_args sup_args; > >> + > >> + if (strcmp(prop_name, "nvmem-cells")) > >> + return NULL; > >> + > >> + if (of_parse_phandle_with_optional_args(np, prop_name, > >> + "#nvmem-cell-cells", > >> index, > >> + &sup_args)) > >> + return NULL; > >> + > >> + return sup_args.np; > >> +} > > > > There's a couple of other cases like that (MSI IIRC), so can we > > generalize this to work in more than 1 case? > > You mean addding a new DEFINE_SIMPLE_PROP_OPTIONAL_ARGS()? Actually, I think you can just do something like the below. I don't think we need to separately handle an optional #.*-cells and a required one. It's really just validation which we do already both with the tools and when the subsystems parse these bindings. Of course, if we need to handle cases other than 0 default cells, we'll have to restructure the define some to pass the default cells. diff --git a/drivers/of/property.c b/drivers/of/property.c index 967f79b59016..198f56633eb0 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1254,7 +1254,7 @@ static struct device_node *parse_suffix_prop_cells(struct device_node *np, if (strcmp_suffix(prop_name, suffix)) return NULL; - if (of_parse_phandle_with_args(np, prop_name, cells_name, index, + if (__of_parse_phandle_with_args(np, prop_name, cells_name, 0, index, &sup_args)) return NULL;
Hi Rob, Michael, robh+dt@kernel.org wrote on Tue, 22 Nov 2022 17:44:26 -0600: > On Fri, Nov 18, 2022 at 4:03 PM Michael Walle <michael@walle.cc> wrote: > > > > Am 2022-11-18 22:52, schrieb Rob Herring: > > > On Fri, Nov 18, 2022 at 3:40 PM Michael Walle <michael@walle.cc> wrote: > > >> > > >> Since recently, there is a new #nvmem-cell-cells. To be backwards > > >> compatible this is optional. Therefore, we need special handling and > > >> cannot use DEFINE_SIMPLE_PROP() anymore. > > >> > > >> Signed-off-by: Michael Walle <michael@walle.cc> > > >> --- > > >> This patch will be part of the following series: > > >> https://lore.kernel.org/linux-arm-kernel/20221118185118.1190044-1-michael@walle.cc/ > > >> > > >> drivers/of/property.c | 17 ++++++++++++++++- > > >> 1 file changed, 16 insertions(+), 1 deletion(-) > > >> > > >> diff --git a/drivers/of/property.c b/drivers/of/property.c > > >> index 967f79b59016..93c0ea662336 100644 > > >> --- a/drivers/of/property.c > > >> +++ b/drivers/of/property.c > > >> @@ -1305,7 +1305,6 @@ DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-cells") > > >> DEFINE_SIMPLE_PROP(power_domains, "power-domains", > > >> "#power-domain-cells") > > >> DEFINE_SIMPLE_PROP(hwlocks, "hwlocks", "#hwlock-cells") > > >> DEFINE_SIMPLE_PROP(extcon, "extcon", NULL) > > >> -DEFINE_SIMPLE_PROP(nvmem_cells, "nvmem-cells", NULL) > > >> DEFINE_SIMPLE_PROP(phys, "phys", "#phy-cells") > > >> DEFINE_SIMPLE_PROP(wakeup_parent, "wakeup-parent", NULL) > > >> DEFINE_SIMPLE_PROP(pinctrl0, "pinctrl-0", NULL) > > >> @@ -1381,6 +1380,22 @@ static struct device_node > > >> *parse_interrupts(struct device_node *np, > > >> return of_irq_parse_one(np, index, &sup_args) ? NULL : > > >> sup_args.np; > > >> } > > >> > > >> +static struct device_node *parse_nvmem_cells(struct device_node *np, > > >> + const char *prop_name, > > >> int index) > > >> +{ > > >> + struct of_phandle_args sup_args; > > >> + > > >> + if (strcmp(prop_name, "nvmem-cells")) > > >> + return NULL; > > >> + > > >> + if (of_parse_phandle_with_optional_args(np, prop_name, > > >> + "#nvmem-cell-cells", > > >> index, > > >> + &sup_args)) > > >> + return NULL; > > >> + > > >> + return sup_args.np; > > >> +} > > > > > > There's a couple of other cases like that (MSI IIRC), so can we > > > generalize this to work in more than 1 case? > > > > You mean addding a new DEFINE_SIMPLE_PROP_OPTIONAL_ARGS()? > > Actually, I think you can just do something like the below. I don't > think we need to separately handle an optional #.*-cells and a > required one. It's really just validation which we do already both > with the tools and when the subsystems parse these bindings. Of > course, if we need to handle cases other than 0 default cells, we'll > have to restructure the define some to pass the default cells. > > diff --git a/drivers/of/property.c b/drivers/of/property.c > index 967f79b59016..198f56633eb0 100644 > --- a/drivers/of/property.c > +++ b/drivers/of/property.c > @@ -1254,7 +1254,7 @@ static struct device_node > *parse_suffix_prop_cells(struct device_node *np, > if (strcmp_suffix(prop_name, suffix)) > return NULL; > > - if (of_parse_phandle_with_args(np, prop_name, cells_name, index, > + if (__of_parse_phandle_with_args(np, prop_name, cells_name, 0, index, > &sup_args)) > return NULL; Excellent, this small change aside with -DEFINE_SIMPLE_PROP(nvmem_cells, "nvmem-cells", NULL) +DEFINE_SIMPLE_PROP(nvmem_cells, "nvmem-cells", "#nvmem-cell-cells") look much simpler and work perfectly. Tested-by: Miquel Raynal <miquel.raynal@bootlin.com> Thanks, Miquèl
diff --git a/drivers/of/property.c b/drivers/of/property.c index 967f79b59016..93c0ea662336 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1305,7 +1305,6 @@ DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-cells") DEFINE_SIMPLE_PROP(power_domains, "power-domains", "#power-domain-cells") DEFINE_SIMPLE_PROP(hwlocks, "hwlocks", "#hwlock-cells") DEFINE_SIMPLE_PROP(extcon, "extcon", NULL) -DEFINE_SIMPLE_PROP(nvmem_cells, "nvmem-cells", NULL) DEFINE_SIMPLE_PROP(phys, "phys", "#phy-cells") DEFINE_SIMPLE_PROP(wakeup_parent, "wakeup-parent", NULL) DEFINE_SIMPLE_PROP(pinctrl0, "pinctrl-0", NULL) @@ -1381,6 +1380,22 @@ static struct device_node *parse_interrupts(struct device_node *np, return of_irq_parse_one(np, index, &sup_args) ? NULL : sup_args.np; } +static struct device_node *parse_nvmem_cells(struct device_node *np, + const char *prop_name, int index) +{ + struct of_phandle_args sup_args; + + if (strcmp(prop_name, "nvmem-cells")) + return NULL; + + if (of_parse_phandle_with_optional_args(np, prop_name, + "#nvmem-cell-cells", index, + &sup_args)) + return NULL; + + return sup_args.np; +} + static const struct supplier_bindings of_supplier_bindings[] = { { .parse_prop = parse_clocks, }, { .parse_prop = parse_interconnects, },