From patchwork Fri Nov 9 07:36:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishad Kamdar X-Patchwork-Id: 10675413 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 561A513BF for ; Fri, 9 Nov 2018 07:36:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40F292E6DB for ; Fri, 9 Nov 2018 07:36:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 352632E6F7; Fri, 9 Nov 2018 07:36:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9E742E6DB for ; Fri, 9 Nov 2018 07:36:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727869AbeKIRPw (ORCPT ); Fri, 9 Nov 2018 12:15:52 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:38287 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727789AbeKIRPw (ORCPT ); Fri, 9 Nov 2018 12:15:52 -0500 Received: by mail-pf1-f193.google.com with SMTP id b11-v6so552197pfi.5; Thu, 08 Nov 2018 23:36:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=D+hgTAknwOvfgpgcMHvVyFVBDFXLuZFMqPVNoy67gvo=; b=QTrzCvOj6AKg8ZpmlfN2nsvfuG6x+foMlC8StA1kzAFLDwCQkHIOQTkKSD34/EzoIl /pcp4fXkxxuoZuhgg/4qBiboAzCM+y9fJ9iZ4cuSmNfZwHOGCdcas2u7zBYe+kS1cpTx Mk/sMBtnKi1fO5n2y/5L9gCpGXYAABxLlwGENMbSl34279nmmsDVa4ovia0wNCFjkcQ7 AYDg2XRicPdjWwTvyahu8UaLH10EbdFPfDzbvCluUtculMmXYP13vOYmyR2zNXg1IEYn feHNOsGdhMNtfG+UQOd5/jBIUkAEJeoEXxKbj55tqAgp9jTqgiAPReUy7OO+OG5FfKh/ 6wZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=D+hgTAknwOvfgpgcMHvVyFVBDFXLuZFMqPVNoy67gvo=; b=TzC4wazqYP5FGgTfmOaClT7enbyP8WuFEccokP7Fcb+NAp1GTeoH11OqdatXuThthQ fzmM0HLszUvdTzVvrRHj3Yu5eYGdISq7Ccl5RxpDjX0p/yjlzB+UhaELhERHyBq3k2o3 Cc9QpxGmBiXeJ6BGBE1ghj6ov1ca38hToZOv0BV7v9+LffvIPzO54VrnjI1lNA6f1/W+ rkAQlysOKTj33N8dwt4Nmod8zgvuKOtroBjZ8Z0bSu9sGaFEWWwMGFssYcnzhvgA/7/u 4mZxkTNf4XKodwSvXiaXPmUQ7386q0k5yKb9w/6ZLMaBdrccbSSsvN3o8FcO4s8GXECo wAmQ== X-Gm-Message-State: AGRZ1gL3Q3XeSRCiRgQBcqD/D0PsENQeRIXYqlP3TbT+hpaBzzBouvyb EjdDadfZYEPpZ/WKGIaL39k= X-Google-Smtp-Source: AJdET5c8AHD4Kf7dl/Sowt1yG7Y4P54rtXfXwTtWGoHgAPyYTN+gFNbn/fz7VJZpei4UzASaCA6fww== X-Received: by 2002:aa7:8546:: with SMTP id y6-v6mr8047452pfn.83.1541748992787; Thu, 08 Nov 2018 23:36:32 -0800 (PST) Received: from nishad ([106.210.186.71]) by smtp.gmail.com with ESMTPSA id n17-v6sm12553638pfj.148.2018.11.08.23.36.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Nov 2018 23:36:32 -0800 (PST) Date: Fri, 9 Nov 2018 13:06:24 +0530 From: Nishad Kamdar To: Lars-Peter Clausen Cc: Michael Hennerich , Jonathan Cameron , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman , linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/4] staging: iio: ad7816: Do not use busy_pin in case of AD7818 Message-ID: <3f0bc36261c54c945a3213ef03425099e57e9060.1541733949.git.nishadkamdar@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP AD7818 does not support busy_pin functionality as per datasheet. Hence drop busy_pin when AD7818 is used. Signed-off-by: Nishad Kamdar --- 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 }, {} };