Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1259607pxb; Fri, 22 Jan 2021 10:48:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwL3tQnAN5b56zqOaDQgnKutd9rkJDBkUQVuIUbknOBnK99aRn9cVxgPuThATlBqOtg5uZ3 X-Received: by 2002:a05:6402:b68:: with SMTP id cb8mr4207955edb.346.1611341299582; Fri, 22 Jan 2021 10:48:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611341299; cv=none; d=google.com; s=arc-20160816; b=ywCC92ebr+TWPaqyJ4JsB7x9JObtxxDWm9reUWIQuaO17pX4cABOpOK/2Oi6c1cF5A bH5pjWOuS8mAnugofYWljpoBnOHzIuGwuEvQH35sF2xhcnHxLNdpwEnTlwd52gmz6W8V WtY+2ruPqyzmfbM43MO7QnX0qMApxIIkxUqCmTTSlYLXRPJEukqBcT2xU65zxBuWyEf9 eK+5R1+AkbzPMtQ8VTI1b+A0MtV3YvSnKqkZYjaHVWLKRnVwC26PZq6gBpkHkfdgpWop uXE5T3SUlVxzTlYc8x+kOAhTDapZb/tCNjsP9zmylTFBmBypQGrRXZyU0J8e6AYcF0JD ylDw== 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=2w1MGZ9mEKOeW8Sp4+SROoauRQHqq4ffMB/bBOfyNEw=; b=DES0eDJCGMsDauryuDHZEp1PBZ9tPXyS9tek94cRARWiFo5FucsN7Xztrzje2v2lzZ wZMnjl0me3PEFg17wedINfEoCQ3w5GW8IXkrS5rdDwC/NHqyZUPOYdwLJnXxQeceEymK uPdUYuB+9ig2IYVyTDEcxKWQbITKpsrDfYrJfsL5SvpWtt17W0dWZxJcyfpScNgqkuD8 tHFME+0uQKEtsOB33qNA4bnvFq2+eiKnbKD+amxhFgkKaEl93zqJx+LdqYjm2yJEcpaz TEEtTEFuNVrIlYhqAFKyunWABzhgISgzX/shQhCYjAVfBT9od56Cg4yy9tU1a9DL9l9r U9Sg== 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 u20si3678565edv.129.2021.01.22.10.47.55; Fri, 22 Jan 2021 10:48:19 -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 S1729793AbhAVSrS (ORCPT + 99 others); Fri, 22 Jan 2021 13:47:18 -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-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-kernel@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?