From patchwork Wed Jul 31 21:52:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis CIOCCA X-Patchwork-Id: 11069611 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 1F2D01395 for ; Wed, 31 Jul 2019 21:53:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EF3226E47 for ; Wed, 31 Jul 2019 21:53:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0346327CF3; Wed, 31 Jul 2019 21:53:06 +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,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 A072326E47 for ; Wed, 31 Jul 2019 21:53:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730348AbfGaVxF (ORCPT ); Wed, 31 Jul 2019 17:53:05 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:33562 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727987AbfGaVxF (ORCPT ); Wed, 31 Jul 2019 17:53:05 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6VLpu42005721; Wed, 31 Jul 2019 23:52:57 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=STMicroelectronics; bh=Ly3YJPVIY4xEVEoftD3Syia6lWrUfkDdvryFpEXMeoE=; b=h9e0mGr+6ebQzLG2QoStRPnOdHGDdZitwvGe6PYXuTLNMO47eHDmAYJpp7v5l4Odpiu2 UHuk/CkHPsqqT11rYsz3W+ROZcQ9lJmF+pMur1hymHz3AjsUuuP1L1tZ9sTd5UgZNLzX XbzkW/EiXBJaFrD709BzGWtQxz0Mj4C0+ntvNF7hxtlY9tCCv2BiU0NfGjW182HArHC7 O4CuK8oRxzfALxiCHOJnrq4wO6aDIetIqOREnLx1LejP5bgZT4MFtq7FOu+SO/5jCJVm 9IJSWTmO+oHNscDnO59/Vc88d8hSpCdBwl9kLV1ZTb1CTBF++IY/315d3UELJ0GtvKMt /A== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2u2jp4heyu-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 31 Jul 2019 23:52:57 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B102131; Wed, 31 Jul 2019 21:52:56 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag1node1.st.com [10.75.127.1]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id A7A38777EB; Wed, 31 Jul 2019 23:52:56 +0200 (CEST) Received: from localhost (10.75.127.45) by SFHDAG1NODE1.st.com (10.75.127.1) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 31 Jul 2019 23:52:55 +0200 From: Denis Ciocca To: , , CC: Denis Ciocca Subject: [PATCH 1/5] iio:common: introduce st_sensors_buffer_preenable/predisable functions Date: Wed, 31 Jul 2019 14:52:46 -0700 Message-ID: <20190731215250.16403-2-denis.ciocca@st.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190731215250.16403-1-denis.ciocca@st.com> References: <20190731215250.16403-1-denis.ciocca@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG7NODE3.st.com (10.75.127.21) To SFHDAG1NODE1.st.com (10.75.127.1) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-07-31_11:,, signatures=0 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 patch is introducing preenable/postdisable in the common st_sensors_buffer code in order to remove the memory allocation / de-allocation from each single st driver. Signed-off-by: Denis Ciocca Reviewed-by: Alexandru Ardelean --- .../iio/common/st_sensors/st_sensors_buffer.c | 22 +++++++++++++++++++ include/linux/iio/common/st_sensors.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c index eee30130ae23..9da1c8104883 100644 --- a/drivers/iio/common/st_sensors/st_sensors_buffer.c +++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c @@ -81,6 +81,28 @@ irqreturn_t st_sensors_trigger_handler(int irq, void *p) } EXPORT_SYMBOL(st_sensors_trigger_handler); +int st_sensors_buffer_preenable(struct iio_dev *indio_dev) +{ + struct st_sensor_data *sdata = iio_priv(indio_dev); + + sdata->buffer_data = kmalloc(indio_dev->scan_bytes, + GFP_DMA | GFP_KERNEL); + if (!sdata->buffer_data) + return -ENOMEM; + + return 0; +} +EXPORT_SYMBOL(st_sensors_buffer_preenable); + +int st_sensors_buffer_postdisable(struct iio_dev *indio_dev) +{ + struct st_sensor_data *sdata = iio_priv(indio_dev); + + kfree(sdata->buffer_data); + return 0; +} +EXPORT_SYMBOL(st_sensors_buffer_postdisable); + MODULE_AUTHOR("Denis Ciocca "); MODULE_DESCRIPTION("STMicroelectronics ST-sensors buffer"); MODULE_LICENSE("GPL v2"); diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index 28fc1f9fa7d5..c66ebb236a15 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h @@ -254,6 +254,8 @@ struct st_sensor_data { #ifdef CONFIG_IIO_BUFFER irqreturn_t st_sensors_trigger_handler(int irq, void *p); +int st_sensors_buffer_preenable(struct iio_dev *indio_dev); +int st_sensors_buffer_postdisable(struct iio_dev *indio_dev); #endif #ifdef CONFIG_IIO_TRIGGER From patchwork Wed Jul 31 21:52:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis CIOCCA X-Patchwork-Id: 11069613 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 82FD4746 for ; Wed, 31 Jul 2019 21:53:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73BA026E47 for ; Wed, 31 Jul 2019 21:53:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6804327CF3; Wed, 31 Jul 2019 21:53:08 +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,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 15C3926E47 for ; Wed, 31 Jul 2019 21:53:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730440AbfGaVxH (ORCPT ); Wed, 31 Jul 2019 17:53:07 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:28116 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727987AbfGaVxH (ORCPT ); Wed, 31 Jul 2019 17:53:07 -0400 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6VLqV4X016197; Wed, 31 Jul 2019 23:52:59 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=STMicroelectronics; bh=Mfj69tr2pDDSjxNqSpPWtwDMc4TWU5VoO/ch6jGhS98=; b=YZtgFn1u+Fx7A6mu8qDVBqTKDXNSBFT2yiGQjpj6qcmLG8IbxwjIfME+E0spsqP1aQSf VGdguhr/7NifxBue+CQ5fnWXp1+pP05uFKFtANyo8gdnhabyEVDbrDcOAdGMY+aTu4YO 9V/5OGePXFWcju3sjy2IL418dI5lCtyMJ0FyrrUEraTRf5iqu/1KVv/SL5sGoW29ubNm Q/m7yk0om7pTt5a2RJ3v1xhTvD8oDjd6eEqrTjUP4DgKhD2K7V4+tz0NSf/c681x0ksp hCam1f8AGip879AUNi7a68ZnkRIc/5++R2qPQxz/IXZ6ZsoevxIAJRiIrB8ZLJzOfXlu Nw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2u0ccwtcxu-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 31 Jul 2019 23:52:59 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4A35131; Wed, 31 Jul 2019 21:52:59 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag1node1.st.com [10.75.127.1]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 42FF4777EB; Wed, 31 Jul 2019 23:52:59 +0200 (CEST) Received: from localhost (10.75.127.47) by SFHDAG1NODE1.st.com (10.75.127.1) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 31 Jul 2019 23:52:58 +0200 From: Denis Ciocca To: , , CC: Denis Ciocca Subject: [PATCH 2/5] iio:accel: do not allocate/de-allocate buffer here but link setup_ops to st_sensors_buffer Date: Wed, 31 Jul 2019 14:52:47 -0700 Message-ID: <20190731215250.16403-3-denis.ciocca@st.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190731215250.16403-1-denis.ciocca@st.com> References: <20190731215250.16403-1-denis.ciocca@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG5NODE3.st.com (10.75.127.15) To SFHDAG1NODE1.st.com (10.75.127.1) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-07-31_11:,, signatures=0 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 Setup buffer_setup_ops pre/post enable/disable to use st_sensor_buffers functions for memory allocation/de-allocation. Signed-off-by: Denis Ciocca Reviewed-by: Alexandru Ardelean --- drivers/iio/accel/st_accel_buffer.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/iio/accel/st_accel_buffer.c b/drivers/iio/accel/st_accel_buffer.c index 59dcef02ec19..fc1ba52152ab 100644 --- a/drivers/iio/accel/st_accel_buffer.c +++ b/drivers/iio/accel/st_accel_buffer.c @@ -31,17 +31,11 @@ int st_accel_trig_set_state(struct iio_trigger *trig, bool state) static int st_accel_buffer_postenable(struct iio_dev *indio_dev) { - struct st_sensor_data *adata = iio_priv(indio_dev); int err; - adata->buffer_data = kmalloc(indio_dev->scan_bytes, - GFP_DMA | GFP_KERNEL); - if (!adata->buffer_data) - return -ENOMEM; - err = iio_triggered_buffer_postenable(indio_dev); if (err < 0) - goto st_accel_free_buffer; + return err; err = st_sensors_set_axis_enable(indio_dev, (u8)indio_dev->active_scan_mask[0]); @@ -58,14 +52,11 @@ static int st_accel_buffer_postenable(struct iio_dev *indio_dev) st_sensors_set_axis_enable(indio_dev, ST_SENSORS_ENABLE_ALL_AXIS); st_accel_buffer_predisable: iio_triggered_buffer_predisable(indio_dev); -st_accel_free_buffer: - kfree(adata->buffer_data); return err; } static int st_accel_buffer_predisable(struct iio_dev *indio_dev) { - struct st_sensor_data *adata = iio_priv(indio_dev); int err, err2; err = st_sensors_set_enable(indio_dev, false); @@ -79,13 +70,14 @@ static int st_accel_buffer_predisable(struct iio_dev *indio_dev) if (!err) err = err2; - kfree(adata->buffer_data); return err; } static const struct iio_buffer_setup_ops st_accel_buffer_setup_ops = { + .preenable = &st_sensors_buffer_preenable, .postenable = &st_accel_buffer_postenable, .predisable = &st_accel_buffer_predisable, + .postdisable = &st_sensors_buffer_postdisable, }; int st_accel_allocate_ring(struct iio_dev *indio_dev) From patchwork Wed Jul 31 21:52:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis CIOCCA X-Patchwork-Id: 11069617 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 BA4E31395 for ; Wed, 31 Jul 2019 21:53:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA59F26E47 for ; Wed, 31 Jul 2019 21:53:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F04027CF3; Wed, 31 Jul 2019 21:53:14 +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,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 4AC4126E47 for ; Wed, 31 Jul 2019 21:53:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731047AbfGaVxO (ORCPT ); Wed, 31 Jul 2019 17:53:14 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:31386 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730504AbfGaVxN (ORCPT ); Wed, 31 Jul 2019 17:53:13 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6VLkVjF028223; Wed, 31 Jul 2019 23:53:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=STMicroelectronics; bh=pEu7VH3P1sxZGeveUOFHsvdCGDG2P//TjcsxxMlYQrw=; b=clKVN1gnJK5RVVyFyA8jBbGIv3u9ic9eXy23jaba8ZFz6AUU9yksAYSGffwUL3qqwOW9 OgfG9YGzTbhPqNNc1GVSQStcrZVGlETPbY3bOgWUuaJVHVKJwRc78dgcGTY4K/Ff+poC lVMDXlsF8xpF+BGsD1/qOWSPNd4ELCNP7sjNkx6F0W1LJOeu226LWpPc/9BPv3N712iI EkMTvkDhpZS6qY1PyX9V8/Wfv36cn/uYOP4XQ5Vwxca/WI6RvSSVvexK+kfYoNQwID+Z UEw1YHD83a3r6gfj1DGbVT/eAz5nL1RzoLyIA8J39VhL0GBuXqPDCX+aT+8/dTUXDjNS 7A== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2u0c2yjhbr-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 31 Jul 2019 23:53:04 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C934331; Wed, 31 Jul 2019 21:53:01 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag1node1.st.com [10.75.127.1]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id C11C1777EB; Wed, 31 Jul 2019 23:53:01 +0200 (CEST) Received: from localhost (10.75.127.50) by SFHDAG1NODE1.st.com (10.75.127.1) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 31 Jul 2019 23:53:01 +0200 From: Denis Ciocca To: , , CC: Denis Ciocca Subject: [PATCH 3/5] iio:gyro: do not allocate/de-allocate buffer here but link setup_ops to st_sensors_buffer Date: Wed, 31 Jul 2019 14:52:48 -0700 Message-ID: <20190731215250.16403-4-denis.ciocca@st.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190731215250.16403-1-denis.ciocca@st.com> References: <20190731215250.16403-1-denis.ciocca@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG5NODE2.st.com (10.75.127.14) To SFHDAG1NODE1.st.com (10.75.127.1) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-07-31_11:,, signatures=0 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 Setup buffer_setup_ops pre/post enable/disable to use st_sensor_buffers functions for memory allocation/de-allocation. Signed-off-by: Denis Ciocca Reviewed-by: Alexandru Ardelean --- drivers/iio/gyro/st_gyro_buffer.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/iio/gyro/st_gyro_buffer.c b/drivers/iio/gyro/st_gyro_buffer.c index c6ddfecc1fc3..48811457a943 100644 --- a/drivers/iio/gyro/st_gyro_buffer.c +++ b/drivers/iio/gyro/st_gyro_buffer.c @@ -31,17 +31,11 @@ int st_gyro_trig_set_state(struct iio_trigger *trig, bool state) static int st_gyro_buffer_postenable(struct iio_dev *indio_dev) { - struct st_sensor_data *gdata = iio_priv(indio_dev); int err; - gdata->buffer_data = kmalloc(indio_dev->scan_bytes, - GFP_DMA | GFP_KERNEL); - if (!gdata->buffer_data) - return -ENOMEM; - err = iio_triggered_buffer_postenable(indio_dev); if (err < 0) - goto st_gyro_free_buffer; + return err; err = st_sensors_set_axis_enable(indio_dev, (u8)indio_dev->active_scan_mask[0]); @@ -58,15 +52,12 @@ static int st_gyro_buffer_postenable(struct iio_dev *indio_dev) st_sensors_set_axis_enable(indio_dev, ST_SENSORS_ENABLE_ALL_AXIS); st_gyro_buffer_predisable: iio_triggered_buffer_predisable(indio_dev); -st_gyro_free_buffer: - kfree(gdata->buffer_data); return err; } static int st_gyro_buffer_predisable(struct iio_dev *indio_dev) { int err, err2; - struct st_sensor_data *gdata = iio_priv(indio_dev); err = st_sensors_set_enable(indio_dev, false); if (err < 0) @@ -79,13 +70,14 @@ static int st_gyro_buffer_predisable(struct iio_dev *indio_dev) if (!err) err = err2; - kfree(gdata->buffer_data); return err; } static const struct iio_buffer_setup_ops st_gyro_buffer_setup_ops = { + .preenable = &st_sensors_buffer_preenable, .postenable = &st_gyro_buffer_postenable, .predisable = &st_gyro_buffer_predisable, + .postdisable = &st_sensors_buffer_postdisable, }; int st_gyro_allocate_ring(struct iio_dev *indio_dev) From patchwork Wed Jul 31 21:52:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis CIOCCA X-Patchwork-Id: 11069615 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 06B05746 for ; Wed, 31 Jul 2019 21:53:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB9E026E47 for ; Wed, 31 Jul 2019 21:53:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E001327CF3; Wed, 31 Jul 2019 21:53:13 +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,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 CC37826E47 for ; Wed, 31 Jul 2019 21:53:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731045AbfGaVxM (ORCPT ); Wed, 31 Jul 2019 17:53:12 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:41753 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727987AbfGaVxM (ORCPT ); Wed, 31 Jul 2019 17:53:12 -0400 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6VLq97h016081; Wed, 31 Jul 2019 23:53:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=STMicroelectronics; bh=2FZ7C50rEs7CbDlj6YokX6ynUj5Qt+oTcPuDxTUEtVM=; b=GTZ8ebp2QgfwuDp5+ZlJgfJ0BamgW6u9OwhfW80D+FBFZybUfKXuDsL5jXLOxexE/3sA nHjWuPgYfWyP58ubH5L3xJzJEqAdiying4MtytplFg0OzNVs2uvj2CDdvWtZlTHnpTSo ELbGLFp0RKidxqyWwRqf2sTP/pyQ9A3ChYg06BJdyyXdZXujiXB5UzudFdgbtlCXj5CK 01Sld4p9zdmJp+cSP1fK1MdCt4ILypzwA5Yyph+IpCN7PFufvaoXBesueP0q+K64havz BMOrXWBkXhCQHxzwUOVPEUad6+6AC6R/7OvSDb/f9k5cSGbYU090UBfNF7BX2tywK2lN Uw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2u0ccwtcy5-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 31 Jul 2019 23:53:05 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9B13638; Wed, 31 Jul 2019 21:53:04 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag1node1.st.com [10.75.127.1]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 915B2777ED; Wed, 31 Jul 2019 23:53:04 +0200 (CEST) Received: from localhost (10.75.127.45) by SFHDAG1NODE1.st.com (10.75.127.1) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 31 Jul 2019 23:53:03 +0200 From: Denis Ciocca To: , , CC: Denis Ciocca Subject: [PATCH 4/5] iio:magn: do not allocate/de-allocate buffer here but link setup_ops to st_sensors_buffer Date: Wed, 31 Jul 2019 14:52:49 -0700 Message-ID: <20190731215250.16403-5-denis.ciocca@st.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190731215250.16403-1-denis.ciocca@st.com> References: <20190731215250.16403-1-denis.ciocca@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG7NODE3.st.com (10.75.127.21) To SFHDAG1NODE1.st.com (10.75.127.1) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-07-31_11:,, signatures=0 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 Setup buffer_setup_ops pre/post enable/disable to use st_sensor_buffers functions for memory allocation/de-allocation. Signed-off-by: Denis Ciocca Reviewed-by: Alexandru Ardelean --- drivers/iio/magnetometer/st_magn_buffer.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/iio/magnetometer/st_magn_buffer.c b/drivers/iio/magnetometer/st_magn_buffer.c index 658d627dad8e..592972f6450e 100644 --- a/drivers/iio/magnetometer/st_magn_buffer.c +++ b/drivers/iio/magnetometer/st_magn_buffer.c @@ -31,17 +31,11 @@ int st_magn_trig_set_state(struct iio_trigger *trig, bool state) static int st_magn_buffer_postenable(struct iio_dev *indio_dev) { - struct st_sensor_data *mdata = iio_priv(indio_dev); int err; - mdata->buffer_data = kmalloc(indio_dev->scan_bytes, - GFP_DMA | GFP_KERNEL); - if (!mdata->buffer_data) - return -ENOMEM; - err = iio_triggered_buffer_postenable(indio_dev); if (err < 0) - goto st_magn_free_buffer; + return err; err = st_sensors_set_enable(indio_dev, true); if (err < 0) @@ -51,14 +45,11 @@ static int st_magn_buffer_postenable(struct iio_dev *indio_dev) st_magn_buffer_predisable: iio_triggered_buffer_predisable(indio_dev); -st_magn_free_buffer: - kfree(mdata->buffer_data); return err; } static int st_magn_buffer_predisable(struct iio_dev *indio_dev) { - struct st_sensor_data *mdata = iio_priv(indio_dev); int err, err2; err = st_sensors_set_enable(indio_dev, false); @@ -67,13 +58,14 @@ static int st_magn_buffer_predisable(struct iio_dev *indio_dev) if (!err) err = err2; - kfree(mdata->buffer_data); return err; } static const struct iio_buffer_setup_ops st_magn_buffer_setup_ops = { + .preenable = &st_sensors_buffer_preenable, .postenable = &st_magn_buffer_postenable, .predisable = &st_magn_buffer_predisable, + .postdisable = &st_sensors_buffer_postdisable, }; int st_magn_allocate_ring(struct iio_dev *indio_dev) From patchwork Wed Jul 31 21:52:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis CIOCCA X-Patchwork-Id: 11069619 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 B1EA11395 for ; Wed, 31 Jul 2019 21:53:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A048926E47 for ; Wed, 31 Jul 2019 21:53:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9179B27CF3; Wed, 31 Jul 2019 21:53:15 +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,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 3DA4326E47 for ; Wed, 31 Jul 2019 21:53:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730504AbfGaVxP (ORCPT ); Wed, 31 Jul 2019 17:53:15 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:14426 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727987AbfGaVxO (ORCPT ); Wed, 31 Jul 2019 17:53:14 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6VLlVoj017013; Wed, 31 Jul 2019 23:53:07 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=STMicroelectronics; bh=c2R5PGscM6eXuYCQbXpNI5k/P+egYypUIzMikfSs97w=; b=fyaSUND6ylSJJPDDjvRMgYpNtGyOsX72VNJ6L7B2KIhM6gX6KUhf5x4FI74CTAQgBf3H 8LWsYT0Pljv5fL6JmR2/q42mHtin+EDUnug1NkdH5Dh7apPiK2SYqqx0ufXIWRC7eGf8 PUy7jdy+vonazow03x90IwWiug0Y6aj1zccvrA65ys3BUTWt74gRvUk0o9UDXSI9Tlu/ ueso3YaM4L4Ql2DcA+j/OacrOPaD2qJrRJJ2Rftpl5xmXOTQmg2tFFt2OKV9kRQdEfzZ Y+RwUK7HEcP5Q40dOCA0EVWrOqSWPBnnnUkxwJ7IbmjwvAejHF169EvarGuK+FMyj72j oA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2u0bra6m4f-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 31 Jul 2019 23:53:07 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2D29C31; Wed, 31 Jul 2019 21:53:07 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag1node1.st.com [10.75.127.1]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 25AFC777EB; Wed, 31 Jul 2019 23:53:07 +0200 (CEST) Received: from localhost (10.75.127.47) by SFHDAG1NODE1.st.com (10.75.127.1) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 31 Jul 2019 23:53:06 +0200 From: Denis Ciocca To: , , CC: Denis Ciocca Subject: [PATCH 5/5] iio:pressure: do not allocate/de-allocate buffer here but link setup_ops to st_sensors_buffer Date: Wed, 31 Jul 2019 14:52:50 -0700 Message-ID: <20190731215250.16403-6-denis.ciocca@st.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190731215250.16403-1-denis.ciocca@st.com> References: <20190731215250.16403-1-denis.ciocca@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG5NODE1.st.com (10.75.127.13) To SFHDAG1NODE1.st.com (10.75.127.1) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-07-31_11:,, signatures=0 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 Setup buffer_setup_ops pre/post enable/disable to use st_sensor_buffers functions for memory allocation/de-allocation. Signed-off-by: Denis Ciocca Reviewed-by: Alexandru Ardelean --- drivers/iio/pressure/st_pressure_buffer.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/iio/pressure/st_pressure_buffer.c b/drivers/iio/pressure/st_pressure_buffer.c index 77cb2d862f19..4306541953d0 100644 --- a/drivers/iio/pressure/st_pressure_buffer.c +++ b/drivers/iio/pressure/st_pressure_buffer.c @@ -31,17 +31,11 @@ int st_press_trig_set_state(struct iio_trigger *trig, bool state) static int st_press_buffer_postenable(struct iio_dev *indio_dev) { - struct st_sensor_data *press_data = iio_priv(indio_dev); int err; - press_data->buffer_data = kmalloc(indio_dev->scan_bytes, - GFP_DMA | GFP_KERNEL); - if (!press_data->buffer_data) - return -ENOMEM; - err = iio_triggered_buffer_postenable(indio_dev); if (err < 0) - goto st_press_free_buffer; + return err; err = st_sensors_set_enable(indio_dev, true); if (err < 0) @@ -51,14 +45,11 @@ static int st_press_buffer_postenable(struct iio_dev *indio_dev) st_press_buffer_predisable: iio_triggered_buffer_predisable(indio_dev); -st_press_free_buffer: - kfree(press_data->buffer_data); return err; } static int st_press_buffer_predisable(struct iio_dev *indio_dev) { - struct st_sensor_data *press_data = iio_priv(indio_dev); int err, err2; err = st_sensors_set_enable(indio_dev, false); @@ -67,13 +58,14 @@ static int st_press_buffer_predisable(struct iio_dev *indio_dev) if (!err) err = err2; - kfree(press_data->buffer_data); return err; } static const struct iio_buffer_setup_ops st_press_buffer_setup_ops = { + .preenable = &st_sensors_buffer_preenable, .postenable = &st_press_buffer_postenable, .predisable = &st_press_buffer_predisable, + .postdisable = &st_sensors_buffer_postdisable, }; int st_press_allocate_ring(struct iio_dev *indio_dev)