Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp405977imp; Wed, 20 Feb 2019 02:21:15 -0800 (PST) X-Google-Smtp-Source: AHgI3IaEwNXA0QG4j/xkGkB9Im5Gq9eOtHS6LiqVc6VrkLiKiMDFyLl9DAWAmKnJoDWibRJYKStd X-Received: by 2002:a62:3a89:: with SMTP id v9mr34010624pfj.26.1550658075291; Wed, 20 Feb 2019 02:21:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550658075; cv=none; d=google.com; s=arc-20160816; b=LvqNHY1KDBO16bsnJHOFaHqIXlxk/UTU4bW2+WfjhrCG0eCxDO8tK9emXTpJeGsNEJ lS8MFFEDjYl4ARmeMxDuvq4k1aQqm70wF4wuzCoouKj4MFdef3E2MnBcZLH/RGTALL32 81BhQFE5QbtGXeuRgPFR0UBoMGx+K/HS/P2eLnqYE/DB3TjT4HRiaAX3dHsBz3fFaG36 5Zjy+8/fA5cqdJkd9QdLQw7+Z2tV3ziN1qhRIij5LeQMP0IWZYNMdGveNcUvrLb+V2Cg gNbuA0X4b7Hl4/PJo0uFLx8rjjE+nb8v5x6tfAPp7gmmCTKxHeNZeyAxjVI2qnFANQf3 NMPA== 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=fNk530/4Ef+FMD2eU5Tx1yWM75pxLl7V8erPimT18nE=; b=BH/7n9UHteq16Y6Jv3UKlmqX9rjyUOdplxdUKh9PEwiF+5bIrMWCdcGADVuQ80wXka poEGplYvAjEwilY/tSy/DUY/bidLIERqaPxrbX5LnHhqIULQ2XMjA7GiF0YCn8oGpudT jteNklYoVQv+LkJiL8aT5xs8UO8Bjhz8+GEoWMu6f5DFmOhhSE2j0GFN8dOvZGezBAuc 1M6webdg8yLtoDPR8YH4vmFhZcSx8nqN2DaqCa9MZBg7whB1EA7IW6hFsl+vGD2Uge9C /HFL/EvjZXB0GHJPfCxyUlp7rskLZKvXjkqaDaHVdVk4imabZc9qj6KGYUXmNAfu+Vd6 Mx6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VoMTkp4Q; 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 g1si8307860pgi.65.2019.02.20.02.21.00; Wed, 20 Feb 2019 02:21:15 -0800 (PST) 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=VoMTkp4Q; 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 S1727198AbfBTKUf (ORCPT + 99 others); Wed, 20 Feb 2019 05:20:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:43732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726142AbfBTKUd (ORCPT ); Wed, 20 Feb 2019 05:20:33 -0500 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 804472146E; Wed, 20 Feb 2019 10:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550658032; bh=z2pN6gqw9dJSz+KlwnI2Ir4v6pm/sy9t0RnyvQTcVSo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VoMTkp4QFdHB86sd4C4X0Zpw9PuRHlo8j4QJLuRRqyPy3mg2+ovZlZ5fjoh6Zxs4e OYqUk/v8KQWFik/Yuyb4hWWQ+mTK0pXiLdjJXagV7H2IHtLlFpbPamQdSbUE866T/4 1m/Mmiwopgbtqw8F2lSjvi11pzC8xugTXjTN87c0= Date: Wed, 20 Feb 2019 10:20:23 +0000 From: Jonathan Cameron To: Stefan Popa Cc: , , , , , , , Subject: Re: [PATCH 1/6] iio: imu: adis16480: Use the default data ready pin configuration Message-ID: <20190220102002.5f918e74@archlinux> In-Reply-To: <1550596338-24220-2-git-send-email-stefan.popa@analog.com> References: <1550596338-24220-1-git-send-email-stefan.popa@analog.com> <1550596338-24220-2-git-send-email-stefan.popa@analog.com> X-Mailer: Claws Mail 3.17.3 (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 Tue, 19 Feb 2019 19:12:13 +0200 Stefan Popa wrote: > The FNCTIO_CTRL register, Bits[3:0] provide three configuration options > for the data ready function: on/off, polarity, and DIOx line. The > factory default assigns DIO2 as a positive polarity, data ready signal. > > The adis16480_enable_irq() function, overwrites this configuration when > it enables/disables the data ready pin by only setting BIT[3]. > As a result, the data ready signal becomes DIO1 pin which is assigned as > negative polarity. > > This patch reads the FNCTIO_CTRL register and creates a mask, such that > only data ready enable (BIT[3]) will be modified when > adis16480_enable_irq function is called. So this is potentially a problem. As I read this, we just changed the default. So a device that has been relying on this 'bug' for a long time will now not work as it will be expecting the interrupt on the wrong physical pin. So, whilst it might seem logical to let the device stay with it's default we can't do it because the defacto Linux default is the other choice. The delights of having to support old 'bugs' :) Jonathan > > Signed-off-by: Stefan Popa > --- > drivers/iio/imu/adis16480.c | 18 ++++++++++++++++-- > 1 file changed, 16 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c > index a27fe20..d222188 100644 > --- a/drivers/iio/imu/adis16480.c > +++ b/drivers/iio/imu/adis16480.c > @@ -9,6 +9,7 @@ > * > */ > > +#include > #include > #include > #include > @@ -107,6 +108,10 @@ > #define ADIS16480_FIR_COEF_C(x) ADIS16480_FIR_COEF(0x09, (x)) > #define ADIS16480_FIR_COEF_D(x) ADIS16480_FIR_COEF(0x0B, (x)) > > +/* ADIS16480_REG_FNCTIO_CTRL */ > +#define ADIS16480_DRDY_EN_MSK BIT(3) > +#define ADIS16480_DRDY_EN(x) FIELD_PREP(ADIS16480_DRDY_EN_MSK, x) > + > struct adis16480_chip_info { > unsigned int num_channels; > const struct iio_chan_spec *channels; > @@ -741,8 +746,17 @@ static int adis16480_stop_device(struct iio_dev *indio_dev) > > static int adis16480_enable_irq(struct adis *adis, bool enable) > { > - return adis_write_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, > - enable ? BIT(3) : 0); > + uint16_t val; > + int ret; > + > + ret = adis_read_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, &val); > + if (ret < 0) > + return ret; > + > + val &= ~ADIS16480_DRDY_EN_MSK; > + val |= ADIS16480_DRDY_EN(enable); > + > + return adis_write_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, val); > } > > static int adis16480_initial_setup(struct iio_dev *indio_dev)