Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3564934pxu; Tue, 15 Dec 2020 09:51:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvsLqHWEGfR9jGFUaygXI/ShmDtME+G+Dj7Dm3GQcRmEdFTK4Gon73moQeeSw/U+QKn/p8 X-Received: by 2002:a05:6402:2377:: with SMTP id a23mr3505610eda.34.1608054712478; Tue, 15 Dec 2020 09:51:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608054712; cv=none; d=google.com; s=arc-20160816; b=N3nfu77egUwu/DHWamW6BwdOuWHIIijg9m4joddw1OMoIw0I1i+0LxVLxZiswHvCgD idugH32+2NAOIi/Kd8s2gMlbTNes9y/G1nK/wJMpDKlyZD1kNYBibfmPxs9b7P5g8pmR XfQ9uaxZBQMlMvTBzZM26lifE0E4cNV4glUguFaJU1yFurh3FgUnLn+iDYHd9tZWhPV+ 8c4NiE4ol6lS5E/BSAi45sfK/kHLjpwsKsosnO0E3lkVdrbAikGkEpnt/JzRpHrJ7Ntf fKMhZ9vGNB7EcDXnlkf8oU3sN4itlff10aY2HF2ZbBIc3OpEqAbDLwPA1FhRX3XbcE9b XOMw== 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=s9+zKZ0t51Yi4UpYePVg2qU/uZjrDKprhqn56lhIt7U=; b=lbdHz5qEA6yuChLz+vis1nUDpahnrNcWYIhF8megk/hEBq4D68gu0kFO0KcwSkCxYB SHsogBJWt56aZa9UhZtB4ZfiP2FIGBQunlXulSbNtukP1oAltYAJQZZgo1g6v9Z9TA+E k5BPtOJwzv4GznTKAg1chvcFiVdv1pmVODI9HycFE5rDplGiBJ6q0jFd+01bVlMqVBx2 ElJQNWvkoHWLitxMVzd4QqSWJD+T84Iqt6VQFnADku/3wiFLMktUPLpynNKsQP2g+4NQ dof88x2eTjclY3zVvtOF4MuXkv3C+pBXFVfBlGjviIRYS4nYt8WRZxR6dTcoS886t6Cz x10g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="g/qgg+hY"; 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=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 s6si1277033ejb.276.2020.12.15.09.51.27; Tue, 15 Dec 2020 09:51:52 -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=@gmail.com header.s=20161025 header.b="g/qgg+hY"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731149AbgLORtH (ORCPT + 99 others); Tue, 15 Dec 2020 12:49:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730636AbgLORtG (ORCPT ); Tue, 15 Dec 2020 12:49:06 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 912BDC06179C; Tue, 15 Dec 2020 09:48:26 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id t22so5547327pfl.3; Tue, 15 Dec 2020 09:48:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=s9+zKZ0t51Yi4UpYePVg2qU/uZjrDKprhqn56lhIt7U=; b=g/qgg+hYJxwJ1wiJKO0C59GAodEnrbrvnncGyWVdQhjNsrQWrZAtSpFUEnVlkHjS4U /L9Vw6pBy2ay+Kxr7ExcGX8tVyKfmeaI/tQz8QcaSt8Vl4NgOztUVOFepe45SuVaWyhi 0JAsdS/kAZVW1arB0DCTGqI3XSX6LqrBVrXIul5EYnVXWiMXP32y7APu6gsNGXKVntDA pwJcgOjGNfTBNnxuIpR2G0Ryhg95ZfdFN0sLmZONwysP+Vus7c1SIhl294KctE05ZSTg B9gHIuCweJHtShSNzDQddRfLNFfuWMZRjykFvP2c1c9u15biGP0tXQEPEziGccXaM5Wn WJNg== 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=s9+zKZ0t51Yi4UpYePVg2qU/uZjrDKprhqn56lhIt7U=; b=pU96pSjGnGRyd0xS4ntY7f0gUT5tG1YPu/wpCCgcDQGar7uXLiDubAeq3rfOw1xqpr n9R4K4bO9/QalgVJJkVdw1u1ejMWsviMxHZaDS027yKqL60EvB7RX0GYWKVwfIx3xp4I LBV1JNgtZWmCkHRuk7VzNzcyNQDz6ckqusOcwHh4mBED/bvFkmkVu1L4JZbjrXgZ9YtS OwKnpbzTAg5Zyqew0sNPzXU3KVlyr3wfkyajahNfhi5RFXYF78j9hODl5c5kodPkjEDI oUuPIqHOALK7ezhLFo/8KY+VWVOsjaSC4d7Wyon4quAtG3CN+2JvsldwMMQTRmWvFR0m n9AA== X-Gm-Message-State: AOAM531WsD2H7ahny3CYgVwmfPwzIBZCkLY69UPcGdid+L/G5N1+9o1l MoLDTMc0k1ppClKSyRGBr/HcwR7IeoO4hLY4wsw6uUdivzk= X-Received: by 2002:a62:19cc:0:b029:19e:321b:a22e with SMTP id 195-20020a6219cc0000b029019e321ba22emr22353379pfz.73.1608054506066; Tue, 15 Dec 2020 09:48:26 -0800 (PST) MIME-Version: 1.0 References: <20201215164315.3666-1-calvin.johnson@oss.nxp.com> <20201215164315.3666-11-calvin.johnson@oss.nxp.com> In-Reply-To: From: Andy Shevchenko Date: Tue, 15 Dec 2020 19:49:14 +0200 Message-ID: Subject: Re: [net-next PATCH v2 10/14] device property: Introduce fwnode_get_id() To: Laurent Pinchart , Rob Herring 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 , "linux.cj" , Laurentiu Tudor , Diana Madalina Craciun , ACPI Devel Maling List , Linux Kernel Mailing List , linux-arm Mailing List , netdev , 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, Dec 15, 2020 at 7:00 PM Laurent Pinchart wrote: > On Tue, Dec 15, 2020 at 10:13:11PM +0530, Calvin Johnson wrote: > > Using fwnode_get_id(), get the reg property value for DT node > > and 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 > > Is the concept of fwnode ID documented clearly somewhere ? I think this > function should otherwise have more documentation, at least to explain > what the ID is. I'm afraid that OF has no clear concept of this either. It's usually used as a unique ID for the children of some device (like MFD) and can represent a lot of things. But I agree it should be documented. Rob, any ideas about this? > > + * Returns 0 on success or a negative errno. > > + */ > > +int fwnode_get_id(struct fwnode_handle *fwnode, u32 *id) > > +{ > > + unsigned long long adr; > > + acpi_status status; > > + > > + if (is_of_node(fwnode)) { > > + return of_property_read_u32(to_of_node(fwnode), "reg", id); > > + } else if (is_acpi_node(fwnode)) { > > + status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(fwnode), > > + METHOD_NAME__ADR, NULL, &adr); > > + if (ACPI_FAILURE(status)) > > + return -ENODATA; > > Would it make sense to standardize error codes ? of_property_read_u32() > can return -EINVAL, -ENODATA or -EOVERFLOW. I don't think the caller of > this function would be very interested to tell those three cases apart. > Maybe we should return -EINVAL in all error cases ? Or maybe different > error codes to mean "the backend doesn't support the concept of IDs", > and "the device doesn't have an ID" ? We may actually get mapping to all three if first we check for the method/name existence followed by value check. But I don't think we need to bloat this simple one. > > + *id = (u32)adr; > > + return 0; > > + } > > + return -EINVAL; > > +} -- With Best Regards, Andy Shevchenko