From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08B3DC433FE for ; Sat, 2 Apr 2022 17:01:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358630AbiDBRDr (ORCPT ); Sat, 2 Apr 2022 13:03:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358615AbiDBRDp (ORCPT ); Sat, 2 Apr 2022 13:03:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD651DBD03; Sat, 2 Apr 2022 10:01:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6A48860C2B; Sat, 2 Apr 2022 17:01:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96D4AC340EE; Sat, 2 Apr 2022 17:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648918912; bh=Q6oVRzXLQUS0n7KhdiXIiMYL80OZfB68gAxTBgZTO6E=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VE2FC75UlzplXarW05pzD62WRDzlZ4DJi1PL6Ps8Z8SOVEy9Wc8HYWkmTcirx+MbP vK6J616wNRZR/3OLAI7vdAej/AUnxETcs6qzmRvr4UtHVu0tYin3n9abu8sji7FION sySnOKUBbrPXGCtidL6ySUV0TClMP5sJ9wbcEKX4J6UNi0SbKBMXgDV1FhKqd1cY4h g0dsfgWByTasoR32YMXPnpxLK99yIdzcjmb3O2Wle8YUrTXHtMVsgt5KQFWavJ0ulJ JuLY9SqQ9hoTt9odyoHorYwXkoLMJtuNbrSFpgmCaMLk83ZlxgEWQxlIaJHajkUHp2 pIRM5xQKP3Ccg== Date: Sat, 2 Apr 2022 18:09:32 +0100 From: Jonathan Cameron To: Cixi Geng Cc: Lars-Peter Clausen , Rob Herring , Orson Zhai , "baolin.wang7@gmail.com" , Chunyan Zhang , lgirdwood@gmail.com, Mark Brown , "=?UTF-8?B?5pyx546J?= =?UTF-8?B?5piO?= (Yuming Zhu/11457) " , linux-iio@vger.kernel.org, Devicetree List , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH V2 6/7] iio: adc: sc27xx: add support for PMIC ump9620 Message-ID: <20220402180905.4e85bd5c@jic23-huawei> In-Reply-To: References: <20220311164628.378849-1-gengcixi@gmail.com> <20220311164628.378849-7-gengcixi@gmail.com> <20220320144151.66450e9a@jic23-huawei> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Hi Jonathan: > It used origin_calib_data in memcpy,and the length of data > may less than sizeof(u32). we expect the other bits keeps 0; > So we initialise 0 in here. Ah. I'd missed that. Thanks for the explanation. > > > > > + size_t len = 0; > > > + > > > + if (!data) > > > + return -EINVAL; > > > + > > > + cell = nvmem_cell_get(data->dev, cell_name); > > > + if (IS_ERR(cell)) > > > + return PTR_ERR(cell); > > > + > > > + buf = nvmem_cell_read(cell, &len); > > > + if (IS_ERR(buf)) { > > > + nvmem_cell_put(cell); > > > + return PTR_ERR(buf); > > > + } > > > + > > > + memcpy(&origin_calib_data, buf, min(len, sizeof(u32))); > > > + > > > + kfree(buf); > > > + nvmem_cell_put(cell); > > > + return origin_calib_data; > > > +} Jonathan