From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8BF5C433E0 for ; Tue, 12 Jan 2021 17:31:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A799522AED for ; Tue, 12 Jan 2021 17:31:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392936AbhALRbu (ORCPT ); Tue, 12 Jan 2021 12:31:50 -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-Google-Smtp-Source: ABdhPJzvX3Y98ulgvyKO0IFzPTIajC5tpI1HRnZnbzV4hlHG99AxqbDl7sUpsC3YuFe0UJcG/cLXCmnMw+AW7TR7a1E= 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