From patchwork Fri Sep 3 07:29:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 12473749 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.7 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 2EBC3C4332F for ; Fri, 3 Sep 2021 07:29:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 19B8F610A2 for ; Fri, 3 Sep 2021 07:29:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347886AbhICHad (ORCPT ); Fri, 3 Sep 2021 03:30:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347912AbhICHad (ORCPT ); Fri, 3 Sep 2021 03:30:33 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69485C061764 for ; Fri, 3 Sep 2021 00:29:33 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id x11so10250208ejv.0 for ; Fri, 03 Sep 2021 00:29:33 -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=1KqigQ4tM0RySsTWyqhUi7bGFJ0gw2Fo1Hm3w8y7jnw=; b=om/xEpEuKYXGQyOY6bh+O6zF7CuLM+3MKZihofXqytwOnwmphD1JvjR5/J/m1zOHrE yjZcEctUsB9we9f7DCNv77dRZ4LwtssMyWPHeZYMQ0FVelyz0Fk3oFaceyPKFggW7VqM VfcPHup5vSCnfX+ZCAWD/s8O1dIrN0TPAVlUrPxF78/yNdY60AhYpyPweOcunu9BAk8e QSqnZ6FHvq7ecXvdBhZb0aHxUfr8DuXRPAU47h9bSzAudUvkOq+DrZ3qz6vCr/yMmHZj hPpYPlfsV5c2w9hrlWbDtr6/hNqh5GIH9FU+ALtydJ5nTtHnk1EOSY6LR7PddBX8x5Fs okpQ== 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=1KqigQ4tM0RySsTWyqhUi7bGFJ0gw2Fo1Hm3w8y7jnw=; b=Y4RD/XS3I/b1CTpwt0cm0ppzavzJ369Ll9oefj4lLFX4Iw+VOZaR5D6GSspgxX9AiH AUPc6vqhg0FHzP3djpuCUmoaxnf3hPu9YOj4WoWXF7RYPc2rP/UaXXZob8S5rl7hsKAA 61qs3amESCBE/gSO73XI7V4NPZC0/r/XeZPBF+gt0Ef+vk/LvMi7taDMlzpduEKOrFpo 0cae54QmJLHqIxStdDt8p9Sm0d789GTdtQHmUHs27qTS74f1VE01J+xyEcFSPgzLVGZm /F+iqqY34YNm20/V+QskBCFU9csnWKQ+xVIQ7a8zF1yDBfOEcAbU1mMHDZV6qc3akwY2 8lfg== X-Gm-Message-State: AOAM531F+8oOWxpztFic7t3Sh8CW5wXmkQuCtSV0V+oot41wNEqt7Dsk yXXEAMSJUpfUq1HvpIORz0DnMQoYYhrvhA== X-Google-Smtp-Source: ABdhPJwSO0CCkCGhRw1a/tkwxzP1RsvMkca/s6M4h3BZwT+ztnjoZFxeMrwNb5pmAezMWK2dGz0wUw== X-Received: by 2002:a17:906:30d6:: with SMTP id b22mr2728381ejb.442.1630654171717; Fri, 03 Sep 2021 00:29:31 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id a15sm2376969edr.2.2021.09.03.00.29.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 00:29:31 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: jic23@kernel.org, hdegoede@redhat.com, wens@csie.org, andriy.shevchenko@linux.intel.com, Alexandru Ardelean Subject: [PATCH 1/5] iio: inkern: introduce devm_iio_map_array_register() short-hand function Date: Fri, 3 Sep 2021 10:29:13 +0300 Message-Id: <20210903072917.45769-2-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210903072917.45769-1-aardelean@deviqon.com> References: <20210903072917.45769-1-aardelean@deviqon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This change introduces a device-managed variant to the iio_map_array_register() function. It's a simple implementation of calling iio_map_array_register() and registering a callback to iio_map_array_unregister() with the devm_add_action_or_reset(). The function uses an explicit 'dev' parameter to bind the unwinding to. It could have been implemented to implicitly use the parent of the IIO device, however it shouldn't be too expensive to callers to just specify to which device object to bind this unwind call. It would make the API a bit more flexible. Signed-off-by: Alexandru Ardelean --- .../driver-api/driver-model/devres.rst | 1 + drivers/iio/inkern.c | 17 +++++++++++++++++ include/linux/iio/driver.h | 14 ++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentation/driver-api/driver-model/devres.rst index 650096523f4f..148e19381b79 100644 --- a/Documentation/driver-api/driver-model/devres.rst +++ b/Documentation/driver-api/driver-model/devres.rst @@ -287,6 +287,7 @@ IIO devm_iio_device_register() devm_iio_dmaengine_buffer_setup() devm_iio_kfifo_buffer_setup() + devm_iio_map_array_register() devm_iio_triggered_buffer_setup() devm_iio_trigger_alloc() devm_iio_trigger_register() diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 391a3380a1d1..0222885b334c 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -85,6 +85,23 @@ int iio_map_array_unregister(struct iio_dev *indio_dev) } EXPORT_SYMBOL_GPL(iio_map_array_unregister); +static void iio_map_array_unregister_cb(void *indio_dev) +{ + iio_map_array_unregister(indio_dev); +} + +int devm_iio_map_array_register(struct device *dev, struct iio_dev *indio_dev, struct iio_map *maps) +{ + int ret; + + ret = iio_map_array_register(indio_dev, maps); + if (ret) + return ret; + + return devm_add_action_or_reset(dev, iio_map_array_unregister_cb, indio_dev); +} +EXPORT_SYMBOL_GPL(devm_iio_map_array_register); + static const struct iio_chan_spec *iio_chan_spec_from_name(const struct iio_dev *indio_dev, const char *name) { diff --git a/include/linux/iio/driver.h b/include/linux/iio/driver.h index 36de60a5da7a..7a157ed218f6 100644 --- a/include/linux/iio/driver.h +++ b/include/linux/iio/driver.h @@ -8,6 +8,7 @@ #ifndef _IIO_INKERN_H_ #define _IIO_INKERN_H_ +struct device; struct iio_dev; struct iio_map; @@ -26,4 +27,17 @@ int iio_map_array_register(struct iio_dev *indio_dev, */ int iio_map_array_unregister(struct iio_dev *indio_dev); +/** + * devm_iio_map_array_register - device-managed version of iio_map_array_register + * @dev: Device object to which to bind the unwinding of this registration + * @indio_dev: Pointer to the iio_dev structure + * @maps: Pointer to an IIO map object which is to be registered to this IIO device + * + * This function will call iio_map_array_register() to register an IIO map object + * and will also hook a callback to the iio_map_array_unregister() function to + * handle de-registration of the IIO map object when the device's refcount goes to + * zero. + */ +int devm_iio_map_array_register(struct device *dev, struct iio_dev *indio_dev, struct iio_map *maps); + #endif From patchwork Fri Sep 3 07:29:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 12473751 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.7 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=unavailable 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 9D93FC433EF for ; Fri, 3 Sep 2021 07:29:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FCD8610A2 for ; Fri, 3 Sep 2021 07:29:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347970AbhICHae (ORCPT ); Fri, 3 Sep 2021 03:30:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347932AbhICHad (ORCPT ); Fri, 3 Sep 2021 03:30:33 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FB12C061760 for ; Fri, 3 Sep 2021 00:29:34 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id bt14so10192376ejb.3 for ; Fri, 03 Sep 2021 00:29:34 -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=DLNVH8XFndwKpvPMj1mgpvvZHBUNyj5D1E9ht5yoDp4=; b=io0DFqQyxa4evyztTcJaGZnx5fg5ZlUTzYhTS6zCTPK4GavCEQh+Z2CuBf+d7dgZrn BLqzaRUgDWMuTiTIT+oljXws+f01Av0fdFw7GVonAcgLVHKsZhw/LafdHbMPAEo3lmmM wJYf3ALSJoWUqvyke95ycPxVTk9702nd6SN/Qmv8uurhkOG3eczMO6Ozr1qUXvPr7Znq 1dv1vlxeeSJgxjWXPlLN9471pU5md8+vbY9hk0nWqhV4zFRsxrta345cYGM3LJvdwGW/ xcRVN/5LPPlcTNTJogYsqQy7NNYcDkFlDJ6wAAg2LL+qmdv/un8wCFk5/sVy7gmUPzhH JL6w== 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=DLNVH8XFndwKpvPMj1mgpvvZHBUNyj5D1E9ht5yoDp4=; b=VU3q+MHfPK7fGOkNHT/pA4+reu0z+HXupacwxShCXuxQKiRQVoafdlMacylGVh50Wq 6ajYdIB262qjTBqyMT2pVF16uj2QEYD2+i+sdDBRtxZtKllgmCBAsPezjJq/LbylU9p+ eQYP3hEw5N/Ar8Z4yMk/htDtcpFIJLoL9RstrugyrOdv4q1sF1a4+uLnKe2I+yn8GW0y XwAJ9bDehLrmOewoAgjgl831h5o74F2M773s+wPWTJckQmbzCjIhCe7p3vtic9A5pwr6 x+MmVSKJniI5LJX2yrn74D1m7xIiFcPQqsCpcDLtRbrTIFsQbnNyspITBvoHhViRhOW5 gjUA== X-Gm-Message-State: AOAM530DwTg7EfRBEWAxej9wg75ZkfByNjV/PvqTAQoosUzXG5Dp/aOO 8kujxtg1w1kjJ53xvQlZKeZcL3WyY6FWSA== X-Google-Smtp-Source: ABdhPJxU58geUUDCfKwGaRmVcaG5WRWgIIaUROXzfl0bXPWrS2w+cP3ixgYEgi8wJPk8YTAH7A3LqQ== X-Received: by 2002:a17:906:660f:: with SMTP id b15mr2568809ejp.491.1630654172607; Fri, 03 Sep 2021 00:29:32 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id a15sm2376969edr.2.2021.09.03.00.29.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 00:29:32 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: jic23@kernel.org, hdegoede@redhat.com, wens@csie.org, andriy.shevchenko@linux.intel.com, Alexandru Ardelean Subject: [PATCH 2/5] iio: adc: intel_mrfld_adc: convert probe to full device-managed Date: Fri, 3 Sep 2021 10:29:14 +0300 Message-Id: <20210903072917.45769-3-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210903072917.45769-1-aardelean@deviqon.com> References: <20210903072917.45769-1-aardelean@deviqon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The only call in the remove hook is the iio_map_array_unregister() call. Since we have a devm_iio_map_array_register() function now, we can use that and remove the remove hook entirely. The IIO device was registered with the devm_iio_device_register() prior to this change. Also, the platform_set_drvdata() can be removed now, since it was used only in the remove hook. Signed-off-by: Alexandru Ardelean Reviewed-by: Andy Shevchenko --- drivers/iio/adc/intel_mrfld_adc.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/drivers/iio/adc/intel_mrfld_adc.c b/drivers/iio/adc/intel_mrfld_adc.c index 75394350eb4c..616de0c3a049 100644 --- a/drivers/iio/adc/intel_mrfld_adc.c +++ b/drivers/iio/adc/intel_mrfld_adc.c @@ -205,8 +205,6 @@ static int mrfld_adc_probe(struct platform_device *pdev) if (ret) return ret; - platform_set_drvdata(pdev, indio_dev); - indio_dev->name = pdev->name; indio_dev->channels = mrfld_adc_channels; @@ -214,28 +212,11 @@ static int mrfld_adc_probe(struct platform_device *pdev) indio_dev->info = &mrfld_adc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_map_array_register(indio_dev, iio_maps); + ret = devm_iio_map_array_register(dev, indio_dev, iio_maps); if (ret) return ret; - ret = devm_iio_device_register(dev, indio_dev); - if (ret < 0) - goto err_array_unregister; - - return 0; - -err_array_unregister: - iio_map_array_unregister(indio_dev); - return ret; -} - -static int mrfld_adc_remove(struct platform_device *pdev) -{ - struct iio_dev *indio_dev = platform_get_drvdata(pdev); - - iio_map_array_unregister(indio_dev); - - return 0; + return devm_iio_device_register(dev, indio_dev); } static const struct platform_device_id mrfld_adc_id_table[] = { @@ -249,7 +230,6 @@ static struct platform_driver mrfld_adc_driver = { .name = "mrfld_bcove_adc", }, .probe = mrfld_adc_probe, - .remove = mrfld_adc_remove, .id_table = mrfld_adc_id_table, }; module_platform_driver(mrfld_adc_driver); From patchwork Fri Sep 3 07:29:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 12473753 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.7 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 07DAFC433F5 for ; Fri, 3 Sep 2021 07:29:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFC67610CC for ; Fri, 3 Sep 2021 07:29:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348003AbhICHah (ORCPT ); Fri, 3 Sep 2021 03:30:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347974AbhICHaf (ORCPT ); Fri, 3 Sep 2021 03:30:35 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3251DC061760 for ; Fri, 3 Sep 2021 00:29:35 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id h9so10191403ejs.4 for ; Fri, 03 Sep 2021 00:29:35 -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=HnKxxaQYNnWTD9UVNnr24MR8zjRJb29eptl0bMy8Qq4=; b=Qcz0qeTuAYOCren9Bte0rJrya/cpxtrK46NHFyqZw0Mlz1MB0RvC//GSaMk1pNJsge u1l1AxWZiJhMBK3JzofjfGSEYBUpXsUTMBf7NUbECF+itGa3CujJQbKacFN0ry9qY5sb uD0p6ZLx1KxONRQOhQCaMz4UJdNRNYFC7TLCEznC3HyfY1/arEYDJd+NiTAWJUrknYiV CPd+1Bm/vFwa4fA2rAD53RKml9MaerqrAEZcJj98yco2ot1fxHdEqhXaqZB3eT+HMsks kERZJGTZlreijmnTbeJsYTlUP9q9ayz1Y5ORKOI0wVDAFuuQ9zPqA3T3pzQC3Vrt0PV1 HqpA== 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=HnKxxaQYNnWTD9UVNnr24MR8zjRJb29eptl0bMy8Qq4=; b=jxd6g1EstdHVtaJ4PLzRHA8fxglQaCqcoLUSujeRxAlezdgqSCjJHUAAzl0f+brSZG XV3CR39qrVF2pW0dNXN4LrBQ6yawEdWrrn0kaKT0Pzzm1J05ldlshSiaubB2DfiF6aea 1Uxa9+qN9vx2cKMyNiZ0188Xi0xHjHdzagQDQPGUmSPl9X/YT5tLdAErBCmgvXvGZDi3 WN56WRfzkLNvZe/WtglPinmVTJ4/JcLFisJK5oWc2emP35Gp91rE2JSE95qK8Jj2N/uD RtQ6/XjzZQVlqG+YaH4g7O/VVDZar8Hlk4yFO1w1zjhph9c+t9v01AyI5F1JFU5GiqM4 DfXg== X-Gm-Message-State: AOAM532Yx8XNGmxKykWSiVxqSfh4U7gdXZihQbMijLmYjj7JEWq9MSJ+ vd5KCa35BOdEWNDcmE048whSoB7xF0uLzA== X-Google-Smtp-Source: ABdhPJwFO572GXMyC8Iym92Njj9JtaNsYe0AZpZmJobeLhP6IQXc2R3B8cIlE08zeVVXsXVevPaQ5g== X-Received: by 2002:a17:906:d20a:: with SMTP id w10mr2724357ejz.426.1630654173566; Fri, 03 Sep 2021 00:29:33 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id a15sm2376969edr.2.2021.09.03.00.29.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 00:29:33 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: jic23@kernel.org, hdegoede@redhat.com, wens@csie.org, andriy.shevchenko@linux.intel.com, Alexandru Ardelean Subject: [PATCH 3/5] iio: adc: axp288_adc: convert probe to full device-managed Date: Fri, 3 Sep 2021 10:29:15 +0300 Message-Id: <20210903072917.45769-4-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210903072917.45769-1-aardelean@deviqon.com> References: <20210903072917.45769-1-aardelean@deviqon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This change converts the probe of this driver to use device-managed functions only, which means that the remove hook can be removed. The remove hook has only 2 calls to iio_device_unregister() and iio_map_array_unregister(). Both these can now be done via devm register functions, now that there's also a devm_iio_map_array_register() function. The platform_set_drvdata() can also be removed now. This change also removes the error print for when the iio_device_register() call fails. This isn't required now. Signed-off-by: Alexandru Ardelean Reviewed-by: Hans de Goede --- drivers/iio/adc/axp288_adc.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c index 5f5e8b39e4d2..a4b8be5b8f88 100644 --- a/drivers/iio/adc/axp288_adc.c +++ b/drivers/iio/adc/axp288_adc.c @@ -259,7 +259,7 @@ static int axp288_adc_probe(struct platform_device *pdev) info->irq = platform_get_irq(pdev, 0); if (info->irq < 0) return info->irq; - platform_set_drvdata(pdev, indio_dev); + info->regmap = axp20x->regmap; /* * Set ADC to enabled state at all time, including system suspend. @@ -276,31 +276,12 @@ static int axp288_adc_probe(struct platform_device *pdev) indio_dev->num_channels = ARRAY_SIZE(axp288_adc_channels); indio_dev->info = &axp288_adc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_map_array_register(indio_dev, axp288_adc_default_maps); + + ret = devm_iio_map_array_register(&pdev->dev, indio_dev, axp288_adc_default_maps); if (ret < 0) return ret; - ret = iio_device_register(indio_dev); - if (ret < 0) { - dev_err(&pdev->dev, "unable to register iio device\n"); - goto err_array_unregister; - } - return 0; - -err_array_unregister: - iio_map_array_unregister(indio_dev); - - return ret; -} - -static int axp288_adc_remove(struct platform_device *pdev) -{ - struct iio_dev *indio_dev = platform_get_drvdata(pdev); - - iio_device_unregister(indio_dev); - iio_map_array_unregister(indio_dev); - - return 0; + return devm_iio_device_register(&pdev->dev, indio_dev); } static const struct platform_device_id axp288_adc_id_table[] = { @@ -310,7 +291,6 @@ static const struct platform_device_id axp288_adc_id_table[] = { static struct platform_driver axp288_adc_driver = { .probe = axp288_adc_probe, - .remove = axp288_adc_remove, .id_table = axp288_adc_id_table, .driver = { .name = "axp288_adc", From patchwork Fri Sep 3 07:29:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 12473757 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.7 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=unavailable 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 0333AC433F5 for ; Fri, 3 Sep 2021 07:29:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF9C3610FA for ; Fri, 3 Sep 2021 07:29:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347978AbhICHak (ORCPT ); Fri, 3 Sep 2021 03:30:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347983AbhICHag (ORCPT ); Fri, 3 Sep 2021 03:30:36 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23A34C0613CF for ; Fri, 3 Sep 2021 00:29:36 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id u14so10126602ejf.13 for ; Fri, 03 Sep 2021 00:29:36 -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=W/2bGRX6h2ShjY2Ue+ETXCUOUj7+vt7FE17ZT3HOV+8=; b=Lvrc4VxY92tToYNa/OcJfuMJMmDvqrpBTZJCKToRaG7VWGR68hJ1446jXykOL/5w18 C4wN0v7li4i53cC69kh0QRxfqj15o199V7ddMOOLKu+IZ8uFk5z8CvRJ2P5eO8cLmSeY 2Yxsrfrckc0tc68ZUAPcHrX0f0QVoaol8AS+1WDLvElOCt8i+nH3Wf0csvAR22q5Ry+0 w+a3ZORE1SaFwtVvNarPg6ZDUC+VWW//l/G/b9g++QxWeeVZtMUA38pieCIFXE6S1T1N /3pthPe1rQ8Ivd4tWLkuzK9fcaq5x25kFHyf1UzSe/qv6/WLhc+Pev75Rz/FWXq54C5l biNw== 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=W/2bGRX6h2ShjY2Ue+ETXCUOUj7+vt7FE17ZT3HOV+8=; b=jP8oOsBLz1OjCuJYUpqPJxQrFq5ds1KYOgvJ0hxBpMsrB0gi0IRY03kCXLS3dqlIPs KAege/35uVW21GFFxP6owGniMyMUruG0GK3DLI1awb8F+TqZoctFBieAq6Hg2DFtDxvW LDnEj4tTrvlCwK80cXNLr/FpYvIu8vkFH9W6J0qa82pt+fNebn4lVh2d4UyIiXCUW0H/ 3rVpIqTyc8fBSdf5GIi+RJl1MBLUpAqvcM4QS1xRcO/xueaWDW2rQAG+gcL/VEvasMlI fkSe4Md+Dr7tfwVA/J31lkObNwYXZPWUn/sQfd6IzJJW9QOh8fhCyZRueKqExSIUF8wO kwow== X-Gm-Message-State: AOAM533xVltTcwpuockwNcyuqUrqEwIrUoZ4Gs6OPbxtJMBxyNbY7GLX Z7yMi9TgGglOwZW0LL44LhaB77MWPHq4ww== X-Google-Smtp-Source: ABdhPJxg0pseOGWd1vWo2NudsDVj5BE/f7evKJG5rPT7E2j7RfWRsClIqJXNCaLzXo2utpB+Pm5rIA== X-Received: by 2002:a17:906:f2d8:: with SMTP id gz24mr2648681ejb.343.1630654174478; Fri, 03 Sep 2021 00:29:34 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id a15sm2376969edr.2.2021.09.03.00.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 00:29:34 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: jic23@kernel.org, hdegoede@redhat.com, wens@csie.org, andriy.shevchenko@linux.intel.com, Alexandru Ardelean Subject: [PATCH 4/5] iio: adc: lp8788_adc: convert probe to full-device managed Date: Fri, 3 Sep 2021 10:29:16 +0300 Message-Id: <20210903072917.45769-5-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210903072917.45769-1-aardelean@deviqon.com> References: <20210903072917.45769-1-aardelean@deviqon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This change converts the probe of this driver to use device-managed functions only, which means that the remove hook can be removed. The remove hook has only 2 calls to iio_device_unregister() and iio_map_array_unregister(). Both these can now be done via devm register functions, now that there's also a devm_iio_map_array_register() function. The platform_set_drvdata() can also be removed now. This change also removes the error print for when the iio_device_register() call fails. This isn't required now. Signed-off-by: Alexandru Ardelean --- drivers/iio/adc/lp8788_adc.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/drivers/iio/adc/lp8788_adc.c b/drivers/iio/adc/lp8788_adc.c index 8fb57e375529..6d9b354bc705 100644 --- a/drivers/iio/adc/lp8788_adc.c +++ b/drivers/iio/adc/lp8788_adc.c @@ -163,7 +163,8 @@ static struct iio_map lp8788_default_iio_maps[] = { { } }; -static int lp8788_iio_map_register(struct iio_dev *indio_dev, +static int lp8788_iio_map_register(struct device *dev, + struct iio_dev *indio_dev, struct lp8788_platform_data *pdata, struct lp8788_adc *adc) { @@ -173,7 +174,7 @@ static int lp8788_iio_map_register(struct iio_dev *indio_dev, map = (!pdata || !pdata->adc_pdata) ? lp8788_default_iio_maps : pdata->adc_pdata; - ret = iio_map_array_register(indio_dev, map); + ret = devm_iio_map_array_register(dev, indio_dev, map); if (ret) { dev_err(&indio_dev->dev, "iio map err: %d\n", ret); return ret; @@ -196,9 +197,8 @@ static int lp8788_adc_probe(struct platform_device *pdev) adc = iio_priv(indio_dev); adc->lp = lp; - platform_set_drvdata(pdev, indio_dev); - ret = lp8788_iio_map_register(indio_dev, lp->pdata, adc); + ret = lp8788_iio_map_register(&pdev->dev, indio_dev, lp->pdata, adc); if (ret) return ret; @@ -210,32 +210,11 @@ static int lp8788_adc_probe(struct platform_device *pdev) indio_dev->channels = lp8788_adc_channels; indio_dev->num_channels = ARRAY_SIZE(lp8788_adc_channels); - ret = iio_device_register(indio_dev); - if (ret) { - dev_err(&pdev->dev, "iio dev register err: %d\n", ret); - goto err_iio_device; - } - - return 0; - -err_iio_device: - iio_map_array_unregister(indio_dev); - return ret; -} - -static int lp8788_adc_remove(struct platform_device *pdev) -{ - struct iio_dev *indio_dev = platform_get_drvdata(pdev); - - iio_device_unregister(indio_dev); - iio_map_array_unregister(indio_dev); - - return 0; + return devm_iio_device_register(&pdev->dev, indio_dev); } static struct platform_driver lp8788_adc_driver = { .probe = lp8788_adc_probe, - .remove = lp8788_adc_remove, .driver = { .name = LP8788_DEV_ADC, }, From patchwork Fri Sep 3 07:29:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 12473755 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.7 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=unavailable 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 50BA0C43217 for ; Fri, 3 Sep 2021 07:29:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A9DA610A2 for ; Fri, 3 Sep 2021 07:29:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347983AbhICHak (ORCPT ); Fri, 3 Sep 2021 03:30:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347993AbhICHag (ORCPT ); Fri, 3 Sep 2021 03:30:36 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 159DAC06179A for ; Fri, 3 Sep 2021 00:29:37 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id ia27so10143706ejc.10 for ; Fri, 03 Sep 2021 00:29:37 -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=sRN51ITeio36BmKOZHKuYdDeMC2KiPiz4hRTJqGRHxs=; b=oZ1/GD10pNbTMqZtG5+WSMrYwZ4exKqLG39SvVuQCVfzu8qWE2S18uVjXyusAQkrof Z4XCWsLG/I+BdV2gqMTh2eWNpIqSr2OPBk/XLhWtoIAO0Fx/TMRoEs2jOyOFo3cyK3qV 79btbZKWwFRXJcwo09LcFKO8xguxT5iMjJSYqd5XG++7OhQj4AnU+45LDzM3bMxnGqSc j9/SdEzP/FXCIZSE0AHDe0LJtafs0ezwaUr68OwkwbJyC7yC3ssvfNpPGYTj8LjGwdzl M6cwWwztzQVs2+4Z+/P/fHcTaVffnFBvAze7f5qCf5lOc+IuQdyRkJQp4Q7pe3EUwq4J Tzog== 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=sRN51ITeio36BmKOZHKuYdDeMC2KiPiz4hRTJqGRHxs=; b=SA6560TjmMvBBPYx2HxgqSQZefaIrzKdixG9lik6lkpJ+RyTHnYqfE0uGLWG/e6B4P 1Zl5Ikc+qM8fjPDC7Wf9gynWTUOOZlUwBpM2JsarALTcByYnZ3RjWkreIhiUQ0aOwlpl uclAKe+aAZpmV/L3wrwuB77WiSBcvmJnLg98cITJNTEYvedZ2NUeJrQjxR0YxUTTwEiI v+wU/IpwN1ycJ5TsWdiyZoL55Rh60ssfBrM1VBS5bks4frVyiJ1cBVXRRJxpEptdihYf AthL/VnT/cYbalzbEXkEkExzXJhrfpWH6RxR58tJsLkd6MT4/e7sJcB6nN9jyo2MTxiZ SvJQ== X-Gm-Message-State: AOAM531U3iboYzVNLxGS7QBoeY7lcxhrk8nQC4hTnS8FhdBBD5xQdnCa mKtjsEgJDDhuZ5x1NJZuU2re499ne3lWVw== X-Google-Smtp-Source: ABdhPJwbhypXgxq1/5TethM8Z4YGTujtW6LmbFATe/BLTvGE9aRV0BhnY8h/3yWGG2cENQ4zQ+0wGQ== X-Received: by 2002:a17:906:d045:: with SMTP id bo5mr2648333ejb.461.1630654175433; Fri, 03 Sep 2021 00:29:35 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id a15sm2376969edr.2.2021.09.03.00.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 00:29:35 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: jic23@kernel.org, hdegoede@redhat.com, wens@csie.org, andriy.shevchenko@linux.intel.com, Alexandru Ardelean Subject: [PATCH 5/5] iio: adc: da9150-gpadc: convert probe to full-device managed Date: Fri, 3 Sep 2021 10:29:17 +0300 Message-Id: <20210903072917.45769-6-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210903072917.45769-1-aardelean@deviqon.com> References: <20210903072917.45769-1-aardelean@deviqon.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This change converts the probe of this driver to use device-managed functions only, which means that the remove hook can be removed. The remove hook has only 2 calls to iio_device_unregister() and iio_map_array_unregister(). Both these can now be done via devm register functions, now that there's also a devm_iio_map_array_register() function. The platform_set_drvdata() can also be removed now. This change also removes the error print for when the iio_device_register() call fails. This isn't required now. Signed-off-by: Alexandru Ardelean --- drivers/iio/adc/da9150-gpadc.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/drivers/iio/adc/da9150-gpadc.c b/drivers/iio/adc/da9150-gpadc.c index 7a7a54a7ed76..8f0d3fb63b67 100644 --- a/drivers/iio/adc/da9150-gpadc.c +++ b/drivers/iio/adc/da9150-gpadc.c @@ -330,7 +330,6 @@ static int da9150_gpadc_probe(struct platform_device *pdev) } gpadc = iio_priv(indio_dev); - platform_set_drvdata(pdev, indio_dev); gpadc->da9150 = da9150; gpadc->dev = dev; mutex_init(&gpadc->lock); @@ -347,7 +346,7 @@ static int da9150_gpadc_probe(struct platform_device *pdev) return ret; } - ret = iio_map_array_register(indio_dev, da9150_gpadc_default_maps); + ret = devm_iio_map_array_register(&pdev->dev, indio_dev, da9150_gpadc_default_maps); if (ret) { dev_err(dev, "Failed to register IIO maps: %d\n", ret); return ret; @@ -359,28 +358,7 @@ static int da9150_gpadc_probe(struct platform_device *pdev) indio_dev->channels = da9150_gpadc_channels; indio_dev->num_channels = ARRAY_SIZE(da9150_gpadc_channels); - ret = iio_device_register(indio_dev); - if (ret) { - dev_err(dev, "Failed to register IIO device: %d\n", ret); - goto iio_map_unreg; - } - - return 0; - -iio_map_unreg: - iio_map_array_unregister(indio_dev); - - return ret; -} - -static int da9150_gpadc_remove(struct platform_device *pdev) -{ - struct iio_dev *indio_dev = platform_get_drvdata(pdev); - - iio_device_unregister(indio_dev); - iio_map_array_unregister(indio_dev); - - return 0; + return devm_iio_device_register(&pdev->dev, indio_dev); } static struct platform_driver da9150_gpadc_driver = { @@ -388,7 +366,6 @@ static struct platform_driver da9150_gpadc_driver = { .name = "da9150-gpadc", }, .probe = da9150_gpadc_probe, - .remove = da9150_gpadc_remove, }; module_platform_driver(da9150_gpadc_driver);