From patchwork Sat Dec 28 01:14:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 13922200 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2081.outbound.protection.outlook.com [40.107.241.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1983C35956; Sat, 28 Dec 2024 01:15:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735348548; cv=fail; b=Q+B6q0F3sPxuWUGna5yA8UGcz8JILMHePJ17aAj8gma8WuZH1HQixRie58wiGR7jrvx/cbFV/tHArjdHmpCcdUa+sYFvdfoBPO7cqiKFoxsHb5CYqfzYOS6VRoIRRBPpMxXhjdejA73XSvTAq4njo2Q7pzlhq2NvIlGeer8YoeY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735348548; c=relaxed/simple; bh=yGvaO4CE8KR0YjpwnelDEdIH1YkR2FTo1uOdpptvhd8=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=g6+Ea6s4UiRoH/ehMhV6cubgcXQCh+oL0zOuTGobSiPaedv2zaKw0RenL/9HgbBfwCjz7rRb2BQUAs++7I96VKHVjW90wkQ/bQGu0HUMz8CUbk4oiRwnJmajPkOkqB91Kr8aqrwss8VUbft3BJlOcBBxwIQTGy5rWCWJMLA6LnE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=cA98UbwE; arc=fail smtp.client-ip=40.107.241.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="cA98UbwE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=w/G8BdliSEHx0Q3RhzvHHb4gZDm7nd8U9oyXzHd55Bb4fFKPUAXiMIEYSbuoOtbEdxG0JouEjRZwG3JSzXWYa2OV8J7Gk7+ZQEc5QSYGTDhlk/iMuumAOLuZKALhA0NY7/vvhvFG9E6J3RvOK4CuJX3ub30pcS5j/pJ+/Y64//MDlyaIPcQBdnYWvKbUKXgnYTanlVTNlau9EHKhC7TeeMe22obWcNCu3BzioLHeUiM/sp/w63EIU2byRUTDWY+fJKY/LlUU+wApDaFlHP+nNCJEog4poH3eW2luSbXdaP6qc6Vugkx1/OxtRQRh7JKKZ0RH0vyoKxBye26eqhkfZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MhC1ngrU87eDqzUYVlj3esO6y93gVDOOhc8DDXGyy0w=; b=hk8K3Ny6SJcd0oB5CBOmWwUHHYSFPOGMqZiLcSj4I6HIJ+mcVCcEqb2DNKWFrSxsg7MMPlW61S33HVlo8RrKXGhCO9GwYVzE0A8XaLTvuQ+m8ZqiGaIGQ/yauGtSQnN/DAMwxLNLBBbINirOoVBiTvHRX76wXszoypYB9oXLr8Qoe+IkInF7d++7eIU+FWvjTGqnCZ/PlMwd9/Ictqn30TqOvEahUoVBpz+fE2FRcN6Xiyfb/LbtdEagShvRYexD4Fz290E6bv++FkNSGfaA5yzw6nBOxYf8o2junUS+Zuv1dzaDMA3UGJvOzUekw6rxYmqWFeYH+AM4tNyv9GqWjg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MhC1ngrU87eDqzUYVlj3esO6y93gVDOOhc8DDXGyy0w=; b=cA98UbwEXYy8AaaZCydgYBXUee5xD9rfXQc112Cwt1t46qevMbnGdlyXYxRiyqTMQbRks6yg33cY6oRN6OZESXv4Z+UGTxs66IztXA5iJyQcha86e84XoulwQtFDFqX9GKkq/7PtytAXgXZrhq64S9OFDvN/pYkiXy/+UFZxRnn4iYFMtV30o/1nqulxuWT+7Qeh1jm11T5WQEkaAAEbCtpmWu5IoJ2LQ5YtVblKRfhUc2WZVeYf+1uHerV0p6xCz1jqP1kcSNKhMaQfuHAdumfibwaUDVvTFp91/OEDHehZVmG52FqQ2QrVjS3KMz11Yio0UUsa/IYPVgyu5Isx5w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by AM0PR04MB7140.eurprd04.prod.outlook.com (2603:10a6:208:192::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8293.15; Sat, 28 Dec 2024 01:15:39 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%5]) with mapi id 15.20.8293.000; Sat, 28 Dec 2024 01:15:39 +0000 From: "Peng Fan (OSS)" Date: Sat, 28 Dec 2024 09:14:41 +0800 Subject: [PATCH 05/12] input: touchscreen: ti_am335x_tsc: Use resource managed API to simplify code Message-Id: <20241228-wake_irq-v1-5-09cfca77cd47@nxp.com> References: <20241228-wake_irq-v1-0-09cfca77cd47@nxp.com> In-Reply-To: <20241228-wake_irq-v1-0-09cfca77cd47@nxp.com> To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , Greg Kroah-Hartman , Dmitry Torokhov , Alexandre Belloni , Maxime Coquelin , Alexandre Torgue , Linus Walleij , Conor Dooley , Daire McNamara Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-rtc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-riscv@lists.infradead.org, Peng Fan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1735348488; l=3411; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=1lZmp/EoQtZDgK9cRNpEHi0IbcGjqZ+/tYP3nl5MGB4=; b=UXvCXFxS0bdNfnP4i9+l23yI6Hpv7q0/4Axzg63Hm6BI7CWYSX2VuRHQZESo9FnGhA2gXLlZK 2S8tSKbe6vRDK3wAMDYcuopjwFCx/eXV4VwLcGndSqEbmeNg5AVJ4EE X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR02CA0099.apcprd02.prod.outlook.com (2603:1096:4:92::15) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|AM0PR04MB7140:EE_ X-MS-Office365-Filtering-Correlation-Id: 441ceda9-a42a-4473-1f83-08dd26dd2404 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|376014|7416014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?AhWqgqw6V9Eav8190tHYAhqJVIqTL4j?= =?utf-8?q?hDTM57787ezjXyGczVqghQmlDpL8mjbS9/m7IkaOKHrex5I3p1n+eYWeH+WWegBQ8?= =?utf-8?q?9auDOwSFNNk8e9sOmwDV8zskTfz5cCxTXkXS74FNDz3AFjer+KiQESN99ltl1VE38?= =?utf-8?q?o3JYAbPLVFyGNHhjqBZMjKxP0yndZMABofmH83XFs3Kbk4Gf05qlpIWehQYDntEYx?= =?utf-8?q?1c0l9M9XVQIlHyzuMEdqDzt7wucp3Hrk4ok7PGVcTZQnXs4r33zk9ovGnWKYaG7Ok?= =?utf-8?q?hhY3ZTW6gLkEGm4OmVgIO/byxvIQgolSkEayyuvG9gVLrYGzV2eOIG6i+hD7vg8RT?= =?utf-8?q?vFELznpLgYBAJ6ob1Nw0QDmY3KVD0BB7gZ6AvZR6mgtbiPuR18JrNBMT/UCiaPYWI?= =?utf-8?q?N2ZPcpMq41MItcQF5HciwB3baX9FpJc57gB2x5BcC2zblvkWhXsqnIXb3q2SA+lP/?= =?utf-8?q?r0BpeDRLEYIlatkSud4iJ32dLB4PU2z2PFqcV/4VRo9PsWGnxLc6tumDWleER3GSg?= =?utf-8?q?Wa8WXhjYc5Cw4qGFqi37RdY0feAIU3keUasNYl8Bd6hiN3C5WqUKJQM9OcJ4wxphW?= =?utf-8?q?BhvzQjfyPrQ5blkwh18ZflGQ8OtlbqaCsXlqm3Ov+2/PSoV7iR2IOKL0l/C1ODdMY?= =?utf-8?q?RNg7Cv27zfGdu1lyumKNDMW++Pu4WWkOXr6bEkeWeHpagw/TaR4AD3JILOe29EW7Y?= =?utf-8?q?TR6shKotG/QaaI3DFAR2Scmq4WfUsN7fLzNq1YzS0KJGkz/KuDqicSFJnOWWeE3Q0?= =?utf-8?q?VbiwMfs3CH9uBQCHHjs1GMcP5B/eFgupa83G2qg6GdFNpdZcEdLvb3bdyLnux17M6?= =?utf-8?q?E4avWmq30pHMprrlQA8+ui3I3CUvNHTVqlI/TMTWjG9zO7qa17ro7871PPcv01Xw9?= =?utf-8?q?WRX/izrW4eSA+MjJHhZysW39if6o7sBfxHgXnv9wLJt2xfY1SSm1z4gmVshnaFB2A?= =?utf-8?q?VKa/1EnnjC7hl4E3ByVLa+pd++H8nTXqbrAzwlhqNUD7/RLnDn4z1FSoYbWOiNB1y?= =?utf-8?q?w/I7Yyx06dNSS0cA+fY0jGCUJpYdsi0K79jYcu8Npv/DdT6Do8IYBcUrh8SIXG13Y?= =?utf-8?q?nC5ByYFsqXITJ7Hr+P9lCBUMBptdvHWnyMVRdCWQ7IzHbL1BkXiQim3pY8x5hx0+8?= =?utf-8?q?ogBQasIbWzQTNndaMsECxJnQcBdSdvm9dDQXQeaq46tDXI3RNZ6H3Ec4FBWP9Se5w?= =?utf-8?q?ao50TejQbhdRuiMsfifPvUD/Moo9hjyN6I0keZRXsUTX5JcodJjvu7vODQavlN2Qi?= =?utf-8?q?ezmRKCAd13seZ6cTRKGI13b/STbf1NeghwszsrHhspNi3ipc8zcW/ZYQwn6RfL2IX?= =?utf-8?q?MX2dBat/PVdYLQ/am3d68R5mu9in6G7WVGhMadcmvOYbdgqR8xNKBCa8L0SfCSx9f?= =?utf-8?q?dkSfhqlO4opvwYcUn3sXtd7qY8j5js8vQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(376014)(7416014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?HRsZKkjQGP615dCpf+vC1NHtBnCy?= =?utf-8?q?WsItLrxlJOJSoDtog0t4AZcsAKJfaw+RuB+BmC28RgHR7emOshiAaT051OpuIonw3?= =?utf-8?q?e35T6x+HcLtxRa7KYT5x9bES73e8Wl2AvDdfUyfj9isRBN4cXmfw+//3fknyNBC1H?= =?utf-8?q?wikbI56F78YJ93HyPsvCwlFdwH80q4pmGz6BCkV/hb5W4q77d3e9tDafFwagSbE8n?= =?utf-8?q?ql7aqmjrKvyOR71IyZzhlg62SsV3dmMqyLW8yWy/zQ5lrCMe8Zz4/2Vi347as///d?= =?utf-8?q?8alFXbxfaWz6lYCSjG8mEBhSyDbnNazJCEiP/YBFVwwtUhXGRNIuslyGe1ImfwI75?= =?utf-8?q?DJCaCp8gj/CX0ytySPOr5JpjUNJhRF6Da56k3RWU3VKsnDt4r/jJq4q+nZCqvIMs3?= =?utf-8?q?oQYI3ZQl5NtCdASrVT615Ja2CIyXur0aEaA00noUzuHr/6kbgj4FP9vjSRPJw+dud?= =?utf-8?q?kQI3BxH2uMGxks1xeE3nj1F/qGu0/Gnpph/uhpw22lDzYLzcS1sLrPL4/bFoQwQ7A?= =?utf-8?q?viIZwDTCw5swGKgTq/X/F788Lgdl8H3vogMaPT09VmUgUyZx/Xw4DyWZ2h6LfrCD5?= =?utf-8?q?EtnRjgYNoIE8CU5bMivYlX2vtEsLg/mqUP/Z3wQeRTuK7GwlkpkQU/6WLxkQUldI6?= =?utf-8?q?9PL2Yt9VRA7ivr5ObD9pzg1UK1KPI36MA9E4eD8BIL7lvGa95rbT7UIQ7iHm3mrv1?= =?utf-8?q?fBR65Yhvt/9I7hKf7xtGZII1T6fsWVc3CggTV1Tvbnf6P0xP9nsedFWMng+cT5Laj?= =?utf-8?q?9KyitRYppet7LUg6Zp9rqvsPj3njlsZULq87YUg61nv/NcQsFulBpqKyses2QBXtb?= =?utf-8?q?FMdRVVZrUDV6hKBazab4JVUm92rcahi0xg5Mfj728CGm2toigb3krNrh5Wj9SGPc7?= =?utf-8?q?KRF/SNB9vBmBSADlIBFx8UCYrY/0nQBJLfn+kU62XZHRxZrLok3m35F4+REROZyt2?= =?utf-8?q?LfUCrTYIQciL5W27AAq3cIgmr2xIWN1W3aO4+JVGcv/JkGulMMVbfbmBTND9O6a6S?= =?utf-8?q?GTMqvWF+Sfz9vd+XHLclF515Wl5ThRRwyHY1P3aW+zYCvSmdV1Ka4bfP2h2f2pivQ?= =?utf-8?q?RN7ge/sIOJYP55uaXL2YId3grycaeQieq9/knHlt2fGjBfla3HXxNlCv28nseuI/B?= =?utf-8?q?7WYqKYetWM6FINUVCweLxE0cXLRxGoXUmtCj1Eut3z8io0sL67i4hrhY7ZouxeLV6?= =?utf-8?q?FlXJdH/uMuesKcBoWSbbv0NkMhzYuXqT36/j7d0w9RJweuQU17tYo20e82WiCkaAw?= =?utf-8?q?6ZN9dYgdnb6owtaSpmQIjiJ44OLTAg11R22sz48wzKcygUrkSc9nxf+tGgyWMFHMb?= =?utf-8?q?6S3OZs8BSTVELFyH7p1Xz+KS8hycR+yWyk6p1YJb7xZK8EFzrbgUgf77bNh8JZwdB?= =?utf-8?q?Z0+OZm8qPccyP9Dqy4jTiP/KXIyiLJNWnogPkLTXALZny+t8qDOHcUfp/8+3ZeAHO?= =?utf-8?q?Trfy0rdL4Dzc+N8RQb30q0pJKC/6LzLt5YgPgDE4sFaSt3FzMmv3IMMs8AVNBPtcm?= =?utf-8?q?wXquFGUJw9HN?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 441ceda9-a42a-4473-1f83-08dd26dd2404 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2024 01:15:39.1267 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PyPBH4LLq7gK/75BIZcgsVFHklg6gECQ4xtlci2JbjNFipDttoEZuJ9Z+RuUABf1SdXC2y/91QcgaaSnArz1Ug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7140 From: Peng Fan Use devm_input_allocate_device/devm_kzalloc/devm_request_irq to simplify code Signed-off-by: Peng Fan --- drivers/input/touchscreen/ti_am335x_tsc.c | 43 ++++++++++--------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index 93d659ff90aa94ecbd7000fe05e0eef8ab3546ba..aef38b2e4e464e3b76395de5991a0f41b4f852f4 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c @@ -418,12 +418,11 @@ static int titsc_probe(struct platform_device *pdev) int err; /* Allocate memory for device */ - ts_dev = kzalloc(sizeof(*ts_dev), GFP_KERNEL); - input_dev = input_allocate_device(); + ts_dev = devm_kzalloc(&pdev->dev, sizeof(*ts_dev), GFP_KERNEL); + input_dev = devm_input_allocate_device(&pdev->dev); if (!ts_dev || !input_dev) { dev_err(&pdev->dev, "failed to allocate memory.\n"); - err = -ENOMEM; - goto err_free_mem; + return -ENOMEM; } tscadc_dev->tsc = ts_dev; @@ -435,18 +434,21 @@ static int titsc_probe(struct platform_device *pdev) err = titsc_parse_dt(pdev, ts_dev); if (err) { dev_err(&pdev->dev, "Could not find valid DT data.\n"); - goto err_free_mem; + return err; } - err = request_irq(ts_dev->irq, titsc_irq, - IRQF_SHARED, pdev->dev.driver->name, ts_dev); + err = devm_request_irq(&pdev->dev, ts_dev->irq, titsc_irq, IRQF_SHARED, + pdev->dev.driver->name, ts_dev); if (err) { dev_err(&pdev->dev, "failed to allocate irq.\n"); - goto err_free_mem; + return err; } - device_init_wakeup(&pdev->dev, true); - err = dev_pm_set_wake_irq(&pdev->dev, ts_dev->irq); + err = devm_device_init_wakeup(&pdev->dev); + if (err) + dev_err(&pdev->dev, "device init wakeup failed.\n"); + + err = devm_pm_set_wake_irq(&pdev->dev, ts_dev->irq); if (err) dev_err(&pdev->dev, "irq wake enable failed.\n"); @@ -456,7 +458,7 @@ static int titsc_probe(struct platform_device *pdev) err = titsc_config_wires(ts_dev); if (err) { dev_err(&pdev->dev, "wrong i/p wire configuration\n"); - goto err_free_irq; + return err; } titsc_step_config(ts_dev); titsc_writel(ts_dev, REG_FIFO0THR, @@ -475,19 +477,10 @@ static int titsc_probe(struct platform_device *pdev) /* register to the input system */ err = input_register_device(input_dev); if (err) - goto err_free_irq; + return err; platform_set_drvdata(pdev, ts_dev); return 0; - -err_free_irq: - dev_pm_clear_wake_irq(&pdev->dev); - device_init_wakeup(&pdev->dev, false); - free_irq(ts_dev->irq, ts_dev); -err_free_mem: - input_free_device(input_dev); - kfree(ts_dev); - return err; } static void titsc_remove(struct platform_device *pdev) @@ -495,18 +488,10 @@ static void titsc_remove(struct platform_device *pdev) struct titsc *ts_dev = platform_get_drvdata(pdev); u32 steps; - dev_pm_clear_wake_irq(&pdev->dev); - device_init_wakeup(&pdev->dev, false); - free_irq(ts_dev->irq, ts_dev); - /* total steps followed by the enable mask */ steps = 2 * ts_dev->coordinate_readouts + 2; steps = (1 << steps) - 1; am335x_tsc_se_clr(ts_dev->mfd_tscadc, steps); - - input_unregister_device(ts_dev->input); - - kfree(ts_dev); } static int titsc_suspend(struct device *dev)