Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp226664pxk; Wed, 16 Sep 2020 02:52:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylorfALgGZS5LiZRPFw0Fk0bC6kMI703bildCBsrfCe/ACUQ+xP4zGhH9u4fU0shcXzG/T X-Received: by 2002:a17:906:6a54:: with SMTP id n20mr25388265ejs.401.1600249935718; Wed, 16 Sep 2020 02:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600249935; cv=none; d=google.com; s=arc-20160816; b=nGXEuJpGuE/7PGx9sGX/dtgYGPHzmWfTT4KdBxZ8PObnDxW5mZfuzEvMnSRYxG4n0L MQsL0sKRlIOKUdhk+AEN+QOw5SGKFf3K7oEWu3cT2fCEjT1OTPjAtinsOTpCBpLvuE96 UFeQt9mB/9xy7y4M8fhZu4n3cSHWUyQEK8j2aaUXRlh5ZOhARH2tEeSw/s4VUWDWqHTR FDnfomzOQ9R4diW/z1/rzwC4Tl4WKY7OD+sr29EfK6VfmaxnhGfhU8qV1u+k7bJt2Tdk B+XY809bocCmCvXeJ6B37wi+Nj0gKwzxJDz079St1t7etSosOvoWEKM7BNAMSxs7xkIZ 6g/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=bboMx6ngFaZ1BJHdpO5SFh3jSPJ51Ty1Gw4ysHl6JRw=; b=wibjv6OEjGxltXFZLxv4FXHxljEMwEiN91sukGtDJgpWKEl0YRyaQJz3qjS3NCnZiS CBynxbp4ghOtFzeOIx7nMSnqAn+l8Nr21wlvnNXxta6Az63944uYWEp4e5oaZzEro2xA yPDRJKOlwBBeF26SolusP1q9aTlW8veC0Y9V6mdbomXJMCWvb0SaPzPIhuqSFMMVsghY pk6aQgOochmdoB2GZ1hBdvyqSkIOd6wi7WpTG4RbYeXTq/QaCxWJhbhF39TLQg2Bhjmu Q4tOROJYcQgIrnB4NWC4JNgUK4cYt0qXqWfmOG0sdrcJ1KyC4MYTJpxIKHzOU9oT/RtS jMpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=ns1FDdV5; 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn20si13725356ejc.342.2020.09.16.02.51.53; Wed, 16 Sep 2020 02:52:15 -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=@nvidia.com header.s=n1 header.b=ns1FDdV5; 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726425AbgIPJvL (ORCPT + 99 others); Wed, 16 Sep 2020 05:51:11 -0400 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:13196 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726610AbgIPJuT (ORCPT ); Wed, 16 Sep 2020 05:50:19 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 16 Sep 2020 02:50:04 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 16 Sep 2020 02:50:18 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 16 Sep 2020 02:50:18 -0700 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 16 Sep 2020 09:50:17 +0000 Received: from hqnvemgw03.nvidia.com (10.124.88.68) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 16 Sep 2020 09:50:17 +0000 Received: from moonraker.nvidia.com (Not Verified[10.26.74.242]) by hqnvemgw03.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Wed, 16 Sep 2020 02:50:17 -0700 From: Jon Hunter To: Bartosz Golaszewski , Rob Herring , Thierry Reding CC: , , , , Jon Hunter Subject: [PATCH V2 3/5] misc: eeprom: at24: Support custom device names for AT24 EEPROMs Date: Wed, 16 Sep 2020 10:49:50 +0100 Message-ID: <20200916094952.458003-4-jonathanh@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200916094952.458003-1-jonathanh@nvidia.com> References: <20200916094952.458003-1-jonathanh@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1600249804; bh=bboMx6ngFaZ1BJHdpO5SFh3jSPJ51Ty1Gw4ysHl6JRw=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=ns1FDdV5ks7eSYRj6Qf94TRIZQvHyNDpcQvLV6phKxSHC3fMHIi8M7UuPhxeF7g2B 3OrS3IoNAvTalGkojJYxZITDW8cZgY0CK0LV3SLjpPtt3WcjuQIWUdT6AC/7iLnioc KP5DE9VFEQTwr6zcyQlN0WLr3Z+lxNumSrnvOUboqqEKYSzdPOIliRWqUeFibETWj+ OanyrWlJYPCxvTDY7uM1QEiwmF4TT7bM4BHOqDIm4XUg6DKzp1KNt7R2TNp5vjl53E Dd8ebUrpvdHvX2as7TK9OsvKmEx2MmnGj++IyWyRbW1o2UQLjWkTg+Wvm8fssi/dwt lfPCkKqwJLoxg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By using the label property, a more descriptive name can be populated for AT24 EEPROMs NVMEM device. Update the AT24 driver to check to see if the label property is present and if so, use this as the name for NVMEM device. Please note that when the 'label' property is present for the AT24 EEPROM, we do not want the NVMEM driver to append the 'devid' to the name and so the nvmem_config.id is initialised to NVMEM_DEVID_NONE. Signed-off-by: Jon Hunter --- drivers/misc/eeprom/at24.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index f76624b5c033..305f2e13107b 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -713,9 +713,28 @@ static int at24_probe(struct i2c_client *client) return err; } =20 - nvmem_config.name =3D dev_name(dev); + /* + * If the 'label' property is not present for the AT24 EEPROM, + * then nvmem_config.id is initialised to NVMEM_DEVID_AUTO, + * and this will append the 'devid' to the name of the NVMEM + * device. This is purely legacy and the AT24 driver has always + * defaulted to this. However, if the 'label' property is + * present then this means that the name is specified by the + * firmware and this name should be used verbatim and so it is + * not necessary to append the 'devid'. + */ + if (device_property_present(dev, "label")) { + nvmem_config.id =3D NVMEM_DEVID_NONE; + err =3D device_property_read_string(dev, "label", + &nvmem_config.name); + if (err) + return err; + } else { + nvmem_config.id =3D NVMEM_DEVID_AUTO; + nvmem_config.name =3D dev_name(dev); + } + nvmem_config.dev =3D dev; - nvmem_config.id =3D NVMEM_DEVID_AUTO; nvmem_config.read_only =3D !writable; nvmem_config.root_only =3D !(flags & AT24_FLAG_IRUGO); nvmem_config.owner =3D THIS_MODULE; --=20 2.25.1