From patchwork Mon Mar 12 18:21:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10276967 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 6550960211 for ; Mon, 12 Mar 2018 18:21:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D44028AF1 for ; Mon, 12 Mar 2018 18:21:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41A6628B00; Mon, 12 Mar 2018 18:21:44 +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=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 C944428AF1 for ; Mon, 12 Mar 2018 18:21:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751229AbeCLSVn (ORCPT ); Mon, 12 Mar 2018 14:21:43 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:43390 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750811AbeCLSVm (ORCPT ); Mon, 12 Mar 2018 14:21:42 -0400 Received: by mail-qk0-f194.google.com with SMTP id j4so12505767qke.10; Mon, 12 Mar 2018 11:21:41 -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=Ej0DJgp1MghDIYdXpPSKlKJnjiaJjURZSZ4zLWkeGULOiWCAQTQp2S1Jh12ZKdZNE0 LkTsegxJsR52HdAKJE2WV5Fj75C/HUAQwS58DI+vyNz8dQPPpr4VX3/2LKTTraNsDRuh jQXPqGayeX9IaMxgD7ROHWa1BprAbTiakeZHMISpPpqIklR5OcuUHouTSxVk3gf9SRqp j0FTTx76i9j9AfdT95CfdFZpajcegAlNqIHkznxRz1thY1fI2ah/yPK+vDXsUnOllYP0 VC1hpYGCH3gSLsvb9Vuw+tBH4In099gXj6M2ZP7JOy4VurEMDYescaNe/B/3znb7xXLx 5xQQ== 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=PFQtGhK4E4r5t4HRMnMjO8lHwvdCT0HRvX+VigZb2bg1p39OMS6o+QrL32FtQ+h3EG nl4Nf/oC+bvxMEkhYekfBTvBhxa6BR79g8UdHx4a8+gCodADkiJMupx2XSOJmrmyGUza 43aDOvw/yJ/o1IfWasRageCHImh9K8ZlE9OZy/8M7ABVEU83XzE2iYtFTjf2L61lAiOP Tax9LUl3j4XZUSZY7Epuhlj2jA3rtIJ6/5jjcLzMJURCZSOrPAE3PIkepiNSGwMSgtwq FoaVCTYAKxgpRh/ffLiRDbckHeNf4+d/TTWaE3yPB2ROhAygSu5IwKPUXO5ARgNOTQfk D7wA== X-Gm-Message-State: AElRT7EQIKrj2UmIATAKgEHamuzuOU1/t3vtH5TVegb7X9tepNcKxBtB t8cpCDMhVqYd+T/57kwQTS4= X-Google-Smtp-Source: AG47ELsPWwaHrtYydqN8zNra2Mo3DaV7JhRwtPJixMmiPF9uN9LgBVCokuIpw7d5HFvIGAEZDyDevw== X-Received: by 10.55.182.68 with SMTP id g65mr13188321qkf.41.1520878901133; Mon, 12 Mar 2018 11:21:41 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id 51sm1685110qtz.51.2018.03.12.11.21.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Mar 2018 11:21:40 -0700 (PDT) Date: Mon, 12 Mar 2018 15:21:36 -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 2/3] staging:iio:ad2s1210: Add frequency handler in read_raw Message-ID: <9296eddbaaa4f815978ce9433c7970a3a498d85b.1520878492.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,