Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2329524rwd; Fri, 2 Jun 2023 08:02:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ59GdI6T1IZCoxmnwv9HE8B1YtuCIkXqJimFKtWQ2rVgVFsX2nBKeJh8Emi/OuO9myE3CmY X-Received: by 2002:a17:902:d38d:b0:1ac:6d4c:c26a with SMTP id e13-20020a170902d38d00b001ac6d4cc26amr213231pld.14.1685718160052; Fri, 02 Jun 2023 08:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685718160; cv=none; d=google.com; s=arc-20160816; b=csDDq4jetc75YRdkByzmOyiGUMqt/uRZ2ueGmcggvFL64q7nTbsYHEwJD4CVFXn/Qm uQ8Excf+gBnQbgxVdJFPyrVsYU5fO2YkUkwN2lFdo8LNilykxMcJXiUIvvVgxGXN4OSy kmhXJdjeh4MptimGfd6mde9k5LhXcIZjBwAxQZrs27MaqyanIkcp1QFhf8L5buJ2mvnX 1PIpKpz1sqejiqqUOptwFKRgaE8u2mKdQsSBV1jj0ThyvsOh3mrsv+/VIjuTd4cti0vj 3GO4uxh6t0L+QvzqLE1fj1WMFp3YhhTJqqZ9voaXuYq7dAMIXVT9AjaX8NUdlVX4UfMG fNZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=QJxfJIxQlfV/hNKHnzbPYuttTFNBw9fF2nkdKP9I7/Y=; b=kDg9KMHO67OhEw2278E//66NCAN37X2hi+FTCjPiskccNmfE7vscYJgRoO2luzbMAy R/kSlkvj1dlfOWvGGEHmo38QKhTROfZc5j86AYgrXnchMXQp4MMrJdVhdz1jo93R+rxJ pcGCZufx23OhNkKcNWAcOdDal0oeCsRgWLzKhrZA6R3U7krgvBCmvPNKAAnKNQTek3JD NTnn6V8X/gELS3XN/R7iDFOxvaI83sslqwvMUFIfnM9s9X0YNt56Uj3PqlAC2G/koOg/ 36tW/JReIBDbbVm4IMDKmRhgj4kUFhyis4OJ7TLRS1SsrhO5VExPPeGVpnZflR/1davD 6iEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iSIFuCLs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u6-20020a170902e80600b001b029604713si1055843plg.108.2023.06.02.08.02.24; Fri, 02 Jun 2023 08:02:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iSIFuCLs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236226AbjFBOtU (ORCPT + 99 others); Fri, 2 Jun 2023 10:49:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236228AbjFBOtS (ORCPT ); Fri, 2 Jun 2023 10:49:18 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D8CEE49; Fri, 2 Jun 2023 07:49:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685717355; x=1717253355; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=YPUlxeS32cApP+ZDIUHR9khrq40A8i+TVQo/LyymAAg=; b=iSIFuCLsrzjIhWQBq0iHm1gHLZ5Fe81EIAgx/XJKBBeb5h4s9L/vuxNi sxbmnLW1Vnpkz3AhKgcybk4fgrK2BzmQ+6gqei9fF0FkGprGa9olHloGP xbX4agugBUo/X5HDCdot1VlKxug48zEhqKIluLCyE89uT7YoWFAMR3dwT YiFJ9I1SCjzWW4pXvbbWu+vcrodW4esE9qEgmGm+AmQvW+g9TyP3NlnQ/ 4FFQHCk5TwMl0rQbmioL314poFzQMNdXl10QfJc4pI33sR3WqYza4DiSN rNi+V4AieD9jdYVpu8Wv6UVZyzPUrz4tEzMO9KgE1ijDl4a/VnxI/bOWP Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="353378802" X-IronPort-AV: E=Sophos;i="6.00,213,1681196400"; d="scan'208";a="353378802" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 07:49:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10729"; a="772905903" X-IronPort-AV: E=Sophos;i="6.00,213,1681196400"; d="scan'208";a="772905903" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga008.fm.intel.com with ESMTP; 02 Jun 2023 07:49:07 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1q565Q-000fQj-0X; Fri, 02 Jun 2023 17:49:04 +0300 Date: Fri, 2 Jun 2023 17:49:03 +0300 From: Andy Shevchenko To: Maksim Kiselev Cc: linux-iio@vger.kernel.org, Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Cristian Ciocaltea , Cosmin Tanislav , Miquel Raynal , ChiaEn Wu , Arnd Bergmann , Ramona Bolboaca , Caleb Connolly , ChiYuan Huang , Ibrahim Tilki , William Breathitt Gray , Leonard =?iso-8859-1?Q?G=F6hrs?= , Haibo Chen , Hugo Villeneuve , Mike Looijmans , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH v2 1/3] iio: adc: Add Allwinner D1/T113s/R329/T507 SoCs GPADC Message-ID: References: <20230601223104.1243871-1-bigunclemax@gmail.com> <20230601223104.1243871-2-bigunclemax@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230601223104.1243871-2-bigunclemax@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 02, 2023 at 01:30:39AM +0300, Maksim Kiselev wrote: > From: Maxim Kiselev > > The General Purpose ADC (GPADC) can convert the external signal into > a certain proportion of digital value, to realize the measurement of > analog signal, which can be applied to power detection and key detection. > > Theoretically, this ADC can support up to 16 channels. All SoCs below > contain this GPADC IP. The only difference between them is the number > of available channels: > > T113 - 1 channel > D1 - 2 channels > R329 - 4 channels > T507 - 4 channels ... > +struct sun20i_gpadc_iio { > + struct regmap *regmap; > + struct completion completion; > + struct mutex lock; The locks should be explained (what are they for? what do they protect?). > + int lastch; > +}; ... > +static const struct regmap_config sun20i_gpadc_regmap_config = { > + .reg_bits = 32, > + .val_bits = 32, > + .reg_stride = 4, > + .fast_io = true, I forgot if I asked about regmap lock do you need it? > +}; ... > + if (!wait_for_completion_timeout(&info->completion, > + msecs_to_jiffies(100))) { Dunno if it's better to have this parameter to be defined with self-explanatory name. > + ret = -ETIMEDOUT; > + goto err; > + } ... > +err: err_unlock: > + mutex_unlock(&info->lock); > + > + return ret; ... > + switch (mask) { > + case IIO_CHAN_INFO_RAW: > + ret = sun20i_gpadc_adc_read(info, chan, val); > + return ret; return sun...; > + case IIO_CHAN_INFO_SCALE: > + /* value in mv = 1800mV / 4096 raw */ > + *val = 1800; > + *val2 = 12; > + return IIO_VAL_FRACTIONAL_LOG2; > + default: > + return -EINVAL; > + } ... > + if (num_channels > SUN20I_GPADC_MAX_CHANNELS) { > + dev_err(dev, "num of channel children out of range"); > + return -EINVAL; > + } Is it really critical error? ... > + channels = devm_kcalloc(dev, num_channels, > + sizeof(*channels), GFP_KERNEL); At least one more parameter can be located on the previous line. > + if (!channels) > + return -ENOMEM; ... > +err_child_out: err_put_child: The goto labels should be self-explanatory of what to expect when goto. > + fwnode_handle_put(node); > + > + return ret; ... > + ret = devm_request_irq(dev, irq, sun20i_gpadc_irq_handler, > + 0, dev_name(dev), info); > + if (ret < 0) Here... > + return dev_err_probe(dev, ret, > + "failed requesting irq %d\n", irq); ... > + ret = devm_iio_device_register(dev, indio_dev); > + if (ret < 0) ...and here, do the positive returned values even possible? > + return dev_err_probe(dev, ret, > + "could not register the device\n"); ... > + { .compatible = "allwinner,sun20i-d1-gpadc", }, Inner comma is not needed. -- With Best Regards, Andy Shevchenko