Message ID | 20230306125805.678668-1-michael@walle.cc |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1836308wrd; Mon, 6 Mar 2023 05:21:17 -0800 (PST) X-Google-Smtp-Source: AK7set8bd3UjLVyE9kAWCJW6XQYn8DtBTV86cuJAPB5WrYsTEgQAkSiL8N4aLgmCr5NRnfgOephz X-Received: by 2002:a17:906:16d5:b0:8b1:79d0:bc58 with SMTP id t21-20020a17090616d500b008b179d0bc58mr9020453ejd.16.1678108877245; Mon, 06 Mar 2023 05:21:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678108877; cv=none; d=google.com; s=arc-20160816; b=vdBUnXpZHWfgmbAxJlBspQG8XAP2NCTHsHZs8a7DsKS7L4aUZeL3ul2XiWuvOb8vNL E7B69X1uXeT2JGinBvSRMMBw8BGLthBVs6A0UhoCi5aalDVXz+Xz4DL4QDgViqUvyEad dnQbZRZz+mvuvHBbseNlQRdSOHejGW1kY/yv9vzx1/V+No7zxfJNBitK8OQI9AvoiPDj kCLOPgM/IyfgHiUrLN7E7KaS0eMn9JJr21l4hQMyjaw/7UnWCfsRlGAyRLTOx9TBp1Rt GmE2vknVysZCxODNFpOuiWeQlrX3+sqmEyot869t9fH5gse0n0uhZ+tTOlDvJPwB8uZy F1ww== 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=felfT43D0ByEEC43Rq1xqotzNKKcG2VF+lRhbg02WB4=; b=bh4Sm7qbMSShT1ORImZn5i+c9QEy5CbRa+BkKTyDf6wZqNp4XPZ8wHlDyzOqhlgvCo EbdZqyUdRTMzBsGgRuXq54BILI0MCJijte+nC2rXa9nP0TUzrqBwXX2wmg0ZPcTr6jLT jIdYVs0piYgn8AJ28ev+F3jZRA2N6GaAq04mxBr+zrRdB9u0ZkTQ/Lf6VY/eP5vOnQkn 03U1s4f4prbOHZUyv0j8LrMYeb5GE7pWfZTwOcC3xDyzb/j05x7hAAsxNrNjdRcDCLri lpn+lqkTY3f6llLsmPpqcdfqXbjng/EvIY+kf4xRzKUniT8lmIKUilVeZwKnh1hnTDiN r7EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=tgaP+NM0; 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 u25-20020a1709063b9900b008dbb5a2ea5fsi396511ejf.644.2023.03.06.05.20.52; Mon, 06 Mar 2023 05:21:17 -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=tgaP+NM0; 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 S230370AbjCFM6c (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 6 Mar 2023 07:58:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230247AbjCFM62 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 6 Mar 2023 07:58:28 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4440623874; Mon, 6 Mar 2023 04:58:22 -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 D7E6D100; Mon, 6 Mar 2023 13:58:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1678107498; 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=felfT43D0ByEEC43Rq1xqotzNKKcG2VF+lRhbg02WB4=; b=tgaP+NM0dhhp7GXFV8BWTt6vnZLjr1w+1W/5++uBU3EwNELH8TA/dSk8nEjPE7hC3vvvxV xbADrut9+vZU3+IEgKrhA+DFgS52V98rRBEtFn2AumZX+b3sLMpowctuF45agryOrcwb0j Sb7fNhecL0+AmyBRFj+tcx/2EGLu4N0DXl9xfDa8qjbniCuD7rZZZXiHDDeckY2xuv/2VW TNUzuwazhSNsxkH5RuJqdv71mgPVF1Eqlul+RjJo6GJtj2rqp4T9MeIybpjy9y9sz0yeIN AvF88gzzRDul1iVPKJ2w+dI2iwVV7eaSkUrh4hVju4W6cZX/+9UjD39RETt4aw== From: Michael Walle <michael@walle.cc> To: Miquel Raynal <miquel.raynal@bootlin.com>, Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com> Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Michael Walle <michael@walle.cc>, stable@vger.kernel.org Subject: [PATCH 1/4] mtd: core: provide unique name for nvmem device, take two Date: Mon, 6 Mar 2023 13:58:02 +0100 Message-Id: <20230306125805.678668-1-michael@walle.cc> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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: <linux-kernel.vger.kernel.org> 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?1759624693609094482?= |
Series |
[1/4] mtd: core: provide unique name for nvmem device, take two
|
|
Commit Message
Michael Walle
March 6, 2023, 12:58 p.m. UTC
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 <michael@walle.cc>
---
drivers/mtd/mtdcore.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
Comments
On Mon, 2023-03-06 at 12:58:02 UTC, Michael Walle wrote: > 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 <michael@walle.cc> Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks. Miquel
Hi Miquel, Am 2023-03-06 13:58, schrieb Michael Walle: > 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 <michael@walle.cc> > --- > drivers/mtd/mtdcore.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c > index 0feacb9fbdac..3fe2825a85a1 100644 > --- a/drivers/mtd/mtdcore.c > +++ b/drivers/mtd/mtdcore.c > @@ -888,8 +888,7 @@ 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; Damn.. although the commit message says it using NVMEM_DEVID_AUTO, this is missing here. :/ Since you already picked it, should I send a follow up patch or can you just drop this patch and I'll resend it? -michael > config.owner = THIS_MODULE; > config.type = NVMEM_TYPE_OTP; > config.root_only = true; > @@ -905,7 +904,6 @@ static struct nvmem_device > *mtd_otp_nvmem_register(struct mtd_info *mtd, > nvmem = NULL; > > of_node_put(np); > - kfree(config.name); > > return nvmem; > }
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 0feacb9fbdac..3fe2825a85a1 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -888,8 +888,7 @@ 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.owner = THIS_MODULE; config.type = NVMEM_TYPE_OTP; config.root_only = true; @@ -905,7 +904,6 @@ static struct nvmem_device *mtd_otp_nvmem_register(struct mtd_info *mtd, nvmem = NULL; of_node_put(np); - kfree(config.name); return nvmem; }