From patchwork Fri Mar 31 12:44:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 96396 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp710366qgd; Fri, 31 Mar 2017 05:45:18 -0700 (PDT) X-Received: by 10.99.172.84 with SMTP id z20mr3097645pgn.123.1490964317988; Fri, 31 Mar 2017 05:45:17 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s128si5144562pgc.85.2017.03.31.05.45.17; Fri, 31 Mar 2017 05:45:17 -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; dkim=pass header.i=@linaro.org; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933230AbdCaMpQ (ORCPT + 21 others); Fri, 31 Mar 2017 08:45:16 -0400 Received: from mail-wr0-f171.google.com ([209.85.128.171]:35858 "EHLO mail-wr0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932864AbdCaMpP (ORCPT ); Fri, 31 Mar 2017 08:45:15 -0400 Received: by mail-wr0-f171.google.com with SMTP id w11so103531945wrc.3 for ; Fri, 31 Mar 2017 05:45:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=O9NwnWCksBTXuvqz0DuHtBfwXnl502Od3g6WW+aaa8M=; b=VH3eWrPsgE64XqiK7gdpyEAY2EWrb2yY7FLKOc0+Lhlf44Q1f1R6a69BgJ+knXJEQl QBJ5dIUr48WSjSOAxWcvHXKhRzS1redVS+ZuGIpIwafQysZKKcv91PgzxyRlFJfUgBwJ wSylLZQhF3JdeIvYyWVPlGlTvIu46vqHcpayQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=O9NwnWCksBTXuvqz0DuHtBfwXnl502Od3g6WW+aaa8M=; b=pNDLGqD1Z3UMeYHdtN0EBwgs2fVY39sWOsJR9uKTLZTOolTR8FEKzg9nwRST5UcZNW 6ad0SccGV/B6nRmgGnD59IDi293Teb0Chd+DUFbjbNyGJY+7lOnSeGJuttTvrxFy6vz/ tjObsGliJ2bJNGT2ZjfE4KEEHM67QIickSfIgt/O0r2aJlWCGMJH4G9lc+TzQ5xmWljM qnwpJtJNk65jo58ZiBwUGDt6E9PVNaw4ExGFT3tl14ZrdrCCuqkLVhWBYr2+0RSxw/Lz BGRPi0hlv7S3aiTDzIaNX4ZZ8V9xNke8v8np9OqV1LoRl2xKZvWMeH+pB5cAQjginsiT Q1cw== X-Gm-Message-State: AFeK/H2NSZUXpwV3zAzLry7Rynqkwr5I1PDwNAKKe1BkFVSIUUkOx2X56BukhLvoX9hDO43J X-Received: by 10.28.207.14 with SMTP id f14mr2761406wmg.72.1490964312642; Fri, 31 Mar 2017 05:45:12 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id n80sm6615514wrb.24.2017.03.31.05.45.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Mar 2017 05:45:11 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, maxime.ripard@free-electrons.com, Aban Bedel , Srinivas Kandagatla Subject: [PATCH 02/11] nvmem: core: Allow allocating several anonymous nvmem devices Date: Fri, 31 Mar 2017 13:44:46 +0100 Message-Id: <1490964295-9647-3-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490964295-9647-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1490964295-9647-1-git-send-email-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aban Bedel 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: Aban Bedel Reviewed-by: Moritz Fischer Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.7.4 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;