From patchwork Tue Mar 13 16:05:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10279771 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9553A602BD for ; Tue, 13 Mar 2018 16:06:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84359287F8 for ; Tue, 13 Mar 2018 16:06:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 787B8290D3; Tue, 13 Mar 2018 16:06:10 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 2277D287F8 for ; Tue, 13 Mar 2018 16:06:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933296AbeCMQF4 (ORCPT ); Tue, 13 Mar 2018 12:05:56 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:37907 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934352AbeCMQFy (ORCPT ); Tue, 13 Mar 2018 12:05:54 -0400 Received: by mail-qt0-f194.google.com with SMTP id n12so143363qtl.5; Tue, 13 Mar 2018 09:05:53 -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=DBBGg3kU+xeePqKWzwru5vM+hMfy6qlky1aqWGuF3bI=; b=TVSZCO/me8bXj/Zv9PTuLmGP6PCTNSYm9xA5Vd34l6pCx+yl1OyGhbq9wzgIpJ4zqX +R7jo+CCZqr/oelO6kVFLG1WOKIS5PXF1j416TOVQ4Bf7FSFAd9Olebtg74iAsAk8CdE BEkRkHN2LCfaqsMfda5IfWNy76jHcVsdGy+hV50U76EP5qP0WcurBCc4BXbn0ilfyDkU ejzYFJEx1AwF0L8E7ePdposKFaN04luzCb1DZkatKSqyFS4xIYfaP+UjBdnpTyNygiH0 54kZ7l4L9Q+EZqU8bHcnuuSAAlGsknFfKCEC+GW2M34SbEUOPzjxCoMABV6zAmh8REW+ fB3g== 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=DBBGg3kU+xeePqKWzwru5vM+hMfy6qlky1aqWGuF3bI=; b=fuXESILgEzEK4a0aiCn302jTqdDeNBzn9htQ8DK02xZghcWyZnywMyuTDVz4xQVGKQ onuRmKXUWyG9x7mb2a+FmVw9v16X3Ex2hMLDNlL5/fTgXnIZFwzUAeWWAXstFPOl2Ub7 KZOiUhaBfkwnkW8YKU5WJ7dyny1IQsfSoMuRJQUN+FXhVqG1H6prX221ZjFr7zjCsaFE fl5E5Q8aAGYW8ViQo+vT+bY4w+Nh4Aeh5+A1/q35iLSlb5fP7wDx0SQorlO69OTPxhk8 TNg3E+RGH102+/BQ+Te1SfXx9JmyBU8JXoGAjrFnuruU80QzykpQEFoLQKWc3/5y0zJf UiHQ== X-Gm-Message-State: AElRT7F1wWk2Tj0e/AWEM/C1ViKNvewHSgsch5LSDhr6ZqLCsjZdXX3j 1OVsV6bXhX5nw1/dl4juJr4= X-Google-Smtp-Source: AG47ELvkU5vViFzAptIdmli23IrMEJaNg3wNl+bHtMFWLxX2Wm56DywdMvMCtfauviwtcEzqp0zqCQ== X-Received: by 10.200.15.140 with SMTP id b12mr1745269qtk.301.1520957153093; Tue, 13 Mar 2018 09:05:53 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id m24sm416249qtc.81.2018.03.13.09.05.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Mar 2018 09:05:52 -0700 (PDT) Date: Tue, 13 Mar 2018 13:05:48 -0300 From: Rodrigo Siqueira To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman , Graff Yang Cc: daniel.baluta@nxp.com, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] staging:iio:ad2s1210: Add frequency handler in read_raw Message-ID: <9296eddbaaa4f815978ce9433c7970a3a498d85b.1520956563.git.rodrigosiqueiramelo@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 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 Read data from fclkin and fexcit does not utilize the ad2s1210_read_raw function. This patch, append the required handler in the ad2s1210_read_raw to return the correct value. Also, this patch removes the legacy code related to the read function Signed-off-by: Rodrigo Siqueira --- drivers/staging/iio/resolver/ad2s1210.c | 45 +++++++++++++++------------------ 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 28c3fd439663..27a42ed10fcd 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -210,15 +210,6 @@ static inline int ad2s1210_soft_reset(struct ad2s1210_state *st) return ad2s1210_config_write(st, 0x0); } -static ssize_t ad2s1210_show_fclkin(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); - - return sprintf(buf, "%u\n", st->fclkin); -} - static ssize_t ad2s1210_store_fclkin(struct device *dev, struct device_attribute *attr, const char *buf, @@ -249,15 +240,6 @@ static ssize_t ad2s1210_store_fclkin(struct device *dev, return ret < 0 ? ret : len; } -static ssize_t ad2s1210_show_fexcit(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); - - return sprintf(buf, "%u\n", st->fexcit); -} - static ssize_t ad2s1210_store_fexcit(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) @@ -486,7 +468,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, - long m) + long mask) { struct ad2s1210_state *st = iio_priv(indio_dev); u16 negative; @@ -535,23 +517,36 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev, *val = vel; ret = IIO_VAL_INT; break; + case IIO_CHAN_INFO_FREQUENCY: + ret = IIO_VAL_INT; + switch (chan->channel) { + case FCLKIN: + *val = st->fclkin; + goto unlock_mutex; + case FEXCIT: + *val = st->fexcit; + goto unlock_mutex; + default: + ret = -EINVAL; + goto unlock_mutex; + } + break; default: - mutex_unlock(&st->lock); - return -EINVAL; + ret = -EINVAL; + goto unlock_mutex; } error_ret: gpio_set_value(st->pdata->sample, 1); /* delay (2 * tck + 20) nano seconds */ udelay(1); +unlock_mutex: mutex_unlock(&st->lock); return ret; } -static IIO_DEVICE_ATTR(fclkin, 0644, - ad2s1210_show_fclkin, ad2s1210_store_fclkin, 0); -static IIO_DEVICE_ATTR(fexcit, 0644, - ad2s1210_show_fexcit, ad2s1210_store_fexcit, 0); +static IIO_DEVICE_ATTR(fclkin, 0644, NULL, ad2s1210_store_fclkin, 0); +static IIO_DEVICE_ATTR(fexcit, 0644, NULL, ad2s1210_store_fexcit, 0); static IIO_DEVICE_ATTR(control, 0644, ad2s1210_show_control, ad2s1210_store_control, 0); static IIO_DEVICE_ATTR(bits, 0644,