Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3702914ybi; Tue, 2 Jul 2019 12:01:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJ5fbIcxgTdAv++aeRb5mHEmAi+iwSpI7Q7MWSKuXLkricUAWrPCMAUkUvARYY74WtAm8m X-Received: by 2002:a17:902:100a:: with SMTP id b10mr36340575pla.338.1562094085022; Tue, 02 Jul 2019 12:01:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562094085; cv=none; d=google.com; s=arc-20160816; b=uIX24qxClOVgrRKpEjd4YZAA2MBYYqnCXt8ntiMLtLL6d2SzFG74uqNVg6hGp18q6U xFYHFrwMTF19ttyXqbVlfe8wjrOy7yX/6jpMNmJy/9FbpnLeKCZKEgGC+02kyrLY0I4G 0BAbTliyvHLtUior5oi7i0dI8lGSVB+HmzrjhclRTwlpZlZimNNQ4Y5wRYf7eLIJV869 jQmuW7x6Xiua9aYJciqAL63GEbXtbObLWYRSyZO7KXCRdRCWFytH3/LICCC6D6NogW1C nQvmi8YXou3jujobuBcTIPPrhRmkSRlb3OU5Mmr0Qsc9jj6M5u1COxC0AQvKZZkKgNSj i0kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=4ymiWiDTN+OcPGDhzIGQDmcYS98gWJuVpLFy7RsYOyc=; b=CUnejAjuYdmImb12oAC6TpJOZ9hw5vdQAoMWb9D7r6OT9gABhCM1PFFkeqt9XIIR/a 2q9mgkCbv6etwQF+pyUJ6gBJyDuPdWy9tTqkh7Q+KmNm+FC8kgNjt/c7eUxtV9O/fGCJ d6igz6pJ1/WmVYSl+Ykank/U3ZaBUHrOKlA4b0wmck09lXD4zBI+vtif4+0ttZtWCO19 dNFPuliWywjf6KNtBu2lDxBiMdfhybFqdsh8Yi8QSN/IOMg7yuGv5cdGuqy+jw7WyMPf e+6U66MTShoOY5q6sZyI73m2Z54g9WOHRUshZ38lqz1tpRoUQaJZGmzD0/r67z0hZ3Ex CVgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z5si12880312pgv.280.2019.07.02.12.01.08; Tue, 02 Jul 2019 12:01:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727053AbfGBS77 (ORCPT + 99 others); Tue, 2 Jul 2019 14:59:59 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59216 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726457AbfGBS76 (ORCPT ); Tue, 2 Jul 2019 14:59:58 -0400 Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id B91032639CD; Tue, 2 Jul 2019 19:59:57 +0100 (BST) Date: Tue, 2 Jul 2019 20:59:55 +0200 From: Boris Brezillon To: Sascha Hauer Cc: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Srinivas Kandagatla , kernel@pengutronix.de Subject: Re: nvmem creates multiple devices with the same name Message-ID: <20190702205955.65f1bce2@collabora.com> In-Reply-To: <20190521085641.i6g5aijwa5zbolah@pengutronix.de> References: <20190521085641.i6g5aijwa5zbolah@pengutronix.de> Organization: Collabora X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 21 May 2019 10:56:41 +0200 Sascha Hauer wrote: > Hi all, > > nvmem derives the device name directly from the partition name of the > underlying device. IMO this is wrong since it's not possible to create > two partitions with the same name on different devices. In my case I > have a NAND device and a SPI NOR device which both happen to have a > partition named 'barebox'. This ends up with: Hm, I think I had suggested to use dev_name(&mtd->dev) instead of mtd->name at some point. But then you have the problem that MTD numbering is dependent on the probe order which is not guaranteed to stay the same, so exposing nvmem devices using "mtdXX" name is not super user-friendly. > > [ 11.222196] sysfs: cannot create duplicate filename '/bus/nvmem/devices/barebox' > [ 11.230136] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 5.2.0-rc1-00014-g793f23e5adb0-dirty #676 > [ 11.240414] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree) > [ 11.247174] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) > [ 11.255171] [] (show_stack) from [] (dump_stack+0xd8/0x110) > [ 11.262722] [] (dump_stack) from [] (sysfs_warn_dup+0x50/0x64) > [ 11.270527] [] (sysfs_warn_dup) from [] (sysfs_do_create_link_sd+0xcc/0xd8) > [ 11.279487] [] (sysfs_do_create_link_sd) from [] (bus_add_device+0x80/0xfc) > [ 11.288441] [] (bus_add_device) from [] (device_add+0x328/0x608) > [ 11.296423] [] (device_add) from [] (nvmem_register.part.1+0x168/0x5e4) > [ 11.305030] [] (nvmem_register.part.1) from [] (add_mtd_device+0x1e8/0x404) > [ 11.313988] [] (add_mtd_device) from [] (add_mtd_partitions+0x74/0x15c) > [ 11.322589] [] (add_mtd_partitions) from [] (parse_mtd_partitions+0x180/0x368) > [ 11.331807] [] (parse_mtd_partitions) from [] (mtd_device_parse_register+0x40/0x164) > [ 11.341560] [] (mtd_device_parse_register) from [] (m25p_probe+0x118/0x200) > [ 11.350513] [] (m25p_probe) from [] (spi_drv_probe+0x80/0xa4) > > While it's easy to rename the partitions I see no reason why it should > be illegal to have two different (mtd) devices with eqeally named > partitions. Are there any suggestions how to register the nvmem devices > with a different name? Note that some MTD users are expecting MTD names to be unique to work properly, the example I have in mind is UBI that can be passed the partition to attach to using the ubi: format, but I'm pretty sure we have other places making the same assumption. I guess not enforcing mtd->name uniqueness was a bad idea, but I'm not sure we can change that now.