Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp11206pxb; Tue, 12 Jan 2021 18:24:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxy+rdV1FgLQEhcuAXtv3omgv4nNLgCACW0k12GQmm8ICNzW280BqWhhalAi1w46cRIls4j X-Received: by 2002:a50:8744:: with SMTP id 4mr1629435edv.362.1610504686830; Tue, 12 Jan 2021 18:24:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610504686; cv=none; d=google.com; s=arc-20160816; b=MJyf1SBocAhCOS4ESc2FAqnRGCMTYwJYr3C2n9SpCqTfYPgHN9NT+iOLbfCfxVpaw1 UaGln/7PFBOjDPeQtO663nnnTsbps0dJTyM20MLA0k51wMfILqq7FceR7TBMivcbRB+b Z+6RoIrcjONjFAQvTCO2YK69EuaaeTCMOGPYRNx0DSryjvkx2EwcdcSXYZ8uFFitsdLx vpPTqut0KCLqBYzz4BlzDEbh5PiiTswNY9kkt85cbrLymrnrrU+OWKldwHZ4YaECrJN0 GOjMV/3srnmCGPO0LcPPHyPqEidwLMviBLypj8LpWc6MH8QTC1On2TgMaJ6jy6mo9r05 ZFcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=G8h8tfJ8gqemGtNmJ0mirm2IRVqfccGLTyM5AnYCHZs=; b=rXMcy7rMR5kVEQ2HuMqpOhd2t5Ar+bAFPlU6tPCgK1Nt5zRkmFq7iEzmBbrImK2cqH iryEKafwWpwmMg4QWgwDSWiXmFFdVRuMvOZg96iDZ9ZWTix/QdmWjhAI7midrutkOKeN MJuf6u47/f6RDtSiTgo3uGOHaktgbSrlAQiLQoN823Qn3uGNSQiXQA/Q3/PHCNOt1WCD 9epVQ70pmFceaAe8Ps9mzPC059LIxzjtNRW4hP6A0IuNFR30ubYVFJdxSilUzSbE1SQj vinOnQhCvFvRnblvinNEQdkbS7iY4sJ20bfz88wd2iYR8wos1+avYtpY9ggajBH1OdFB rl2w== 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b21si244575ejk.520.2021.01.12.18.24.23; Tue, 12 Jan 2021 18:24:46 -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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390566AbhALSDd (ORCPT + 99 others); Tue, 12 Jan 2021 13:03:33 -0500 Received: from mga11.intel.com ([192.55.52.93]:8871 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727622AbhALSDd (ORCPT ); Tue, 12 Jan 2021 13:03:33 -0500 IronPort-SDR: /y30fUKi3fy0PsP2L6ib52cAaLwmhepf9j/3kGS0lU2T9cnRGtSV6RHKJGu2EJnnBkwftkJkYH w1Xr2Cvs+MQQ== X-IronPort-AV: E=McAfee;i="6000,8403,9862"; a="174575798" X-IronPort-AV: E=Sophos;i="5.79,342,1602572400"; d="scan'208";a="174575798" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 10:02:50 -0800 IronPort-SDR: IghNfaeOKkLonEtFV3SlDC2GPc2G7LVoov8V38TT6EAGjGeBDykr49C+0uZnWOi1b/HJT0NDd6 FpQAlxctiuGQ== X-IronPort-AV: E=Sophos;i="5.79,342,1602572400"; d="scan'208";a="404557273" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 10:02:42 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1kzO19-00C00S-FU; Tue, 12 Jan 2021 20:03:43 +0200 Date: Tue, 12 Jan 2021 20:03:43 +0200 From: Andy Shevchenko To: Saravana Kannan 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 , LKML , netdev@vger.kernel.org, Laurentiu Tudor , ACPI Devel Maling List , linux.cj@gmail.com, linux-arm-kernel , Bartosz Golaszewski , Greg Kroah-Hartman , Laurent Pinchart , Randy Dunlap Subject: Re: [net-next PATCH v3 09/15] device property: Introduce fwnode_get_id() Message-ID: <20210112180343.GI4077@smile.fi.intel.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> <20210112134054.342-10-calvin.johnson@oss.nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. ... > fwnode is lower level that the device-driver framework. Agree. > Making > it aware of busses like mdio, etc doesn't sound right. Disagree. Conceptually resource providers can be quite different and fwnode API *is* LCM for them. -- With Best Regards, Andy Shevchenko