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=-2.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 9767BC2BB9A for ; Tue, 15 Dec 2020 17:49:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 615962076D for ; Tue, 15 Dec 2020 17:49:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730771AbgLORtH (ORCPT ); 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-Google-Smtp-Source: ABdhPJzymc6jnpVMoKVo8nxL5P6Vbt77JXltH1HwbknkAaR4p5CWR5f4ROkpxYPU6o8UTlWDPtsR0WAYGpRbRDJv6Oo= 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-acpi@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 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=-0.7 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 C6E9BC4361B for ; Tue, 15 Dec 2020 17:49:51 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 83C712076D for ; Tue, 15 Dec 2020 17:49:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83C712076D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VQRAtc2ODC77R056j+P0R8mwGdYDBG6Wmu5i0y+/SXs=; b=fA12VcxANs90K2SdPeUVvePnL 5WRCaR1Nkg/qfwXArZ3UCLivcdLKZ6WaQggYAtY/EeWoD9Pzn+e0SRjf/xRsGcS7CucJe3uk9BxJN CZ3ZOXxy3Qo1BgMaU3pW1inzjaCeXBSDWH/uCyWbcbO6w55SrGy1HtcsIunebT7R2kcmSclgeoKlv Aob0Sq73NT749Rq6aPGTbtXhnh26iACP6oFkbz7f+30dWpjL12ijp1GDGMKygSty9Tte7/97Q4wZa WDZpwmBIrciNqhc77oRQ6aFzZnjhYXfaOI5M34qQA7yNJgQXO9+OkuqxAT09K8jT7GZdh3JFyA411 QWnJsLtcQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpER3-0000q6-PM; Tue, 15 Dec 2020 17:48:29 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpER2-0000p9-0p for linux-arm-kernel@lists.infradead.org; Tue, 15 Dec 2020 17:48:28 +0000 Received: by mail-pg1-x544.google.com with SMTP id w16so15719314pga.9 for ; Tue, 15 Dec 2020 09:48:27 -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=HyJpCP+gt3Lb+3WE1bPuDdrUye6k+Md+ZPwJsuBYb1XAcdYsF07zuFdnDL6OehHGIm Tmw/jtYCtakcaeDSLrhMva6BJbU40sLXX3VNXAv8C3YmIhvHulQRWw/yqRL1MEEo8ekT S1WC67ZnkDDGAvuF/jBECU5rOqhXYpg8ZPf3MpG0KF96j2z0yS8mE3Ak2LwTEx77u86Y vU58mlWq8/fmeFg4QcB3GQkqrPGJMxm2fgsHYaV+Pbrc0Qk7hOgruVwdaoek10j4TU7p QRtx6EOOP1ElA2YTIJkAjul/yyXa0KvcOQQRKQaJOh4CnoVaa4U/43epTe//LVYDiNhQ QwCw== X-Gm-Message-State: AOAM5338FDgr33h/gbjmjNIPyR31dpTF3s4wXWVulc0q+BgoDo7WjwD2 eNE4Cc8cUxuJOPIkZczaNWzXg1c7Qp08kiYroKU= X-Google-Smtp-Source: ABdhPJzymc6jnpVMoKVo8nxL5P6Vbt77JXltH1HwbknkAaR4p5CWR5f4ROkpxYPU6o8UTlWDPtsR0WAYGpRbRDJv6Oo= 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201215_124828_080299_7CC77FB0 X-CRM114-Status: GOOD ( 25.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Heikki Krogerus , "Rafael J . Wysocki" , Andy Shevchenko , Grant Likely , Calvin Johnson , Ioana Ciornei , Florian Fainelli , Bartosz Golaszewski , Jon , Russell King - ARM Linux admin , Diana Madalina Craciun , ACPI Devel Maling List , Florin Laurentiu Chiculita , Madalin Bucur , Pieter Jansen Van Vuuren , Laurent Pinchart , Marcin Wojtas , linux-arm Mailing List , Laurentiu Tudor , netdev , Randy Dunlap , Linux Kernel Mailing List , Jeremy Linton , Cristi Sovaiala , "linux.cj" , Greg Kroah-Hartman Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel