Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp448675pxb; Wed, 20 Jan 2021 10:53:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsXvVwxDWKZNLuGIHKPazjyZSHWLxE6yhsXPdyPBNYK62l7144ASS47LcfoLIwpK4BPI0f X-Received: by 2002:a17:906:76d6:: with SMTP id q22mr6828531ejn.221.1611168823109; Wed, 20 Jan 2021 10:53:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611168823; cv=none; d=google.com; s=arc-20160816; b=ebPACWyxqHGFYDteSXNcf0NwvuVpXJMznModIqY13+RGtm4aikdhW7NkWuVJSBrub5 HwkC1goi/DhOsRCZobULPJeEtTFQVVyp/eMFS6wkoBDkKR/LF0HSd4IM9lq+xDHguPpp op9BNOLp+5F8pDorJFuJl9OQSFSeAG65mmlchjcVfGWlijbcTThKUmpHEYr8seDMrKrb lMJ+MnTcR0uDFfcoKxGuR2k19catYREA+jzYf08Eu5r2JRax7UPzINFC5elAoJvGiI/E /RP2rWnbsLIxKViviDm4giHEHyTa9MoYrPippvnYHk6E5rHyBzJgexBW1CiYqXm0cHJL /bPw== 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=RfjCq1s0j/dTx5RKp24NHHvH/UNwDWa3zTESuWCm4vc=; b=APgTGaEfP9NoBylsaJR1HfFXYshrnlelpu/WxJxMMNEWifKekDspk/mCXMDZx+GeTy 4cAPLaM3d4g37NL+bX9/7NQN2+u77Y11v7rFAcdK/zIvaH6eOWGKkYRUXSvuzwTW2r8V oPYRSYvoTGxIFdu7iCJAgUDTHQqrQW5nGQ2ogSBOmYC33P55VrPL+ZkKP/iBNLhjdabz ThPIAM0T1dN7f/bKhX9o24pDtMOfZ8XrsP6AoHKdnZlGoTfr+gBcDVWvl4HqhQm0P1uC VWNSyucr5Ah32GAGoNpavHp94B21jaK9cO1+y34qWdTYvmUKJo6szJK7ASbQNWt7E6Qk OzmA== 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 q12si934598eji.679.2021.01.20.10.53.17; Wed, 20 Jan 2021 10:53:43 -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 S2392087AbhATSu2 (ORCPT + 99 others); Wed, 20 Jan 2021 13:50:28 -0500 Received: from mail-ot1-f46.google.com ([209.85.210.46]:34726 "EHLO mail-ot1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391982AbhATSTc (ORCPT ); Wed, 20 Jan 2021 13:19:32 -0500 Received: by mail-ot1-f46.google.com with SMTP id a109so24298289otc.1; Wed, 20 Jan 2021 10:19:16 -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=RfjCq1s0j/dTx5RKp24NHHvH/UNwDWa3zTESuWCm4vc=; b=mDE8Iqla1LpEh4hRirQ/VukquO76UAYyO2JXq06S1WGDQJDGsARPGjuqL3bPSGmA91 WUym30LvO0fsAMJ+FSlS1ZyEauz8XjdL7lT0QkDyOQO4akV9dUKM8sT08zwFGcTY+24D /3Kr+lYzD4uk+MaRRJbsiRp/l9P1gDhpyNxSk5/FyCDPCmhhqVyrrfYf6t3GMQUo5UbU 5wF5E9z5VbZAnbBe+9gZeilPkk+GGvtmyT+wFj9oAR3EcmIY91QnuAQyjztQxiX0ftRc /TK7XhXzkFXNmmiO+aiNqsryXo+tbcPScVrt7gLL2wx+dhEi22i7LYl0qP5INRBZ4z8a /teQ== X-Gm-Message-State: AOAM530tfxjvCFXhM3B/sAjeMkZbGxyFfJpTRKAGhEHRjmATveSGfXus Ew+QStqbBdw+U5WrG+4NDMCu4oEdoV9r3gzV6wQ= X-Received: by 2002:a05:6830:138f:: with SMTP id d15mr1590839otq.321.1611166731213; Wed, 20 Jan 2021 10:18:51 -0800 (PST) MIME-Version: 1.0 References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> <20210112134054.342-10-calvin.johnson@oss.nxp.com> <20210112180343.GI4077@smile.fi.intel.com> In-Reply-To: <20210112180343.GI4077@smile.fi.intel.com> From: "Rafael J. Wysocki" Date: Wed, 20 Jan 2021 19:18:39 +0100 Message-ID: Subject: Re: [net-next PATCH v3 09/15] device property: Introduce fwnode_get_id() To: Andy Shevchenko Cc: Saravana Kannan , 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 , LKML , netdev , Laurentiu Tudor , ACPI Devel Maling List , linux.cj@gmail.com, linux-arm-kernel , 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 7:02 PM Andy Shevchenko wrote: > > On Tue, Jan 12, 2021 at 09:30:31AM -0800, Saravana Kannan wrote: > > 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. > > ... > > > > +/** > > > + * 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. > > Not fully true. We have non-POD getters that are conditional. Moreover, > we have additional layer of Primary / Secondary fwnodes on top of that. > > The caller of fwnode API is indeed agnostic, but under the hood it differs by > the definition (obviously due to natural differences between ACPI and DT and > whatever else might come in the future. > > > Also ACPI and DT > > aren't mutually exclusive if I'm not mistaken. > > That's why we try 'reg' property for both cases first. > > is_acpi_fwnode() conditional is that what I don't like though. I'm not sure what you mean here, care to elaborate?