From patchwork Sun Jan 22 23:02:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 92173 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp982056qgi; Sun, 22 Jan 2017 15:03:33 -0800 (PST) X-Received: by 10.99.227.5 with SMTP id f5mr6939434pgh.102.1485126213001; Sun, 22 Jan 2017 15:03:33 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h6si13711519plk.94.2017.01.22.15.03.32; Sun, 22 Jan 2017 15:03:32 -0800 (PST) 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 S1750857AbdAVXDN (ORCPT + 25 others); Sun, 22 Jan 2017 18:03:13 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:35861 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750704AbdAVXDL (ORCPT ); Sun, 22 Jan 2017 18:03:11 -0500 Received: by mail-wm0-f51.google.com with SMTP id c85so108671458wmi.1 for ; Sun, 22 Jan 2017 15:03:11 -0800 (PST) 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=iJHnvZlZOqm7UnR9AlPdwJ9T7y/33+YOMj002juo0OM=; b=KfEE+aA2P8jQQHEbCtI8s7abwVTe7AFb4THfPLvHljc/fZYQ78vEHRvZFkX3baZ8Wu d3Jb6HsFssCWoTTQdKn/9ND22tO8717nZh79hIUXwlTBbpszW6AXqeq6oEKVojdLFLrn eOcYC9UoKjh2s0aZDX5/MzCOjl3OpsFhF3MHw= 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=iJHnvZlZOqm7UnR9AlPdwJ9T7y/33+YOMj002juo0OM=; b=uX1dXYwjJsanblksl+45hSbJMDH4PBpsqjEA7QhR5YTIeIcIR/LIlUXHvpdy3wDGve 8V5MF3HOzNHtEv4VlnTh1wx1wMgO+qvryB5G9x2tP9c7d/wzd290uZ2pyGWPYX5TOb0/ jW/CZbL6ZS9a2ArzCMLlQAfgM4KhJQP2bltclgx6UTFwezKR5jXt7HA8ZfFiaCvT65VR af0FiuGJiakLOzRjQhF6xoshn8wTRdBRF7Quwu5kiO6K51wGjSrb4uwG23rffTgt5RfE Jw0k5bLcSvMSVwIS/6BU575Ams8FpuWfNKY8k6SaJfLYGYv+vlwHT1RHSRUt+OpXIZ2H +3ZA== X-Gm-Message-State: AIkVDXJZ9Vab6PT6GXl16MGiLm7RYxWiYUwbdlUetFM4UYoPEGJJgK7yI2AYKZkB6u5sQHDx X-Received: by 10.223.168.111 with SMTP id l102mr20528087wrc.150.1485126185549; Sun, 22 Jan 2017 15:03:05 -0800 (PST) Received: from localhost.localdomain (host-2-98-105-38.as13285.net. [2.98.105.38]) by smtp.gmail.com with ESMTPSA id l74sm18084857wmg.2.2017.01.22.15.03.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 22 Jan 2017 15:03:05 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: maxime.ripard@free-electrons.com, linux-kernel@vger.kernel.org, Vivek Gautam , Srinivas Kandagatla Subject: [PATCH 5/5] nvmem: core: Allow getting nvmem cell with a NULL cell id Date: Sun, 22 Jan 2017 23:02:40 +0000 Message-Id: <1485126160-3892-7-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485126160-3892-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1485126160-3892-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: Vivek Gautam The nvmem cell with a NULL cell name/id should be the one with no accompanying 'nvmem-cell-names' property, and thus will be the cell at index 0 in the device tree. So, we default to index 0 and update the cell index only when nvmem cell name id exists. Suggested-by: Stephen Boyd Signed-off-by: Vivek Gautam Reviewed-by: Stephen Boyd Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/core.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 9c05921..408b521 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -747,7 +747,9 @@ static struct nvmem_cell *nvmem_cell_get_from_list(const char *cell_id) * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id * * @np: Device tree node that uses the nvmem cell. - * @name: nvmem cell name from nvmem-cell-names property. + * @name: nvmem cell name from nvmem-cell-names property, or NULL + * for the cell at index 0 (the lone cell with no accompanying + * nvmem-cell-names property). * * Return: Will be an ERR_PTR() on error or a valid pointer * to a struct nvmem_cell. The nvmem_cell will be freed by the @@ -760,9 +762,12 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, struct nvmem_cell *cell; struct nvmem_device *nvmem; const __be32 *addr; - int rval, len, index; + int rval, len; + int index = 0; - index = of_property_match_string(np, "nvmem-cell-names", name); + /* if cell name exists, find index to the name */ + if (name) + index = of_property_match_string(np, "nvmem-cell-names", name); cell_np = of_parse_phandle(np, "nvmem-cells", index); if (!cell_np)