From patchwork Fri Jan 3 08:41:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 854982 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012064.outbound.protection.outlook.com [52.101.66.64]) (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 68D891D517B; Fri, 3 Jan 2025 08:42:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735893753; cv=fail; b=PHN0XOAClWZ3bYX6kw/Oupc6DcCqfIiZfppwBEYyhLan7zq0GRwUac3De5f7l1Pbkk3lqIs4Wi3wySnd4inZaSKqHVBfvKn232sCbey9qqlZfeY5u3suZ2RzeMJ57+7Tobhn/beXnSyLg2dyvVfeVuEYZOZy43xsN6/D4GnHm1s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735893753; c=relaxed/simple; bh=yGvaO4CE8KR0YjpwnelDEdIH1YkR2FTo1uOdpptvhd8=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=N/YLCrXoLCC72PxrBP8p1BZ7//UH3hpMcZ5mUdAFbXX/K4LuIV8RbUAh0DqDk1PECv4GdnkiOVGgJVB4/zgRTEHOWxTuYTSresJRCwpPdmnHUXhlSd5Lvhd9/ziCyWCz2VoEWZBI4XWCkzXVBwy5pifPghgllEPYb3TdGohJFpI= 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=UzqqZG2w; arc=fail smtp.client-ip=52.101.66.64 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="UzqqZG2w" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UTjwbQU3kUsgvzGcCD3VBqY2J7+BYx7ckbBrgQCKX+8MCj4X1a9RY8hOfmcN6omDNc9dx7rkF6rW2WmFfHM17xCxijcq3wFIgaOP134Jw0iSq6AczjgMveuzdPVKhf/71t19EDZyZ0DkElxwZVKlNy0/6mnk6lqZoX1ZemSBS+awWHDm91jFYlzRTFR2Krru2dWN59MvKP9FCjN9ySWBwoBPhgdE3Ti0sPm/WmQLmDw8aUfbF4IOvUkuXX9/4Ubu9bXQkPfvKZaasHMOkCPlFWsUo7sbj0s3o6dfy3bSAyANcjKbbV65rAIcklpHxH33NeQDb1317If6DAVfMMv85w== 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=PI5ZGczYPQLrL1jP2Od5JiZSEG4FLCVBKFOubqTgMlA1agtGr2CVKGLY9KyvNKi52XuxpJgG4QgLzErtuxvUZaAzWJE9twsYiOB5f8e33OPVbCRbvl71DRiZaPJ5uGQ+P53+upzoqL2oKDhZ/j+7PInt11xgVAh15NUprJH1aUzl7L3wWrE+RscKj9NMtWwZyoYUO2kGUNRUS5lyLE2m5ddM+hUBmwy+n5D9ITlnzgcxcw4TBspE0pvck2e/kfd0FXj4bGjK0PwBPXjQPKSwQoP0j4kl8Zf6WCQeFrrNSFuxnT5b2XgA/m2sTdBEeU2f7hrwfiPrpUWefQ1elDz0JA== 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=UzqqZG2wt7u3GOyLoPgZRvDb0RQGwAtCgwI1vmNZKRVjTpo07sVTFJns9v27st1R4idAwSHngrXtsOL9vq82o2EP5W0/YJHFEhVRib4EJrPLYim81mGqel+8asUavjxbSg48gJC+z/KqbKudGA/JvroHDHLYfXT9njob8Gj/rU5L9Mwnlg+nIfwfUe2EJh/2hwm/tRM3Onpq50VydBl7g6oKGgGgXO+q3Z8E5W34sIh4hTnQ5VODrj4xaRD4DgtMLO4yXmQUJzH1L1gznzVHXd/cxEz76fRbEfDEwGPHMB7QH3txBc3GftkX2byH6R/2ovO+igebHQO4pFZUytQCCw== 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 GV1PR04MB9101.eurprd04.prod.outlook.com (2603:10a6:150:20::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.14; Fri, 3 Jan 2025 08:42:23 +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.8314.013; Fri, 3 Jan 2025 08:42:23 +0000 From: "Peng Fan (OSS)" Date: Fri, 03 Jan 2025 16:41:17 +0800 Subject: [PATCH v2 05/12] input: touchscreen: ti_am335x_tsc: Use resource managed API to simplify code Message-Id: <20250103-wake_irq-v2-5-e3aeff5e9966@nxp.com> References: <20250103-wake_irq-v2-0-e3aeff5e9966@nxp.com> In-Reply-To: <20250103-wake_irq-v2-0-e3aeff5e9966@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=1735893689; l=3411; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=1lZmp/EoQtZDgK9cRNpEHi0IbcGjqZ+/tYP3nl5MGB4=; b=d+ynM2f+87jzy29uH2AmtGEhWDRO9UQf3P+P0Uubu3afIPgRsDzhnXyS3RMl2g4FSX1MqPgcH dHCQMbcmHz7ChbsmlULhgPAwEhZEjpD+rfpLGpCbGI27Ef2eX0u0yKJ X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR02CA0003.apcprd02.prod.outlook.com (2603:1096:4:194::13) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: linux-pm@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_|GV1PR04MB9101:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e97a831-88b6-49cf-1515-08dd2bd28b28 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|376014|7416014|52116014|366016|1800799024|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?utAUYH7aHERo85/NJvMafx9YBouQUuH?= =?utf-8?q?PL+xGqaDUx4fOsWD4ysejYogZ0sWn4Kc34rUd60V9vtXauWY+Sjn4QtOvzc0wzB65?= =?utf-8?q?LyDlpUXz2Prs/i3XJkrgJU4jvf7LHBI1AjwmPZfG0IFJtD39MOcWP1pN2pHsoe2Gp?= =?utf-8?q?0g0vsrdDfF9fqc3shv04FH+jhCr5p2lAm4baYBUHu9zBVcBcF8smaTaJ4of2F8a/I?= =?utf-8?q?L5YchhJYq34LPOJTDV5hjDTKvg34nB7l2dssbezu1enJVwHGTMz7Q22o6KENdQBN2?= =?utf-8?q?XE96lSrhgonIcvS2OvJfEquwtzcJ9ndlAMj25oR/NWShduvFqcoWmZIJDhE3sxXJZ?= =?utf-8?q?CrppFKsXaYeI0Qx5u+GWa4/iPyj4EWbojTYhG4D3wNwa84B3XqCewhAbLhezexD78?= =?utf-8?q?RJU04WlTvPkZ7pMTFapEf2cSmAFEtPZQB67byi4CkzMAaSeJWqmPNJC0KnVxjDpdn?= =?utf-8?q?sMeDn7S/wkW12uBoaA+ZgmquugF/obBt8F+Xvuvnf26HQeyAHwVhCBcNxTrGbmlmj?= =?utf-8?q?t7xKCYYjrELHTJVhemySPCUWRPeGnrDMvNzENjdCd+9ItjjD217T7rL2iyihFdF6t?= =?utf-8?q?V/4vAY4WcJbSvYXsAESLYE8zLCWkNtmsQXn8wHwjf6dmlfsR1z77PRjhLm/Vjm9QP?= =?utf-8?q?kR2giNg2u59AQZzZE7dx5110ZE0ALFifEJmBFCisUuNBPtM1NNVedWjNMp8GRrEt3?= =?utf-8?q?Pf3fg1RwLWN3xER6z8Zq0PkmnfZk8H3VtNHIr42nW05lRBPeKvRbtFBiBZah9AupL?= =?utf-8?q?mS2OryShwkQ1xwOY+oaBtzkvtBo7Kh55mgJWPekXQP8UtGjpQSAF4gSzRz0SQTcXY?= =?utf-8?q?bXJqp1zTZDYMkjOSSMo95OQiWlVFcI8n7U2jtsBr3zHGXJkNonQXNLCqJYyk4vwd2?= =?utf-8?q?BB7XyJUGgSE/wvoFe7RG4q15mvywtHQq+TAo7dwrHeMbg57gfJtPPpNA84h31bMsV?= =?utf-8?q?RI0bSH1+VcLd55ZJDsWVMB1qgBMnbQPtxSSrDvEqQTq8gJvn5IRcmO3zJh61HNZem?= =?utf-8?q?aNRrsQmp0l8gAixtW1AAtc+1l1W422YJZOLaa0iLYl1Rc7I6epqMYdzRU/PM6E7I1?= =?utf-8?q?I5iWp1ptEInb5oPc7ZvOtgy+0GkkiZG5k606BKZxJrYeq0WmPDMUPB/s6tCw0TsJZ?= =?utf-8?q?rhy+bMOy57W0xLzigyw2xyJJhAvrmfrKVXPE1hS4gDCQa3KqwRxOPDIrjJyYqa1eO?= =?utf-8?q?2FYYEz2Rmxe5+36bS0x7PSxEDzP6JQgb4Onx+VqUHjUpqa1qQ7RegygjFwIHH3I9/?= =?utf-8?q?ZISLgXC2Oxu2RmzAw91dQfeh+gajcWFdTcYTFEz+cn8dC89136VFMHsexzTxa5+ww?= =?utf-8?q?eOBE91eD4uIg4Fh+gUsWa7wRw4KDhg4JlEzzCfWyU5ck0xy0fLuZL1ulGtaFElCyY?= =?utf-8?q?eN89hFSYTfb0TTSSD60zerqdjvOLS5dXw=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)(376014)(7416014)(52116014)(366016)(1800799024)(921020)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?SQgbRUwe+R9iszkwJFgpsffp/vvc?= =?utf-8?q?vMk+BV/HMbQ10W9UCZv6gO8nF271oH0c6+0nCCaaRgTK7tqHr0yy5qpZfG3S3Bfcw?= =?utf-8?q?ECibnwfbGOBEnv1T6oVwdo9Z/zWMkGa8x15PCv2q6gzyPV3LC2n2y1WrA0hFcw1ZH?= =?utf-8?q?BQljJHl5jWYBr3pQMZfIi9VDA3Exo3dl3wwy0kFWPy6YX+3lAduorKBYAFrapscmD?= =?utf-8?q?f7ZxPTexur40zXFhqC6xNgmUJblihKLCl226CGGSu8b2w+oUuR1Hq1FPN7OUFe8V9?= =?utf-8?q?sTzB/+v5ZD5Uh3EQM95B44YC9pOWdkyC6QNpB/rSUVZyN+s7U4K7703dDn4o0zW8O?= =?utf-8?q?R15pqjReY0dJX6VH+q80BEQgcoKlksryd64COAVwzVk8I6BB9c4Vmv8s7Pe4KfNmt?= =?utf-8?q?xU8G/IodXKVoaO2pT1pUd0mU83c+cX6aJWP4Eec7KxhrplY2Bw34+jDx/g2+D1mSQ?= =?utf-8?q?T1xNTYeGt+FvdJ2pcV1aOYm4uVSw49eD4BzlErKcaXJmLdvoAF9GeSqtSg7Yjinwv?= =?utf-8?q?T4GRLpoLvW40NygxpaJMwGuf09+bhS92oo6t2RPXO0jIl7sZ/LQ8GFjwqW22wQrol?= =?utf-8?q?WuwfM2KlJLp/xRQnQJBwpsRapcmV28dm86OuMxXE+hzYrvczxFVw3IMlci6vFfBFT?= =?utf-8?q?b2sYYPsREOVxmkTXy1v/zUfMX0CHI+RiPjE8yjHFgoPJrobvzUlfXPLLH6BUW2vpW?= =?utf-8?q?1bAEqiYBO/6+HhF9V3RuYLyt7VC7w6XIee1GRS6UUogZj5ILLcZ1RzGcrua2RTzLb?= =?utf-8?q?eaD7nDUBvL+6gUyTi1DAdTC6v/uChWbK4L5n3auCgu8K5ELCiNqdvLMbmBmfYIPtd?= =?utf-8?q?wWHxVvguFO8vTPmkrVZdJ10JGvCcQQMZsoiqSHWoktuUxpm9UV+7uuWknPgboStMt?= =?utf-8?q?+vWBgVuBqKvFpvYtQ4a2/7ZMssgozAU0L7q/sDMvlUpYm35NuT7k5k6PxN0kYGhgU?= =?utf-8?q?g7Vt06NZSPINDSDZQ9P7jVLZb12p3EP7xMQQEBVqJUIboba0yx9HIEEaXoPHSpxbQ?= =?utf-8?q?4TDS/Ho2WCk2ADgmYnLQErFsDZWH8IGlju6u4/LTVBexYvM7laNYdvRUEKCRl/7B/?= =?utf-8?q?QPXDpvxrldm6r9ypxyfpBoozmm1yMlK9xv5FfHpHgUHlKQRg9yisknwrbk7Il4RZs?= =?utf-8?q?TYRiNSlhq1qsQ41mNzQqqjtdcS9EJBhxZLG3vBKmay6Vz7JjMslzyYidj6rVBrOi8?= =?utf-8?q?tCFDbXFNAd1McZzO+/jsujMm8z0R6jmo91G+S7bvdnjZRwPBjFecMl9C7sfGg5TiH?= =?utf-8?q?7FcWcgDasWr++h2GkfFqkRVHpxfctJ2rOdQZVhwaaKdcU4UQzp3FFmeLkDWPBjoVb?= =?utf-8?q?23J18ihodqtUALBIEvI3iHnfUyoHDuCWSxO17aptgtRaagu1bzCfemTmFB/UPL1D6?= =?utf-8?q?nX3+z262vfyzieFcy/tNR5534WA71Ze2FtTU7zLvRDt37UOYAb+iQ2UXax9jdR0sK?= =?utf-8?q?nbv1juB/jrX/PFYYGbmZ2un/hs9B4uF1Gr7hcI3On8Id1Sp5WVEgFesh6f/bd0vOv?= =?utf-8?q?y640lF2SRgqu?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e97a831-88b6-49cf-1515-08dd2bd28b28 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 08:42:23.6458 (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: y76hL7eWCAXZ4d7JTo9bVzePVFX0j2fzFAQMsLIZQ5JQTBOPaaIewcvUe031gS25x5U7dcSyP+9f+TbdD/EjpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9101 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)