From patchwork Wed Mar 8 08:20:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 66104 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp213005wrd; Wed, 8 Mar 2023 00:44:36 -0800 (PST) X-Google-Smtp-Source: AK7set/YM5ZiR+HlHKpsyDUnllgw5fUNYVcb7TrCPx/hpLIwvoqhcEwFhYe0w6qtc9upvhAfbbTI X-Received: by 2002:a50:ed83:0:b0:4c3:4da1:3df8 with SMTP id h3-20020a50ed83000000b004c34da13df8mr15266967edr.17.1678265075971; Wed, 08 Mar 2023 00:44:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678265075; cv=none; d=google.com; s=arc-20160816; b=TTOZP8/Dbxr3vwzDrRsp6dryWh5yoi97aBQHt18RlT6tCqWgxeQyI4vSDm3fiOSrDC +s8raeOfRCSxsBk0UhdyU8iRone0eQzQcvsj3eamJgN5rn/UgG3kkkevLhZmSGKDjsa1 bX46KMUsAOa8VK6s3eKgFwLFX7o2QmtjkO5bKDTiHPIDkUlCqelJ1WmuVpsM25Vrc8J5 uK12iKAPsn5Ihy0i0Q+T/RjqKxAu6myXSaPcI4x8eXH8tCIuk04prfPqzGHF3uoOS0hL EL5eTpmUYI6AzK1aNRggU78fX2+AfXUN9tGXsUe+8CaysZuR/I78st5RDM6TEtR5eSgH mw7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=yET4dLTaObig7qd5g7VQ441qs/AE4iGVqJGo9VFvELM=; b=SLX2FRWxsFvIDa6zHLC8L2JJ2+i4erMkjqxBXj2YTeGyoXVIxR8gdwaeO6zj0Ijwl2 hojGZDepFmDtd/Ovellx9s6whp+KiLx2nz9o9y4DD8m4aqqJ0bVJjA2KdkPciS4xT2FI O36NGgvB2vD90KajYnXhHM/MZdQv789U1lGom4vZiEJVZPNL5aNhi7p9Dcf4K7RNTs3w k/UHgNHnSWktRhipavTkr1/UqZgTeGepNp+LcWBtm+K0C2SebSUpmR9pZ/RVxwNpL3Zi 3BjCxd6CknjKpdTz4F3yyVdEx7QmKO1if7fgUulfWlPguDfFZIzr2rpM+1h2jLu4Ca5T 0yaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=Yw7ZU0D5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020aa7c403000000b004aab3450a00si4348742edq.498.2023.03.08.00.44.12; Wed, 08 Mar 2023 00:44:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=Yw7ZU0D5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230117AbjCHIVy (ORCPT + 99 others); Wed, 8 Mar 2023 03:21:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230129AbjCHIVN (ORCPT ); Wed, 8 Mar 2023 03:21:13 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDAF0B1B0F; Wed, 8 Mar 2023 00:20:39 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id EC788164F; Wed, 8 Mar 2023 09:20:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1678263631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=yET4dLTaObig7qd5g7VQ441qs/AE4iGVqJGo9VFvELM=; b=Yw7ZU0D5aF0J5rT2eBxLrjCuBMRUKxNw2f+XWYKNJolrx44g2bHUFHE8p3PGmKRaiK3NjO EhKRVtHDeFCLbpwJ0BLElXf5IF0cet5xBPnWy7122aUZap0x1redtfRJOvsND7Wv70hYMs z3u4FPQfw/s9iHjZvkskAPldMNDfByx9nA5lbmlUpZJz+K1MyELdIVxqVhPtCfdrnscyHl Vq/j/WslG4eHXZn0QuLaq+t8Uwcks9Uuu80N4RltNqlA/MhnFm4/wtSEgUIxbNicOewKZu a3oTbl6c89VhTkeHI70u/KeKpPvxxMaUdL4bhyfhr3Zxmlfm3+ajcskYaf3M4A== From: Michael Walle To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Michael Walle , stable@vger.kernel.org Subject: [PATCH v2 1/4] mtd: core: provide unique name for nvmem device, take two Date: Wed, 8 Mar 2023 09:20:18 +0100 Message-Id: <20230308082021.870459-1-michael@walle.cc> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759624693609094482?= X-GMAIL-MSGID: =?utf-8?q?1759788480550509695?= Commit c048b60d39e1 ("mtd: core: provide unique name for nvmem device") tries to give the nvmem device a unique name, but fails badly if the mtd device doesn't have a "struct device" associated with it, i.e. if CONFIG_MTD_PARTITIONED_MASTER is not set. This will result in the name "(null)-user-otp", which is not unique. It seems the best we can do is to use the compatible name together with a unique identifier added by the nvmem subsystem by using NVMEM_DEVID_AUTO. Fixes: c048b60d39e1 ("mtd: core: provide unique name for nvmem device") Cc: stable@vger.kernel.org Signed-off-by: Michael Walle --- v2: - actually use NVMEM_DEVID_AUTO as described in the commit message drivers/mtd/mtdcore.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 0feacb9fbdac..8fc66cda4a09 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -888,8 +888,8 @@ static struct nvmem_device *mtd_otp_nvmem_register(struct mtd_info *mtd, /* OTP nvmem will be registered on the physical device */ config.dev = mtd->dev.parent; - config.name = kasprintf(GFP_KERNEL, "%s-%s", dev_name(&mtd->dev), compatible); - config.id = NVMEM_DEVID_NONE; + config.name = compatible; + config.id = NVMEM_DEVID_AUTO; config.owner = THIS_MODULE; config.type = NVMEM_TYPE_OTP; config.root_only = true; @@ -905,7 +905,6 @@ static struct nvmem_device *mtd_otp_nvmem_register(struct mtd_info *mtd, nvmem = NULL; of_node_put(np); - kfree(config.name); return nvmem; }