Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1251256ima; Sun, 21 Oct 2018 07:44:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV611xMa+KE8YiQzeP3mevEXOMd93vj/HaFr67SWbah1RRSI1ou4JWcEj4/2emQb6sMMzYxJp X-Received: by 2002:a62:48ce:: with SMTP id q75-v6mr42871366pfi.22.1540133082224; Sun, 21 Oct 2018 07:44:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540133082; cv=none; d=google.com; s=arc-20160816; b=sBsRefnxuGfRiWuC7F1lcFofnIEILwaU0LgkwxILE9Lv3iMZ9HkiCS7MWhvsOGZqlw /NtHPxF0V1MCI91oc2nyd6fZKm76+7KxdrwQ/Cv5GDIVt8kjvDTtOcZSZHv5mDPyX+v4 /7jyLgGveMEEpl71VyhbRHA7TdotRQUtf/IbBIGjeATUoazcU3O7IeM60vV4X5ZU04Oz 6/cPMwvhIqnvTFC3u8Jp+EmXJKdKMM+yTyWSBMoMvT1AEysWZQkgALVXMFB4RjitH7L5 BHAo21twPShEb07NH6Ql47YGXZKEVABHbU0/0wiGT3X683DCvZ1EDW8qFvOmatMmQX+/ 6g1Q== 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=3Ilj1dpwOWM7bi7acX+2J7t9io9CI1bO3ZnJdKzSlQQ=; b=GEutvqyDjwBnpCiCF2WSHVN1uzeIb+T+yeyorKLYnpQrJ0uVyepjimHfeO4MqEX7sw JCT2Z2NKqUU7fMLg3pZJQa3ZYbIM4raOyCHdiJBCBImjNo9v9y/iVwUwldNW+qjQgW0P XvYRYhJE6aQ7Tx05k7fqYncS7pJtuEfpAGGCZq3WTbuWe3YZ+Ic6R2/J4OVurKA5w1O4 k2/0OAq58VHaqGYeYV9RIXpmT3mwk179pHAHzyZUpsmBEiLNG8MgwNG691oj+rfyRd4o WtDjrr+eDjaaQEt2klGoA/yydQjtfGdQWk8koeBCwoSQolA2dRT3ffqr1leowyvr3pbu 6AKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mM8TRUQo; 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 p25-v6si12899826pli.239.2018.10.21.07.44.27; Sun, 21 Oct 2018 07:44:42 -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=mM8TRUQo; 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 S1727780AbeJUW3E (ORCPT + 99 others); Sun, 21 Oct 2018 18:29:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:47770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727266AbeJUW3E (ORCPT ); Sun, 21 Oct 2018 18:29:04 -0400 Received: from archlinux (unknown [176.12.107.140]) (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 E4D9320836; Sun, 21 Oct 2018 14:14:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540131273; bh=5ozLdjNbogvagVNSIuHHJY/AXlM+49c9BHGEzLc12IU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=mM8TRUQo59UY5Mk1v9Awb5kZHN2oemzRmGx8qmmvzFvVU4SKWox6DuZX+JgnfirJK 0g6g7t+H2YEOrOZHJeJ78tD/MXPiGLAlCPmqL5d6RX2LOe9W9G3jk76w1HmFr2SBvo nMFNe0cDRnVJRfs7lzQa5o5JIyYh0z5pAPPFa3yA= Date: Sun, 21 Oct 2018 15:14:27 +0100 From: Jonathan Cameron To: Song Qiang Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, robh+dt@kernel.org, mark.rutland@arm.com, preid@electromag.com.au, himanshujha199640@gmail.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 3/3] iio: magnetometer: Add driver support for PNI RM3100 Message-ID: <20181021151427.5b3dbb9b@archlinux> In-Reply-To: References: <20181002143812.3661-1-songqiang1304521@gmail.com> <20181012073536.20339-1-songqiang1304521@gmail.com> <20181012073536.20339-4-songqiang1304521@gmail.com> <20181013111935.00a2e1af@archlinux> 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=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 18 Oct 2018 16:24:15 +0800 Song Qiang wrote: > On 2018/10/13 =E4=B8=8B=E5=8D=886:19, Jonathan Cameron wrote: > > On Fri, 12 Oct 2018 15:35:36 +0800 > > Song Qiang wrote: > > =20 > >> PNI RM3100 is a high resolution, large signal immunity magnetometer, > >> composed of 3 single sensors and a processing chip with a MagI2C > >> interface. > >> > >> Following functions are available: > >> - Single-shot measurement from > >> /sys/bus/iio/devices/iio:deviceX/in_magn_{axis}_raw > >> - Triggerd buffer measurement. > >> - DRDY pin for data ready trigger. > >> - Both i2c and spi interface are supported. > >> - Both interrupt and polling measurement is supported, depends on if > >> the 'interrupts' in DT is declared. > >> > >> Signed-off-by: Song Qiang =20 > > A few questions for you (getting very close to being good to go btw!) > > > > Why do we have the 3second additional wait for conversions? I know we > > rarely wait that long, but still seems excessive. > > > > Few more comments inline. > > > > Thanks, > > > > Jonathan =20 >=20 > Hi Jonathan, >=20 >=20 > The measurement time of this device varies from 1.7ms to 13 seconds, 3 se= conds=20 > is just a number in the middle between them. This may be worth discussing= ,=20 > hoping to get a better solution from the community. We should 'know' which of those it will be though as I assume it is depende= nt on the device configuration which we control. So waiting for say, double, the expected time should be sufficient to detect that things have gone horribly wrong. >=20 >=20 > >> --- > >> MAINTAINERS | 7 + > >> drivers/iio/magnetometer/Kconfig | 29 ++ > >> drivers/iio/magnetometer/Makefile | 4 + > >> drivers/iio/magnetometer/rm3100-core.c | 627 +++++++++++++++++++++++= ++ > >> drivers/iio/magnetometer/rm3100-i2c.c | 58 +++ > >> drivers/iio/magnetometer/rm3100-spi.c | 64 +++ > >> drivers/iio/magnetometer/rm3100.h | 17 + > >> 7 files changed, 806 insertions(+) > >> create mode 100644 drivers/iio/magnetometer/rm3100-core.c > >> create mode 100644 drivers/iio/magnetometer/rm3100-i2c.c > >> create mode 100644 drivers/iio/magnetometer/rm3100-spi.c > >> create mode 100644 drivers/iio/magnetometer/rm3100.h > >> =20 >=20 > ... >=20 > > =20 > >> +static irqreturn_t rm3100_trigger_handler(int irq, void *p) > >> +{ > >> + struct iio_poll_func *pf =3D p; > >> + struct iio_dev *indio_dev =3D pf->indio_dev; > >> + unsigned long scan_mask =3D *indio_dev->active_scan_mask; > >> + unsigned int mask_len =3D indio_dev->masklength; > >> + struct rm3100_data *data =3D iio_priv(indio_dev); > >> + struct regmap *regmap =3D data->regmap; > >> + int ret, i, bit; > >> + > >> + mutex_lock(&data->lock); > >> + switch (scan_mask) { > >> + case BIT(0) | BIT(1) | BIT(2): > >> + ret =3D regmap_bulk_read(regmap, RM3100_REG_MX2, data->buffer, 9); > >> + mutex_unlock(&data->lock); > >> + if (ret < 0) > >> + goto done; > >> + break; > >> + case BIT(0) | BIT(1): > >> + ret =3D regmap_bulk_read(regmap, RM3100_REG_MX2, data->buffer, 6); > >> + mutex_unlock(&data->lock); > >> + if (ret < 0) > >> + goto done; > >> + break; > >> + case BIT(1) | BIT(2): > >> + ret =3D regmap_bulk_read(regmap, RM3100_REG_MY2, data->buffer, 6); > >> + mutex_unlock(&data->lock); > >> + if (ret < 0) > >> + goto done; > >> + break; =20 > > What about BIT(0) | BIT(2)? > > > > Now you can do it like you have here and on that one corner case let th= e iio core > > demux code take care of it, but then you will need to provide available= _scan_masks > > so the core knows it needs to handle this case. > > =20 >=20 > This confused me a little. The available_scan_masks I was using is {BIT(0= ) |=20 > BIT(1) | BIT(2), 0x0}. Apparently in this version of patch I would like i= t to=20 > handle every circumstances like BIT(0), BIT(0) | BIT(2), BIT(1) | BIT(2),= etc.=20 > Since Phil mentioned he would like this to reduce bus usage as much as we= can=20 > and I want it, too, I think these three circumstances can be read consecu= tively=20 > while others can be read one axis at a time. So I plan to let=C2=A0 BIT(0= ) | BIT(2)=20 > fall into the 'default' section, which reads axis one by one. >=20 > My question is, since this handles every possible combination, do I still= need=20 > to list every available scan masks in available_scan_masks? Ah. I see, I'd missed that the default was picking up that case as well as = the single axes. It would be interesting to sanity check if it is quicker on a 'typical' platform to do the all axis read for the BIT(0) | BIT(2) case and drop the middle value (which would be done using available scan_masks) or to just do two independent reads. (I would guess it is worth reading the 'dead' axis). >=20 >=20 > All other problems will be fixed in the next patch. >=20 > yours, >=20 > Song Qiang >=20 >=20 > ... Thanks, Jonathan