Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1394312ybh; Fri, 13 Mar 2020 00:06:42 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv5BJCWqoMaD0h89Ou6/otXbMESYsYnKkB8uNgbN1CTVb9+FEaUU+Wv7OA+H8efSXlOn/EZ X-Received: by 2002:aca:5155:: with SMTP id f82mr5920971oib.103.1584083202443; Fri, 13 Mar 2020 00:06:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584083202; cv=none; d=google.com; s=arc-20160816; b=OonundOT7X54Nf2py8xfAjVdYvFt6gZYkArfv/5Bwtdf1y8lQxXjsnopbZM7M7U+zM DSyrhd6j1nnI0owbrHanHReferpYHaxPEjLRg8fvkPgQNPD2Xng5Y7j7plQEVKqWjVdJ 9a3HFj9W6E4fuHpqkh7XnlABxeAEIiTjmqek4Zqlckd/JLicTpl0TVmHBCqycagRMcEI ZV41/fcbXBcp7BljzKMFtGSGhnOgfkc9x3wAOXNu6xicWf84g04BeLkA/8V0V3zu3BAU vXu/r7SJ2oetnKJura/6Z8pghOb1JOY3EWjnR47MvQgyl/MouALivrlPKEFFlNsMUOAf mkrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=LxdUK9uQxTjwVGnRnEWogRWYyZUJY2BVOyFHaNSrZFo=; b=bA1jgQ04CEIgQWELDTgbtL0KRg/xLPQRm76fkXPPkAsduwixlwbDJY8RdG8cyHgtD5 2ObpdPNHQ8LkT4eg30aS90MCLFXr1+RScBeqLEb5G8qcQh4+bDqJWx5FhU/1HbYamgEP WNw8oFfzQ/TC4m37FfZY4R+Dn0bYDJge4/gy3l3o8F60WLEWv5iVn6ZUncnSP4/5hzRx IALpXCNXHTLr1TTFmkc1IO9pjYoQTqDwlUBVX62kC6ylgTLpQYZs0WMciaSpDOaTHzYb fShIW9lVT9kFbaF/pSmDQRG8mdf5NnfkR7Nqtt6aROieo96ybtxHw15ERk6TuIutYgy+ 2YDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k28si1963302otb.94.2020.03.13.00.06.28; Fri, 13 Mar 2020 00:06:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726443AbgCMHFu (ORCPT + 99 others); Fri, 13 Mar 2020 03:05:50 -0400 Received: from inva020.nxp.com ([92.121.34.13]:36290 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbgCMHFu (ORCPT ); Fri, 13 Mar 2020 03:05:50 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 8A2ED1A1282; Fri, 13 Mar 2020 08:05:48 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 4B7461A132F; Fri, 13 Mar 2020 08:05:43 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 340FF40245; Fri, 13 Mar 2020 15:05:37 +0800 (SGT) From: Anson Huang To: dmitry.torokhov@gmail.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, robh@kernel.org, linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Linux-imx@nxp.com Subject: [PATCH] input: keyboard: imx_sc_key: Use devm_add_action_or_reset() to handle all cleanups Date: Fri, 13 Mar 2020 14:59:11 +0800 Message-Id: <1584082751-17047-1-git-send-email-Anson.Huang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use devm_add_action_or_reset() to handle all cleanups of failure in .probe and .remove, then .remove callback can be dropped. Signed-off-by: Anson Huang --- drivers/input/keyboard/imx_sc_key.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/input/keyboard/imx_sc_key.c b/drivers/input/keyboard/imx_sc_key.c index 2672fd4..eab5dfb 100644 --- a/drivers/input/keyboard/imx_sc_key.c +++ b/drivers/input/keyboard/imx_sc_key.c @@ -96,6 +96,15 @@ static void imx_sc_check_for_events(struct work_struct *work) msecs_to_jiffies(REPEAT_INTERVAL)); } +static void imx_sc_key_action(void *data) +{ + struct imx_key_drv_data *priv = data; + + imx_scu_irq_group_enable(SC_IRQ_GROUP_WAKE, SC_IRQ_BUTTON, false); + imx_scu_irq_unregister_notifier(&priv->key_notifier); + cancel_delayed_work_sync(&priv->check_work); +} + static int imx_sc_key_probe(struct platform_device *pdev) { struct imx_key_drv_data *priv; @@ -146,27 +155,16 @@ static int imx_sc_key_probe(struct platform_device *pdev) return error; } + error = devm_add_action_or_reset(&pdev->dev, imx_sc_key_action, &priv); + if (error) + return error; + priv->key_notifier.notifier_call = imx_sc_key_notify; error = imx_scu_irq_register_notifier(&priv->key_notifier); - if (error) { - imx_scu_irq_group_enable(SC_IRQ_GROUP_WAKE, SC_IRQ_BUTTON, - false); + if (error) dev_err(&pdev->dev, "failed to register scu notifier\n"); - return error; - } - - return 0; -} - -static int imx_sc_key_remove(struct platform_device *pdev) -{ - struct imx_key_drv_data *priv = platform_get_drvdata(pdev); - - imx_scu_irq_group_enable(SC_IRQ_GROUP_WAKE, SC_IRQ_BUTTON, false); - imx_scu_irq_unregister_notifier(&priv->key_notifier); - cancel_delayed_work_sync(&priv->check_work); - return 0; + return error; } static const struct of_device_id imx_sc_key_ids[] = { @@ -181,7 +179,6 @@ static struct platform_driver imx_sc_key_driver = { .of_match_table = imx_sc_key_ids, }, .probe = imx_sc_key_probe, - .remove = imx_sc_key_remove, }; module_platform_driver(imx_sc_key_driver); -- 2.7.4