From patchwork Wed Oct 31 15:58:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishad Kamdar X-Patchwork-Id: 10662871 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 3183914BD for ; Wed, 31 Oct 2018 15:59:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F04D2B199 for ; Wed, 31 Oct 2018 15:59:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12B662B1DF; Wed, 31 Oct 2018 15:59:04 +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 F21122B199 for ; Wed, 31 Oct 2018 15:59:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729670AbeKAA5g (ORCPT ); Wed, 31 Oct 2018 20:57:36 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:38642 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729613AbeKAA5g (ORCPT ); Wed, 31 Oct 2018 20:57:36 -0400 Received: by mail-pf1-f195.google.com with SMTP id b11-v6so7828985pfi.5; Wed, 31 Oct 2018 08:59:00 -0700 (PDT) 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=2w9Mcpjm7MYB5Rop0fmMMmUwu5zTLpOe3lPx2S6vcfU=; b=KSTrDzaaRgCJv3I5gePJ41GHeWAsPzM6ALuCEm0TNTbbhIA+F3j6uTUVyJn8H3y2gU IuUYOJq2n5BmHbO/pPuwqxlXGUhGnT/HpYwmWIjo5r4V7tVvJvIXFl2wOLFkuS2TYvmI mFKi98u6Tl2k/zKbWlm8MJwOKriVBTXY2TY0SMEuP2sh2bT4sD40mkKUzjEx94cxOiME ieOtINq0u4QJETc47eWT3Fycvd8UTXfhTEYDPAB+68DLWO1bTGH5HaQ1RdTa8Pup9DRN 7PsxRyEQqGfFawsqLAr+wfYn2dp+KYZxhIDksMaHXAsu+aYSa6bV5XJ1VI3WxW6rH0a8 t1rQ== 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=2w9Mcpjm7MYB5Rop0fmMMmUwu5zTLpOe3lPx2S6vcfU=; b=uQmaR+EWOQTMZGN0XmQYGbabMtQCiMK1+Vv3waLTyHSxX+T6aUNzTqPtsFzCxIsg+d VIgRcMr5uJANyh0Xql9WD6+nbbvV/FgUyuXY5wCUO/zSL/sJSqrQYQxtQrXT7ij3CJUm Q7NfuzrEowSOsX+4+vgR1wCtwNZdU992Psx0P15MDP1KVWCvmg+qGNtMqELl3+vKGtvq 28UO8Q5xqEzKdpqTBOJPVkc0uTXf6h9KvvDLVKIQuiT4eZ1u0rh0wfVVedylCX0E27RA Kp/f5KoE76ML9nvfaVsShYU0gqgz5LmcJb4m982gQ902U8ouhOp1jt7AxqaMsl2CQNv2 dy+A== X-Gm-Message-State: AGRZ1gJSWj3mksfcqDNOZgXP1fmgahpQmfKyXxRwiP8S5qEMVPwWQWxZ GqKiryBqPbRXJb2KzoQLDIw= X-Google-Smtp-Source: AJdET5ekj3ZuRUsPLA4RPeGB0TdlIh0H2bDwnMF5ewlV/cgcmNI/K6e0e1NQkiv63QFcoCxUriuNmg== X-Received: by 2002:a63:1848:: with SMTP id 8mr3645014pgy.81.1541001539893; Wed, 31 Oct 2018 08:58:59 -0700 (PDT) Received: from nishad ([106.51.27.228]) by smtp.gmail.com with ESMTPSA id k72-v6sm60536001pfj.63.2018.10.31.08.58.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Oct 2018 08:58:59 -0700 (PDT) Date: Wed, 31 Oct 2018 21:28:52 +0530 From: Nishad Kamdar To: Jonathan Cameron Cc: Slawomir Stepien , 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: [PATCH v7 1/3] staging: iio: ad2s1210: Switch to the gpio descriptor interface Message-ID: <1626698317a8f0b1caf5596374088f6d5b6141c9.1541000375.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 Use the gpiod interface instead of the deprecated old non-descriptor interface. Signed-off-by: Nishad Kamdar --- drivers/staging/iio/resolver/ad2s1210.c | 106 ++++++++++++++---------- drivers/staging/iio/resolver/ad2s1210.h | 3 - 2 files changed, 62 insertions(+), 47 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index ac13b99bd9cb..82ac9847f6f4 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include @@ -67,12 +67,42 @@ enum ad2s1210_mode { MOD_RESERVED, }; +enum ad2s1210_gpios { + AD2S1210_SAMPLE, + AD2S1210_A0, + AD2S1210_A1, + AD2S1210_RES0, + AD2S1210_RES1, +}; + +struct ad2s1210_gpio { + const char *name; + unsigned long flags; +}; + +static const struct ad2s1210_gpio gpios_in[] = { + [AD2S1210_SAMPLE] = { .name = "adi,sample", .flags = GPIOD_IN }, + [AD2S1210_A0] = { .name = "adi,a0", .flags = GPIOD_IN }, + [AD2S1210_A1] = { .name = "adi,a1", .flags = GPIOD_IN }, + [AD2S1210_RES0] = { .name = "adi,res0", .flags = GPIOD_IN }, + [AD2S1210_RES1] = { .name = "adi,res1", .flags = GPIOD_IN }, +}; + +static const struct ad2s1210_gpio gpios_out[] = { + [AD2S1210_SAMPLE] = { .name = "adi,sample", .flags = GPIOD_OUT_LOW }, + [AD2S1210_A0] = { .name = "adi,a0", .flags = GPIOD_OUT_LOW }, + [AD2S1210_A1] = { .name = "adi,a1", .flags = GPIOD_OUT_LOW }, + [AD2S1210_RES0] = { .name = "adi,res0", .flags = GPIOD_OUT_LOW }, + [AD2S1210_RES1] = { .name = "adi,res1", .flags = GPIOD_OUT_LOW }, +}; + static const unsigned int ad2s1210_resolution_value[] = { 10, 12, 14, 16 }; struct ad2s1210_state { const struct ad2s1210_platform_data *pdata; struct mutex lock; struct spi_device *sdev; + struct gpio_desc *gpios[5]; unsigned int fclkin; unsigned int fexcit; bool hysteresis; @@ -91,8 +121,8 @@ static const int ad2s1210_mode_vals[4][2] = { static inline void ad2s1210_set_mode(enum ad2s1210_mode mode, struct ad2s1210_state *st) { - gpio_set_value(st->pdata->a[0], ad2s1210_mode_vals[mode][0]); - gpio_set_value(st->pdata->a[1], ad2s1210_mode_vals[mode][1]); + gpiod_set_value(st->gpios[AD2S1210_A0], ad2s1210_mode_vals[mode][0]); + gpiod_set_value(st->gpios[AD2S1210_A1], ad2s1210_mode_vals[mode][1]); st->mode = mode; } @@ -152,8 +182,8 @@ int ad2s1210_update_frequency_control_word(struct ad2s1210_state *st) static unsigned char ad2s1210_read_resolution_pin(struct ad2s1210_state *st) { - int resolution = (gpio_get_value(st->pdata->res[0]) << 1) | - gpio_get_value(st->pdata->res[1]); + int resolution = (gpiod_get_value(st->gpios[AD2S1210_RES0]) << 1) | + gpiod_get_value(st->gpios[AD2S1210_RES1]); return ad2s1210_resolution_value[resolution]; } @@ -164,10 +194,10 @@ static const int ad2s1210_res_pins[4][2] = { static inline void ad2s1210_set_resolution_pin(struct ad2s1210_state *st) { - gpio_set_value(st->pdata->res[0], - ad2s1210_res_pins[(st->resolution - 10) / 2][0]); - gpio_set_value(st->pdata->res[1], - ad2s1210_res_pins[(st->resolution - 10) / 2][1]); + gpiod_set_value(st->gpios[AD2S1210_RES0], + ad2s1210_res_pins[(st->resolution - 10) / 2][0]); + gpiod_set_value(st->gpios[AD2S1210_RES1], + ad2s1210_res_pins[(st->resolution - 10) / 2][1]); } static inline int ad2s1210_soft_reset(struct ad2s1210_state *st) @@ -401,15 +431,15 @@ static ssize_t ad2s1210_clear_fault(struct device *dev, int ret; mutex_lock(&st->lock); - gpio_set_value(st->pdata->sample, 0); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 0); /* delay (2 * tck + 20) nano seconds */ udelay(1); - gpio_set_value(st->pdata->sample, 1); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 1); ret = ad2s1210_config_read(st, AD2S1210_REG_FAULT); if (ret < 0) goto error_ret; - gpio_set_value(st->pdata->sample, 0); - gpio_set_value(st->pdata->sample, 1); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 0); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 1); error_ret: mutex_unlock(&st->lock); @@ -466,7 +496,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev, s16 vel; mutex_lock(&st->lock); - gpio_set_value(st->pdata->sample, 0); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 0); /* delay (6 * tck + 20) nano seconds */ udelay(1); @@ -512,7 +542,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev, } error_ret: - gpio_set_value(st->pdata->sample, 1); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 1); /* delay (2 * tck + 20) nano seconds */ udelay(1); mutex_unlock(&st->lock); @@ -630,30 +660,23 @@ static const struct iio_info ad2s1210_info = { static int ad2s1210_setup_gpios(struct ad2s1210_state *st) { - unsigned long flags = st->pdata->gpioin ? GPIOF_DIR_IN : GPIOF_DIR_OUT; - struct gpio ad2s1210_gpios[] = { - { st->pdata->sample, GPIOF_DIR_IN, "sample" }, - { st->pdata->a[0], flags, "a0" }, - { st->pdata->a[1], flags, "a1" }, - { st->pdata->res[0], flags, "res0" }, - { st->pdata->res[0], flags, "res1" }, - }; - - return gpio_request_array(ad2s1210_gpios, ARRAY_SIZE(ad2s1210_gpios)); -} - -static void ad2s1210_free_gpios(struct ad2s1210_state *st) -{ - unsigned long flags = st->pdata->gpioin ? GPIOF_DIR_IN : GPIOF_DIR_OUT; - struct gpio ad2s1210_gpios[] = { - { st->pdata->sample, GPIOF_DIR_IN, "sample" }, - { st->pdata->a[0], flags, "a0" }, - { st->pdata->a[1], flags, "a1" }, - { st->pdata->res[0], flags, "res0" }, - { st->pdata->res[0], flags, "res1" }, - }; + struct ad2s1210_gpio *pin = st->pdata->gpioin ? &gpios_in[0] : &gpios_out[0]; + struct spi_device *spi = st->sdev; + int i, ret; + + for (i = 0; i < ARRAY_SIZE(gpios_in); i++) { + st->gpios[i] = devm_gpiod_get(&spi->dev, pin[i].name, + pin[i].flags); + if (IS_ERR(st->gpios[i])) { + ret = PTR_ERR(st->gpios[i]); + dev_err(&spi->dev, + "ad2s1210: failed to request %s GPIO: %d\n", + pin[i].name, ret); + return ret; + } + } - gpio_free_array(ad2s1210_gpios, ARRAY_SIZE(ad2s1210_gpios)); + return 0; } static int ad2s1210_probe(struct spi_device *spi) @@ -692,7 +715,7 @@ static int ad2s1210_probe(struct spi_device *spi) ret = iio_device_register(indio_dev); if (ret) - goto error_free_gpios; + return ret; st->fclkin = spi->max_speed_hz; spi->mode = SPI_MODE_3; @@ -700,10 +723,6 @@ static int ad2s1210_probe(struct spi_device *spi) ad2s1210_initial(st); return 0; - -error_free_gpios: - ad2s1210_free_gpios(st); - return ret; } static int ad2s1210_remove(struct spi_device *spi) @@ -711,7 +730,6 @@ static int ad2s1210_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); iio_device_unregister(indio_dev); - ad2s1210_free_gpios(iio_priv(indio_dev)); return 0; } diff --git a/drivers/staging/iio/resolver/ad2s1210.h b/drivers/staging/iio/resolver/ad2s1210.h index e9b2147701fc..63d479b20a6c 100644 --- a/drivers/staging/iio/resolver/ad2s1210.h +++ b/drivers/staging/iio/resolver/ad2s1210.h @@ -12,9 +12,6 @@ #define _AD2S1210_H struct ad2s1210_platform_data { - unsigned int sample; - unsigned int a[2]; - unsigned int res[2]; bool gpioin; }; #endif /* _AD2S1210_H */ From patchwork Wed Oct 31 15:59:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishad Kamdar X-Patchwork-Id: 10662873 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 7579F1751 for ; Wed, 31 Oct 2018 16:00:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63A052B20D for ; Wed, 31 Oct 2018 16:00:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 579932B210; Wed, 31 Oct 2018 16:00:03 +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 C237C2B20D for ; Wed, 31 Oct 2018 16:00:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729716AbeKAA6h (ORCPT ); Wed, 31 Oct 2018 20:58:37 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45654 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729674AbeKAA6h (ORCPT ); Wed, 31 Oct 2018 20:58:37 -0400 Received: by mail-pf1-f196.google.com with SMTP id v5-v6so2919016pfm.12; Wed, 31 Oct 2018 09:00:01 -0700 (PDT) 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=Yd/3lgKv3aScnwEWBYitvGxVTTRqGZdya6lty2Vfx+M=; b=neoxY/Q7uLWJ2nP89tRAWXzvi1lLtbTiq6nsOuTXX5IZbgrDU3pWs9EsagFQGxk+a8 pEFGE2c3aYW0QSzScC70sH0bKywKLhlomp9GHuSwq4UIkDqhoyfNV76K3ekTFRIKW8L+ ZNYZkp/wmO0ykSG+SW6ERG3A6p9Q5fpGnxFX2f4iv5rjoEZsPbhrdapUusBoI4rbp+0F y2Nx7tHlMnJweT1OBoU6hAfz/Xq2FMA/9qVYMUk2FhEJ/qxewy4uIRE4tLVyM0TU5tc9 4nQpluyBXLdNPRB6jQYcXflXX73jAa6S55Fq5xLPPXlcSSJtG28GNdCg3CjlfUmm0Acx z9MQ== 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=Yd/3lgKv3aScnwEWBYitvGxVTTRqGZdya6lty2Vfx+M=; b=WYNysb9w0KSyIT59mdtPP+RtfuNv0J/UtuAYVVEP5FADUPL8jGq0x7VAOvxDBKoHq5 v7/cYb8OmBaN88wVF3u+SodzB/AH8emh0M9sqqIlKiWpHVZ/ZSvrK4V9tBdwARMIoHkQ FCPZzryYurufKt2CeX6F2sbvz5dCPEO7Nmb5ztCQtvdkgP14QeUMx8ImEARk4X2cIrPh +5n33nq7c0VSrp3S23PBuO2FfhzRgmjYWOZcVBppDwwAqYRHf3wlsmrlp73Frg9lZ6OG LPMWoUXMfiVRgXBKFhu5aPuBfS3ptSgjhuHSNpF6bKHAiUAstOzYWqK2vQ1j1z/PgFxV ieHg== X-Gm-Message-State: AGRZ1gIxPLVfvgQwe/FWnZcZ1M4zIDzSELvaO8e5EdooHoHl/0cw7ehb wWPt+Bcq4xGBYJkXBGRyqjc= X-Google-Smtp-Source: AJdET5cIm2TOpZACYo20CQ8CTDWKqLejriT6E8GE3Rr6fSXahDqxA0MouXvG8Lh22hXTVFR201tVJQ== X-Received: by 2002:a63:4c6:: with SMTP id 189mr3723044pge.391.1541001600807; Wed, 31 Oct 2018 09:00:00 -0700 (PDT) Received: from nishad ([106.51.27.228]) by smtp.gmail.com with ESMTPSA id v1-v6sm11995206pfn.94.2018.10.31.08.59.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Oct 2018 09:00:00 -0700 (PDT) Date: Wed, 31 Oct 2018 21:29:53 +0530 From: Nishad Kamdar To: Jonathan Cameron Cc: Slawomir Stepien , 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: [PATCH v7 2/3] staging: iio: ad2s1210: Drop the gpioin flag. Message-ID: <28e4acb0161ad59832150ae67be83a648684eb73.1541000375.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 Drop gpioin flag which decides how the GPIOs are controlled as the GPIOs must be outputs for the host as per the datasheet. Signed-off-by: Nishad Kamdar --- drivers/staging/iio/resolver/ad2s1210.c | 45 ++++--------------------- drivers/staging/iio/resolver/ad2s1210.h | 17 ---------- 2 files changed, 6 insertions(+), 56 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 82ac9847f6f4..d3e7d5aad2c8 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -80,15 +80,7 @@ struct ad2s1210_gpio { unsigned long flags; }; -static const struct ad2s1210_gpio gpios_in[] = { - [AD2S1210_SAMPLE] = { .name = "adi,sample", .flags = GPIOD_IN }, - [AD2S1210_A0] = { .name = "adi,a0", .flags = GPIOD_IN }, - [AD2S1210_A1] = { .name = "adi,a1", .flags = GPIOD_IN }, - [AD2S1210_RES0] = { .name = "adi,res0", .flags = GPIOD_IN }, - [AD2S1210_RES1] = { .name = "adi,res1", .flags = GPIOD_IN }, -}; - -static const struct ad2s1210_gpio gpios_out[] = { +static const struct ad2s1210_gpio gpios[] = { [AD2S1210_SAMPLE] = { .name = "adi,sample", .flags = GPIOD_OUT_LOW }, [AD2S1210_A0] = { .name = "adi,a0", .flags = GPIOD_OUT_LOW }, [AD2S1210_A1] = { .name = "adi,a1", .flags = GPIOD_OUT_LOW }, @@ -99,7 +91,6 @@ static const struct ad2s1210_gpio gpios_out[] = { static const unsigned int ad2s1210_resolution_value[] = { 10, 12, 14, 16 }; struct ad2s1210_state { - const struct ad2s1210_platform_data *pdata; struct mutex lock; struct spi_device *sdev; struct gpio_desc *gpios[5]; @@ -180,14 +171,6 @@ int ad2s1210_update_frequency_control_word(struct ad2s1210_state *st) return ad2s1210_config_write(st, fcw); } -static unsigned char ad2s1210_read_resolution_pin(struct ad2s1210_state *st) -{ - int resolution = (gpiod_get_value(st->gpios[AD2S1210_RES0]) << 1) | - gpiod_get_value(st->gpios[AD2S1210_RES1]); - - return ad2s1210_resolution_value[resolution]; -} - static const int ad2s1210_res_pins[4][2] = { { 0, 0 }, {0, 1}, {1, 0}, {1, 1} }; @@ -333,13 +316,7 @@ static ssize_t ad2s1210_store_control(struct device *dev, } st->resolution = ad2s1210_resolution_value[data & AD2S1210_SET_RESOLUTION]; - if (st->pdata->gpioin) { - data = ad2s1210_read_resolution_pin(st); - if (data != st->resolution) - dev_warn(dev, "ad2s1210: resolution settings not match\n"); - } else { - ad2s1210_set_resolution_pin(st); - } + ad2s1210_set_resolution_pin(st); ret = len; st->hysteresis = !!(data & AD2S1210_ENABLE_HYSTERESIS); @@ -395,13 +372,7 @@ static ssize_t ad2s1210_store_resolution(struct device *dev, } st->resolution = ad2s1210_resolution_value[data & AD2S1210_SET_RESOLUTION]; - if (st->pdata->gpioin) { - data = ad2s1210_read_resolution_pin(st); - if (data != st->resolution) - dev_warn(dev, "ad2s1210: resolution settings not match\n"); - } else { - ad2s1210_set_resolution_pin(st); - } + ad2s1210_set_resolution_pin(st); ret = len; error_ret: mutex_unlock(&st->lock); @@ -622,10 +593,7 @@ static int ad2s1210_initial(struct ad2s1210_state *st) int ret; mutex_lock(&st->lock); - if (st->pdata->gpioin) - st->resolution = ad2s1210_read_resolution_pin(st); - else - ad2s1210_set_resolution_pin(st); + ad2s1210_set_resolution_pin(st); ret = ad2s1210_config_write(st, AD2S1210_REG_CONTROL); if (ret < 0) @@ -660,11 +628,11 @@ static const struct iio_info ad2s1210_info = { static int ad2s1210_setup_gpios(struct ad2s1210_state *st) { - struct ad2s1210_gpio *pin = st->pdata->gpioin ? &gpios_in[0] : &gpios_out[0]; + struct ad2s1210_gpio *pin = &gpios[0]; struct spi_device *spi = st->sdev; int i, ret; - for (i = 0; i < ARRAY_SIZE(gpios_in); i++) { + for (i = 0; i < ARRAY_SIZE(gpios); i++) { st->gpios[i] = devm_gpiod_get(&spi->dev, pin[i].name, pin[i].flags); if (IS_ERR(st->gpios[i])) { @@ -692,7 +660,6 @@ static int ad2s1210_probe(struct spi_device *spi) if (!indio_dev) return -ENOMEM; st = iio_priv(indio_dev); - st->pdata = spi->dev.platform_data; ret = ad2s1210_setup_gpios(st); if (ret < 0) return ret; diff --git a/drivers/staging/iio/resolver/ad2s1210.h b/drivers/staging/iio/resolver/ad2s1210.h index 63d479b20a6c..e69de29bb2d1 100644 --- a/drivers/staging/iio/resolver/ad2s1210.h +++ b/drivers/staging/iio/resolver/ad2s1210.h @@ -1,17 +0,0 @@ -/* - * ad2s1210.h plaform data for the ADI Resolver to Digital Converters: - * AD2S1210 - * - * Copyright (c) 2010-2010 Analog Devices Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ -#ifndef _AD2S1210_H -#define _AD2S1210_H - -struct ad2s1210_platform_data { - bool gpioin; -}; -#endif /* _AD2S1210_H */ From patchwork Wed Oct 31 16:00:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishad Kamdar X-Patchwork-Id: 10662875 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 D567A1751 for ; Wed, 31 Oct 2018 16:00:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE64F2B1F3 for ; Wed, 31 Oct 2018 16:00:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B28562B20D; Wed, 31 Oct 2018 16:00:46 +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 641A82B1F3 for ; Wed, 31 Oct 2018 16:00:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729674AbeKAA7V (ORCPT ); Wed, 31 Oct 2018 20:59:21 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:45715 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728848AbeKAA7V (ORCPT ); Wed, 31 Oct 2018 20:59:21 -0400 Received: by mail-pf1-f195.google.com with SMTP id v5-v6so2920107pfm.12; Wed, 31 Oct 2018 09:00:44 -0700 (PDT) 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=CVl1ESSj4idIa/gbF1NQ+Xy9kDUcvqho4q0SllzV20U=; b=Ab7w+9WHaj5ieIEXc158y+Grk9mmLMeZzCEaKMNf3P+OgbEG6E/I+ylQtqV3KkiR4F LMVBR0NClQsxCO5IqnxHa2RVuNJ61lkzZY799rk5fMtBrxh7506rfBxlSiloqHe9DP5W lAJPE6LTPxxtiO6agbJOdfJPz8IL7CokheIABeXkrhjoX5rvjzPr68uRTLFuZ91+iFbL bObi2iBzhIYk78LI4hUjJm+8hrhxYmTQYxjNoF9DnyV7flx5RzxEnYi17ySD6k8E4+Bs 7QlyYFAcXr9c6HrWAU4pTvQNJFOP1Q6XOfPpGNk8efGduK9M2dzECOjWYuiKgRdOCmte Xn7Q== 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=CVl1ESSj4idIa/gbF1NQ+Xy9kDUcvqho4q0SllzV20U=; b=mkr/G0fqn/mVrlDgmwIks8K8WuqDsqkgix2ea41xrOdCrbXrIgQLrfwdIV1Z+RJW3W nHoubTnHRM41KL83Rg8AEu4DCdctlHh3Nhto335ldk6Kc6j5xkk2pk+oirv+us5LmH9O asSCqoKE5ggRnvPaQcXIBrMkQQQ/o33pYv8mVHcDyrlTP3f+aM5RCGgLSJ21ecKxKgw7 ISOo+F2LKqWmM9iRd68JXz/WmEojUgEAFhLVnj+m+Uqp1Ajij2xj+o0gy6RnupQaiBwV 1xR5qGJ4CgMxW+PBZOg7BenLvf5Mpxd5kwUlyhZnrvMR4Pz/LqsTr6voZPq0jMFCTYjn 2CzQ== X-Gm-Message-State: AGRZ1gLE4jmGLqi3QV9Veny30aK++qinuYHczQbv5J5Ko3N3Khh2zCCO S/EjIF5dUTiSnZJX57C1blg= X-Google-Smtp-Source: AJdET5fdFZ9qbWSa8LWQg0zUojvdgpJgZyJu998JYFlMuPqP1J+WY+5ytIf36Ed+Ej3rHTUzVXTMDA== X-Received: by 2002:a62:7086:: with SMTP id l128-v6mr4118503pfc.181.1541001644140; Wed, 31 Oct 2018 09:00:44 -0700 (PDT) Received: from nishad ([106.51.27.228]) by smtp.gmail.com with ESMTPSA id u19-v6sm30759983pfj.115.2018.10.31.09.00.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Oct 2018 09:00:43 -0700 (PDT) Date: Wed, 31 Oct 2018 21:30:36 +0530 From: Nishad Kamdar To: Jonathan Cameron Cc: Slawomir Stepien , 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: [PATCH v7 3/3] staging: iio: ad2s1210: Add device tree table. Message-ID: 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 Add device tree table for matching vendor ID. Signed-off-by: Nishad Kamdar --- drivers/staging/iio/resolver/ad2s1210.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index d3e7d5aad2c8..7c50def91a2b 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -701,6 +701,12 @@ static int ad2s1210_remove(struct spi_device *spi) return 0; } +static const struct of_device_id ad2s1210_of_match[] = { + { .compatible = "adi,ad2s1210", }, + { } +}; +MODULE_DEVICE_TABLE(of, ad2s1210_of_match); + static const struct spi_device_id ad2s1210_id[] = { { "ad2s1210" }, {} @@ -710,6 +716,7 @@ MODULE_DEVICE_TABLE(spi, ad2s1210_id); static struct spi_driver ad2s1210_driver = { .driver = { .name = DRV_NAME, + .of_match_table = of_match_ptr(ad2s1210_of_match), }, .probe = ad2s1210_probe, .remove = ad2s1210_remove,