Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2947108imu; Sun, 11 Nov 2018 04:35:49 -0800 (PST) X-Google-Smtp-Source: AJdET5eZkdD0vnpivwwTln99SiJAjpMGfBomKcHv1Sq1i0j9WWNQ50xN3nWDJdc/iUkL1WHPc55g X-Received: by 2002:a17:902:76cc:: with SMTP id j12-v6mr16289677plt.339.1541939749430; Sun, 11 Nov 2018 04:35:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541939749; cv=none; d=google.com; s=arc-20160816; b=hjpCUksv2r9SHPKYoWOGzlKH3Rb8btC7OFVC2vWqylQ+zvPEzC8aJQqXtALajDQpaV dkSTOdoxeUp+RL+QzPdO7p1tvOdxlkdYvZpfbF2v7gh+o6YUt6iZ7Y/G6zb57VtiqUc8 m69Dy8pHQXoUiDFU4LXzh4OSMt7AvVA4cnbonzWCjoGytdNG9VV92x3iH88nEqnt44ef l4UkrNSTp2+NswsPgtVzwiwox1w9AAD760CznDP4olPzQsKxGkvIzrCQYET6RgfOX19G hz3HmwmQkvbSNkBfy8ooArdm/WGDCL0YXv2xRqKb5RcY0W9wNSD1fyuNhUFXhnkDjSy/ 9Z3Q== 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=haOlU7zN6cbtlVji04EG8q9KsJNDq+A2D/no4S2YMBM=; b=dPANC474IIh6piIHFb7xJNlb8RMFniIt6k8A3Gf09nkkrOo33oIJsGnWM2D/DdGQ4p kc7RNdgA5iDPLyQ/y1vnweV4rTHntZv+8chVA2neyr1Smu8fr1hzuQazmXu+zCderc69 L4HF29VqPZDrs42sBeJmT5tqwG6BnEGz+m9fZu3/Ht3n2i4DZyR3/NWukzZ3dB3FXOEr EXEpOcwUmUPM0VQK+vEJb9NZRoUgG4TPuDdvct2xbYNknJjxL2S9E56mUC6EiN4k3tIs 2WMiXcKMLdO+6GZFbGV2aIxRpdf6Yc7zZBjUEmP6ASR6YQE960nJmlSDDjKuojmPFe+V lLCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X46B2jYH; 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 i187-v6si7003432pfb.91.2018.11.11.04.35.33; Sun, 11 Nov 2018 04:35:49 -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=X46B2jYH; 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 S1727876AbeKKWXg (ORCPT + 99 others); Sun, 11 Nov 2018 17:23:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:55318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727510AbeKKWXg (ORCPT ); Sun, 11 Nov 2018 17:23:36 -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 7434A20866; Sun, 11 Nov 2018 12:35:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541939708; bh=S4dLL4SN0fS03qGxTOgFgky1fQXEx+GruS26JQFnCzA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=X46B2jYHuH4xwVuv9YnomTEDkcUFZEHAZ6JNpgajBMaauhpbxksK9gLk3Li6rC4K3 lP8Zr4klAcwX7bApYCaFpvKZWKcBLezNl99xTFLqgi2dqdIrF72dBH2bMGlA62PaU3 CdkeTQ1FuU4hC13UoP/+Wb1Gmcf0ywpl1DymZTfs= Date: Sun, 11 Nov 2018 12:35:03 +0000 From: Jonathan Cameron To: Nishad Kamdar Cc: Lars-Peter Clausen , Michael Hennerich , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman , linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/4] staging: iio: ad7816: Do not use busy_pin in case of AD7818 Message-ID: <20181111123503.3a4acef2@archlinux> In-Reply-To: <3f0bc36261c54c945a3213ef03425099e57e9060.1541733949.git.nishadkamdar@gmail.com> References: <3f0bc36261c54c945a3213ef03425099e57e9060.1541733949.git.nishadkamdar@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 Fri, 9 Nov 2018 13:06:24 +0530 Nishad Kamdar wrote: > AD7818 does not support busy_pin functionality as per datasheet. > Hence drop busy_pin when AD7818 is used. > > Signed-off-by: Nishad Kamdar Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. A slight concern that I can't immediately find an answer to, is whether we should be waiting a short while for the ad7818 given we can't wait on the gpio? We can add this in a follow up patch if it is necessary. Thanks, Jonathan > --- > drivers/staging/iio/adc/ad7816.c | 35 ++++++++++++++++++++++---------- > 1 file changed, 24 insertions(+), 11 deletions(-) > > diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c > index 12c4e0ab4713..3cda5cd09365 100644 > --- a/drivers/staging/iio/adc/ad7816.c > +++ b/drivers/staging/iio/adc/ad7816.c > @@ -43,6 +43,7 @@ > */ > > struct ad7816_chip_info { > + kernel_ulong_t id; > struct spi_device *spi_dev; > struct gpio_desc *rdwr_pin; > struct gpio_desc *convert_pin; > @@ -52,6 +53,12 @@ struct ad7816_chip_info { > u8 mode; > }; > > +enum ad7816_type { > + ID_AD7816, > + ID_AD7817, > + ID_AD7818, > +}; > + > /* > * ad7816 data access by SPI > */ > @@ -78,8 +85,10 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data) > gpiod_set_value(chip->convert_pin, 1); > } > > - while (gpiod_get_value(chip->busy_pin)) > - cpu_relax(); > + if (chip->id == ID_AD7816 || chip->id == ID_AD7817) { > + while (gpiod_get_value(chip->busy_pin)) > + cpu_relax(); > + } > > gpiod_set_value(chip->rdwr_pin, 0); > gpiod_set_value(chip->rdwr_pin, 1); > @@ -359,6 +368,7 @@ static int ad7816_probe(struct spi_device *spi_dev) > for (i = 0; i <= AD7816_CS_MAX; i++) > chip->oti_data[i] = 203; > > + chip->id = spi_get_device_id(spi_dev)->driver_data; > chip->rdwr_pin = devm_gpiod_get(&spi_dev->dev, "rdwr", GPIOD_IN); > if (IS_ERR(chip->rdwr_pin)) { > ret = PTR_ERR(chip->rdwr_pin); > @@ -373,12 +383,15 @@ static int ad7816_probe(struct spi_device *spi_dev) > ret); > return ret; > } > - chip->busy_pin = devm_gpiod_get(&spi_dev->dev, "busy", GPIOD_IN); > - if (IS_ERR(chip->busy_pin)) { > - ret = PTR_ERR(chip->busy_pin); > - dev_err(&spi_dev->dev, "Failed to request busy GPIO: %d\n", > - ret); > - return ret; > + if (chip->id == ID_AD7816 || chip->id == ID_AD7817) { > + chip->busy_pin = devm_gpiod_get(&spi_dev->dev, "busy", > + GPIOD_IN); > + if (IS_ERR(chip->busy_pin)) { > + ret = PTR_ERR(chip->busy_pin); > + dev_err(&spi_dev->dev, "Failed to request busy GPIO: %d\n", > + ret); > + return ret; > + } > } > > indio_dev->name = spi_get_device_id(spi_dev)->name; > @@ -409,9 +422,9 @@ static int ad7816_probe(struct spi_device *spi_dev) > } > > static const struct spi_device_id ad7816_id[] = { > - { "ad7816", 0 }, > - { "ad7817", 0 }, > - { "ad7818", 0 }, > + { "ad7816", ID_AD7816 }, > + { "ad7817", ID_AD7817 }, > + { "ad7818", ID_AD7818 }, > {} > }; >