Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp438782imu; Thu, 8 Nov 2018 23:38:30 -0800 (PST) X-Google-Smtp-Source: AJdET5fnQESzhlwWnGYOIzGlg0wBU/40Z/Dny5DZPKqEy+C4FtR3Q5GyFbO3UBCUeEOlswy1ssiG X-Received: by 2002:a62:2cca:: with SMTP id s193-v6mr3031335pfs.10.1541749110470; Thu, 08 Nov 2018 23:38:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541749110; cv=none; d=google.com; s=arc-20160816; b=KJ3Ay+9BrbAenfOBY3HFkHTd5tzJz+kLf1abKoNcIiDnFEwdqcYDITmkTQ/iGqHiMK RAC+eDpuTDGHvl/Kqda/ufmx4HTeq/yYKBFELMcMANnUxaE2I/DW0wbBoHuub7dJOU6v FQNIqr/dW2jLzwU4ATw2n4mXA6ktuB4ku/kyJmtjlU2VItatV9PngW0Cx6Ws3Fb9hq5B lFm+euieBSY+PspGdO4KD81Q3/Alo/v7H1fpsxsspjT7Z9Aiw1CcWmj/+uwtQFju3TgU xQGnH0kebxBySpO2fsRIS1ynLtd0hVA6iWpQosofV4UU942jnmvlwEGqTIVyxJOWyhuN +YAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=D+hgTAknwOvfgpgcMHvVyFVBDFXLuZFMqPVNoy67gvo=; b=hKFq1btLAdvukFIasjQF7fFxY77/NQDLHhqI60TEU1ViOPoVqbLRFYaPvql1YRx9E+ LK4MaWZWN8OJyqQoF2X5o/Wt9K+EEqr8fAPwWp13oPbPaqzDMMipuDsGpkh9FTwZPvbI JLR0v1XJUhfv7Sn6qd14fXWPbdqFYtl8peNISGUid3PZ5cod8PpVqepN2i72DMSFqpAp 3DkbXLC54fYN6DKU73JTqbGOQ7C7MP55nnmi1W2LKjFu8BO9Udo8HnoxyzlKHvaFJalO RovnNdKBRsixTfQRxYTrHNY+ZR4DyGUueuOHCT2CXFveTvHbZCmaduqeDttHTK87kGL1 NqXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QTrzCvOj; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c4-v6si6611734plo.69.2018.11.08.23.38.14; Thu, 08 Nov 2018 23:38:30 -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=@gmail.com header.s=20161025 header.b=QTrzCvOj; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728120AbeKIRPw (ORCPT + 99 others); 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-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 }, {} }; -- 2.17.1