From patchwork Thu Jul 1 15:28:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 469265 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=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham 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 B8FCAC11F64 for ; Thu, 1 Jul 2021 15:28:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 833286140A for ; Thu, 1 Jul 2021 15:28:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233064AbhGAPbL (ORCPT ); Thu, 1 Jul 2021 11:31:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31322 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232969AbhGAPbL (ORCPT ); Thu, 1 Jul 2021 11:31:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625153319; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DmXj8caY15pwsQgjtiEZnmZUg1bkwyeXw/rOXNl13yM=; b=Z8AELCkClhgSNY4shKNxMn1Ei1ZCYFo2QRQ0AbJHS/InYhK1OhGAKHNOFMUjqAFO2biCGP VLhVrOcSakDeyiqtDAVrSQKx9ofKKQ36wLKjpYIYB9cDqKUwzVP6PP/7EvED3YVfqxVR/n Kr36mpW3/ADZf1+zXVLpXpkrmrpgA9Y= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-2j6XOe-zPpK98edlVNmnrw-1; Thu, 01 Jul 2021 11:28:38 -0400 X-MC-Unique: 2j6XOe-zPpK98edlVNmnrw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7C42B19611AE; Thu, 1 Jul 2021 15:28:36 +0000 (UTC) Received: from fedora.hsd1.ca.comcast.net (ovpn-116-250.rdu2.redhat.com [10.10.116.250]) by smtp.corp.redhat.com (Postfix) with ESMTP id 233C85C22B; Thu, 1 Jul 2021 15:28:31 +0000 (UTC) From: jglisse@redhat.com To: linux-kernel@vger.kernel.org Cc: =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Diego Santa Cruz , Bartosz Golaszewski , Jon Hunter , stable@vger.kernel.org, linux-i2c@vger.kernel.org Subject: [PATCH] misc: eeprom: at24: Always append device id even if label property is set. Date: Thu, 1 Jul 2021 08:28:25 -0700 Message-Id: <20210701152825.265729-1-jglisse@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Jérôme Glisse We need to append device id even if eeprom have a label property set as some platform can have multiple eeproms with same label and we can not register each of those with same label. Failing to register those eeproms trigger cascade failures on such platform (system is no longer working). This fix regression on such platform introduced with 4e302c3b568e Signed-off-by: Jérôme Glisse Cc: Diego Santa Cruz Cc: Bartosz Golaszewski Cc: Jon Hunter Cc: stable@vger.kernel.org Cc: linux-i2c@vger.kernel.org Tested-by: Alexander Fomichev --- drivers/misc/eeprom/at24.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 7a6f01ace78a..305ffad131a2 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -714,23 +714,20 @@ static int at24_probe(struct i2c_client *client) } /* - * 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'. + * We initialize nvmem_config.id to NVMEM_DEVID_AUTO even if the + * label property is set as some platform can have multiple eeproms + * with same label and we can not register each of those with same + * label. Failing to register those eeproms trigger cascade failure + * on such platform. */ + nvmem_config.id = NVMEM_DEVID_AUTO; + 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); }