Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp435661pxb; Wed, 20 Jan 2021 10:31:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNJwU+O6Eh7YntsoIsEaaALoYahfi+AK4uNt6tfXKM2upS+m2j9755Yx+fHmRIVzW/mvR/ X-Received: by 2002:a05:6402:17a2:: with SMTP id j2mr8193501edy.15.1611167483935; Wed, 20 Jan 2021 10:31:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611167483; cv=none; d=google.com; s=arc-20160816; b=I5wQtOIlOdqeRJqjgnjd/SLDtmx6y5IWtQyWpHVon4smpJjA0uVoWx3Qus1hjuBE06 wuZOXaoFi3NvfCCOIqBxgd3CX+Vnxibbvd4AnUOhXWG4gxkqqVlK+rpaUodol0Fyspdh QpznMvtLoGsSMCyZ5k9PNF25xT8EhZ+bMgtatH/H8H1JUXPAPOEXmqfG2ow5wLK/pHp9 FveGKfMpIOHzzkT10BIG755jAyfV/1zN33fbWwvyhRi4CiuqOxfW99qzvQaJ63ws0X/z p+5k+SIpiwixb2PpjC83JS1ytbkEw7FKzw0RU4pTphfL4YaR52pOAPbgudCu5RJI/Usc bSGw== 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; bh=IgWDE0PErg3ORn5MUSyThw1N3Ecrc6Z8pCtsc577ahI=; b=uJ9Hi4w4n68GCDI4h2B9iy7beM5XxINrD2qbF9CFmR6sjidu+fyTGblkiWJm6CTig6 EZVPXDud7Tj5cTUiGmCsyOdrGyVpyxOgIbV3EJezCS8aBKsQzjXuVe7N5yYqmeR70pDR YVpNPn3UKgip9j68vkSfmlAk+X9kpEHTiETpiJozOPXu3sHCVIL0BAmOM0v+tKi0d8BU dInXJ6pUZ+1bshcsKATqwdEgrvqrJNl70VjGFbvB2+TGhNy0ApAQGYwGE8CgQhRClOIA S4fIKTgqIgVzLrkV/vBLiN1bANqunfYyhDwL6IuQG3/1jNLucXOmYtSOEAcArdigqSx/ afhQ== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg13si992712ejc.616.2021.01.20.10.30.59; Wed, 20 Jan 2021 10:31:23 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404690AbhATS0l (ORCPT + 99 others); Wed, 20 Jan 2021 13:26:41 -0500 Received: from mail-ot1-f50.google.com ([209.85.210.50]:39512 "EHLO mail-ot1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391964AbhATSSo (ORCPT ); Wed, 20 Jan 2021 13:18:44 -0500 Received: by mail-ot1-f50.google.com with SMTP id i30so11348535ota.6; Wed, 20 Jan 2021 10:18:27 -0800 (PST) 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=IgWDE0PErg3ORn5MUSyThw1N3Ecrc6Z8pCtsc577ahI=; b=ojM9r7PCtlxNYXItFNuFj/iw6hmuaeCLkNxVczASwTCTvtBngMAekwLoUvvd6etJaI ybFnwSmuTOkJoyBjly/xRwbNLWye/NhawA2DdPwZRVj/ilBSIhz5Eo7crOy2+itv0nNV CVcL7Tsw77M7BMHNUNHT3u/vQOlMggZ8R77Fl2P0wfSyzjuFrAvDQuFe5AZDM2sTKUxE yJSK1lErEmX26ucnQWobUn2fJ32RYt5FYhrlWU+jLaHSWABujrBDC5nZod/Jlx1JOMjZ P7B/LQPO1JeBtWjEkwgI/+b06V5MWh8DoJrkiWvy5Lpq27Ii0kQ8mgg6OWZMhhuBvo7e 6a0Q== X-Gm-Message-State: AOAM5319XFPLIJwgtWTE35qCnVYCoOV0ZimRJ132nvoFjO4vSDacAFK4 vDHXGKIyblYZqlCEhS0v3Ikp3kcOQLjtnVeNQHs= X-Received: by 2002:a05:6830:138f:: with SMTP id d15mr1588674otq.321.1611166682565; Wed, 20 Jan 2021 10:18:02 -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: From: "Rafael J. Wysocki" Date: Wed, 20 Jan 2021 19:17:51 +0100 Message-ID: Subject: Re: [net-next PATCH v3 09/15] device property: Introduce fwnode_get_id() To: Andy Shevchenko Cc: Calvin Johnson , Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , 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 , Linux Kernel Mailing List , netdev , Laurentiu Tudor , ACPI Devel Maling List , "linux.cj" , linux-arm Mailing List , Andy Shevchenko , Bartosz Golaszewski , Greg Kroah-Hartman , Laurent Pinchart , Randy Dunlap , Saravana Kannan 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 4:47 PM Andy Shevchenko wrote: > > On Tue, Jan 12, 2021 at 3:42 PM 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; > > Shouldn't be > > return 0; > #else > return -EINVAL; > #endif > > ? > > Yes, it's a theoretical case when is_acpi_node() returns true when > CONFIG_ACPI=n. How so? is_acpi_node() is defined as a static inline returning false then.