Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp973967ybh; Tue, 21 Jul 2020 12:29:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJww0/hrY+WevazAK1SoTIdUte31ZdE2D8W2fgIMsmDEpSr78Z5TMosDVaLiEe0DDV6s4IJC X-Received: by 2002:a17:906:5949:: with SMTP id g9mr26014267ejr.305.1595359787248; Tue, 21 Jul 2020 12:29:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595359787; cv=none; d=google.com; s=arc-20160816; b=Lbn5CZ51LpFPZyIcXsmuUB3jgtTssrgu/DPzD85zlOHbRCKcxjkfONUi3b+ltY3p/b dPAZDZk67PH/uq7n0gCaLYeyQYxoNJueCMSWOWnIzCgTYSMe7fmhoS7A5/6zNz0jR/ki 9x6wOBagqhKxV0bTBHNm8Xq9wZ4HscVvOLjxFX48jhO48h/t5YJP1xTIowt+4DG2jSuX egd3Khzim/2jitltqynJZ0ShKu/GnHRgRf34pq75DDAg/gdBoTmjsLww19VDr1fx8LLA pbX2wxKZDQDTMDOwG6w9Lp1cpYwfQu27jnyoaDXYjVHItPtzw6iFptK3pGT6NCZMoOKt QtLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=62ADtBFBhYcqBVR6Gt91xol/T5WTzsilk8v+olTZ/u4=; b=LmTLKbjX3eWULgOyS0AFYE9PAndPOIa/zYRQk3PlDWxHkpkMesmEfsyOB8CK55eM2O B79QdD11QQAKBSU07Qgy5ivn/Nqigrfzs5qsPyDLGLJTYCmlfIRYyPolWtNCTuc6xR+l WvWA4cpIf9Erx83erCcgLBwv1VmmNr1k4Mm+FBhXViyfi4J7jUaY4+vMWHsCmMBPZMKc MAYw1DByBZok/pVn2GiCm8VsdLQMUXpmcVodAlQX4GaBOGTGWP9qasO5mIxHH5FMi3mf vSCfnsNNjTR6mIcKdVRRffrbYTQdGldA7MmXHJOwWoy0O/X949xjnXYP+WeKp9v+8Qjb rlJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uPoRI6dP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g19si12166388edv.174.2020.07.21.12.29.22; Tue, 21 Jul 2020 12:29:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uPoRI6dP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730567AbgGUT3G (ORCPT + 99 others); Tue, 21 Jul 2020 15:29:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729171AbgGUT3G (ORCPT ); Tue, 21 Jul 2020 15:29:06 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8052C061794; Tue, 21 Jul 2020 12:29:05 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id w17so10674036ply.11; Tue, 21 Jul 2020 12:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=62ADtBFBhYcqBVR6Gt91xol/T5WTzsilk8v+olTZ/u4=; b=uPoRI6dPcH7lfcbfKHIbIv4yuwrI87QxMF6Nw7ID1lmREq/NbtC2uisUx/IF5Mk5HH tRsfLSoD+27L/2AyGJI2YL7KUQEdkJ/9bZbDTn6KRL9NMx2QKe9RTSeTxCIpdRVcIULs Wj2s1sQRMQcgkU0U7O7L85z6/63HYkKQOCFPrbOrGRQIcITgMoPEdHx94S0vetZvcEVp DO1odYJ3Dcds8JKOJUIIAX9OmoTYDG5S6pvXwlkP8Y+cmySKaVv5sGa8QWxWlOz2iRo1 mVZRxiUkjUncXjz9R/IDl/zCavvndKt3Mv8ZVhi4dmWRkGBXeIARa0ztIAwmS67Jehzm Gl6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=62ADtBFBhYcqBVR6Gt91xol/T5WTzsilk8v+olTZ/u4=; b=IexVSx63YokFreZbOSxEnjdal7Lce1FtJX9svWJplrZ8D2s4JDzD62OUbW0SS7YCS1 Qo5g1tvMwW8v05Ny7GX+swTCTh/ngV18tWIrImbd8t9nH8UAH4cV6KjNTu/E/30701ku tgCG9sWhJ4Ya+DzLEIbg7LJoW9lc0GBKQJmBGIAtPIk1Tlt0onyJyhpoObkoMR0OGuha 3WgeXT6oA/iQtdhH7xaX/PABPgic+fNYi44DafX5wOCuH5lAvOfyOD4bP+9AX6OGHAUD OuDEUkItmHo/ambAjvvcTG/60dkaZduuPExh9yeqFcuDAdj5zZYHpg1gpAUjy38Zob5t vAqw== X-Gm-Message-State: AOAM533LYsoF4HKE9gYwiT25vQQapZUyi+cBrG+Amb+F3dJjPyJdLjse Vx3ds9+31Lo46Lvxbre+rBxIfCvSDqP4WcgxGHoXYF10 X-Received: by 2002:a17:90a:a393:: with SMTP id x19mr6527601pjp.228.1595359745442; Tue, 21 Jul 2020 12:29:05 -0700 (PDT) MIME-Version: 1.0 References: <20200716072737.9535-1-cristian.pop@analog.com> In-Reply-To: <20200716072737.9535-1-cristian.pop@analog.com> From: Andy Shevchenko Date: Tue, 21 Jul 2020 22:28:49 +0300 Message-ID: Subject: Re: [RFC PATCH] one-bit-adc-dac: Add initial version of one bit ADC, DAC To: Cristian Pop Cc: linux-iio , Linux Kernel Mailing List , Jonathan Cameron Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 16, 2020 at 10:27 AM Cristian Pop wrote: > > Implementation for 1-bit ADC (comparator) and a 1-bit DAC (switch) ... > +struct one_bit_adc_dac_state { > + struct platform_device *pdev; Wouldn't 'struct device *dev;' be enough? > + struct gpio_descs *in_gpio_descs; > + struct gpio_descs *out_gpio_descs; > +}; ... > +{ > + struct one_bit_adc_dac_state *st = iio_priv(indio_dev); > + int in_num_ch = 0, out_num_ch = 0; > + int channel = chan->channel; > + if (st->in_gpio_descs) > + in_num_ch = st->in_gpio_descs->ndescs; > + > + if (st->out_gpio_descs) > + out_num_ch = st->out_gpio_descs->ndescs; I'm wondering if you need these conditionals. Is it even possible you have ndescs > 0 and no descriptors? > + switch (info) { > + case IIO_CHAN_INFO_RAW: > + if (channel < in_num_ch) { > + *val = gpiod_get_value_cansleep( > + st->in_gpio_descs->desc[channel]); Strange indentation... > + } else { > + channel -= in_num_ch; > + *val = gpiod_get_value_cansleep( > + st->out_gpio_descs->desc[channel]); Ditto. > + } > + return IIO_VAL_INT; > + default: > + return -EINVAL; > + } > +} > + > +static int one_bit_adc_dac_write_raw(struct iio_dev *indio_dev, > + struct iio_chan_spec const *chan, > + int val, > + int val2, > + long info) > +{ Same comments as per previous function above. > +} ... > + ret = device_property_read_string_array(&st->pdev->dev, > + propname, > + gpio_names, > + num_ch); > + if (ret < 0) if (ret) > + return ret; ... > + channels = devm_kcalloc(indio_dev->dev.parent, (in_num_ch + out_num_ch), Extra parentheses. > + sizeof(struct iio_chan_spec), GFP_KERNEL); sizeof(*channels) ? > + if (!channels) > + return -ENOMEM; ... > +static const struct of_device_id one_bit_adc_dac_dt_match[] = { > + { .compatible = "adi,one-bit-adc-dac" }, > + {}, No comma here! > +}; > + Unnecessary blank line. > +MODULE_DEVICE_TABLE(of, one_bit_adc_dac_dt_match); ... > + Ditto. > +module_platform_driver(one_bit_adc_dac_driver); -- With Best Regards, Andy Shevchenko