From patchwork Thu Oct 5 02:37:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Reid X-Patchwork-Id: 9986315 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 416426020F for ; Thu, 5 Oct 2017 02:45:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F74E28C10 for ; Thu, 5 Oct 2017 02:45:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2361F28C24; Thu, 5 Oct 2017 02:45:09 +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.9 required=2.0 tests=BAYES_00,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 D16E728C10 for ; Thu, 5 Oct 2017 02:45:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751225AbdJECpG (ORCPT ); Wed, 4 Oct 2017 22:45:06 -0400 Received: from anchovy3.45ru.net.au ([203.30.46.155]:41183 "EHLO anchovy.45ru.net.au" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751218AbdJECpF (ORCPT ); Wed, 4 Oct 2017 22:45:05 -0400 X-Greylist: delayed 400 seconds by postgrey-1.27 at vger.kernel.org; Wed, 04 Oct 2017 22:45:04 EDT Received: (qmail 23630 invoked by uid 5089); 5 Oct 2017 02:38:23 -0000 Received: by simscan 1.2.0 ppid: 23606, pid: 23607, t: 0.0278s scanners: regex: 1.2.0 attach: 1.2.0 clamav: 0.88.3/m:40/d:1950 X-RBL: $rbltext Received: from unknown (HELO preid-centos7.electromag.com.au) (preid@electromag.com.au@203.59.230.133) by anchovy2.45ru.net.au with ESMTPA; 5 Oct 2017 02:38:22 -0000 Received: by preid-centos7.electromag.com.au (Postfix, from userid 1000) id 3CEB63013AC1E; Thu, 5 Oct 2017 10:38:20 +0800 (AWST) From: Phil Reid To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, preid@electromag.com.au, linux-iio@vger.kernel.org Subject: [PATCH 1/1] iio: inkern: add helper to enable a channel Date: Thu, 5 Oct 2017 10:37:46 +0800 Message-Id: <1507171066-83517-1-git-send-email-preid@electromag.com.au> X-Mailer: git-send-email 1.8.3.1 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 This is done by calling a generic write attribute helper similar to the existing read attribute helper. Update write raw helper to use new write attribute function. Signed-off-by: Phil Reid --- drivers/iio/inkern.c | 17 +++++++++++++++-- include/linux/iio/consumer.h | 9 +++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 069defc..51c5c967 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -850,7 +850,9 @@ static int iio_channel_write(struct iio_channel *chan, int val, int val2, chan->channel, val, val2, info); } -int iio_write_channel_raw(struct iio_channel *chan, int val) +static int iio_write_channel_attribute(struct iio_channel *chan, + int val, int val2, + enum iio_chan_info_enum attribute) { int ret; @@ -860,14 +862,25 @@ int iio_write_channel_raw(struct iio_channel *chan, int val) goto err_unlock; } - ret = iio_channel_write(chan, val, 0, IIO_CHAN_INFO_RAW); + ret = iio_channel_write(chan, val, val2, attribute); err_unlock: mutex_unlock(&chan->indio_dev->info_exist_lock); return ret; } + +int iio_write_channel_raw(struct iio_channel *chan, int val) +{ + return iio_write_channel_attribute(chan, val, 0, IIO_CHAN_INFO_RAW); +} EXPORT_SYMBOL_GPL(iio_write_channel_raw); +int iio_write_channel_enable(struct iio_channel *chan, int val) +{ + return iio_write_channel_attribute(chan, val, 0, IIO_CHAN_INFO_ENABLE); +} +EXPORT_SYMBOL_GPL(iio_write_channel_enable); + unsigned int iio_get_channel_ext_info_count(struct iio_channel *chan) { const struct iio_chan_spec_ext_info *ext_info; diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h index 5e347a9..4a5a90d 100644 --- a/include/linux/iio/consumer.h +++ b/include/linux/iio/consumer.h @@ -226,6 +226,15 @@ int iio_read_channel_raw(struct iio_channel *chan, int iio_write_channel_raw(struct iio_channel *chan, int val); /** + * iio_write_channel_enable() - enable a given channel + * @chan: The channel being queried. + * @val: Value being written. + * + * Enable / disable the channel. + */ +int iio_write_channel_enable(struct iio_channel *chan, int val); + +/** * iio_read_max_channel_raw() - read maximum available raw value from a given * channel, i.e. the maximum possible value. * @chan: The channel being queried.