From patchwork Sun Oct 28 07:51:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishad Kamdar X-Patchwork-Id: 10658511 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 5BC93161F for ; Sun, 28 Oct 2018 07:51:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4961729EE0 for ; Sun, 28 Oct 2018 07:51:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CC5D29EF9; Sun, 28 Oct 2018 07:51: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 9BF8B29EE0 for ; Sun, 28 Oct 2018 07:51:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727567AbeJ1QfZ (ORCPT ); Sun, 28 Oct 2018 12:35:25 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:44468 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726488AbeJ1QfZ (ORCPT ); Sun, 28 Oct 2018 12:35:25 -0400 Received: by mail-pl1-f195.google.com with SMTP id s5-v6so716155plq.11; Sun, 28 Oct 2018 00:51:33 -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=E92Wh5JZ8eoDlZ0Z0ALHufJDY7LyfXxGPBRFU8RRm3s=; b=Ce+N/GjCeDP0xPXT7JvzIXU1TtXOZ+RUY6LeIeIIS1s36YNbeVtUNtluHoLhVkMBNv /2uo5nxbBuPWbRI0OJrUIzW9ODKzjowQTFi27k+fYXWZz8jorPKQkzG/PMWIGOAijYLI hiNMy0yfjFlqLkHzBt5eLRrC+YLSaOMm0Y6dM6YkqPW+b6DLXBzfsnWgiPP7MQFhcBCD 6+ha6Y5qTtbcx7oiQtIyNMUgc81R3waOkpyhJWgOHa7BbULhMfr1b6DSBuE9QMuFLGx0 WIyWv3rPtKkeJC02wlphjChRBCNOSaNPosGSwktE5dJLwKNMUQ6MJqEaDYtRz5vXyoJs 7r8g== 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=E92Wh5JZ8eoDlZ0Z0ALHufJDY7LyfXxGPBRFU8RRm3s=; b=DSP4f2wahwQQ6eJmBGofP+FLEzCmF4zKdHhBxfrB1FAzlaYqWHT/3+xtl3V44XrTnJ Q22FoHKu/XILzlgSmirbHt23QcY8e5tkyrkIv9vXqooO3AJneihEPhlOkD4mcZtxm0PG 52BpWEEZIkohEkJX8Ya0V5Hp9SiZZP/vndqrKDq7qjn2So2UeORwEdtSk/OrkufSu4/y 2CxxBQ9Wnp6/z1EFx5RbwzaPDYud1rVgAmfqINzoo3hyCYiHTujMIIelZHrbzig2pMYK f7aC4GKUzgMYgNsnh/RyjPMYUomEz2hrcszqzwpS5HdDQWuZeLAbFkaSOXtWPaQAdEV0 4spg== X-Gm-Message-State: AGRZ1gID1JsCxjLSgTINdo+mV+2IaqiVWfg0asflRnkOxo78zImJ2d08 Ggtk5juRWdyhIOsuIYEr5Nk= X-Google-Smtp-Source: AJdET5eWCj4FfrcLzVtbw7FRmWmOaBZ0qpf7Vqr7EmaoagEUmB0n76rNgLUrYFufrbVCVrMvzHKKKw== X-Received: by 2002:a17:902:76c3:: with SMTP id j3-v6mr9779882plt.339.1540713093041; Sun, 28 Oct 2018 00:51:33 -0700 (PDT) Received: from nishad ([106.51.27.228]) by smtp.gmail.com with ESMTPSA id x189-v6sm9580737pfb.162.2018.10.28.00.51.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Oct 2018 00:51:32 -0700 (PDT) Date: Sun, 28 Oct 2018 13:21:25 +0530 From: Nishad Kamdar To: Slawomir Stepien Cc: Lars-Peter Clausen , 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 v6 1/3] staging: iio: ad2s1210: Switch to the gpio descriptor interface Message-ID: <3b51eb662d107472e8bab38a87714354a1381779.1540712249.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 | 92 ++++++++++++++----------- drivers/staging/iio/resolver/ad2s1210.h | 3 - 2 files changed, 50 insertions(+), 45 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index ac13b99bd9cb..93c3c70ce62e 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 @@ -69,10 +69,21 @@ enum ad2s1210_mode { static const unsigned int ad2s1210_resolution_value[] = { 10, 12, 14, 16 }; +struct ad2s1210_gpio { + struct gpio_desc **ptr; + const char *name; + unsigned long flags; +}; + struct ad2s1210_state { const struct ad2s1210_platform_data *pdata; struct mutex lock; struct spi_device *sdev; + struct gpio_desc *sample; + struct gpio_desc *a0; + struct gpio_desc *a1; + struct gpio_desc *res0; + struct gpio_desc *res1; unsigned int fclkin; unsigned int fexcit; bool hysteresis; @@ -91,8 +102,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->a0, ad2s1210_mode_vals[mode][0]); + gpiod_set_value(st->a1, ad2s1210_mode_vals[mode][1]); st->mode = mode; } @@ -152,8 +163,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->res0) << 1) | + gpiod_get_value(st->res1); return ad2s1210_resolution_value[resolution]; } @@ -164,10 +175,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->res0, + ad2s1210_res_pins[(st->resolution - 10) / 2][0]); + gpiod_set_value(st->res1, + ad2s1210_res_pins[(st->resolution - 10) / 2][1]); } static inline int ad2s1210_soft_reset(struct ad2s1210_state *st) @@ -401,15 +412,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->sample, 0); /* delay (2 * tck + 20) nano seconds */ udelay(1); - gpio_set_value(st->pdata->sample, 1); + gpiod_set_value(st->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->sample, 0); + gpiod_set_value(st->sample, 1); error_ret: mutex_unlock(&st->lock); @@ -466,7 +477,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->sample, 0); /* delay (6 * tck + 20) nano seconds */ udelay(1); @@ -512,7 +523,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev, } error_ret: - gpio_set_value(st->pdata->sample, 1); + gpiod_set_value(st->sample, 1); /* delay (2 * tck + 20) nano seconds */ udelay(1); mutex_unlock(&st->lock); @@ -630,30 +641,32 @@ 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" }, + int ret, i; + struct spi_device *spi = st->sdev; + struct ad2s1210_gpio *pin; + unsigned long flags = st->pdata->gpioin ? GPIOD_IN : GPIOD_OUT_LOW; + + struct ad2s1210_gpio gpios[] = { + { .ptr = &st->sample, .name = "sample", .flags = GPIOD_IN }, + { .ptr = &st->a0, .name = "a0", .flags = flags }, + { .ptr = &st->a1, .name = "a1", .flags = flags }, + { .ptr = &st->res0, .name = "res0", .flags = flags }, + { .ptr = &st->res1, .name = "res1", .flags = flags }, }; - 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" }, - }; + for (i = 0; i < ARRAY_SIZE(gpios); i++) { + pin = &gpios[i]; + *pin->ptr = devm_gpiod_get(&spi->dev, pin->name, pin->flags); + if (IS_ERR(*pin->ptr)) { + ret = PTR_ERR(*pin->ptr); + dev_err(&spi->dev, + "ad2s1210: failed to request %s GPIO: %d\n", + pin->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 +705,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 +713,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 +720,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 Sun Oct 28 07:52:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishad Kamdar X-Patchwork-Id: 10658513 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 32ED8109C for ; Sun, 28 Oct 2018 07:52:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D8E229EE0 for ; Sun, 28 Oct 2018 07:52:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B9F129EF9; Sun, 28 Oct 2018 07:52:41 +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 B0CB529EE0 for ; Sun, 28 Oct 2018 07:52:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727532AbeJ1Qgb (ORCPT ); Sun, 28 Oct 2018 12:36:31 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:37658 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726488AbeJ1Qgb (ORCPT ); Sun, 28 Oct 2018 12:36:31 -0400 Received: by mail-pl1-f193.google.com with SMTP id bh10-v6so2356902plb.4; Sun, 28 Oct 2018 00:52:39 -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=+eDLvkiiPUO0D/lugMgy57N+b7fklqEyeUYtP+nRnAs=; b=PKVpIkGwboaryX/KZ5QbQmpBbNbNQ7kPymEIUHKxQYqlLlOnRuwi7i+Jj1l7V1Uy69 hbucVgyGk9CDQ3JZzfzBIPr04Ff4B51JqXeQqbbupOJUlGvtD4nhfZJ3UVNnMRu4tQft J8QWqpcGfDdni6+Gx8sPIs1TMkof/eCs32XX0m6yLJ0BF+ag9xM/JEo1r7CTe2hdvHmJ Dn0rR++r2E1LTPZw/gFOcDxMI01pxhqIcDT9u4cUelOm2H/T4bJNkj9PuEUE6iY7Pk2d z5uJ+OR5CW0zkoI6NbGj5pRM7QOolxooXCVdjn5ip3logmTtQSuxhVkrM0S59JI1u5PJ f5xw== 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=+eDLvkiiPUO0D/lugMgy57N+b7fklqEyeUYtP+nRnAs=; b=hiy2vjxAVjmiZ4tJ/UdYuCoJeDQYw+u82+QUSpGsD3PR6MJke4JmADBCnuDz0qljNE fpkdzhlC+GbeMnq2xPk/6p4tn5tPezvyjf9Y84ilNUyICehQIkJUI5CRCbUrRolrscGw 2WMteTNzgw4JrvKUJLb5sWdntcg5buFnzywLY7141edS2XX1AQ+m2oYg/n3ppJK3Hn26 olMwDh/87IsMhVCEkF3MkipgZ0wGxlrnzeV+5O//XjPBghQ4kd1IxF0AqICy82unF52/ +RmV+RpB78ZtRoS8GqXqM8Y9BAiG5xNknxHWzXxalW/PGR86KPRuONFWSs5saAJocbNd 4fZA== X-Gm-Message-State: AGRZ1gLVIXTkwvz4y2mJHvyoeflwGIqPwmKzHDi1YTaq6iUqhI2grrH+ 9VqO7ERb2e02Tcsty1ywwCo= X-Google-Smtp-Source: AJdET5ePTf48hv9W7rUoFU0pozDV59sH9Cqa6oMfnW7bpmFVIV7jHKUoaJlwnTI5ckJtIHUhT3dqZQ== X-Received: by 2002:a17:902:930a:: with SMTP id bc10-v6mr9923887plb.17.1540713158978; Sun, 28 Oct 2018 00:52:38 -0700 (PDT) Received: from nishad ([106.51.27.228]) by smtp.gmail.com with ESMTPSA id b62-v6sm17642892pfa.159.2018.10.28.00.52.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Oct 2018 00:52:38 -0700 (PDT) Date: Sun, 28 Oct 2018 13:22:31 +0530 From: Nishad Kamdar To: Slawomir Stepien Cc: Lars-Peter Clausen , 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 v6 2/3] staging: iio: ad2s1210: Add device tree table. Message-ID: <6b324781850b7543f8bbe67a6a48c9469d8a707b.1540712249.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 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 93c3c70ce62e..0234869e9d74 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -724,6 +724,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" }, {} @@ -733,6 +739,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, From patchwork Sun Oct 28 07:53:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishad Kamdar X-Patchwork-Id: 10658515 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 E0939109C for ; Sun, 28 Oct 2018 07:53:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB96A28640 for ; Sun, 28 Oct 2018 07:53:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA9EB28653; Sun, 28 Oct 2018 07:53:33 +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 3C62028640 for ; Sun, 28 Oct 2018 07:53:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727567AbeJ1QhY (ORCPT ); Sun, 28 Oct 2018 12:37:24 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:37698 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726488AbeJ1QhY (ORCPT ); Sun, 28 Oct 2018 12:37:24 -0400 Received: by mail-pl1-f196.google.com with SMTP id bh10-v6so2357375plb.4; Sun, 28 Oct 2018 00:53:31 -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=8y0O3OECRakgF6U92KTpyKmli03v5f+vs380fG93zRI=; b=Lj+18g+Fpei1AUnU3UsbrZcBpfEsoOnITzSTQXpgPiswcCMrX+FnT6gNltrol9+p0N BOcLgaZBJXCPKnMYFcfVyU2iraWpnTubwN/2k47hl042BRi73VNoWb5VTwQ/DWblL29B mFNcsRxX0Q4ZIk6/vY1FltZ9L2wLW3pykAFsWdPjGV/z30RCyu+F+R5+0AxZ1dFMK6F+ SK9+wDouE3ylgbj6EVCsXA8OCWpNEVIz/0I9269SDh4ffbllFK4cUnubPGF8aOX/NCsE Pr6hVss1b/yF8klVlzpJjtBH6kkE6Rf+eTw6C+lmKE0Bb8BwlGBMAAGJa80guctjQvni njtw== 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=8y0O3OECRakgF6U92KTpyKmli03v5f+vs380fG93zRI=; b=VEAjbfJzSM4Ui5lu0rVAfat0vt/cFkGh+5EBFZ3/yjBfAFNNBol/nmxFt0gGwA6tG/ JMn9Jnp9mPzNWH8qlnfipeyI06cnSzpPvjXzJ5eDjwKelu2luVmh5SeNaDvU2h27kCNZ kOiDA+ynldfHojJQi47xTiosERxOwUJixsau3jjE2amZJUzXlzcr16sGs68JvbwTeL69 O2F8CHUREvmVG3y5m8ijRsqKcUjdkdAElBn5HnCuOi1FIkxy5f0LDk9vjUnlMVMsEkuX kH345y2eWbd+k1l/XAuJGtGNtte2sTwamGCcouMuuwhwN7MUmouTYWKo+RlCGxswxrii rweg== X-Gm-Message-State: AGRZ1gLX4ZNsghoxsBlwOA7kLL93OBHeV7TxpcXzYcaTbO0yhxb9AuTv 7zxS8h1mOZnGmGfbPxKrEVo= X-Google-Smtp-Source: AJdET5fuQxjcS5fbaWSfjycK+ITfzJFiCvCL50Op24m4vhNjXJneTXCRZAGaH1wh6s0oG+b+2nr5kA== X-Received: by 2002:a17:902:8202:: with SMTP id x2-v6mr9707115pln.192.1540713211280; Sun, 28 Oct 2018 00:53:31 -0700 (PDT) Received: from nishad ([106.51.27.228]) by smtp.gmail.com with ESMTPSA id l26-v6sm28543310pfg.161.2018.10.28.00.53.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Oct 2018 00:53:30 -0700 (PDT) Date: Sun, 28 Oct 2018 13:23:23 +0530 From: Nishad Kamdar To: Slawomir Stepien Cc: Lars-Peter Clausen , 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 v6 3/3] staging: iio: ad2s1210: Add device tree support. Message-ID: <473e6abfe959e1ac78fe65bf8dc53ad25ad3b358.1540712249.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 Replace platform data with device tree support. Signed-off-by: Nishad Kamdar --- drivers/staging/iio/resolver/Kconfig | 1 + drivers/staging/iio/resolver/ad2s1210.c | 17 ++++++++--------- drivers/staging/iio/resolver/ad2s1210.h | 17 ----------------- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/drivers/staging/iio/resolver/Kconfig b/drivers/staging/iio/resolver/Kconfig index 6a469ee6101f..cc1202ff813d 100644 --- a/drivers/staging/iio/resolver/Kconfig +++ b/drivers/staging/iio/resolver/Kconfig @@ -15,6 +15,7 @@ config AD2S90 config AD2S1210 tristate "Analog Devices ad2s1210 driver" + depends on OF depends on SPI depends on GPIOLIB || COMPILE_TEST help diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 0234869e9d74..5ecdb5785132 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -76,7 +77,6 @@ struct ad2s1210_gpio { }; struct ad2s1210_state { - const struct ad2s1210_platform_data *pdata; struct mutex lock; struct spi_device *sdev; struct gpio_desc *sample; @@ -84,6 +84,7 @@ struct ad2s1210_state { struct gpio_desc *a1; struct gpio_desc *res0; struct gpio_desc *res1; + bool gpioin; unsigned int fclkin; unsigned int fexcit; bool hysteresis; @@ -314,7 +315,7 @@ static ssize_t ad2s1210_store_control(struct device *dev, } st->resolution = ad2s1210_resolution_value[data & AD2S1210_SET_RESOLUTION]; - if (st->pdata->gpioin) { + if (st->gpioin) { data = ad2s1210_read_resolution_pin(st); if (data != st->resolution) dev_warn(dev, "ad2s1210: resolution settings not match\n"); @@ -376,7 +377,7 @@ static ssize_t ad2s1210_store_resolution(struct device *dev, } st->resolution = ad2s1210_resolution_value[data & AD2S1210_SET_RESOLUTION]; - if (st->pdata->gpioin) { + if (st->gpioin) { data = ad2s1210_read_resolution_pin(st); if (data != st->resolution) dev_warn(dev, "ad2s1210: resolution settings not match\n"); @@ -603,7 +604,7 @@ static int ad2s1210_initial(struct ad2s1210_state *st) int ret; mutex_lock(&st->lock); - if (st->pdata->gpioin) + if (st->gpioin) st->resolution = ad2s1210_read_resolution_pin(st); else ad2s1210_set_resolution_pin(st); @@ -644,7 +645,7 @@ static int ad2s1210_setup_gpios(struct ad2s1210_state *st) int ret, i; struct spi_device *spi = st->sdev; struct ad2s1210_gpio *pin; - unsigned long flags = st->pdata->gpioin ? GPIOD_IN : GPIOD_OUT_LOW; + unsigned long flags = st->gpioin ? GPIOD_IN : GPIOD_OUT_LOW; struct ad2s1210_gpio gpios[] = { { .ptr = &st->sample, .name = "sample", .flags = GPIOD_IN }, @@ -673,16 +674,14 @@ static int ad2s1210_probe(struct spi_device *spi) { struct iio_dev *indio_dev; struct ad2s1210_state *st; + struct device_node *np = spi->dev.of_node; int ret; - if (!spi->dev.platform_data) - return -EINVAL; - indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (!indio_dev) return -ENOMEM; st = iio_priv(indio_dev); - st->pdata = spi->dev.platform_data; + st->gpioin = of_property_read_bool(np, "gpioin"); 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 */