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 */