From patchwork Tue Jul 20 07:46:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 12387655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0231BC07E95 for ; Tue, 20 Jul 2021 07:47:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CEE356100C for ; Tue, 20 Jul 2021 07:47:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229922AbhGTHG3 (ORCPT ); Tue, 20 Jul 2021 03:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbhGTHGV (ORCPT ); Tue, 20 Jul 2021 03:06:21 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01D87C061762 for ; Tue, 20 Jul 2021 00:46:59 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id x17so27290726edd.12 for ; Tue, 20 Jul 2021 00:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=deviqon.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fG+TIrBcXjlGO0172HoRoFhmSuH5RlW2FCQ8LPJTxcA=; b=E6A58g+Lxxb3C64WKwhiotp6QXgwxqOZiTq0QJWxLpteG83/n68uQukFP+683QRkRD fI3dw+hh6jxcsggGwNdq6VTHINik0f7S+0BrHyCFwy1rWofUOj9L29Cwif0rpvtpUsIZ qbpUjF2ZWUE/2FNQj6vFVhrba97b5VLIbfn4bnb2In3UbYnOwg6MuiQQ3AMF5+XlJIFA gXUndFL/EjcUPmfh9XPRDBu3FTzQixv3i9DVNu/WbcC6SNmMBRRK29WikHKC8R4mExhJ RsLFyWt6w+5c5U7HZNcMuTY0HVpus7g2jQPxRaLjUamfqNHZweGsTBj5ozEeO4lXv4Yb z1NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fG+TIrBcXjlGO0172HoRoFhmSuH5RlW2FCQ8LPJTxcA=; b=LYiFYRbq0Mi6YHWwTKsOP2ioSgR45hqI5GSo5uPMp/pdhI98eFBTatNyfipXXNYw+f IzlfffqfqDVbU03mHt6M6cOiB9HGnkFJMBzwjmiFdOcwExRaae3+5POwcM6N57DKc038 4PB+BksLw3OJTEsgg0288ogKua4Os96Hi8pbCOdqdm9iSuH263e3GLL9zMgOZ7FPLpf3 ws9ch2ZZDYje1w0RXrfV8FCKHJNMn5LRON1L4QhMgWvBXl1B2sug9RqWaDw4+JUw6vKE 8U5MiEpcyImT/CeJu9W49S8pm8YU/MdFKspcRZ+Gu++BN9uttQz1ky9zEdJWmQlvvHF4 /XIw== X-Gm-Message-State: AOAM531BF94OMwejSgB0ssb/jtR1AaeyBnpJlWWYv7D2z+MgE2Bp8Hoo 9yany8oUPC4OP4W1b5CNwTTx5MX0HjrsxUHJs0Q= X-Google-Smtp-Source: ABdhPJwVPGLOWrVCyBdS20griRcddlKUnItVcUPsOMQ5oQFe+y353CEMx0ElGvUVui+8ajQIJ3pR+Q== X-Received: by 2002:aa7:ca54:: with SMTP id j20mr39333039edt.137.1626767217417; Tue, 20 Jul 2021 00:46:57 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id b22sm7530940edj.24.2021.07.20.00.46.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 00:46:57 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: denis.ciocca@st.com, jic23@kernel.org, Alexandru Ardelean Subject: [PATCH 1/4] iio: pressure: st_pressure: use devm_iio_triggered_buffer_setup() for buffer Date: Tue, 20 Jul 2021 10:46:39 +0300 Message-Id: <20210720074642.223293-1-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The st_press_allocate_ring() function calls iio_triggered_buffer_setup() to allocate a triggered buffer. But the same can be done with devm_iio_triggered_buffer_setup() and then the st_press_common_remove() no longer needs to manually deallocate it. We know that the parent of the IIO device is used to manage other instances of the devm unwind, so it can be used in the st_press_allocate_ring() as well. Signed-off-by: Alexandru Ardelean --- drivers/iio/pressure/st_pressure.h | 5 ----- drivers/iio/pressure/st_pressure_buffer.c | 9 ++------- drivers/iio/pressure/st_pressure_core.c | 6 +----- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/drivers/iio/pressure/st_pressure.h b/drivers/iio/pressure/st_pressure.h index 9417b3bd7513..156e6a72dc5c 100644 --- a/drivers/iio/pressure/st_pressure.h +++ b/drivers/iio/pressure/st_pressure.h @@ -43,7 +43,6 @@ static __maybe_unused const struct st_sensors_platform_data default_press_pdata #ifdef CONFIG_IIO_BUFFER int st_press_allocate_ring(struct iio_dev *indio_dev); -void st_press_deallocate_ring(struct iio_dev *indio_dev); int st_press_trig_set_state(struct iio_trigger *trig, bool state); #define ST_PRESS_TRIGGER_SET_STATE (&st_press_trig_set_state) #else /* CONFIG_IIO_BUFFER */ @@ -51,10 +50,6 @@ static inline int st_press_allocate_ring(struct iio_dev *indio_dev) { return 0; } - -static inline void st_press_deallocate_ring(struct iio_dev *indio_dev) -{ -} #define ST_PRESS_TRIGGER_SET_STATE NULL #endif /* CONFIG_IIO_BUFFER */ diff --git a/drivers/iio/pressure/st_pressure_buffer.c b/drivers/iio/pressure/st_pressure_buffer.c index b651e7c31e90..25dbd5476b26 100644 --- a/drivers/iio/pressure/st_pressure_buffer.c +++ b/drivers/iio/pressure/st_pressure_buffer.c @@ -41,13 +41,8 @@ static const struct iio_buffer_setup_ops st_press_buffer_setup_ops = { int st_press_allocate_ring(struct iio_dev *indio_dev) { - return iio_triggered_buffer_setup(indio_dev, NULL, - &st_sensors_trigger_handler, &st_press_buffer_setup_ops); -} - -void st_press_deallocate_ring(struct iio_dev *indio_dev) -{ - iio_triggered_buffer_cleanup(indio_dev); + return devm_iio_triggered_buffer_setup(indio_dev->dev.parent, indio_dev, + NULL, &st_sensors_trigger_handler, &st_press_buffer_setup_ops); } MODULE_AUTHOR("Denis Ciocca "); diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 4ff6d40e3670..ab1c17fac807 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -718,7 +718,7 @@ int st_press_common_probe(struct iio_dev *indio_dev) err = st_sensors_allocate_trigger(indio_dev, ST_PRESS_TRIGGER_OPS); if (err < 0) - goto st_press_probe_trigger_error; + return err; } err = iio_device_register(indio_dev); @@ -733,8 +733,6 @@ int st_press_common_probe(struct iio_dev *indio_dev) st_press_device_register_error: if (press_data->irq > 0) st_sensors_deallocate_trigger(indio_dev); -st_press_probe_trigger_error: - st_press_deallocate_ring(indio_dev); return err; } EXPORT_SYMBOL(st_press_common_probe); @@ -746,8 +744,6 @@ void st_press_common_remove(struct iio_dev *indio_dev) iio_device_unregister(indio_dev); if (press_data->irq > 0) st_sensors_deallocate_trigger(indio_dev); - - st_press_deallocate_ring(indio_dev); } EXPORT_SYMBOL(st_press_common_remove); From patchwork Tue Jul 20 07:46:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 12387657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 872BBC07E9B for ; Tue, 20 Jul 2021 07:47:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C1886100C for ; Tue, 20 Jul 2021 07:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230092AbhGTHGe (ORCPT ); Tue, 20 Jul 2021 03:06:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbhGTHGV (ORCPT ); Tue, 20 Jul 2021 03:06:21 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08F3CC061766 for ; Tue, 20 Jul 2021 00:47:00 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id ca14so27366562edb.2 for ; Tue, 20 Jul 2021 00:46:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=deviqon.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ph3XEUc88z5VPxCMsIt7VVIKG5XsfAQWJvNfdBNntnk=; b=GSTaoJFveI3Rb2+0ZQ6fgPBXGkscL7rtZZa1WmNAqD+6P5PH9OjPSC0QbIbCAkNEzH m0puof917wFKNqXecyS9zF2FU9Q+Fv9bjeofbyHT/eZr5V6G8D3aVHjf2PClX+GfUZK9 CFUvlC+83kgYr0r6gF8CnN/1b4JVai6Tptsbv75ixN1E7T5D5m361gUyIqh4d+AnV1IL iLG8f278PRItWIgHBukh8qohwa6kbGjfweHRikQx275U71VYJdgLFgIMm0xiJhYCeAjD aOJpfhkK04sM8aOOcZ8TPYc2a1F5Jkvi43MLvFa0cRvdTJh3dwBM5zPI9MXKJDIdbKsp Z3tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ph3XEUc88z5VPxCMsIt7VVIKG5XsfAQWJvNfdBNntnk=; b=UC1sUfSUWaBjUNpItJBiet1nxreO/kRefwkPLL+/QgepUw7z1V+ua5SCt7GlXb2qPS 2NiO/Ipi42S9EMn9/MJ+Qg/d2SpFsfCMyimoOU683TMDPcufqTs/oL/cbI17nW4t+Bix L3Wd40VvkE3PVMXpiTecUOM2KiMYsTllcj+TSZSjp4vSw2mjSUny5wxZQ7P6cTiavHKS Ty+afP7UdHJgvUBj71FiArXWauZvcwkk7Zz1Apxr/BVlJum7YmEwBgZmgnSuH0cuwwwM 3M800jHP3P3lvWcNSE4A52r0AtunRWfFvIzkqkXTwzBnSmn7dMqnU7m0I+HqOJbO1c9x qhww== X-Gm-Message-State: AOAM530fV1V+a/n2/HvEhN7MzKbQpHJX1Ks2ulk62XTxYrCu57/8uSJq dNM0GzP/X6J54KGA9C2mDqQCBjmn0xDex7m+ww0= X-Google-Smtp-Source: ABdhPJxtIED7exLgQ17KR5hySSV24mU/wgy6LrPsIp4OwZFNH7GrOqKdIH1WH8RrAahE6BUkTlZDhA== X-Received: by 2002:a05:6402:487:: with SMTP id k7mr38582633edv.315.1626767218392; Tue, 20 Jul 2021 00:46:58 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id b22sm7530940edj.24.2021.07.20.00.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 00:46:58 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: denis.ciocca@st.com, jic23@kernel.org, Alexandru Ardelean Subject: [PATCH 2/4] iio: accel: st_accel: use devm_iio_triggered_buffer_setup() for buffer Date: Tue, 20 Jul 2021 10:46:40 +0300 Message-Id: <20210720074642.223293-2-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210720074642.223293-1-aardelean@deviqon.com> References: <20210720074642.223293-1-aardelean@deviqon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The st_accel_allocate_ring() function calls iio_triggered_buffer_setup() to allocate a triggered buffer. But the same can be done with devm_iio_triggered_buffer_setup() and then the st_accel_common_remove() no longer needs to manually deallocate it. We know that the parent of the IIO device is used to manage other instances of the devm unwind, so it can be used in the st_accel_allocate_ring() as well. Signed-off-by: Alexandru Ardelean --- drivers/iio/accel/st_accel.h | 4 ---- drivers/iio/accel/st_accel_buffer.c | 9 ++------- drivers/iio/accel/st_accel_core.c | 6 +----- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h index f5b0b8bbaff7..8750dea56fcb 100644 --- a/drivers/iio/accel/st_accel.h +++ b/drivers/iio/accel/st_accel.h @@ -64,7 +64,6 @@ enum st_accel_type { #ifdef CONFIG_IIO_BUFFER int st_accel_allocate_ring(struct iio_dev *indio_dev); -void st_accel_deallocate_ring(struct iio_dev *indio_dev); int st_accel_trig_set_state(struct iio_trigger *trig, bool state); #define ST_ACCEL_TRIGGER_SET_STATE (&st_accel_trig_set_state) #else /* CONFIG_IIO_BUFFER */ @@ -72,9 +71,6 @@ static inline int st_accel_allocate_ring(struct iio_dev *indio_dev) { return 0; } -static inline void st_accel_deallocate_ring(struct iio_dev *indio_dev) -{ -} #define ST_ACCEL_TRIGGER_SET_STATE NULL #endif /* CONFIG_IIO_BUFFER */ diff --git a/drivers/iio/accel/st_accel_buffer.c b/drivers/iio/accel/st_accel_buffer.c index f89770f251d9..fc82fa83f1fb 100644 --- a/drivers/iio/accel/st_accel_buffer.c +++ b/drivers/iio/accel/st_accel_buffer.c @@ -62,13 +62,8 @@ static const struct iio_buffer_setup_ops st_accel_buffer_setup_ops = { int st_accel_allocate_ring(struct iio_dev *indio_dev) { - return iio_triggered_buffer_setup(indio_dev, NULL, - &st_sensors_trigger_handler, &st_accel_buffer_setup_ops); -} - -void st_accel_deallocate_ring(struct iio_dev *indio_dev) -{ - iio_triggered_buffer_cleanup(indio_dev); + return devm_iio_triggered_buffer_setup(indio_dev->dev.parent, indio_dev, + NULL, &st_sensors_trigger_handler, &st_accel_buffer_setup_ops); } MODULE_AUTHOR("Denis Ciocca "); diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 365e4e64ca18..f1e6ec380667 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -1377,7 +1377,7 @@ int st_accel_common_probe(struct iio_dev *indio_dev) err = st_sensors_allocate_trigger(indio_dev, ST_ACCEL_TRIGGER_OPS); if (err < 0) - goto st_accel_probe_trigger_error; + return err; } err = iio_device_register(indio_dev); @@ -1392,8 +1392,6 @@ int st_accel_common_probe(struct iio_dev *indio_dev) st_accel_device_register_error: if (adata->irq > 0) st_sensors_deallocate_trigger(indio_dev); -st_accel_probe_trigger_error: - st_accel_deallocate_ring(indio_dev); return err; } EXPORT_SYMBOL(st_accel_common_probe); @@ -1405,8 +1403,6 @@ void st_accel_common_remove(struct iio_dev *indio_dev) iio_device_unregister(indio_dev); if (adata->irq > 0) st_sensors_deallocate_trigger(indio_dev); - - st_accel_deallocate_ring(indio_dev); } EXPORT_SYMBOL(st_accel_common_remove); From patchwork Tue Jul 20 07:46:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 12387659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01079C07E9B for ; Tue, 20 Jul 2021 07:47:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE15361165 for ; Tue, 20 Jul 2021 07:47:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230252AbhGTHGh (ORCPT ); Tue, 20 Jul 2021 03:06:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229845AbhGTHGX (ORCPT ); Tue, 20 Jul 2021 03:06:23 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 062D6C061768 for ; Tue, 20 Jul 2021 00:47:01 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id ec55so27343932edb.1 for ; Tue, 20 Jul 2021 00:47:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=deviqon.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6WyA9TXdUs//oenEd121gmP7wNOs6Aapjq3zo8t6a0A=; b=ccbBxAn67cIsRP+FE8rsrxkIrAcx19Y1IdownOVpm1Si8tbZSAE9oHmBHei5rLp/1i +KJjmJAebDZnFgTks5T8INe/EG0RKpjo+bCyiKIvIlKlGg5WIhlf/XcRrxlihP6kc+L1 FmNSwby2388n0FG+gIuHhC0DmZsVt/BG6ippE6NMWb60UgpJ5n9oVmLcSOBnJdlrXDbD Z8lVbQwqX67QMZAibdtmT3A5EeWtVS25Jat+eFjKUTN5ajq4orl0K7i6Cy26vHkQ57Ln zfA07z1DxVQYipydRqIq+wqKbS2z7pWO74gPgK8zbBUAcwRtsrp8Q0jM3l9w0yky7cM5 apcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6WyA9TXdUs//oenEd121gmP7wNOs6Aapjq3zo8t6a0A=; b=fQ3fCGR+Wug2+rb0SguTQL3FJ6vs2F+LdZluRUIWjW29kw4kt6XqpRK3hNaRtRKxA0 3rxYHTxT/QLN9WpqyRFK4x/3DxPZx7i85X9u207yibaNyftTMHkio7uE4w/Z8ZRysrI5 F8U5q/JjGKsZo7s1gr5kxw6nXHJuAZVAjTVlSzppIuQNhckqxGyDARiBqd5HkrJvkA68 DnRkbCm82v6SGnVNJ093wJWRIqGqRA30XoKUA056ZMKxLdli3NfWecOKMMIH250HvUSO i4qXWlOZ7SLLloDbeEVRtPCnnhhxHGSncyECw3SdJiTE5jcCc4ghPNvib7Lbz7JDjrpc tdRg== X-Gm-Message-State: AOAM532X9146iWpvtAz5FojXlDemLgBIk0KubH2ROw+DPZY1sxn863pm IBOT/60BFLc6X3ZxRZys66tAcnjumNyRMvYSrnw= X-Google-Smtp-Source: ABdhPJwQ4HryQnpuHExMrnwayhRVr6oKw57439OG0nNncjq+Y5axRgABCOKGEMXpwCq5AbWsFguJ3w== X-Received: by 2002:a05:6402:100c:: with SMTP id c12mr9865569edu.326.1626767219452; Tue, 20 Jul 2021 00:46:59 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id b22sm7530940edj.24.2021.07.20.00.46.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 00:46:59 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: denis.ciocca@st.com, jic23@kernel.org, Alexandru Ardelean Subject: [PATCH 3/4] iio: magn: st_magn: use devm_iio_triggered_buffer_setup() for buffer Date: Tue, 20 Jul 2021 10:46:41 +0300 Message-Id: <20210720074642.223293-3-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210720074642.223293-1-aardelean@deviqon.com> References: <20210720074642.223293-1-aardelean@deviqon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The st_magn_allocate_ring() function calls iio_triggered_buffer_setup() to allocate a triggered buffer. But the same can be done with devm_iio_triggered_buffer_setup() and then the st_magn_common_remove() no longer needs to manually deallocate it. We know that the parent of the IIO device is used to manage other instances of the devm unwind, so it can be used in the st_magn_allocate_ring() as well. This change also removes some omitted st_magn_{probe,remove}_trigger() inline hooks. Signed-off-by: Alexandru Ardelean --- drivers/iio/magnetometer/st_magn.h | 12 ------------ drivers/iio/magnetometer/st_magn_buffer.c | 9 ++------- drivers/iio/magnetometer/st_magn_core.c | 6 +----- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/drivers/iio/magnetometer/st_magn.h b/drivers/iio/magnetometer/st_magn.h index fb6c906c4c0c..785b7f7b8b06 100644 --- a/drivers/iio/magnetometer/st_magn.h +++ b/drivers/iio/magnetometer/st_magn.h @@ -25,25 +25,13 @@ #ifdef CONFIG_IIO_BUFFER int st_magn_allocate_ring(struct iio_dev *indio_dev); -void st_magn_deallocate_ring(struct iio_dev *indio_dev); int st_magn_trig_set_state(struct iio_trigger *trig, bool state); #define ST_MAGN_TRIGGER_SET_STATE (&st_magn_trig_set_state) #else /* CONFIG_IIO_BUFFER */ -static inline int st_magn_probe_trigger(struct iio_dev *indio_dev, int irq) -{ - return 0; -} -static inline void st_magn_remove_trigger(struct iio_dev *indio_dev, int irq) -{ - return; -} static inline int st_magn_allocate_ring(struct iio_dev *indio_dev) { return 0; } -static inline void st_magn_deallocate_ring(struct iio_dev *indio_dev) -{ -} #define ST_MAGN_TRIGGER_SET_STATE NULL #endif /* CONFIG_IIO_BUFFER */ diff --git a/drivers/iio/magnetometer/st_magn_buffer.c b/drivers/iio/magnetometer/st_magn_buffer.c index 68f01714304f..cb43ccda808d 100644 --- a/drivers/iio/magnetometer/st_magn_buffer.c +++ b/drivers/iio/magnetometer/st_magn_buffer.c @@ -41,13 +41,8 @@ static const struct iio_buffer_setup_ops st_magn_buffer_setup_ops = { int st_magn_allocate_ring(struct iio_dev *indio_dev) { - return iio_triggered_buffer_setup(indio_dev, NULL, - &st_sensors_trigger_handler, &st_magn_buffer_setup_ops); -} - -void st_magn_deallocate_ring(struct iio_dev *indio_dev) -{ - iio_triggered_buffer_cleanup(indio_dev); + return devm_iio_triggered_buffer_setup(indio_dev->dev.parent, indio_dev, + NULL, &st_sensors_trigger_handler, &st_magn_buffer_setup_ops); } MODULE_AUTHOR("Denis Ciocca "); diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index 2c44a92590fc..9ffd50d796bf 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -647,7 +647,7 @@ int st_magn_common_probe(struct iio_dev *indio_dev) err = st_sensors_allocate_trigger(indio_dev, ST_MAGN_TRIGGER_OPS); if (err < 0) - goto st_magn_probe_trigger_error; + return err; } err = iio_device_register(indio_dev); @@ -662,8 +662,6 @@ int st_magn_common_probe(struct iio_dev *indio_dev) st_magn_device_register_error: if (mdata->irq > 0) st_sensors_deallocate_trigger(indio_dev); -st_magn_probe_trigger_error: - st_magn_deallocate_ring(indio_dev); return err; } EXPORT_SYMBOL(st_magn_common_probe); @@ -675,8 +673,6 @@ void st_magn_common_remove(struct iio_dev *indio_dev) iio_device_unregister(indio_dev); if (mdata->irq > 0) st_sensors_deallocate_trigger(indio_dev); - - st_magn_deallocate_ring(indio_dev); } EXPORT_SYMBOL(st_magn_common_remove); From patchwork Tue Jul 20 07:46:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 12387661 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5E74C07E9B for ; Tue, 20 Jul 2021 07:47:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B0A676100C for ; Tue, 20 Jul 2021 07:47:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229527AbhGTHGl (ORCPT ); Tue, 20 Jul 2021 03:06:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229887AbhGTHGY (ORCPT ); Tue, 20 Jul 2021 03:06:24 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E292FC0613DC for ; Tue, 20 Jul 2021 00:47:01 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id t3so27290166edc.7 for ; Tue, 20 Jul 2021 00:47:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=deviqon.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yws7s4TXHWQe2pKmn33RrpTgITzoOEmoytMF72afsZA=; b=iA11nX9aO55Ub5rAjlydHf16P+FeqYzwVKEDAuGGA7+AIj4Cx86fbhFwd44ItAZx3o ppQv6xbyPdtE1wwiDsTWI3nKs3A43twiYuzErrhS7O5GFrRP+qyX+d0gSChBrJKA2kpI JUt13Z4U4jIGhPfop/9RxmHzPnyasyXX4nDdV76uyIZHXsM5JaJkyeIFjBRJS1qn+hsi mY3yhYgCatuJLm+VSNuYvx3mcUE796FOFJljyhlXcFdaHERCefVklw/0zVcFjn4dtQrL X50PMD72lIwFyqvtb0Fjd7irYTgP84j7HKGU188uOzmBaFAfbNadzdnqj7+S+L7ea3Si gUPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yws7s4TXHWQe2pKmn33RrpTgITzoOEmoytMF72afsZA=; b=RxX5yoh8mTwanUb4lZfd5d9NoX85/vPZXdOni0kBTMvvKS+Fa9k2Dk3gGwF6L0pPBD f635nVkVXCETxuGP8zwf/FgrAa8XCBJK+DtJ2wr3THC8am8ZbtICtNGkLTO6eF3j+eEE F0DiYLrjhGkUTzYhpkYKRzKgbmbdKjB4n8Wly8Yhwpdmw8Wxmmpb6M7bayBmEGfGC01g tHckEwkkWos9SnMb6gmXk70DEZP5fu3ChAXlw/Gyg8EZ6+mkhLglYvviP8w4tLgrWU5M PBv7I0t35kqveXG8Et9gbfLWP+ItsXVurZKr+dutjpY4Z9ajnTE6GWfir/46NMTH/s// h14Q== X-Gm-Message-State: AOAM530V7ui83tbZMedl5JfrrWREonacP0SFPclWHHNBihuS5+K+hFEE fGUP5J3TyX5KXAJZuLzkYEcJXQ+B5zob+h1loms= X-Google-Smtp-Source: ABdhPJwr+3oKQ9L+qo0jwHjaqZ3HD1KElQ5R2NnqVAyyw96iK0WZ6Ubs+sq2EHVMFAhrph6zcC+P0w== X-Received: by 2002:a05:6402:29a:: with SMTP id l26mr39209861edv.207.1626767220356; Tue, 20 Jul 2021 00:47:00 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id b22sm7530940edj.24.2021.07.20.00.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 00:47:00 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: denis.ciocca@st.com, jic23@kernel.org, Alexandru Ardelean Subject: [PATCH 4/4] iio: gyro: st_gyro: use devm_iio_triggered_buffer_setup() for buffer Date: Tue, 20 Jul 2021 10:46:42 +0300 Message-Id: <20210720074642.223293-4-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210720074642.223293-1-aardelean@deviqon.com> References: <20210720074642.223293-1-aardelean@deviqon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The st_gyro_allocate_ring() function calls iio_triggered_buffer_setup() to allocate a triggered buffer. But the same can be done with devm_iio_triggered_buffer_setup() and then the st_gyro_common_remove() no longer needs to manually deallocate it. We know that the parent of the IIO device is used to manage other instances of the devm unwind, so it can be used in the st_gyro_allocate_ring() as well. Signed-off-by: Alexandru Ardelean --- drivers/iio/gyro/st_gyro.h | 4 ---- drivers/iio/gyro/st_gyro_buffer.c | 9 ++------- drivers/iio/gyro/st_gyro_core.c | 6 +----- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/iio/gyro/st_gyro.h b/drivers/iio/gyro/st_gyro.h index 6537f5cb8320..f5332b6a02bc 100644 --- a/drivers/iio/gyro/st_gyro.h +++ b/drivers/iio/gyro/st_gyro.h @@ -26,7 +26,6 @@ #ifdef CONFIG_IIO_BUFFER int st_gyro_allocate_ring(struct iio_dev *indio_dev); -void st_gyro_deallocate_ring(struct iio_dev *indio_dev); int st_gyro_trig_set_state(struct iio_trigger *trig, bool state); #define ST_GYRO_TRIGGER_SET_STATE (&st_gyro_trig_set_state) #else /* CONFIG_IIO_BUFFER */ @@ -34,9 +33,6 @@ static inline int st_gyro_allocate_ring(struct iio_dev *indio_dev) { return 0; } -static inline void st_gyro_deallocate_ring(struct iio_dev *indio_dev) -{ -} #define ST_GYRO_TRIGGER_SET_STATE NULL #endif /* CONFIG_IIO_BUFFER */ diff --git a/drivers/iio/gyro/st_gyro_buffer.c b/drivers/iio/gyro/st_gyro_buffer.c index 02b5562b6585..4ae33ef25b9c 100644 --- a/drivers/iio/gyro/st_gyro_buffer.c +++ b/drivers/iio/gyro/st_gyro_buffer.c @@ -61,13 +61,8 @@ static const struct iio_buffer_setup_ops st_gyro_buffer_setup_ops = { int st_gyro_allocate_ring(struct iio_dev *indio_dev) { - return iio_triggered_buffer_setup(indio_dev, NULL, - &st_sensors_trigger_handler, &st_gyro_buffer_setup_ops); -} - -void st_gyro_deallocate_ring(struct iio_dev *indio_dev) -{ - iio_triggered_buffer_cleanup(indio_dev); + return devm_iio_triggered_buffer_setup(indio_dev->dev.parent, indio_dev, + NULL, &st_sensors_trigger_handler, &st_gyro_buffer_setup_ops); } MODULE_AUTHOR("Denis Ciocca "); diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c index fe227ad400f0..e8fc8af65143 100644 --- a/drivers/iio/gyro/st_gyro_core.c +++ b/drivers/iio/gyro/st_gyro_core.c @@ -512,7 +512,7 @@ int st_gyro_common_probe(struct iio_dev *indio_dev) err = st_sensors_allocate_trigger(indio_dev, ST_GYRO_TRIGGER_OPS); if (err < 0) - goto st_gyro_probe_trigger_error; + return err; } err = iio_device_register(indio_dev); @@ -527,8 +527,6 @@ int st_gyro_common_probe(struct iio_dev *indio_dev) st_gyro_device_register_error: if (gdata->irq > 0) st_sensors_deallocate_trigger(indio_dev); -st_gyro_probe_trigger_error: - st_gyro_deallocate_ring(indio_dev); return err; } EXPORT_SYMBOL(st_gyro_common_probe); @@ -540,8 +538,6 @@ void st_gyro_common_remove(struct iio_dev *indio_dev) iio_device_unregister(indio_dev); if (gdata->irq > 0) st_sensors_deallocate_trigger(indio_dev); - - st_gyro_deallocate_ring(indio_dev); } EXPORT_SYMBOL(st_gyro_common_remove);