Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2621583imm; Sun, 7 Oct 2018 08:08:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV62uks+7s9mwrVBfWKm4cadLNxw7BmBYMmKoVDk0duQ64FQKUPqAAtcmPdQVFGtz9EoRKeeZ X-Received: by 2002:a62:be1a:: with SMTP id l26-v6mr11507709pff.204.1538924881461; Sun, 07 Oct 2018 08:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538924881; cv=none; d=google.com; s=arc-20160816; b=stbtwgv6uxynbPaA70y9I2cAWU3pXercvFd9Rz177tn9wL3J+HNEyDVnLS9Qh4b9yP h5/YKOB+a2Aqr262wksikBFC1Jz1iEBxzfx7j11KnzkNAk9h8X78bcwscE9bYHBHuJUn LATxvjREGrWChMdDnZF+qAayj/XzQGHCJIPNimAG051dmM1B2upIcS7us+ePNtvfklUB vEp+0MeuPUasFJDbRsxxUCMlbsnNz7upPiJ4q61KkogKX5WBOTUhfxtQaebH9dOM9sr8 G47hdyNdyZTyS5vIYoSS16esyzXc4kFFHKqdAeWdMnq7+6hSzo4qR+sf5LY1dkewNgs9 QvwQ== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=9nwGZcN9itMqyUT+yp0W/j8CZWYKvKa+Yf3wQuYxAfU=; b=B/2jZgKIMG/T3LUsMsmTrG2l2MQDaFei1BkGT8+6++ZxHXaiAFHANVa6YU6R/o4SVT aGlpp7ciCBIs+6TVtw25tH44YADQ8tZhNkPzeccwvtt5f4rQ0FQjtlZdtu9CLOv530bS ReYtrG8T/fxmeSQqntSx7uHabopecYsjkkP/fGwfD1eoJ5EY2XDrwnvNrDk0keR66ZJK wOMMzlR1QfxrkaFk6zFlDEkpQm2L/ibNrInVwN1t/AWAJ5gPedVHy9W4yw5e5kz4jM/I 5hzIABxy9p3vAlD74k2p+XIWyexSYBKmlUK7G49DPSSnIsqII32jLLxE5sAHjHDI8XRs LLMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qXU+EDbq; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 74-v6si14770022pga.231.2018.10.07.08.07.43; Sun, 07 Oct 2018 08:08:01 -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=@kernel.org header.s=default header.b=qXU+EDbq; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728243AbeJGWPK (ORCPT + 99 others); Sun, 7 Oct 2018 18:15:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:54756 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727517AbeJGWPK (ORCPT ); Sun, 7 Oct 2018 18:15:10 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B3AC620841; Sun, 7 Oct 2018 15:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1538924856; bh=fkZmFJvHx1zrZQi1tQvugTshno8csFtGyRAw5XWpwCs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qXU+EDbq2jeJaNlXk9Q07sSV9dZYuPlZCinpNRrOLLcNs4O5tSC1U2ig9MRJxCDSV bhxPSMkEi/a5sHoG+p3FKdC3mqPwO6r+3HwqRfHzmTs0p/w1tsZAnmOIfE6Chgr6Sx 7arkvD2IB2oN6DSfJsww09ZyDnbP2Pv7clWSCUBo= Date: Sun, 7 Oct 2018 16:07:30 +0100 From: Jonathan Cameron To: Phil Reid Cc: Song Qiang , knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, robh+dt@kernel.org, mark.rutland@arm.com, himanshujha199640@gmail.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/3] iio: magnetometer: Add driver support for PNI RM3100 Message-ID: <20181007160730.4df1010b@archlinux> In-Reply-To: References: <20180925031724.21399-1-songqiang1304521@gmail.com> <20181002143812.3661-1-songqiang1304521@gmail.com> <20181002143812.3661-4-songqiang1304521@gmail.com> X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 3 Oct 2018 09:42:14 +0800 Phil Reid wrote: > G'day Song, Hi Phil. Good point below. One general thing though, if you could possibly crop down a review email when you are addressing one specific point it would be very much appreciated! Saves everyone else scrolling and if they have a rubbish email client missing the comment entirely! Thanks, > > Noticed a one more thing below > ... > > +int rm3100_common_probe(struct device *dev, struct regmap *regmap, int irq) > > +{ > > + struct iio_dev *indio_dev; > > + struct rm3100_data *data; > > + unsigned int tmp; > > + int ret; > > + > > + indio_dev = devm_iio_device_alloc(dev, sizeof(*data)); > > + if (!indio_dev) > > + return -ENOMEM; > > + > > + data = iio_priv(indio_dev); > > + data->regmap = regmap; > > + > > + mutex_init(&data->lock); > > + > > + indio_dev->dev.parent = dev; > > + indio_dev->name = "rm3100"; > > + indio_dev->info = &rm3100_info; > > + indio_dev->channels = rm3100_channels; > > + indio_dev->num_channels = ARRAY_SIZE(rm3100_channels); > > + indio_dev->modes = INDIO_DIRECT_MODE; > > + indio_dev->available_scan_masks = rm3100_scan_masks; > > + > > + if (!irq) > > + data->use_interrupt = false; > > + else { > > + data->use_interrupt = true; > > + ret = devm_request_irq(dev, > > + irq, > > + rm3100_irq_handler, > > + IRQF_TRIGGER_RISING, > > + indio_dev->name, > > + data); > > Assuming the irq source is the DRDY pin, this pin is active high. > Which is automatically cleared when reading the measurement results register. > > Perhaps when using interrupts the irq handler should do the read into data->buffer > to clear the irq. Would need to use devm_request_threaded_irq instead. Agreed. With a level interrupt that is the easiest way to handle it. Grab the data in the threaded handler and complete after that. Jonathan > > The SOC irq block I use doesn't support edge triggered irqs, so this currently wouldn't work if > DRDY was connected to that. > > > > + if (ret < 0) { > > + dev_err(dev, "request irq line failed.\n"); > > + return ret; > > + } > > + init_completion(&data->measuring_done); > > + } > > + > > + ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL, > > + rm3100_trigger_handler, NULL); > > + if (ret < 0) > > + return ret; > > + > > + ret = regmap_read(regmap, RM3100_REG_TMRC, &tmp); > > + if (ret < 0) > > + return ret; > > + /* Initializing max wait time, 3sec more wait time for conversion. */ > > + data->conversion_time = > > + rm3100_samp_rates[tmp - RM3100_TMRC_OFFSET][2] + 3000; > > + ...