Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp87059pxk; Fri, 11 Sep 2020 00:48:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIEIOX4DqUIlwVkfB7viPcYDNRHXDDRp6vCDuGFHgHnfeAX0iTbJFCQA8jjaDjQBCpgP+p X-Received: by 2002:a17:906:819:: with SMTP id e25mr842916ejd.211.1599810485725; Fri, 11 Sep 2020 00:48:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599810485; cv=none; d=google.com; s=arc-20160816; b=WWVcZoTsrD8O/7qxUPsCQujGADg1Ojif2VtqK7Ntqbcupbdf/8g/SXXYLF4ZeJ6U7X hWBGWCyHmYJhOdG0Amrp7pryhs7gJTUOgtYXFZdk6bZXRIQ4F5KlYaRwdQGL1Nb2UVrt 5qxaIeU0nTFiypEwx4fcP4YkqZWkvcVlAKKKleAhAJt/vScA9PTZDMZ9U1Gp31dqdtoq Jf9XpLBaqRd4i4Vtidg96ke18pjwySQypiJDjeiD9qEQN7o126SpprYFfO0WIqgOWp3T s9zG1k1e887x8tEkEHSPe1kTTWtizpGY4541aA1aLzROOM2aM+hh9WxBmNAftSxBBFTJ 385g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=H10t/PoYzFp2YJmus+JauG6BT44xTI8He+24ZzfKGuc=; b=iUM1b8gH++kcEEBfRXni6CuO9tkri2KA4JfnFKm6luVcneUVBW0j6A9IBTG+VfZVG8 es8BhC0Or2vLQrSSveMlljJ3yVQ2Y+CB9RM6M62oiNez0T3JarmGyo9LNF4v7hwH1641 8pDD0FkD2boxUHCB6bY79V8CAOW0nKqps6HRoyK/WYqDDNtNO9P57z21eWfhu16FeuKS 51vQlkXrRaKhSF9SNEnofwS6nsaSwYReDqvpfNs/W9zobFjyFylq2gtHeMdWOfwX9svz qjgdUydW4VsTOWaBkWzDJ4v3IBCrYjuUcDK7W3tTiPXiRWDANJ3TkCgAgi8XFJa9K9C3 pZCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=iJSfcSRD; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si784110ejt.59.2020.09.11.00.47.42; Fri, 11 Sep 2020 00:48:05 -0700 (PDT) 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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=iJSfcSRD; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725820AbgIKHqR (ORCPT + 99 others); Fri, 11 Sep 2020 03:46:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725601AbgIKHp6 (ORCPT ); Fri, 11 Sep 2020 03:45:58 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98E73C0613ED for ; Fri, 11 Sep 2020 00:45:56 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id w1so9020790edr.3 for ; Fri, 11 Sep 2020 00:45:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=H10t/PoYzFp2YJmus+JauG6BT44xTI8He+24ZzfKGuc=; b=iJSfcSRDOI0uj91Wf8MfSv/rALU7QF9mAKdWgTtdYgxxMFt80M8rsPWnXsXYMzUpZK xHebxWWZTzyE/epGDO1WpaKpE8SOrd0QpZqajO8z3MCuct47/WoledDN2wrpFrTVsELB C/Dyw6kPcsR4JDILPM/nBFjJEI3h0YHOinecmu1KOgC5RsTbTTEEaZwZDv4YHbWn9RIm ZviGWZDSck3+GZAMoo2bfIS1Lxd32PEiG9+OLmj4P9a/W52MoUUrfQmqYprssftujuh9 DmCIv8Yi1GSnT8yjI/bThPIVd20V7UVAMCV+ydLH3qveG2n2iguoJxEkaBA2PVarhCv6 2M+A== 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=H10t/PoYzFp2YJmus+JauG6BT44xTI8He+24ZzfKGuc=; b=KmYBNB9NtDT7lt32KoPBMlp8Ck23SZ3QVrWrzdd7S+YoMVGqWwMKPBlUnUEXxwLY3t x+RDYyll9w1SJS4bnWxdeiwpdzLvXkpQk5qamm+fAJheHPB9cyc5t7tLc0YJLbAkfa6o 4jwzn4cyb15BDdUfQ+xKAhEbPZrSxyN0eMfzsTFn9en5699S0lAooL53UkmNlZZ6JjWi d12t1BWxROnhEcZiaX5z2JpCeeEI40wExHHf4432jdxwbNKYWwMtLgvWuE0q2HMR3Nbk aqlYicLsqXDBsEM6qdY6E/mOzdC/N2LdZ3ZNmEy/NLuZmceXOtlh2g55QUZJbAHvEw5J KIfw== X-Gm-Message-State: AOAM533NBkZXQJ7GFqf/lE1Mu9YH2iucMj/eD2uboWr4ZzX74yjs31JR mTScc3/YplzIZKJrWYfdOkYTOnXfOvr1AJyb2HSIaA== X-Received: by 2002:a50:e79c:: with SMTP id b28mr712767edn.371.1599810354627; Fri, 11 Sep 2020 00:45:54 -0700 (PDT) MIME-Version: 1.0 References: <20200910134239.192030-1-jonathanh@nvidia.com> <20200910134239.192030-2-jonathanh@nvidia.com> <88021f57-b8cf-d3d6-0e9c-19ed0bccb729@nvidia.com> <5afe9537-dc50-16ff-028e-b4539c6f924a@nvidia.com> In-Reply-To: <5afe9537-dc50-16ff-028e-b4539c6f924a@nvidia.com> From: Bartosz Golaszewski Date: Fri, 11 Sep 2020 09:45:43 +0200 Message-ID: Subject: Re: [PATCH 1/5] misc: eeprom: at24: Initialise AT24 NVMEM ID field To: Jon Hunter Cc: Rob Herring , Thierry Reding , linux-i2c , LKML , linux-devicetree , linux-tegra@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 10, 2020 at 8:19 PM Jon Hunter wrote: > > > On 10/09/2020 19:15, Jon Hunter wrote: > > > > On 10/09/2020 16:35, Bartosz Golaszewski wrote: > >> On Thu, Sep 10, 2020 at 3:43 PM Jon Hunter wrote: > >>> > >>> The AT24 EEPROM driver does not initialise the 'id' field of the > >>> nvmem_config structure and because the entire structure is not > >>> initialised, it ends up with a random value. This causes the NVMEM > >>> driver to append the device 'devid' value to name of the NVMEM > >>> device. Although this is not a problem per-se, for I2C devices such as > >>> the AT24, that already have a device unique name, there does not seem > >>> much value in appending an additional 0 to the I2C name. For example, > >>> appending a 0 to an I2C device name such as 1-0050 does not seem > >>> necessary and maybe even a bit confusing. Therefore, fix this by > >>> setting the NVMEM config.id to NVMEM_DEVID_NONE for AT24 EEPROMs. > >>> > >>> Signed-off-by: Jon Hunter > >>> --- > >>> drivers/misc/eeprom/at24.c | 1 + > >>> 1 file changed, 1 insertion(+) > >>> > >>> diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c > >>> index e9df1ca251df..3f7a3bb6a36c 100644 > >>> --- a/drivers/misc/eeprom/at24.c > >>> +++ b/drivers/misc/eeprom/at24.c > >>> @@ -715,6 +715,7 @@ static int at24_probe(struct i2c_client *client) > >>> > >>> nvmem_config.name = dev_name(dev); > >>> nvmem_config.dev = dev; > >>> + nvmem_config.id = NVMEM_DEVID_NONE; > >>> nvmem_config.read_only = !writable; > >>> nvmem_config.root_only = !(flags & AT24_FLAG_IRUGO); > >>> nvmem_config.owner = THIS_MODULE; > >>> -- > >>> 2.25.1 > >>> > >> > >> This patch is correct and thanks for catching it. I vaguely recall > >> wondering at some point why the appended 0 in the nvmem name for at24. > >> Unfortunately this change would affect how the device is visible in > >> user-space in /sys/bus/nvmem/devices/ and this could break existing > >> users. Also: there are many in-kernel users that would need to be > >> updated. I'm afraid we'll need some sort of backward compatibility. > > > > > > Thanks, yes that is a problem. I guess for now we could explicitly init > > to NVMEM_DEVID_AUTO or maybe just 0 so that it defaults to the same path > > in the NVMEM driver. However, I am not sure how we can make allow some > > devices to use NVMEM_DEVID_NONE and others use something else. This is > > not really something that we can describe in DT because it has nothing > > to do with h/w. > > > Unless we make the configuration of the 'id' dependent on the 'label' > property so something like ... > > if (device_property_present(dev, "label")) { > nvmem_config.id = NVMEM_DEVID_NONE; > err = device_property_read_string(dev, "label", > &nvmem_config.name); > if (err) > return err; > } else { > nvmem_config.id = NVMEM_DEVID_AUTO; > nvmem_config.name = dev_name(dev); > } > > Cheers > Jon > > -- > nvpublic Yes, this looks like the best compromise we can get for now. Please make sure to document why we do this in the code. Bartosz