From patchwork Sun Jan 22 23:02:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 92175 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp982292qgi; Sun, 22 Jan 2017 15:04:20 -0800 (PST) X-Received: by 10.84.133.163 with SMTP id f32mr23043701plf.64.1485126260873; Sun, 22 Jan 2017 15:04:20 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f2si13668676pga.244.2017.01.22.15.04.20; Sun, 22 Jan 2017 15:04:20 -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 S1750940AbdAVXDx (ORCPT + 25 others); Sun, 22 Jan 2017 18:03:53 -0500 Received: from mail-wm0-f52.google.com ([74.125.82.52]:35728 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750805AbdAVXDF (ORCPT ); Sun, 22 Jan 2017 18:03:05 -0500 Received: by mail-wm0-f52.google.com with SMTP id r126so108990136wmr.0 for ; Sun, 22 Jan 2017 15:03:04 -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=i8KSbPy0oCPwMRpna9w4DnpfFP6B2jVUEKLuwGguWjk=; b=ZilYumegA3+Ks/cYbFxIhmx3WbFQyzpUSPjAuaOsP77hFhD1HVYfGEBCXwrEzcBDNQ RZP8KHKvGp+zgipWgVqBvTnWQJukwwUAyJziDTO4DeLemXqVoow+r7TmhDzmNh1A5yP3 3v9tWUl/G01FdIBPZcy62x/ZBbkulMwL1Xa/Y= 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=i8KSbPy0oCPwMRpna9w4DnpfFP6B2jVUEKLuwGguWjk=; b=g1H1dCJA6n9xstFH5t8sH2t3KK0j135iVWQD0/P2xeuvKjCdBH4hMKBUPRaMKx5rRG wlYVFKUjmMEprf3fJJRbcE9LR8FXcyBWOMFlPz7Wa5k97xh73nAscDk6vvbH77d55BT0 YOKDzTbdKqPBF+AJu2gcJgeEmympvKqzJAYnIymfY8TLX4g4nNqFHrwJO9Fn7eT2plnr T+IZzS1aSE1pCEt0lshM5fyN0mIT0qxPpgRB9+owzuGFjkgPa8HaYxlh9MLx5Rmo0QjJ B0AsRtRmT9p1NiRfBjExEECBYsQiQ0RdEyD5c5OqSh0zgPG1AauLjriPhaXvSRDriFJX edug== X-Gm-Message-State: AIkVDXJ3NVoqwHUbyilAU9ro6LK+6bfXm7+za7rI3RdeaCWOFJ57O3vAEp+QprSsIW30mSHM X-Received: by 10.223.164.151 with SMTP id g23mr21337229wrb.86.1485126183603; Sun, 22 Jan 2017 15:03:03 -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.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 22 Jan 2017 15:03:03 -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 3/5] nvmem: core: Allow ignoring length when reading a cell Date: Sun, 22 Jan 2017 23:02:38 +0000 Message-Id: <1485126160-3892-5-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 nvmem_cell_read() API fills in the argument 'len' with the number of bytes read from the cell. Many users don't care about this length value. So allow users to pass a NULL pointer to this len field. Signed-off-by: Vivek Gautam Reviewed-by: Stephen Boyd Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 398ea7f..78aa06a 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -970,7 +970,8 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem, if (cell->bit_offset || cell->nbits) nvmem_shift_read_buffer_in_place(cell, buf); - *len = cell->bytes; + if (len) + *len = cell->bytes; return 0; } @@ -979,7 +980,8 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem, * nvmem_cell_read() - Read a given nvmem cell * * @cell: nvmem cell to be read. - * @len: pointer to length of cell which will be populated on successful read. + * @len: pointer to length of cell which will be populated on successful read; + * can be NULL. * * Return: ERR_PTR() on error or a valid pointer to a buffer on success. The * buffer should be freed by the consumer with a kfree().