Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1593356rwb; Sun, 14 Aug 2022 07:28:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR6L9N4cbuNHeXngih2lZVxQBEb7sY4FVT1uPiZw+HMc7Lh3eQ7WYJvP1tvx9NBlA16BxHhB X-Received: by 2002:a17:907:2704:b0:734:e5ae:e1f5 with SMTP id w4-20020a170907270400b00734e5aee1f5mr5305839ejk.761.1660487319705; Sun, 14 Aug 2022 07:28:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660487319; cv=none; d=google.com; s=arc-20160816; b=KHz9mgrp7IEvQIQce3HdcrEwA16NWqpEhTjaOOl/O9M7w+L1e7XI7kmrEh+ojEVL9o 796spc+8DdwOYuTdQ4WqYHyHyCYOGisxU03WC7i1bl7on9v+dlWJROi+gqYR+b8UM7+m CZb0F3N6be5ABBK4R1LkCoU9dRDCPqIeFyCC6CEWLTmBtS2YEOHiyjkw3aS2n1i+PdOL 4QlDmKn7KA/4H8ztRT73+wnz2VYZr1NcXI2PrdprT07NYdVwU+iQsYH4TkT4yXH85hlH lbgaB61BGVR6mBSFutVq9bu96V/31zGj07rcFgSqzk71MvqCBY9gRIj7DbswTRgIi6I4 gBKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=SVz2V6wbv8evz3LHWFcsYQ+Me4i32WPz3to0fwfDz50=; b=F9SbEZpEDRnDr97RFoF49BVMFyOdOKYTcOwmPytNvcQwm4PB44DqFd2NWGSv9KJEOE 2Mak3q3o3UCdyL7RwRr9MdnBkJlihbOZ4gPRoUCr90TkEysQZIvOsdVH5dmg+KhX3TPB FWfwnJGv/W541PKG4o1I03NBBKGjK66rTvOUxx7Ux6oQ+rhYFFocCvPEfyqSZdqTC0J9 +1oKX2N0imdMSEjliCVDwl8upa3ENPGlnsKxHzXPBPf7KjdlJRnKaO29MZ2xkb4+GjRK prQIfiqgSqSzbf37A0bJL/MPnbTU/GwH8rYcvCrIueJZSBeAuqY33QT3OJz2QVpQHQiD L4Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C+uK5dlB; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o6-20020a056402438600b0043cf3369c9bsi6436166edc.57.2022.08.14.07.28.14; Sun, 14 Aug 2022 07:28:39 -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=@kernel.org header.s=k20201202 header.b=C+uK5dlB; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239929AbiHNOVe (ORCPT + 99 others); Sun, 14 Aug 2022 10:21:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239901AbiHNOVc (ORCPT ); Sun, 14 Aug 2022 10:21:32 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FE1FBE02; Sun, 14 Aug 2022 07:21:31 -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 ams.source.kernel.org (Postfix) with ESMTPS id 32855B80AEF; Sun, 14 Aug 2022 14:21:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B37D1C433D6; Sun, 14 Aug 2022 14:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660486888; bh=En3+VuMkA87sn2bRF2hyGdrJ4D418NzIDZAtlEGnp58=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=C+uK5dlBzLDq3i4IO4JuwnH47qUeo840PkcxnAS4TeCbLHyYQreJxEc5uLB96Jk21 /mt7rLtkxgnlvMOML+I7IMOsmby2YfOQeYJbOzI6IvPaYXh9Hx12UfiiuvhkDMCBxn d+2WuRaewJC3rPZCdjBeLsth6hDv1qcoTWeplUazWw+vQP7NZWpstlm+nmb1+wWwVt xYaA3EvpOHdKrdSUCAZ5ceBHDQC5DRq5wsYAqoBgwWiGPWrc+csfwlLIDKPVhjKEMJ 7S8j9xjwiTFavdAKONJahK7Xja5hlcQCALTGKCwIIUz0MozTWiHnDm1TYVOLrrGbex +IOBtsHHqAWyQ== Date: Sun, 14 Aug 2022 15:31:57 +0100 From: Jonathan Cameron To: Marcus Folkesson Cc: Kent Gustavsson , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Andy Shevchenko , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 5/9] iio: adc: mcp3911: add support for buffers Message-ID: <20220814153157.5e26ebd8@jic23-huawei> In-Reply-To: <20220809073648.167821-6-marcus.folkesson@gmail.com> References: <20220809073648.167821-1-marcus.folkesson@gmail.com> <20220809073648.167821-6-marcus.folkesson@gmail.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Tue, 9 Aug 2022 09:36:44 +0200 Marcus Folkesson wrote: > Add support for buffers to make the driver fit for more usecases. > > Signed-off-by: Marcus Folkesson > Reviewed-by: Andy Shevchenko One really trivial comment from me below if you are respinning anyway. > +static irqreturn_t mcp3911_trigger_handler(int irq, void *p) > +{ > + struct iio_poll_func *pf = p; > + struct iio_dev *indio_dev = pf->indio_dev; > + struct mcp3911 *adc = iio_priv(indio_dev); > + struct spi_transfer xfer[] = { > + { > + .tx_buf = &adc->tx_buf, > + .len = 1, > + }, { > + .rx_buf = adc->rx_buf, > + .len = sizeof(adc->rx_buf), > + }, > + }; > + > + int scan_index; > + int i = 0; > + int ret; > + > + mutex_lock(&adc->lock); > + adc->tx_buf = MCP3911_REG_READ(MCP3911_CHANNEL(0), adc->dev_addr); > + ret = spi_sync_transfer(adc->spi, xfer, ARRAY_SIZE(xfer)); > + if (ret < 0) { > + dev_warn(&adc->spi->dev, > + "failed to get conversion data\n"); > + goto out; > + } > + > + for_each_set_bit(scan_index, indio_dev->active_scan_mask, > + indio_dev->masklength) { > + const struct iio_chan_spec *scan_chan = &indio_dev->channels[scan_index]; > + > + adc->scan.channels[i] = get_unaligned_be24(&adc->rx_buf[scan_chan->channel * 3]); > + i++; > + } > + iio_push_to_buffers_with_timestamp(indio_dev, &adc->scan, > + iio_get_time_ns(indio_dev)); iio_get_time_ns(indio_dev)); trivial: align with opening bracket unless the resulting line length is going to be very high as a result. I could be wrong but I thought checkpatch warned on this... > +out: > + mutex_unlock(&adc->lock); > + iio_trigger_notify_done(indio_dev->trig); > + > + return IRQ_HANDLED; > +}