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=-4.0 required=3.0 tests=BAYES_00,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 05FAEC433DB for ; Fri, 22 Jan 2021 18:41:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CAEDC23ABA for ; Fri, 22 Jan 2021 18:41:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729048AbhAVSl0 (ORCPT ); Fri, 22 Jan 2021 13:41:26 -0500 Received: from mail-oi1-f169.google.com ([209.85.167.169]:33649 "EHLO mail-oi1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729481AbhAVSNN (ORCPT ); Fri, 22 Jan 2021 13:13:13 -0500 Received: by mail-oi1-f169.google.com with SMTP id j25so1531962oii.0; Fri, 22 Jan 2021 10:12:32 -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=2w1MGZ9mEKOeW8Sp4+SROoauRQHqq4ffMB/bBOfyNEw=; b=ORlX412qKrgV4JxTUpFT7Q3WyB+zYa+fLa0Bs9LScPIOK5sjcx1NWchZeaWv9nSvux PtrkdwDPKtWms7X7u36XxQTNSFj7xOjO419EFlN0QKlUbyPd+ttPaSMl3iSmGNSP0n0u kbHkMjbX/H+tImVw5oTJYABK7QGUPkIoNJJDpXTIn1plWzk555DzsVKJ6ZoJ8AiXA6D8 nC1s93Fvjdi6udPfV/Ev/AP7J4cExVTcxhDC2xn+WJ9WVoMSDWXyNQUJIfSzqAKXuKv2 BhfwH6uNUWh1vQ3a0Em+62V5suvPKyFZ/Iv+UWheVm46k/H4QG1TwQOvUB21iU6HpkDD nBpg== X-Gm-Message-State: AOAM532PKjiRrHDdw9Lk9DzL2J0ebAuh7HxecvV+yQgLDQLtHoHhe6Fm 2zP6hDDyjxI9zQosRde3wPra9dqkxYTfYtWv1bQ= X-Google-Smtp-Source: ABdhPJy91RVudidWYxELqnygUSA2p+C95kGYOGIrI1wvFq4TZMb7X0SCn3XrnZILhPOJoQqW++x7/SLKAYPKkqA3EOQ= X-Received: by 2002:aca:308a:: with SMTP id w132mr3993915oiw.69.1611339127524; Fri, 22 Jan 2021 10:12:07 -0800 (PST) MIME-Version: 1.0 References: <20210122154300.7628-1-calvin.johnson@oss.nxp.com> <20210122154300.7628-10-calvin.johnson@oss.nxp.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Fri, 22 Jan 2021 19:11:56 +0100 Message-ID: Subject: Re: [net-next PATCH v4 09/15] device property: Introduce fwnode_get_id() To: Andy Shevchenko Cc: "Rafael J. Wysocki" , Calvin Johnson , Grant Likely , 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 , Saravana Kannan , Randy Dunlap , "linux.cj" , Diana Madalina Craciun , ACPI Devel Maling List , Linux ARM , Linux Kernel Mailing List , netdev , Laurentiu Tudor , Bartosz Golaszewski , Greg Kroah-Hartman , Kieran Bingham , Laurent Pinchart Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Fri, Jan 22, 2021 at 6:12 PM Andy Shevchenko wrote: > > On Fri, Jan 22, 2021 at 05:40:41PM +0100, Rafael J. Wysocki wrote: > > On Fri, Jan 22, 2021 at 4:46 PM Calvin Johnson > > wrote: > > > > > > Using fwnode_get_id(), get the reg property value for DT node > > > or get the _ADR object value for ACPI node. > > > > So I'm not really sure if this is going to be generically useful. > > > > First of all, the meaning of the _ADR return value is specific to a > > given bus type (e.g. the PCI encoding of it is different from the I2C > > encoding of it) and it just happens to be matching the definition of > > the "reg" property for this particular binding. > > > IOW, not everyone may expect the "reg" property and the _ADR return > > value to have the same encoding and belong to the same set of values, > > I have counted three or even four attempts to open code exact this scenario > in the past couple of years. And I have no idea where to put a common base for > them so they will not duplicate this in each case. In that case it makes sense to have it in the core, but calling the _ADR return value an "id" generically is a stretch to put it lightly. It may be better to call the function something like fwnode_get_local_bus_id() end explain in the kerneldoc comment that the return value provides a way to distinguish the given device from the other devices on the same bus segment. Otherwise it may cause people to expect that the "reg" property and _ADR are generally equivalent, which is not the case AFAICS. At least the kerneldoc should say something like "use only if it is known for a fact that the _ADR return value can be treated as a fallback replacement for the "reg" property that is missing in the given use case". > > so maybe put this function somewhere closer to the code that's going > > to use it, because it seems to be kind of specific to this particular > > use case? 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=-4.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 5CCB0C433E0 for ; Fri, 22 Jan 2021 18:13:47 +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 1DA1F23A9C for ; Fri, 22 Jan 2021 18:13:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DA1F23A9C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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=MqpukHFjSQ4CqNVSWGOW9kC/w6R6Q9B5igb6WMSyg9g=; b=xLkeBFC6R+qkeNG7dZnRnnVZs l0pVeC3QYJPs/y4ifKpJO0SDUr6qNj90iOUFW+G4LFivaphv3L5a7DY4+2aDaeYDU5U344qj5wHzZ 1ztpFPCz7KiQeKkVLz9ez8RvGB9LNAo3SgHWJlQ2kJEsx9usR5wVS4Wp8RFTMZAj5yjCU6SZKOdrH ZItPYHfGKVfWsf/C+tYPezAd2w/7EFZzVsao82aKBgIUh6qcq3ghHvCAH+LvEnWwpK9ym+77ysW7A 57Fa9C0CnbxsTKN616HuRR/kAlLF5tRHbhNHIxSq5hmYsbenbVmpYUv8oOX1MMWf/9TiJd3h2S5vs W3ZkBiVKA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l30uo-0000Kh-IV; Fri, 22 Jan 2021 18:12:10 +0000 Received: from mail-oi1-f181.google.com ([209.85.167.181]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l30um-0000FK-Kj for linux-arm-kernel@lists.infradead.org; Fri, 22 Jan 2021 18:12:09 +0000 Received: by mail-oi1-f181.google.com with SMTP id h192so6979913oib.1 for ; Fri, 22 Jan 2021 10:12:07 -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=2w1MGZ9mEKOeW8Sp4+SROoauRQHqq4ffMB/bBOfyNEw=; b=Fmwy/gv6kv0KxcI/dIKx9l+2HjSbEbwDTfvAVn1dLgs3sKhtjJ7rf4oDECjZponApU VrbkOO0Mk56zA25Rv6yAHndLDP2w0fXxpygkwDlcfOV7aN+bX2SUnPrt5Q6rlj/X597a eBXOrcuFGmQx1LrQ2kxk46A7SCeQIM0E4VV+do/MW34v/+akQrcGArJbyWEW1tqn5PEH SfZHyrip4mX85bV7o3qC0enpfGPtkt0rmX/FdNPYzlO1oKH6HJDT+pLY5rTU7N3kgtAC 8JVOmwFNVz/zjBEwIkDNX4uwuLXzdjG9ccKkJ9e3nxYRGWeeY9oXzpVFELuiYOpJH8gM wLUQ== X-Gm-Message-State: AOAM532/nCuf1YdNwG/5nL02BrIBaJdFCQFFIA9g66B3T9XloDXCRXNz OSLIGHaUKKk5lqNlCofCHdYQUefpKWy1WaDOvRA= X-Google-Smtp-Source: ABdhPJy91RVudidWYxELqnygUSA2p+C95kGYOGIrI1wvFq4TZMb7X0SCn3XrnZILhPOJoQqW++x7/SLKAYPKkqA3EOQ= X-Received: by 2002:aca:308a:: with SMTP id w132mr3993915oiw.69.1611339127524; Fri, 22 Jan 2021 10:12:07 -0800 (PST) MIME-Version: 1.0 References: <20210122154300.7628-1-calvin.johnson@oss.nxp.com> <20210122154300.7628-10-calvin.johnson@oss.nxp.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Fri, 22 Jan 2021 19:11:56 +0100 Message-ID: Subject: Re: [net-next PATCH v4 09/15] device property: Introduce fwnode_get_id() To: Andy Shevchenko X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210122_131208_700720_6B5E0099 X-CRM114-Status: GOOD ( 26.95 ) 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" , Grant Likely , Calvin Johnson , Ioana Ciornei , Florian Fainelli , Saravana Kannan , Bartosz Golaszewski , Jon , Russell King - ARM Linux admin , Diana Madalina Craciun , ACPI Devel Maling List , Kieran Bingham , Laurentiu Tudor , Madalin Bucur , Pieter Jansen Van Vuuren , Laurent Pinchart , Marcin Wojtas , Linux ARM , Florin Laurentiu Chiculita , 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 Fri, Jan 22, 2021 at 6:12 PM Andy Shevchenko wrote: > > On Fri, Jan 22, 2021 at 05:40:41PM +0100, Rafael J. Wysocki wrote: > > On Fri, Jan 22, 2021 at 4:46 PM Calvin Johnson > > wrote: > > > > > > Using fwnode_get_id(), get the reg property value for DT node > > > or get the _ADR object value for ACPI node. > > > > So I'm not really sure if this is going to be generically useful. > > > > First of all, the meaning of the _ADR return value is specific to a > > given bus type (e.g. the PCI encoding of it is different from the I2C > > encoding of it) and it just happens to be matching the definition of > > the "reg" property for this particular binding. > > > IOW, not everyone may expect the "reg" property and the _ADR return > > value to have the same encoding and belong to the same set of values, > > I have counted three or even four attempts to open code exact this scenario > in the past couple of years. And I have no idea where to put a common base for > them so they will not duplicate this in each case. In that case it makes sense to have it in the core, but calling the _ADR return value an "id" generically is a stretch to put it lightly. It may be better to call the function something like fwnode_get_local_bus_id() end explain in the kerneldoc comment that the return value provides a way to distinguish the given device from the other devices on the same bus segment. Otherwise it may cause people to expect that the "reg" property and _ADR are generally equivalent, which is not the case AFAICS. At least the kerneldoc should say something like "use only if it is known for a fact that the _ADR return value can be treated as a fallback replacement for the "reg" property that is missing in the given use case". > > so maybe put this function somewhere closer to the code that's going > > to use it, because it seems to be kind of specific to this particular > > use case? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel