Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp3238881pxb; Tue, 12 Jan 2021 09:34:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrTZ0bwQgLAAdBYqb8e+8NsLN0l6joqYdUoluMulbwBDU2VonL0cihjdI5n+k/AdZ3o87W X-Received: by 2002:a05:6402:b2f:: with SMTP id bo15mr203425edb.220.1610472870134; Tue, 12 Jan 2021 09:34:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610472870; cv=none; d=google.com; s=arc-20160816; b=LJS6SQPSNmJXoSMfl5WsnPvyEZnrhQGdUFSwB1jnqrVE25/Yon39QFdxMAHfVOFZWJ TX4spk6LP//xY3CKfjG35r5GisSfXhrdtZyxTo8kE/AFKKKBMZI24qMfmZMEr6kAEAA8 HDW063/m4CxKETGTsoeDx6VfsZ0AbbnAXY+tKOnXJtNI5MSuFqI9dhJwjFFX2jhiCc/H R2NDw26SBpZd2a9gxnyFwqBqFPi6NkuGdNNy4NLtKjW33UIR+BwMZgyPUFvQ+W0Ynx61 50ijeJPjL8Oxge/Ry/EPfwrr3tSKsZV6qGLHeNFzLNBwZsj5JATDodec1x/gtosQXac7 WkMw== 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=wHYTNknkwpoy6JOyEuCZUTiQpYW6RiiwwNhsMpLX55E=; b=XX7p7GTaJ7D0PBuwVBp1hm3JoxpQgMeWCI59s760SfqTSqrqnw13R/gL3cQ3xZpq19 /FMcYyxu9fBi+bFlaDSd1o2tJH5xhQ6htBLjF++9i15MQo3MYxJN3n6jkO1yMFE3qQAw RhQEzz5vu+ur1JYlk7Algs4usPnRyxbp+p4ZKhMKq3EajzAJz+NBqYCWBf3x77cTYxbK zJVjEdqFEArKLffcF1q5EOaoBjWCPdxjnKa70/yhU4EBD2d9ldPf3RZF4vuMDNL7i5sn rO+Vlm/KWV67JsrJQzFZRREj7+JzVPSIDnnuKP4Vdrrr4h28RNnL9XDbhrpx1wYWFSi0 Lzsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pfLR8VAg; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v4si1713960edi.191.2021.01.12.09.34.06; Tue, 12 Jan 2021 09:34:30 -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=@google.com header.s=20161025 header.b=pfLR8VAg; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390109AbhALRbt (ORCPT + 99 others); Tue, 12 Jan 2021 12:31:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388033AbhALRbt (ORCPT ); Tue, 12 Jan 2021 12:31:49 -0500 Received: from mail-yb1-xb2d.google.com (mail-yb1-xb2d.google.com [IPv6:2607:f8b0:4864:20::b2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91342C06179F for ; Tue, 12 Jan 2021 09:31:08 -0800 (PST) Received: by mail-yb1-xb2d.google.com with SMTP id o144so2915851ybc.0 for ; Tue, 12 Jan 2021 09:31:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wHYTNknkwpoy6JOyEuCZUTiQpYW6RiiwwNhsMpLX55E=; b=pfLR8VAgFLpM47Rq2XgngC7O/byRzQBN7LWsU7dwftmjBfR1hSUwOemHF+NV3KVedJ lLrLAxv48acZ3mWwdNn1i4cx4moq8c1SPh3mV44btJ7m+WwTZHRKjHnlasTaIZEO+gZu PBOto0xadIXtWKogT16sOxjLSfD/jV4WceQM9ti/okToMAX/atSZWPj6dSrRkO1FDqrz qeeGQqKN6hYl1q9pUjxRJN/PRQcX4oEfw1Wmda5cGXjnroPye1ePSA/RGEE1z7HxoRuv cz51TP3gfd6YzwPvdAThNdN/wP8+/rf3Wch6Jn6vbYzVBooAn6EUCZ20poFxoN1lO9Bw Xc2g== 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=wHYTNknkwpoy6JOyEuCZUTiQpYW6RiiwwNhsMpLX55E=; b=RS/JpOycnGwj+gNd5C4TDqdfQSAFnKkwkcxas3bj5kJZbljImMHyfyeROyrs5+1HwR A5o8ykzizHLVjC20ZZSCq4zDEikgn5KSAyjXjKiP11pYljVqJHTeV/RHyNBlQBiTYnih sFdWyPGscq7VAoBiUBjTsWo1+y7sL+rlSuYB2kJSCbl661GjiiE3EfrzbarEKisoih2y bAUEOs39OjYEwLc8bdOwYUxoqRhAMKMC2UPDhIjL2OoCM2tEH+ymTmLlcl4F7W5Zn3mS aa8Z8PX+63u02nbWvk1xnjxT7mtUJGiY3+ZyoTV0yUpyHz8X2/1iyByxM5H83vq9XqrN MnsA== X-Gm-Message-State: AOAM532NLLq0IBld5Sd+tI4XzXvGGSzYb6vgfWBFhRs85UDv3iADGjND gBYIYBcy3d0WchtyvJnn1iOOUMCDf04PcTQQu38hFA== X-Received: by 2002:a25:6604:: with SMTP id a4mr739710ybc.412.1610472667507; Tue, 12 Jan 2021 09:31:07 -0800 (PST) MIME-Version: 1.0 References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> <20210112134054.342-10-calvin.johnson@oss.nxp.com> In-Reply-To: <20210112134054.342-10-calvin.johnson@oss.nxp.com> From: Saravana Kannan Date: Tue, 12 Jan 2021 09:30:31 -0800 Message-ID: Subject: Re: [net-next PATCH v3 09/15] device property: Introduce fwnode_get_id() To: Calvin Johnson Cc: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Diana Madalina Craciun , LKML , netdev@vger.kernel.org, Laurentiu Tudor , ACPI Devel Maling List , linux.cj@gmail.com, linux-arm-kernel , Andy Shevchenko , Bartosz Golaszewski , Greg Kroah-Hartman , Laurent Pinchart , Randy Dunlap Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 12, 2021 at 5:42 AM Calvin Johnson wrote: > > Using fwnode_get_id(), get the reg property value for DT node > or get the _ADR object value for ACPI node. > > Signed-off-by: Calvin Johnson > --- > > Changes in v3: > - Modified to retrieve reg property value for ACPI as well > - Resolved compilation issue with CONFIG_ACPI = n > - Added more info into documentation > > Changes in v2: None > > drivers/base/property.c | 33 +++++++++++++++++++++++++++++++++ > include/linux/property.h | 1 + > 2 files changed, 34 insertions(+) > > diff --git a/drivers/base/property.c b/drivers/base/property.c > index 35b95c6ac0c6..2d51108cb936 100644 > --- a/drivers/base/property.c > +++ b/drivers/base/property.c > @@ -580,6 +580,39 @@ const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode) > return fwnode_call_ptr_op(fwnode, get_name_prefix); > } > > +/** > + * fwnode_get_id - Get the id of a fwnode. > + * @fwnode: firmware node > + * @id: id of the fwnode > + * > + * This function provides the id of a fwnode which can be either > + * DT or ACPI node. For ACPI, "reg" property value, if present will > + * be provided or else _ADR value will be provided. > + * Returns 0 on success or a negative errno. > + */ > +int fwnode_get_id(struct fwnode_handle *fwnode, u32 *id) > +{ > +#ifdef CONFIG_ACPI > + unsigned long long adr; > + acpi_status status; > +#endif > + int ret; > + > + ret = fwnode_property_read_u32(fwnode, "reg", id); > + if (!(ret && is_acpi_node(fwnode))) > + return ret; > + > +#ifdef CONFIG_ACPI > + status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(fwnode), > + METHOD_NAME__ADR, NULL, &adr); > + if (ACPI_FAILURE(status)) > + return -EINVAL; > + *id = (u32)adr; > +#endif > + return 0; > +} > +EXPORT_SYMBOL_GPL(fwnode_get_id); Please don't do it this way. The whole point of fwnode_operations is to avoid conditional stuff at the fwnode level. Also ACPI and DT aren't mutually exclusive if I'm not mistaken. Also, can you CC me on the entire series please? I want to reply to some of your other patches too. Most of the fwnode changes don't seem right. fwnode is lower level that the device-driver framework. Making it aware of busses like mdio, etc doesn't sound right. Also, there's already get_dev_from_fwnode() which is a much more efficient way to look up/get a device from a fwnode instead of looping through a bus. -Saravana