From patchwork Thu Apr 6 16:11:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrice Gasnier X-Patchwork-Id: 9667797 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 52B99602B8 for ; Thu, 6 Apr 2017 16:13:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CA55285A3 for ; Thu, 6 Apr 2017 16:13:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9163B285AB; Thu, 6 Apr 2017 16:13:05 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 84716285A3 for ; Thu, 6 Apr 2017 16:13:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KxQp79FHOSrQYOyZD3lAPk4IWdKCA6kaTgZGD6VaEHM=; b=JPocGmUaSCnC5O NUb2+4k64Q62BpBdY5DKlcJhHRkBP+9gi4MaB8xKY3NOLHe5NM+yRGII6FSPYcsq9sp5ztfOIowbI A9j/k/eP3nyx8zGM9xF811q9hcqq0VGLyGw6xsbKbNlfFM1gL7pyKQh7iYXEko+OuhHZXzlUM7Ib+ TQ3Mv6Utg8n1dsQknWlIa5/0xrGDBW07vuR4iynxOgjFn0po4cMw8VAUlSdf89XuFFcL1/FS/kx2I VjIYXsRPni0F/zh5zxaiTpfoILNdE2KjZB9lWufkLYRtsqTSTqGrXYr/dYnWVzsHEVCuBRhmI1foI Dm49yqkRGGaq0bMVcokA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cwA1u-000603-BC; Thu, 06 Apr 2017 16:13:02 +0000 Received: from mx08-00178001.pphosted.com ([91.207.212.93] helo=mx07-00178001.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cwA1g-0005m0-2a for linux-arm-kernel@lists.infradead.org; Thu, 06 Apr 2017 16:12:50 +0000 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id v36GArBI017331; Thu, 6 Apr 2017 18:12:09 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-.pphosted.com with ESMTP id 29j1b49hrm-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 06 Apr 2017 18:12:09 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 77F983A; Thu, 6 Apr 2017 16:12:08 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node3.st.com [10.75.127.15]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 5090D2912; Thu, 6 Apr 2017 16:12:08 +0000 (GMT) Received: from localhost (10.75.127.47) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Thu, 6 Apr 2017 18:12:07 +0200 From: Fabrice Gasnier To: , , , , , Subject: [PATCH v2 3/5] iio: trigger: add set_trigger callback to notify device Date: Thu, 6 Apr 2017 18:11:54 +0200 Message-ID: <1491495116-7209-4-git-send-email-fabrice.gasnier@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1491495116-7209-1-git-send-email-fabrice.gasnier@st.com> References: <1491495116-7209-1-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG5NODE1.st.com (10.75.127.13) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-06_14:, , signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170406_091248_448390_8CD92C30 X-CRM114-Status: GOOD ( 11.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, benjamin.gaignard@linaro.org, lars@metafoo.de, alexandre.torgue@st.com, linux-iio@vger.kernel.org, pmeerw@pmeerw.net, mcoquelin.stm32@gmail.com, knaack.h@gmx.de, fabrice.gasnier@st.com, benjamin.gaignard@st.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add 'set_trigger' callback to iio info structure. This allows device to be notified when a trigger (or no trigger) has been assigned. This maybe useful for instance in non buffered mode (e.g. event triggered). This is called, after trigger and device side validate callbacks have been called. Signed-off-by: Fabrice Gasnier --- Changes in v2: - Added set_trigger callback used in remaining patches --- drivers/iio/industrialio-trigger.c | 6 ++++++ include/linux/iio/iio.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index 978e1592..010bdf2 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -434,6 +434,12 @@ static ssize_t iio_trigger_write_current(struct device *dev, goto out_trigger_put; } + if (indio_dev->info->set_trigger) { + ret = indio_dev->info->set_trigger(indio_dev, trig); + if (ret) + goto out_trigger_put; + } + indio_dev->trig = trig; if (oldtrig) { diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 3f5ea2e..9f51065 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -399,6 +399,7 @@ static inline bool iio_channel_has_available(const struct iio_chan_spec *chan, * @write_event_value: write a configuration value for the event. * @validate_trigger: function to validate the trigger when the * current trigger gets changed. + * @set_trigger: function to notify current trigger gets changed. * @update_scan_mode: function to configure device and scan buffer when * channels have changed * @debugfs_reg_access: function to read or write register value of device @@ -478,6 +479,7 @@ struct iio_info { int (*validate_trigger)(struct iio_dev *indio_dev, struct iio_trigger *trig); + int (*set_trigger)(struct iio_dev *indio_dev, struct iio_trigger *trig); int (*update_scan_mode)(struct iio_dev *indio_dev, const unsigned long *scan_mask); int (*debugfs_reg_access)(struct iio_dev *indio_dev,