From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751894AbdCCKRM (ORCPT ); Fri, 3 Mar 2017 05:17:12 -0500 Received: from mail-wm0-f45.google.com ([74.125.82.45]:35966 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751356AbdCCKRF (ORCPT ); Fri, 3 Mar 2017 05:17:05 -0500 Subject: Re: [PATCH 3/3] nvmem: core: Allow allocating several anonymous nvmem devices To: Alban , linux-kernel@vger.kernel.org References: <1488484223-844-1-git-send-email-albeu@free.fr> <1488484223-844-4-git-send-email-albeu@free.fr> Cc: devicetree@vger.kernel.org, linux-mtd@lists.infradead.org, Cyrille Pitchen , Richard Weinberger , Marek Vasut , Boris Brezillon , Brian Norris , David Woodhouse , Mark Rutland , Rob Herring , Maxime Ripard , Moritz Fischer From: Srinivas Kandagatla Message-ID: <4440721f-c66d-c3bf-812b-da4defeeacce@linaro.org> Date: Fri, 3 Mar 2017 10:08:46 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1488484223-844-4-git-send-email-albeu@free.fr> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/03/17 19:50, Alban wrote: > Currently the nvmem core expect the config to provide a name and ID > that are then used to create the device name. When no device name is > given 'nvmem' is used. However if there is several such anonymous > devices they all get named 'nvmem0', which doesn't work. > > To fix this problem use the ID from the config only when the config > also provides a name. When no name is provided take the uinque ID of > the nvmem device instead. > > Signed-off-by: Alban > --- Thanks for the Fix, looks good to me, I will queue this up once rc1 is out. > drivers/nvmem/core.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > index 408b521..8c830a8 100644 > --- a/drivers/nvmem/core.c > +++ b/drivers/nvmem/core.c > @@ -468,7 +468,8 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) > np = config->dev->of_node; > nvmem->dev.of_node = np; > dev_set_name(&nvmem->dev, "%s%d", > - config->name ? : "nvmem", config->id); > + config->name ? : "nvmem", > + config->name ? config->id : nvmem->id); > > nvmem->read_only = of_property_read_bool(np, "read-only") | > config->read_only; >