Received: by 10.192.165.148 with SMTP id m20csp928645imm; Thu, 10 May 2018 03:00:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpYv+2DkWhMp8wuOCoB5zKVT+jbz9bgdpCOY//IBJrjUBrkfNEtKILTrJsnA515VOmyr20Z X-Received: by 2002:a17:902:14d:: with SMTP id 71-v6mr723245plb.275.1525946411981; Thu, 10 May 2018 03:00:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525946411; cv=none; d=google.com; s=arc-20160816; b=0ZcsT+k0DA1km0AfHARHSdKPyZ+XN7UJV/AIy1ZpJBCOIzUDblgkCBTf9FD4OE7w1+ QqwkIwClFG4NAHE66CijbLqfz8BQd0qB0AQp2SWKiCPQ6D3BmbIjp4aPz+VlaDOjwfoX KrjW0GhsUSwA3cv8C9zFpL3tz4hXp7Jh5dWJs+LqgjLj5t+vKNf8IFbqgim3rzQGd7F0 4xRTrReo5sStObaW7AL7033qBcv/KFxmQzTLZMi1n6kP9jYMRUgsSSXmp1+4YHU8aiGV gKExTDYj/bVB/FnXhknxziNSIfsxNk991tgzLZ2KJa6aWrRuHuzKxJD8iZufAbTWtY8f Xscw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=rFBiReDFFTrebZYqRS4BraEEoDvrKlxPLPqARlTJtGA=; b=nsew4Ma9TjGk7boFnh0mA/iCd2uz6+ITibj2/mQFeW4lsXKhQ149tLdOATVpXMjU3X YE1gfzL2l/rQTQewIF4VQeeBC9wxMR1v/9aNpGdk5C7SpVC6IVvVIlDABs6WRsQ7ndhb 65Z+yKDaYs7/msmRtE3W8b7FBn4h3IAcE4q9lkL+PSqUuvEMBzu09YO1JmbxmpE1Z28b mUEKX5HMF57h2rgap9iP10vzNag+RY+GpD/Gw8yF3gHludybCAG0P/5KHFlNcN/Q9Qjs pS7lzQPaYRiF21KGjjb1gldeoxVKa5su8SZyCE+7vJUmwm0JgovQMRy36e5QWiRD9UZC VZjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OMMLZZBx; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h67-v6si496658pfk.15.2018.05.10.02.59.57; Thu, 10 May 2018 03:00:11 -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 header.s=google header.b=OMMLZZBx; 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 S934910AbeEJJ6b (ORCPT + 99 others); Thu, 10 May 2018 05:58:31 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:52648 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934430AbeEJJ6a (ORCPT ); Thu, 10 May 2018 05:58:30 -0400 Received: by mail-wm0-f65.google.com with SMTP id w194-v6so2961414wmf.2 for ; Thu, 10 May 2018 02:58:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=rFBiReDFFTrebZYqRS4BraEEoDvrKlxPLPqARlTJtGA=; b=OMMLZZBxcj92BWiIA6uBSdfoWLLMEsij4rd/F2pQx4wlcqybSiZw4DDX6epfJEfrL0 gg4CVi+1/Za39mWPiebvebx61iWRe0PYEgbECaydxC3lJ/QlXm2ECgt7nzVGdVMKlElJ vi6utWkatVr2dx10N/E52D92+sfSGgrhe+xA4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=rFBiReDFFTrebZYqRS4BraEEoDvrKlxPLPqARlTJtGA=; b=Ba7ev2omCxE+YfpbMLcQSR4xWfjAcjY5q+KktWoDjWCEu1O4kEb/E0WEmxLC/NDFpa Wa06BNjUwhDzjzmCRp2DsAF9aFlzbFxqg3t8wyWCi3bp7oltEJrKOSBNmPP2xcWQq3nq S2ugyrj3yBQghIruT5EUjK2oESojMkZY9ofSAMpi6nV4aElb6WWr/gdtFUotmkmWog/1 cZgbVMQrfNe20Bzfi1IBKEXQw/ndfRNzsv25ZzJlm/7nIGg/ZU9tHXyVFCyfOrWZsZVS MORpeasLYn+ngoAtfEu6JWUcAa/AaxUcDK0Jr/k+1BcgLLQN2iHq9dwRQFVtRTBV+tZP Gsrw== X-Gm-Message-State: ALKqPweF1i9/XJbC9EKd8HWpJqpKMWg/MdyDKwh9cY/W/Q+wTQXlUx7T OQVFbegNUxOBCAnLGdePYuqzaYV9l8Y= X-Received: by 2002:a1c:c405:: with SMTP id u5-v6mr850848wmf.46.1525946308686; Thu, 10 May 2018 02:58:28 -0700 (PDT) Received: from [192.168.0.18] (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.googlemail.com with ESMTPSA id w6-v6sm639586wra.16.2018.05.10.02.58.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 May 2018 02:58:28 -0700 (PDT) Subject: Re: [PATCH v2] nvmem: properly handle returned value nvmem_reg_read To: Mathieu Malaterre Cc: linux-kernel@vger.kernel.org References: <20180505202450.26630-1-malat@debian.org> <20180509185724.24079-1-malat@debian.org> From: Srinivas Kandagatla Message-ID: <2cb62de4-f8be-e3cf-f415-54de60bb669e@linaro.org> Date: Thu, 10 May 2018 10:58:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20180509185724.24079-1-malat@debian.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/05/18 19:57, Mathieu Malaterre wrote: > Function nvmem_reg_read can return a non zero value indicating an error. > This returned value must be read and error propagated to > nvmem_cell_prepare_write_buffer. Silence the following gcc warning (W=1): > > drivers/nvmem/core.c:1093:9: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable] > > Signed-off-by: Mathieu Malaterre > --- > v2: prefer ERR_PTR(-EINVAL) over a simple return NULL > > drivers/nvmem/core.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > index b05aa8e81303..f7b6c85cf393 100644 > --- a/drivers/nvmem/core.c > +++ b/drivers/nvmem/core.c > @@ -1107,6 +1107,8 @@ static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell, > > /* setup the first byte with lsb bits from nvmem */ > rc = nvmem_reg_read(nvmem, cell->offset, &v, 1); > + if (rc) > + goto err; > *b++ |= GENMASK(bit_offset - 1, 0) & v; > > /* setup rest of the byte if any */ > @@ -1125,11 +1127,16 @@ static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell, > /* setup the last byte with msb bits from nvmem */ > rc = nvmem_reg_read(nvmem, > cell->offset + cell->bytes - 1, &v, 1); > + if (rc) > + goto err; > *p |= GENMASK(7, (nbits + bit_offset) % BITS_PER_BYTE) & v; > > } > > return buf; > +err: > + kfree(buf); > + return ERR_PTR(-EINVAL); You should return ERR_PTR(rc) not EINVAL here. errors should always propagate to caller! thanks, srini > } > > /** >