From patchwork Fri Jul 14 08:06:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 703029 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F9B3EB64DC for ; Fri, 14 Jul 2023 08:09:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235153AbjGNIJO (ORCPT ); Fri, 14 Jul 2023 04:09:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234972AbjGNIIs (ORCPT ); Fri, 14 Jul 2023 04:08:48 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2114.outbound.protection.outlook.com [40.107.255.114]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77B4C46AF; Fri, 14 Jul 2023 01:06:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=efVKJi+Nu5fJldOztSAGHnWUAp8xvYcTy/Juni062gArjc87UUbm3sisQDbkqPmMwglCnZZ4G3hdMM7ERqFNx8aTkYbL6nAqESvVR5ROx8dFogi+4rN/m3PCh9jAlE7tstTwtVoKCOOYnGaamymL8uzcpZh6tB6zRKQt2saj/SHAqNZEIgRxt9m18oetYIZMF+KvQkFw6j+rqnOTvoCteLaw8O388jdgZWAH/GzAjP3zbyNSKf/EADciYN1Ck1hHauXvuk2yHdsCtj/L/qRGEJmxh2GqxtI/QmdUMaMcyZWyIfutNP6rkj8bRUb6q5Lj/HcNKqYhz9bFUO+22B/npg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=saEl64TDhrT6KRUSNF9mduU8aXv4PHc+GMBrNqfWFeI=; b=dg1UDD8T7UYb/FYjfdI5jJeBdSgA7UGka3I/7nbTXQT1H1p1sT+7/RykABlaOrwDNIpmg6HSerxjk7pW/bb/7seGEWxZShtgNc7HcEdRbLwJL8ph4kFwpg5gyBKhD55xKQhNNHG6xZxNHss8WpAJh6QVy6EGR3sYTsoQR4QNW7ubgp+DVChdYdhq04C8P6/8apysGHNApI9a/DD+GM+iC1hsnJZSxC6Dwn1UW+9b90MHGp5DOHWpDdgnxXDmIwbnMAkqGsoJTmBVQmyQCTRfB35iExJyXNqsZD+d7yWKZLjcXoFvC/heJmG4A5QTNP7HP7LQ7gGnVad4zqVBUjzvpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=saEl64TDhrT6KRUSNF9mduU8aXv4PHc+GMBrNqfWFeI=; b=dwidkKm62eWr9sEsp4PQ5/ZczBtjAp0lYv+zBkqzAoAK19bIbolIyP2hTcgH8eogsdWmnq7rWMdveZeYBDB2CatS2ToDl5Ghz4FPKcQMOsyqJd5YkAnXT4HfMQ8lEOujgBx6nRE8Ks0/FMOr8Fy/clz4+L5CHKbuVFSR6X98HJk9K5JBY/Fl4Evxo3gesstQepxJFx0HbMu2zecvJaU1T/T4x8KuVLXZ52m23SE/NopBAMvXTghp/3JICL3DiXvrGb07HqriJBcyQDavl0zo5AiOsea2M2BEpC97awpZE9myPcP4gZ2geVSt+kNe6bmCWuGXvdxqEq4cXuME19XSMQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by SI2PR06MB4059.apcprd06.prod.outlook.com (2603:1096:4:f4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.27; Fri, 14 Jul 2023 08:06:22 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c%5]) with mapi id 15.20.6565.028; Fri, 14 Jul 2023 08:06:21 +0000 From: Yangtao Li To: Dmitry Torokhov Cc: Yangtao Li , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/8] Input: lm8333 - convert to use devm_* api Date: Fri, 14 Jul 2023 16:06:04 +0800 Message-Id: <20230714080611.81302-1-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 X-ClientProxiedBy: TYCPR01CA0108.jpnprd01.prod.outlook.com (2603:1096:405:4::24) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SI2PR06MB4059:EE_ X-MS-Office365-Filtering-Correlation-Id: e11625d6-92fb-4c6d-c20d-08db844135a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1KhSX391UVjyX0sUCYAdsjbGyh9AaS+DPAxrd2M9PfRPbL8fcOx/f9ZK9H8/tdJvmuV0moWpkuYylO73qAMnsW4AQuEporfYMVpRok8N9jxlwjlRiJpIJzFZJWp7Edip81J6dW6PrW9oljLlT5O+QZLX8mBvJrnmAsY1VOqrncG4jGgZx6Kz9AxhcOkJY/ocewQX0WJ2PRucvbHDh71l3Thbhq815Mv2hMo75PLJxCRyZR7E8eD/qc9s344+jv9xhs1KUkCMCEAc0zrNR/Qux2EXE2tJBPJc9phKOKMRiuD1sVQnKK9yL42+nI71NUuwl5kyC5bQrePGZSOqVOE+87yg9mKhRz6vAsBov4exBPvSb0EuwrtPx/Zo49s9uNXcxXL7YoKMhlGHcM3lf5+iCFKmNjCDQFn4Rm7rsIZ3VbtC/5ma+WbBrM34jsm6RbJMpYoaqI0NHRmvGvQMbi+ce5PGBW3pvDQ+q5/4zyewRx3KyO33hEPJ1v8dIcmwx/gfovsqfnWv83EHhq0lGnpFj+Yx4qD4mlBj7x04rqg0e36Ldi+Kw+yy/9dgCI9KMX4VO/fuRnUXVFNswcM+vIVGORVRbT/EfiY8o+2LlgE2UDpJAWYkIT0y5qW/EvYtktia X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SEZPR06MB5269.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(376002)(136003)(346002)(366004)(396003)(39860400002)(451199021)(52116002)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(86362001)(2906002)(26005)(186003)(1076003)(6506007)(6512007)(316002)(38100700002)(38350700002)(66556008)(66476007)(6916009)(4326008)(66946007)(41300700001)(8936002)(8676002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NGWwlLni5BG6tXaM8EApStxUkOKxHvBN/E6iP38rv3FietmYuGqA+K0+jb98u145aHm2V/Ej2hZ41F8X/r2N3yGMkOVspP1D96UyjFvo51hSWojt2sDciwqeJFxU1foL+D1NJJwW3tV2vHt6zmF3H0iJTqychFSVm4C3JfIMqFFmfUp6pqwRJ2OjRKQ4BOaHczs6h5gsb8KHaWYJrztOdwjWxcD6e245UUplOw/r+GD3DnmlgYYtgguMYQFph5tJHGFuvPaeAC//kC1V1KYa91OVchh42wzUZ9JpcSzRLECcikgnkstRBRbaVSuINd8tGqKpLjOwpM0KZui3xN1WXDvMMdafPRYvFCNg9T5V+68HjCK3a5XT+GHxKJ5TwIgak4Q4fZvk+2J6WxYcdXuUI/dQaSglHX/VUWjJQyQI+GRRu81apJQS0q4H74EiWAT0qwpCgZDqjMy1/p1JYqlZNdZXOvlLNVDo1T5FaPvNnIo/E4WUKwde3pgBNSTWtXMZYn1PL+jOoL5wUlKbpxTNVjIC/9OKY2GCGCNPyAIwTq9lVOmX5NYvXpUHPzOCH6XcWeYisc2P3179hzDhkkz6BTqju5ApMI7UigXWyRrOf4DWFxuiwIslvcy0FD2FI8Q72W9BB9DkqxtGkYCKFDm3rk9E24ZxaCIP1eQ4fCCTnQofBuJATTgSs/aTKkqWMzMtzyeZTcnwzqFnMLlFY2g+hrBfs10UhM6w/CUpTEVx+gJNJq3Bk9DGcgrnSBoHbVY16+H8jKJlfABCYu4TJLBLu0UatA30+uuTrQ5q/QCySlai/5iEsd7dQTSt001KDqhacU7oQUWTgBL1Tx9/rEudfetZT4JOIwVPyFggbKQtw6iuBNwiAhqFg0mRQULLO4pL1pMfFHXgR78yRwjmv2eEPY8NvE6GIddMoHT3GmVIBlwITa6GI5gXNPrRaBGCUslXI8CGPUIRtPGOuzN4sLaSD0D53gsSprPIEVQ/Bh68UgIefCBt4A1Fu48gPICVE2BkH0qQThu//+eWMLr68oYc0G3RApMKQtb7f4eVFeL14MUTnRMky2U5mp7poUdNFV4GlG9pDyYTuj2KTeMqwiCU5Ri9tsi60xuvRNpLf2YAg8pS3wfdr7qgVAxoYB3LeHGjgRI5Tj9qzPwed72f3GD3KQ8QV0WyFtpRWvBwqfWwxgHCtghPg/JXhYOtOVkXPPVe8vOyZV8NOrUOh11F9EFsER/MacNYp4DGCglLQleCKKa/tK7hk1DN82qaQLVr7ZpupLTRYhL3g0TSbUf0IopKJoCfRZGYjL0n39F4Bzy2BwpgppWX+8Pa/TsOBHHtB0ntEQp2/6O+v//RxX+gBEHpSo5FHt2TYiOfukOOGMgE2LHUEX6roMdnS9oEtowY4+jyB2xxnL++Tjamio4LJCVE8sWYFQAqMSowuPOs36vRwALcurwcEuU5DVfTw/vS4YLBJ70MTecI7sZ/A4A+nuSxpwDox0eZbudVPs90iB3Y/W+BP7NMdEvkgzA3d9yh4U/eUysEk5YH8q0sQUH8/ox445/St2QdT+Dhr3wbbIfzVd4Ru5JnVcGvm5xH0QvEmpY9 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e11625d6-92fb-4c6d-c20d-08db844135a8 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 08:06:21.2895 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kVPwA9KjzH57b2YGxzPre9UwZX8sT9IRjyejjTD01qxVSlkDkgok8dkOGvpV952qYFy8xGKM6InOhqirQrrtmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR06MB4059 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use devm_* api to simplify code, this makes it unnecessary to explicitly release resources. Signed-off-by: Yangtao Li --- drivers/input/keyboard/lm8333.c | 40 +++++++++------------------------ 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/drivers/input/keyboard/lm8333.c b/drivers/input/keyboard/lm8333.c index c9f05764e36d..41d088933e01 100644 --- a/drivers/input/keyboard/lm8333.c +++ b/drivers/input/keyboard/lm8333.c @@ -129,6 +129,7 @@ static int lm8333_probe(struct i2c_client *client) { const struct lm8333_platform_data *pdata = dev_get_platdata(&client->dev); + struct device *dev = &client->dev; struct lm8333 *lm8333; struct input_dev *input; int err, active_time; @@ -142,12 +143,10 @@ static int lm8333_probe(struct i2c_client *client) return -EINVAL; } - lm8333 = kzalloc(sizeof(*lm8333), GFP_KERNEL); - input = input_allocate_device(); - if (!lm8333 || !input) { - err = -ENOMEM; - goto free_mem; - } + lm8333 = devm_kzalloc(dev, sizeof(*lm8333), GFP_KERNEL); + input = devm_input_allocate_device(dev); + if (!lm8333 || !input) + return -ENOMEM; lm8333->client = client; lm8333->input = input; @@ -162,7 +161,7 @@ static int lm8333_probe(struct i2c_client *client) LM8333_NUM_ROWS, LM8333_NUM_COLS, lm8333->keycodes, input); if (err) - goto free_mem; + return err; if (pdata->debounce_time) { err = lm8333_write8(lm8333, LM8333_DEBOUNCE, @@ -178,34 +177,18 @@ static int lm8333_probe(struct i2c_client *client) dev_warn(&client->dev, "Unable to set active time\n"); } - err = request_threaded_irq(client->irq, NULL, lm8333_irq_thread, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - "lm8333", lm8333); + err = devm_request_threaded_irq(dev, client->irq, NULL, lm8333_irq_thread, + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + "lm8333", lm8333); if (err) - goto free_mem; + return err; err = input_register_device(input); if (err) - goto free_irq; + return err; i2c_set_clientdata(client, lm8333); return 0; - - free_irq: - free_irq(client->irq, lm8333); - free_mem: - input_free_device(input); - kfree(lm8333); - return err; -} - -static void lm8333_remove(struct i2c_client *client) -{ - struct lm8333 *lm8333 = i2c_get_clientdata(client); - - free_irq(client->irq, lm8333); - input_unregister_device(lm8333->input); - kfree(lm8333); } static const struct i2c_device_id lm8333_id[] = { @@ -219,7 +202,6 @@ static struct i2c_driver lm8333_driver = { .name = "lm8333", }, .probe = lm8333_probe, - .remove = lm8333_remove, .id_table = lm8333_id, }; module_i2c_driver(lm8333_driver); From patchwork Fri Jul 14 08:06:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 703028 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E5E7C00528 for ; Fri, 14 Jul 2023 08:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235024AbjGNIJP (ORCPT ); Fri, 14 Jul 2023 04:09:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235005AbjGNIIu (ORCPT ); Fri, 14 Jul 2023 04:08:50 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2128.outbound.protection.outlook.com [40.107.255.128]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3175046B0; Fri, 14 Jul 2023 01:06:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dcLozNJRARfQR5s+De9nRIKIfPlCI1en4EYIXL6OsYYOcx2S9C2YSyuviSScGr7KuJlkeswNHuVuvpz5kD/OO/60mZGvWedExFUijEVtULOQK9ySlhDd2MZ5Fr4xAYIwTz60EUC8ecLTUpo6B6lrSGtumY9bVjMb3E+KvP40KcyyMF8nzKGWRyx076T6+I/59Sv43NWTJtgqWnWFti8fiPu4vRryRVfK245eLQrijt4phODj6JCJAnJdSVWUSjoCjXKCkygDYiyD7g7iAwnJG90YaaiomYyq1YEBT1xD1AyOUIjpmJgtnr0pI1mc7JlIuPASuJaFmAk6D2nsjfbFPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=CeJurPe7ItKE7RXvcYGKs7Z4OLyB1jbsfYIGHzoI8J4=; b=eGm2W8sDtaR3Jbs51vJDt2aAApzv2Hjq2kIXAECa+9sfAMn1OyHEdIufoWMrVqMQ2u3KC5Jqs1FXvhTlm4yiUPH1wASDmZK/jEsJhK8b/EVrIC9QCpkooqPZN9PoufuPEIH3zogbrk8GMKTdLDFzWFr+hWsJBRwgm04GqjrmdiSJt6bUbXJw7/CKHCC9d/bRyXb7UwpHPqIFTFv6w20AKYYQw3f7mLcr8t57G/gTP+pTMGlE68JtMGpKRTjf/aeg4NyEuXdG6vD8XdP82qUPKoRYfvEewlo38Y9iniYioY7rOoarXJC5EvWCFTyb5ChBaf/kLxFjyj/Fgt6E+SFItg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CeJurPe7ItKE7RXvcYGKs7Z4OLyB1jbsfYIGHzoI8J4=; b=P+aVzCsMjXydpFPQAwH/ig5ad/WzFTLAg+dPHtWjTZVBWHTudLunvC4HjKkhZnEY6ES4V/Go4ERvYrBbV4aGY2vmrzEDZxoCY/C2X2VbYy6DY7t1VEci4+/du7loOT1643qdxUbTnJ0YeWRAVcpzGJ4ph2qw1IiSoxSMl3NFhD0y1JFSzwsLuDp4avqobVBZ/uu14lRIorj9pwxomhQceLEqDoO6ZyyfLpl59PtD6yv2SBZ4EY8Lr+uVFRh1qZ7IuBWzdL1OB2Au6R5kvt5/pUgV+6LoqY0dsLMspbMvYZOWXDUSNC5SujK7bfOcVSNTTKPo9REiPR5J/TIxK+fDUQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by SEZPR06MB6058.apcprd06.prod.outlook.com (2603:1096:101:e3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.27; Fri, 14 Jul 2023 08:06:23 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c%5]) with mapi id 15.20.6565.028; Fri, 14 Jul 2023 08:06:23 +0000 From: Yangtao Li To: Dmitry Torokhov Cc: Yangtao Li , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/8] Input: amikbd - convert to use devm_* api Date: Fri, 14 Jul 2023 16:06:05 +0800 Message-Id: <20230714080611.81302-2-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230714080611.81302-1-frank.li@vivo.com> References: <20230714080611.81302-1-frank.li@vivo.com> X-ClientProxiedBy: TYCPR01CA0108.jpnprd01.prod.outlook.com (2603:1096:405:4::24) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SEZPR06MB6058:EE_ X-MS-Office365-Filtering-Correlation-Id: b0c8d827-20cd-43fc-0baa-08db844136c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i9ZB3SpGg1un/I/BIBWka77MFL5PeSxOj84DtlEnxA6zJwxX9o6lwTA39R9mNYTrA822Y0kklm0tOrz7rJMnu/1bT99AkxeABqslu5P61WYvRjlXzihjToGUQ95mCxbYnhFEdPd6CZ+hZRlfL3zMllmyaiMdHqzQgv5C/q402S9YHIyeksUiWxmoEKXTjwjem2J+uQTuj+IYVC2MMdKmlPHADDNfkK6CZ2GnyoJfxrCzlGPQFj6dSS8kkLFJA/yU99PBuCbqgmf+j5acXKu8zbW/k0RnV9OaL7rnrgEpNPC+hcPUtkDh5rTBe2qnla3n9MGYqxeo3/ebo7Htrk/sojQ+ut0RT3+xf5y1EpBTWZovE9J/7/bjesmZOON8jq9QdW8UUdHw0YAIJADLHH90Ff/6Tb50CFEDjIVGxhDFNeqdR08ZPkn3TYHnY9U0AHAXxYT5Y32zayIW3/PYx0p3cYp6zA2+Tplib0IYVWdNTAU8wCN4pbKp4zpwHfdSiW4rU1HNuQmvF9WNdsabAbpkeVL2hOm8fUyZp1Stet0VAnIyOfW4O6uCxvq0a3iXr5L7fTP7dYa46JBMJdFrjyai03ep7N06AywpHw86mjf+rGrYnhd4X01qA1vCXZYS8aSt X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SEZPR06MB5269.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(346002)(366004)(396003)(136003)(39860400002)(376002)(451199021)(4326008)(6916009)(66556008)(66946007)(66476007)(41300700001)(316002)(2906002)(478600001)(5660300002)(8676002)(8936002)(6666004)(6486002)(52116002)(6512007)(26005)(2616005)(186003)(36756003)(83380400001)(6506007)(38100700002)(1076003)(38350700002)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LG0lOUObEqqCCbaiDyV2wUzV46gO2O7YsbsZ6repDziWQt9s+sMMQNin0P1e6YsDxMKrFIWT21WzJBVf9JU/o+qWDWA7qpxkB32PfTmD5yMbyonwI6JTK9joy/k10dwtGniWB9+XYGL6S171UdJ++pz+IH9o05fMtYfhVGm4HmHbKw1eT3eb4lGUQweHhXJR1JPY9tPxzz1TrCrwk4IZHXe5Qs8xrb6sSlwnKj8FbIsxb0yikcQQa+HtPSNnmbx7ztXukDCqvuE+HkxUa8oKoA1TuZ0k962dk/NhmcpWhXqp6/TrRY2ZcppFfXLZfB+Ig2DQCbWuOkSSrCJa3cRRrhhiDs6jvZ+9loLaJI0YldjRx4JarZUqODmL7s9YW5Pe7oeB/+k1JYpGr0dQOdlKDVSXGDY3QNGR4JCWf9ImgDbNxfye3Xlb+DCmb3P6GgDE7/FsdUTbVh/6l0qLLzFe8otLuB459v7kjJhb1uSdn1DaoGh+ob3flhocL0tJdYGQiRjzentf5kOAgaoCsvsnSjwndeNKEdfXT8MCv7VyYd5BkSgxYEf2xGB67AO95qOu2VPELXWlp9W3/65gxQreVuh6AO7B5Du3RJ/u8AuiQxbH8SZKUbiFCwVLiwOGXUbXQ1WAQpIKSBKedRN1C+aC1wyb6UH9FGJB+PsKfM0vSM8u9kDkUP1Iz2RCB07l/PafzjbgNDPJTLNS+dJrE/lHf3L4ESeqs8iE0ssaD6uQk1owiJ7VWihAxftVkVZOwthOwNb16ClL2aCOPcJ7rgc7EBtgwED3c8DQ+E1UEnDGPwTJwNLGyiIeataq3RxaD0/79eolvul/q3fw5W9zber8XCflUtr/wj7cUKfHRZRIlk3/sJ7tcQ6qhNKdnTcEkQArZVdIodXS2W7buw7W/onb0N7CDs/09pJHlZVJOXr2/BGkb9Z+IFTDXEcGISm4h6TO+ZU9lxp9PkWZLNDOhszeMds3YWGGjuXTbAh0vZzTyzhDZwJkeIgEa6RUiqM4b+Kja7W9Xp8J8ySbh8d5/HYqCyPz9PAsSHLXZdD/0J6orgCRc7OhQVNZ3e0mz4RRHr/QYvz74shtMK1YEEVweK4L18Zwg4HO6lqNb84JF2nePVvEw0Mb4BTyVxS5nKyS5E6Pem1cy/oq/1D9dLJTIbAI4BtpXdBcm9xao2i2nHc9xk5lU0FeKKOwdJBbzgK0iVc3NauopqB8K4WpbHHmffarD8UFXxKeCQrFUe7gSOj8U1K22rYpP7hJne13GuT2AGd10HRx+uK7Gp/415MqQu1Cg4zvtczAgJNhibdoJFflc8VNAukEwrteSERtb2IpiylSuHyYOXOTxFjgPmSHP0/Xle9V7DkPsC0/S/kg5s+MqVQ2fyEVykItNvJIuKSQCAoxe3I7nZvPp3B77UTG0YtWhSYsDYJtSCDL4aSCa5EYvp2agvJcS23g8L9L3qhw7Xh/l4uwpF4mVyA9o3ebBBIOj1RJosfnFZXeUCUaPeQa0BKYbaPQAMS/sFgZc8c+2ReJLoyKeR5+fmGX8OiOLImrpJjsQZA0a25nyJTJs5OyaC3AoB93UC+CLlvyJeW3KcTg X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0c8d827-20cd-43fc-0baa-08db844136c2 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 08:06:23.1144 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lhCSSl42C1vjAJwMYssLwLBWAlUveXqoKvApjp52M1d06zalQMyFmSZghHCb6vOpVuK7mxzWSRx7USGGu0Vl6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB6058 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use devm_* api to simplify code, this makes it unnecessary to explicitly release resources. Signed-off-by: Yangtao Li --- drivers/input/keyboard/amikbd.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c index a20a4e186639..4cbac79f5a4b 100644 --- a/drivers/input/keyboard/amikbd.c +++ b/drivers/input/keyboard/amikbd.c @@ -193,10 +193,11 @@ static irqreturn_t amikbd_interrupt(int irq, void *data) static int __init amikbd_probe(struct platform_device *pdev) { + struct device *device = &pdev->dev; struct input_dev *dev; int i, err; - dev = input_allocate_device(); + dev = devm_input_allocate_device(device); if (!dev) { dev_err(&pdev->dev, "Not enough memory for input device\n"); return -ENOMEM; @@ -218,35 +219,21 @@ static int __init amikbd_probe(struct platform_device *pdev) amikbd_init_console_keymaps(); ciaa.cra &= ~0x41; /* serial data in, turn off TA */ - err = request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", - dev); + err = devm_request_irq(device, IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", + dev); if (err) - goto fail2; + return err; err = input_register_device(dev); if (err) - goto fail3; + return err; platform_set_drvdata(pdev, dev); return 0; - - fail3: free_irq(IRQ_AMIGA_CIAA_SP, dev); - fail2: input_free_device(dev); - return err; -} - -static int __exit amikbd_remove(struct platform_device *pdev) -{ - struct input_dev *dev = platform_get_drvdata(pdev); - - free_irq(IRQ_AMIGA_CIAA_SP, dev); - input_unregister_device(dev); - return 0; } static struct platform_driver amikbd_driver = { - .remove = __exit_p(amikbd_remove), .driver = { .name = "amiga-keyboard", }, From patchwork Fri Jul 14 08:06:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 703027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEB3BEB64DC for ; Fri, 14 Jul 2023 08:09:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234411AbjGNIJj (ORCPT ); Fri, 14 Jul 2023 04:09:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233975AbjGNIJB (ORCPT ); Fri, 14 Jul 2023 04:09:01 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2127.outbound.protection.outlook.com [40.107.255.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC58F49DB; Fri, 14 Jul 2023 01:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZfS8WlMgyQXp/GgBps6LYFDjojM5xPm49+bdeB0zA3Ag7V7bbMwEQgpfY8A6WuSV5Py8DBbVO5MRv+3UMmpCtVHFKTKfQRCmZltp2RfMShSU3mi3ywy4aIMUhfee/zyb0M1Z5Py82/sDi3mTrrd6ERSew9/Gjjns+luLluLLx3qVKKy74AAmvmNt9EUjRy3BTrTu1NWDhvqt5zX9rJqbTsmjjhoWHXpBVOpxUE48BDnevOw76paFgdxdLKPLngNuaCg2+0ySBiCiNKPTOrcgEtfLlrzQTiGXrKfDjGz4PNdNEZYhh8tHnwqQM+mnwFrW/6hEDXguBO9mUSpx3NAZ2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=qGZS1aX1YoU5sn+WGWBNX293+dnAu8SuwDDxkW/KL9w=; b=c9qYMmF53+229hkoiztlb4sWVW4tt+bOegtwNsmBuZCqVURe2Cx/TAO+BuTwyf7ibMMlnyj6KAAH7Omnr9GdwAhetJPn5yA2tvroGKLiONjOS10i3YMYxfUadrlghRFMHRo7jr9EkMt7KqkS7+ai6t/TOH33kMB9BCNdTSLOhFVeioz/GG8K88ZZvjWNIAVlG8Pzzm8/Ix3ReBskfm6Yfw91PxCvkokbIBRh9wLmBu7U7BYE8YqlCh9YuXtJtKcImde1JdHCu0F2bwql/8jJqu5LK5nKxkOyPCruuYRWm+MKV7PuHkvw0zQ21zYmsX/c9hUDOzkCqxks3d38JE/Vmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qGZS1aX1YoU5sn+WGWBNX293+dnAu8SuwDDxkW/KL9w=; b=ayJubJnPx08xGwsindauVxPUfbPpnQT+9FvN4pjfdhwl73lg3KU7bjzrqcFStFLPFuqM0XZtproJZZXZyE0VS/s5GP+j53XJsE4qOlVTFUHb392lPFOmUEH0+n10UVVr6Hnk98aejCraNLSUeuDhs2qqc9YI2YlezX8nqHN6sq5ZRDAJ/Abq3Iv+g1WJwQnZvk1k205QF/qr1ShQ0mvNAoV94BrswKNIw2N1BIQftAl0RnvYmnXBUjvX4x8kKcV/rcIvDmq7dIz/BQaVzc3PSJ6YyVte+++F7zcI/2SarUyy0QSkdRSuVKUjgiPHYybzCD79Geai1DAlWtDtHTNF8g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by TYZPR06MB4510.apcprd06.prod.outlook.com (2603:1096:400:65::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.27; Fri, 14 Jul 2023 08:06:25 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c%5]) with mapi id 15.20.6565.028; Fri, 14 Jul 2023 08:06:24 +0000 From: Yangtao Li To: Dmitry Torokhov Cc: Yangtao Li , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/8] Input: mcs-touchkey - convert to use devm_* api Date: Fri, 14 Jul 2023 16:06:06 +0800 Message-Id: <20230714080611.81302-3-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230714080611.81302-1-frank.li@vivo.com> References: <20230714080611.81302-1-frank.li@vivo.com> X-ClientProxiedBy: TYCPR01CA0108.jpnprd01.prod.outlook.com (2603:1096:405:4::24) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TYZPR06MB4510:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e30b41d-f05f-4d91-4654-08db844137a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: khgX/6OlhrFSzMsDOfK+Wo9tRcbQgIDHAT3zhxZVh4dAbkOwPw+VOcNDcES0CLp8IMjD/f+O/jpHk+sB/jpiQRXoaKXFqj8ON7XwENYtK+4vMrsCJoU3GlliEsTYrGepOFmCdpVUCXSRBD+3VebylNlkz27WX/ctqX9w9bGGKXVqiJojQa/8GUCUrcge0dr722hiTDRmmiqWSy+MiNWsWrJFqNhYNYZyDZUryMK5+cIRMpkUih6nSqYStJ/woR3EXI1/SWh0jbyPespZiX04TWRjKsw4iedjaXmW+xcAeMi/VuvufiB3iOJ4lu0fZfneSBF5xtvhfwvuDQOLa5ktbeIwWyfI9vQ0q3RL7Hzzp92e2/nKBMnqZBqJ8f9/uHTMYVBlYVXHSmgo2kz9e8LtELdu12VeSkGaJZEQas8/cOyvbtjPOeyoj4+AKYBkFv/4LF+tx8gYFyzV5kKb1lbEpZ+zeJeSTSpoVSVV2sDT20lcgqGZKZPlHvNfkDh13zgXhW35ZHVWEJM3iIlSYgBerwL/ij03FwuR8lFCSqPf8e1jUQ7YKWNusIy+2MQyb/hIWyHz7rWsO351HE8pwttYbm69fXkjXnjHmFqePqHcF9dJGuHvlmYk5KqtCf1XfJ+t X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SEZPR06MB5269.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(366004)(396003)(346002)(376002)(136003)(39860400002)(451199021)(66946007)(4326008)(66556008)(66476007)(6916009)(41300700001)(2906002)(316002)(478600001)(5660300002)(8936002)(8676002)(6666004)(6486002)(52116002)(6512007)(26005)(186003)(36756003)(6506007)(83380400001)(38100700002)(1076003)(2616005)(86362001)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GChrSvug9KsKiEoSSwam8qaN2Hb8pQqiH4N7NWs6lJIKaGaQdyuwuHvjHo6ai0TMebdO8+YeA5bfDaAf0yNtWVtiS7gkNXhuWXJg2zB4zIkQS3RhpAE7XTQ2fcIMu9CF4lkqYEm6oRJK+GtexF9XPI4UdMhDuuk2lAs/HE9Y1g2kGhfFZgtYgJTbGdDrRMBEQ6+lhjvpu4WOreNLTE1z5RdfazWqEour7Xd741WCXlw/BxLVp9Ueo5e1YHTypmGtLwCvLYuzS3QSLy04ni5S03cAUbk4NS2S1nwMoAFlPhjUyH9RB+W8v2oa73BhbCUqAukO6ciTuXJQ7hItwPrq5xUvVcT8+9Pk1k6/F3iXCdz+JIt6mSWkHAZuLVWMBMBYn6nlNCHPfFHhN1bFcTZKREv0TauNerP/nFhi9CbiKM0kafBP8S/tXnWrRWFUuEZGzdnCqDF+Koqe4+Ww4zkl/YNKAnZrjIEK14OhvyvitxpuJXUt2XLgnrdbkKC9vtghZAHptC2qTJaKos/kYTK8ch+851qbJQPHVWa0uah+EkegHCSVbuD+dcpyrJ4jS62aU0FvPOqpcXANGLP+rbDiu72/+pWycdmFwjp9IbRS2XSvVWHISSvDhx3sfNS18+Csc5MOi6uidC3HRDittryrNJFrDk/QNpbdk34HBxZRdzge6UAOxEdW3XyDCAXIR5fXdyb8Hyv3gIkRyCPQXBGvBTUW0Twmwraqf1m1vMfC/7gkTyjs0agKZC5PE+yUmdA7P6s4smOWsTRqjrkmdJroJICMQIAtMloaNAEXqX7FkCq6J+y6w2cSEZkzz0JH1/spAcbVxfHqS9DSswGCZMewkIkR9aoo6rZs26A0154Hm7Ls1xBI9H3UXjddU1VqInLakM4R9z5RgTDsMn8Z5tY19NeSSaVUGJlSNm64c2c0w4AIIdan/gR2kgaRFDHwDZr555bQ1EV3hwsmN6y1CRjt0clkilDQ1MKtx2CNAO/VIXChwK8/bGFpwGHtZP85qjB8Lx+Wr2+D/55B4ZUhb5FxZ/uRbKtGIG1GAYd4IWFJqSQ3dlfquim0+DYdosoCoUjyCukBW9wElMUV27wt7kOH0ZAuJqF62nPsiXjGFLELayPuJSZwhhcDdk/0NGmaVOvRwR+sZZMCeCtidMk0ZkaAmEl0LdmKNb8TJBMeu6jDIfH3aLGfnqFEzt0ttAFMV2sB/TTrva+cesYblsU60JMqRlfrc5dnGJztDsTlG2idd/BlzJ9ahdqbM0HNLk2mt8q3XACgRAOrJZdFJl+mQlo+asItjhuFZ0hvDtA48zXMSMVvoKpUg4BeaISJ3wxOeebp2xBsKlAdT/v817BgJ6g+TQOV+kH5TxfxxR54/9hStsmYkoRq0XUnpyhre6We3pEzKPjqUGKU1bZgiYnR33qhMWDImGzxXhcqFkiT/TH2XmqbEd0OBLPnrSkYEqcgOUvpN+gT9O1LrQxNfyoe92EbsUTDluzgnT4y3x9UB29p8YGLcpKfEK7pZskzhq4j8WuqJvNqsjOiGrbqRd5fobo5MvT9Pa+AIvYVfcsn8//QTWEMlplrL+9q2loSAz1+sxlG X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e30b41d-f05f-4d91-4654-08db844137a9 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 08:06:24.6091 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: F0FrwISd+NVVJeZ/Us8DaOa+8qr4KRVkL8xQSrgWZafOPsbqHB6BhqK7hbxYNf9k5O+1MIgj0jCZLw3w6FtS8A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB4510 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use devm_* api to simplify code, this makes it unnecessary to explicitly release resources. Signed-off-by: Yangtao Li --- drivers/input/keyboard/mcs_touchkey.c | 51 +++++++++++---------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/drivers/input/keyboard/mcs_touchkey.c b/drivers/input/keyboard/mcs_touchkey.c index de312d8eb974..a0d2e3b1bdc9 100644 --- a/drivers/input/keyboard/mcs_touchkey.c +++ b/drivers/input/keyboard/mcs_touchkey.c @@ -92,10 +92,18 @@ static irqreturn_t mcs_touchkey_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } +static void mcs_touchkey_poweroff(void *data) +{ + struct mcs_touchkey_data *touchkey = data; + + touchkey->poweron(false); +} + static int mcs_touchkey_probe(struct i2c_client *client) { const struct i2c_device_id *id = i2c_client_get_device_id(client); const struct mcs_platform_data *pdata; + struct device *dev = &client->dev; struct mcs_touchkey_data *data; struct input_dev *input_dev; unsigned int fw_reg; @@ -109,13 +117,12 @@ static int mcs_touchkey_probe(struct i2c_client *client) return -EINVAL; } - data = kzalloc(struct_size(data, keycodes, pdata->key_maxval + 1), + data = devm_kzalloc(dev, struct_size(data, keycodes, pdata->key_maxval + 1), GFP_KERNEL); - input_dev = input_allocate_device(); + input_dev = devm_input_allocate_device(dev); if (!data || !input_dev) { dev_err(&client->dev, "Failed to allocate memory\n"); - error = -ENOMEM; - goto err_free_mem; + return -ENOMEM; } data->client = client; @@ -136,9 +143,8 @@ static int mcs_touchkey_probe(struct i2c_client *client) fw_ver = i2c_smbus_read_byte_data(client, fw_reg); if (fw_ver < 0) { - error = fw_ver; dev_err(&client->dev, "i2c read error[%d]\n", error); - goto err_free_mem; + return fw_ver; } dev_info(&client->dev, "Firmware version: %d\n", fw_ver); @@ -169,40 +175,26 @@ static int mcs_touchkey_probe(struct i2c_client *client) if (pdata->poweron) { data->poweron = pdata->poweron; data->poweron(true); + + error = devm_add_action_or_reset(dev, mcs_touchkey_poweroff, data); + if (error) + return error; } - error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - client->dev.driver->name, data); + error = devm_request_threaded_irq(dev, client->irq, NULL, mcs_touchkey_interrupt, + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + client->dev.driver->name, data); if (error) { dev_err(&client->dev, "Failed to register interrupt\n"); - goto err_free_mem; + return error; } error = input_register_device(input_dev); if (error) - goto err_free_irq; + return error; i2c_set_clientdata(client, data); return 0; - -err_free_irq: - free_irq(client->irq, data); -err_free_mem: - input_free_device(input_dev); - kfree(data); - return error; -} - -static void mcs_touchkey_remove(struct i2c_client *client) -{ - struct mcs_touchkey_data *data = i2c_get_clientdata(client); - - free_irq(client->irq, data); - if (data->poweron) - data->poweron(false); - input_unregister_device(data->input_dev); - kfree(data); } static void mcs_touchkey_shutdown(struct i2c_client *client) @@ -259,7 +251,6 @@ static struct i2c_driver mcs_touchkey_driver = { .pm = pm_sleep_ptr(&mcs_touchkey_pm_ops), }, .probe = mcs_touchkey_probe, - .remove = mcs_touchkey_remove, .shutdown = mcs_touchkey_shutdown, .id_table = mcs_touchkey_id, }; From patchwork Fri Jul 14 08:06:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 703433 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02B04C001B0 for ; Fri, 14 Jul 2023 08:09:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234942AbjGNIJP (ORCPT ); Fri, 14 Jul 2023 04:09:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234994AbjGNIIs (ORCPT ); Fri, 14 Jul 2023 04:08:48 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2127.outbound.protection.outlook.com [40.107.255.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8FCE46B4; Fri, 14 Jul 2023 01:06:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gnoPn7XB5ZzM4b9vk+C/NAd5NnFbKiLEVPmpT1h+P2GXQHhrIabqQQ4N88JiVYPkdiaJFHvvnVxRVeMA8SgrhluOkNPDy8h5tXT/RbeCwns1rtjDR1le9xEmH8qNB4hdYOvnLd42NYMK79lhWKVpivVx7gwNYMj6CkMQw1G8i7YdFTzqOpEXFFDESmu0wMXXUyIzRR3NSjeZhBzKFtiR7mBpvJVuJB8VJ4pK+jLYsv2tBMwn8xFxUKb8A75EZaRcc7oQnNM6knET8P0IZQH7pyMFNQt55ixzFtbED3mSnh4M5MqopP4CFfC3nJJjwQfzb1jCYKPOteVzavVaw0+7FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=nhXtyfFNn2c13mX+gMTcuJZa02qAz3DW/hl8K+j7UXw=; b=eQWlBvfXGtsz0gNd9gyFCP5nXW0nQiciLvaO0KhHW+1dxhUzYfRv0X+k0thS7H3emOOhp5vNXMsRAsfyhlYyB/3fXbuD1NZH77Gl++ungsEfzgRQHNnVhN9+/nG3+n4V4fJpgAVkaJd7XtzQ9UwqqbXH6s8o/kLa/RgTH2IzUxC8AjhY11ETiGz1Dm1L4eSehV6UjpFfMIzKGC4bbox+KLvXdJyAZ0qeAaL2Oajjf+bX3epCxawo44E/IhElvvUFUysobo5vrZunZ7WWLH5xVasq/ze7AA+uxENodueTD0LFHeqI9llD86JX1zGLQU8xxDq77JSYhy19UZbb+y7vTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nhXtyfFNn2c13mX+gMTcuJZa02qAz3DW/hl8K+j7UXw=; b=RiSsbu6xmW8exSp1N+NJj1SjU/7asAoq+5FRcmUqnpJaNfixZj8SWIzs5xik8PNUCql2fpqKkATTjby3/YzZxDT0uL4LDELeF46eS1YM11D8iOiYqZZDZjtnOSjRu3LOAB9iClU006QF/g15kwjIzFSxXlVPhnHRBAweX0sUUlpBso3heqvw3dk4uaj46IOZIofZtmR4YNLC9HET222S2klr1lngU6mZdeUV+bZa4+c/g0q3g2E5fowqo6Odt+Us5XNYi2GDWO0obC1PUgGmS9AHfjonF3Smlu7WoDB5RNXrfX59LrPQmED6xy1otp6D982ig1ri3R4gHp6e1QVMJQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by TYZPR06MB4510.apcprd06.prod.outlook.com (2603:1096:400:65::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.27; Fri, 14 Jul 2023 08:06:25 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c%5]) with mapi id 15.20.6565.028; Fri, 14 Jul 2023 08:06:25 +0000 From: Yangtao Li To: Dmitry Torokhov Cc: Yangtao Li , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/8] Input: tca6416-keypad - convert to use devm_* api Date: Fri, 14 Jul 2023 16:06:07 +0800 Message-Id: <20230714080611.81302-4-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230714080611.81302-1-frank.li@vivo.com> References: <20230714080611.81302-1-frank.li@vivo.com> X-ClientProxiedBy: TYCPR01CA0108.jpnprd01.prod.outlook.com (2603:1096:405:4::24) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TYZPR06MB4510:EE_ X-MS-Office365-Filtering-Correlation-Id: 3cb56a8b-27a4-43e0-1f13-08db84413850 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IQuGBCIzbh0xWl7KxSxebmaOEsVeSg7AbCFR7k8SzyXlNrBIiBnXVYks5TLI/i64XISiSHU8zeUA+js0VNH+zEi0GGs1N8W1mf+qzGSVeAXoUpAPdmjpmny/fVRTW+fTcaK3lLC21JXhwHkuoNTZyCMXBnnHo+kolHywmE55XtiPyMZfsf/9gYElZQBkpl7GdUavEulgOYsBUbqp5l2q+Q4UDc16GE0AmC8qP9ffZLMhaYlZGhGT1XgpB5iamEu7ezo4vbQHrxc2aJzKYrnIv9oUzL8fH/m1ars5r2ePKuxePs88TBCV0sk+71QlIeAcYcxGqLEix49KIvkSMkLrMkJrhCXWFCXiCZNuMzdjjKFQwjkGJRuQsCaxUu8RiAMzSterY41LRr0V8eEvneol1/NXyBxZdwIcjwDSXAU15P34pdFirm3KwkGc7fdqkeas6z4w99bm0kmXk569CFkptEzo+jkQUQDIk8pBSqTXcH6WvtL77/m/hPJujpfulGeJduCsEjmVJ+zxuqBA3wXL/AY/W7FQRHht/CfaxKU9mi93GVP10vw9wKK+GZ/kHtzP2zubMpwD1MJkufKRrIvo4ajljtk1kSstF/3hvu2bK6oKcgiww/Gmx1Zxvt7tZ9CF X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SEZPR06MB5269.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(366004)(396003)(346002)(376002)(136003)(39860400002)(451199021)(66946007)(4326008)(66556008)(66476007)(6916009)(41300700001)(2906002)(316002)(478600001)(5660300002)(8936002)(8676002)(6666004)(6486002)(52116002)(6512007)(26005)(186003)(36756003)(6506007)(83380400001)(38100700002)(1076003)(2616005)(86362001)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: erTubDaqHu+OorCIoVzC2QwD7/pSKpDrG74+YWeMu2k/Mg/jkhMj+NsjPZPrBb0hg4FyivOmxrLRC32PWD9m3RH0xo7ZSWhRYajWnQJVuvR5mF9/F5GtrOAgt5g3WgEgonKRTIuQP/UiV8i0SJ04bSi//AiXK9MZdjM4BG6xvDvbDImFuJz8hpwmHibqV0cJW2p5tH+N7XPgPe/K3QHu4kUhBtgoFQY5h0rxZQjlp33y6RnEW3+ecJHqyWlwyvPbSZKoxvSEC8jdecmYDoyR6KQ9wACHznnhJD6CpyRL45c8lbwF/qm3XarLydn4oEcnjB3VUUpEqKNpuyHyOHF9q5YS+FcfJutzR1cLkKtryfDSQQ7qciatgoLCetU3cOo3u4mIp51SqW6VEAG0gEy1ELMbdidg+hwXfoXmkxqqTShJw1UNoud2TSPI7A9WBhkPgDR55nYZo5gSJYWOq4f3LX7aH8up2isCEP3B5828zps3W+1qepaqeHCrviqVU9l5yLwz+MSuNz4g4PGYYJj1t1eDk954RXpNY1pWNUXifTBlg9sIj9uh25etLOnZALOyzNbQEroYhn5UQ3aHSxw0SzUFvnJ/hCP67+q/fG8mNNJMGMq8XYW3mt3eD9vuqryK88n5ObYylaCV6SAKJ7C3eLfzWiPkRYdFYFyUQ2FVG1Dqn9N5YRl+LJ1BJQaLsnANgapJukQZcdFqRzLDxJmrLRVlWYdOscW6rokVIfdzaCHKh31Z16xIRWTdBkFzpEv1DcUpDs/4SCNQ3Dn16Bn7SuyQ/3gL6Mu65DbjwGYTC1BIkXWPIeggZq7Kvsl6WP2Y08ATOpKR6osQhdJHOneF2nXKEEbIwUUl9Oyu/BjeEPUA9yUhB6Wx+HO9oR+0NkfKcxDBt53kQPFG8qVD1MRdiXUnEKA+aDpd+4LiDctMhte//V4Tjzp9PXJ54pgokOIHOPOWxDwv7mHPUL733YdSXAv3G0bwyk+AftqQRakVemMKsLFWoqDggvH2T8Y8SSmUGhmSxjp3qE32RvVnti13gA2sQFIEEVH0O6mLZb9DBOkuUUxLYp7mskRKppvXwKV2JpcW0rLESG60tUge+8AQF4N9ywCOOezXGk9H6EotNJuMrj4xQI5PHNGI+gM6JDkH8RCtVyPZg+17mg2o0C0qnP2QyIopdOEC4gE1sYvcdxsY59HCvKoxIisqnBoQs2RsvPJ5X69cArEKRcylq8M3edfuzegy+uvFJfHHdmWaTjS1+aqJrpKSmJ6UDSyZSN7zvRHopFE87n0Z9o0vR2xoR3Vfxt94bCn97GYdogXCCAYqDKTnF5i75RTQtSL3h79VC9De6fGMdlpeDPUniDnTUTy94psECZmS3TXWe4LwF5J8s0rIf5c86trm9A9gzEkw+W1xWVQ91cA0TsJavjI2S5hMYijS+WPxRE4SJAqJhbjx3AC8ZP46p74r5msOJOTY661uNlwwXN1AQCmkAi9WsS5kNEaiPgPBC15QFVOOK9WE/dLyd0EeE5QMC0emS5XErXzZlyZzYK64S959W54PVD37KRUrLUB3IeYcF37Y8NeYaRB1BKoW1u9E4zhAY+j/ X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3cb56a8b-27a4-43e0-1f13-08db84413850 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 08:06:25.7267 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: e+GqWfqo/xXGzaQYSsRh43R70FMUZ7z4gxXcSxVSibi7phw6yX65mGuR6O3oZ/BwwWEnv8LfuCY7QYzmA8Qx/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB4510 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use devm_* api to simplify code, this makes it unnecessary to explicitly release resources. Signed-off-by: Yangtao Li --- drivers/input/keyboard/tca6416-keypad.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/input/keyboard/tca6416-keypad.c b/drivers/input/keyboard/tca6416-keypad.c index 2f745cabf4f2..8db204696191 100644 --- a/drivers/input/keyboard/tca6416-keypad.c +++ b/drivers/input/keyboard/tca6416-keypad.c @@ -198,6 +198,7 @@ static int tca6416_keypad_probe(struct i2c_client *client) { const struct i2c_device_id *id = i2c_client_get_device_id(client); struct tca6416_keys_platform_data *pdata; + struct device *dev = &client->dev; struct tca6416_keypad_chip *chip; struct input_dev *input; int error; @@ -216,12 +217,10 @@ static int tca6416_keypad_probe(struct i2c_client *client) return -EINVAL; } - chip = kzalloc(struct_size(chip, buttons, pdata->nbuttons), GFP_KERNEL); - input = input_allocate_device(); - if (!chip || !input) { - error = -ENOMEM; - goto fail1; - } + chip = devm_kzalloc(dev, struct_size(chip, buttons, pdata->nbuttons), GFP_KERNEL); + input = devm_input_allocate_device(dev); + if (!chip || !input) + return -ENOMEM; chip->client = client; chip->input = input; @@ -263,7 +262,7 @@ static int tca6416_keypad_probe(struct i2c_client *client) */ error = tca6416_setup_registers(chip); if (error) - goto fail1; + return error; if (!chip->use_polling) { if (pdata->irq_is_gpio) @@ -280,7 +279,7 @@ static int tca6416_keypad_probe(struct i2c_client *client) dev_dbg(&client->dev, "Unable to claim irq %d; error %d\n", chip->irqnum, error); - goto fail1; + return error; } } @@ -288,7 +287,7 @@ static int tca6416_keypad_probe(struct i2c_client *client) if (error) { dev_dbg(&client->dev, "Unable to register input device, error: %d\n", error); - goto fail2; + goto fail; } i2c_set_clientdata(client, chip); @@ -296,14 +295,11 @@ static int tca6416_keypad_probe(struct i2c_client *client) return 0; -fail2: +fail: if (!chip->use_polling) { free_irq(chip->irqnum, chip); enable_irq(chip->irqnum); } -fail1: - input_free_device(input); - kfree(chip); return error; } @@ -315,9 +311,6 @@ static void tca6416_keypad_remove(struct i2c_client *client) free_irq(chip->irqnum, chip); enable_irq(chip->irqnum); } - - input_unregister_device(chip->input); - kfree(chip); } static int tca6416_keypad_suspend(struct device *dev) From patchwork Fri Jul 14 08:06:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 703431 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5F3CEB64DA for ; Fri, 14 Jul 2023 08:09:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235363AbjGNIJl (ORCPT ); Fri, 14 Jul 2023 04:09:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235101AbjGNIJE (ORCPT ); Fri, 14 Jul 2023 04:09:04 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2127.outbound.protection.outlook.com [40.107.255.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6B4649E5; Fri, 14 Jul 2023 01:06:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PK7Nv8weDiBUGXbS5xLF+K5IZ20h4RynohrScbDsbnpc5Rlai0Nm1k3PG2A6dGM0aDs9beBRE34LJAw2uF0HH0Cp24hHo+72AnNlKLo0Y76xJcssntNeHd4JcVGvUKhELyeZ/T2+TLsgjBnYB/anb6VezUzGuZQ+rEbFpajj8DZH6iNlPQXifqiP/M4IycALKx5I8pizRGTn5MtA7rt46LJu115SVfw70moLOebu3anQgDgYRbEC4CS/HNZMMEw2t568corlFtlaSX/Mxqbk1OkHBi7BAsemANmKjCR0z22/PjnDFB+F6rpDj9AFh1IshyS/F6PLZBZIID+yJYx2Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=pGftaSQHOqN63JNTpkM3aKIihrg8EH1pmJWu/L4qoYs=; b=VuNHlLbWmOAf7bKtpz44pI7QqLPf+0aFzR4Lo9C38HtQT5pnAZck5RChckvUiaX45d1rToPeiV2pwNiOgC1VKlMVrOPe1F1k6MwyU9BbprF5NK7tUfyYd+tJXA2uH2XlEyaXm64jDoCrKbylyoK07CJ1SNnthzro/jJw1389MlryIQh0WRWd+Ye3s3O+EWu65SBM6rS52mOoplZSEE1OTygkvaEyFBNsbM5UqHf+6iN8la1BZv9hkeC1KADqoQvzoydyAbA4ceFt9LBtbPsrAEGRRJtpbGVB/cBIZPdoZ1bG/gLfCex6ejkzSN3YNAMJug4SJWD5rmKGZOPDUzu2zQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pGftaSQHOqN63JNTpkM3aKIihrg8EH1pmJWu/L4qoYs=; b=FeYjs4vtRXVwybKLT8/Bbs+NYnTshwwRZ/Oan4OTtPB4MkqOH/Lj20q8AVH7wsYwOkDob3vQM8pLLYJ2XIa6XkGViMh5EJULNmsCIqL82kJ81wqREgEjndFGhj4WLCq9hbgTkyqcW9mqKfLD4vv/QH4UFcIpFwQLqT0/HozC5TVrszkAYj9bUTtmANMxRYHzoZa4Ec66j47JVZAhE4NIGg0nSPMxwQQZS4qsVW+etOoXHlb4Kflq76qFY3VObFmzJ0FDFYAfivOpcEg7/KbKAbyYQ/c/NFt36W7zEhi1yk+BJyue4LFN4HhEc3LEPL4AJUf0qhNFOAqjPdSNPvD73Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by TYZPR06MB4510.apcprd06.prod.outlook.com (2603:1096:400:65::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.27; Fri, 14 Jul 2023 08:06:27 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c%5]) with mapi id 15.20.6565.028; Fri, 14 Jul 2023 08:06:26 +0000 From: Yangtao Li To: Dmitry Torokhov Cc: Yangtao Li , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/8] Input: qt1070 - convert to use devm_* api Date: Fri, 14 Jul 2023 16:06:08 +0800 Message-Id: <20230714080611.81302-5-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230714080611.81302-1-frank.li@vivo.com> References: <20230714080611.81302-1-frank.li@vivo.com> X-ClientProxiedBy: TYCPR01CA0108.jpnprd01.prod.outlook.com (2603:1096:405:4::24) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TYZPR06MB4510:EE_ X-MS-Office365-Filtering-Correlation-Id: b04a9266-84ac-4086-222f-08db844138fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KPO6ugd8oOnpmX98pO3QIz3XxAyai2iJtYV/ooj9wBk9B9836SwrOLk/0KRgOWOtW8n6sPqdRbgnq+YlSPWz6952rQtgfL2Biei1gP5IQcyjazstjVfRU521cCO3ifyjCl0RxP8NCnAzCra02f8PwZemUsAPk7mXFUqsIQe6PBwOOzpacZ+ar3ULosJ96Ol7X90GOwRKl664VoxzFL9C1N5QK7ov7T1FNUyNAoeaDQZPnDLkwhcBlDsDqSSxUhe0BvjczV1HUcVIfSRr3qQJnoZqbhl3Rxrf1B/nPzpA1KEMgU5pJ39XELN8qts4D0sJkGC5CoIAVy5tgwRI8a9UMSSOwhKomjDYuoRbYrrZfut1w7+KC32prp+paaO/jCwkRZJl5tWk044WGSSug918E213U7ceohQNghqYrK/392QgG4DP1DSWQZreeBCWjX4ggC+L8t+JDpZGnTk1tCejRaPBmr5W1nA5ScVr4NmnzenfxpuCfShVaRCqoE7ugavFh8bnvnag7a0pRbYxVkLh6HjoJw/kN5BtdYDuGBdKorR3zr40rXnzzf/zegV/hu/sWuQwZLi/Nkyp0yjS6NvB9Zo3TJQLmnzbR+M4Ea5Kkf1b8o8tj8F9dnI2cVCFSW0F X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SEZPR06MB5269.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(366004)(396003)(346002)(376002)(136003)(39860400002)(451199021)(66946007)(4326008)(66556008)(66476007)(6916009)(41300700001)(2906002)(316002)(478600001)(5660300002)(8936002)(8676002)(6666004)(6486002)(52116002)(6512007)(26005)(186003)(36756003)(6506007)(83380400001)(38100700002)(1076003)(2616005)(86362001)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3e2y3vQyB4fjdUodCOUOo7YiuAtmGjT3/dQLXG/HrcaV6BoilG1Yf7+fhRhYosEj/NJNJ/F+9Qc9ITq2oH1zSDlSbcbL9rloScKI8BKVO7n2F8AjgP7xAWc38cEMgP+P4HDtbEa64D09lclOj26Xfqw76GKwIhFxwu8QKzTRMKomCdilt2OuZhaQcjxfJs063SuCwyuEriO6AWxFVzaTFkwrT7agl/IqgorGb7I7iui+QB4BE44SXqJkgmX7h2TXY4N0YKbggpDHzdnlhgYOa298LiSEqmOSy+5W3bTJJ40/RHB3U0j8xMCyFfxoIQPeRJZWBmnY7I1Y3GOCkfeDxoIvSunJbG5oGx7QW61ecGl+iLzsNUJiZU6oZGcyzdiR82wl0WQkYNfR6nbMoGKNp/V+auacoYLBftk8M5+Y+/9Eqzb/QtyoR+xEV3E/wNcbTtxn9aCunNV7oIIPy542H8ZEjreKaQhyDKInAexONVZXKw8s+qZ60I2n3lKP5wcuPSWuVapmC6ad6h9ristZfeP5Sb50jWDm91cNfUO3HJsU14S3MOggP6gvslzbMozqdzAtAN7LZMJ8qcZpX6fjBz5FFMkkPLhiss5fuB4DumgLhCYrYRpqljsihHyVtmvK3Byxv0vnM2QMaPtSaSCjeoVgreC5ntx4v7l794ZPnXTQySkNe5+Dd+guSLuAPNxYQOJxV3LiU5AlWpbaMH0Y8WsuNXbFwEW9wWidRB7D60HX/GcIpVin0jFVUzGqs5gnpyaGhIxyJxqs4RRcVevUycNsYUGDFwNO6pYMQrwLPXlThb9osr1jwl7GTyINu8NxAqeqo61erhofWcBtk2zj21iaWlKsCUkJt+UBZIoJcEAmi4V8Lmy+/rCm1BH5AXtZcYa65MZuxrsT1w/OhuWd9TzV7phFbVd2GwnkC1ogwBHOXlbq9AJ5xcS02PLbz24Q6Ct3VDK4h7RJhBiK6sj8TmM1Zjwz6YN96+RwBPCJE2ntrdAwIQzZ595NWryf+efyNi4IfzCy68Jm2fKnQFYEheo6e4goNNHD0ieDsmhmCfUAo4i5S2VRI4+jMk7UcIwLk8xDJVoRFQbwuzb4aUvwFlL0NiMQ5kxaISPxEdmxMHedeRncDtqC/EoVxxPu7qf4GwdCswhdOz9tXf0RoDEpTQ595tMkzwc3zhjbX4ANfURhupRjR00QsEL27artcH7ubPHzjbfJzfRppdse99t3W4ePX0jTiZ9XDdTDzmvGHBsNRVcwlzQ4Z02rqg8rO2R5VJKqW7teaVnPSFuoyEy1pXijdR5U6I/kvx0y05ivmrfthdbC+flL/IbnP0/L4oujc3OnGM/5s8TH2rkku3r7QhLa/sRGnpPyBQ/DPp6PLlwWgsJKu6QpzBAClTk7+IDADfAqNFJaJXdSgckAEnj6w6p/L3n9dDYyqoQNmVFpENhjmOWjWTVoT7WtcIuLcoS27+QBtXEn1+sLPhbvF1q+US9VECEmIadcZXTwX1WuARBOc8VFURYgEi+giDXPbr0uhPE7qh2v7SZKw7nl6lNL3Z9hbWp1n8TEkilqpeMSrm1d/iRtHRxUBGcrqtAKUw4Q X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b04a9266-84ac-4086-222f-08db844138fe X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 08:06:26.8617 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NwlksOTN5UblKZV4jcLi+4CVL1Ci6BoT60zi9lpqybuGLeZve2fI5qRvlzCIZJziHXWrbxKm7hnPZsuBi+ZS/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB4510 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use devm_* api to simplify code, this makes it unnecessary to explicitly release resources. Signed-off-by: Yangtao Li --- drivers/input/keyboard/qt1070.c | 37 ++++++++------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/drivers/input/keyboard/qt1070.c b/drivers/input/keyboard/qt1070.c index 91aaa9fc43a4..b240779b6a93 100644 --- a/drivers/input/keyboard/qt1070.c +++ b/drivers/input/keyboard/qt1070.c @@ -128,6 +128,7 @@ static irqreturn_t qt1070_interrupt(int irq, void *dev_id) static int qt1070_probe(struct i2c_client *client) { + struct device *dev = &client->dev; struct qt1070_data *data; struct input_dev *input; int i; @@ -149,12 +150,11 @@ static int qt1070_probe(struct i2c_client *client) if (!qt1070_identify(client)) return -ENODEV; - data = kzalloc(sizeof(struct qt1070_data), GFP_KERNEL); - input = input_allocate_device(); + data = devm_kzalloc(dev, sizeof(struct qt1070_data), GFP_KERNEL); + input = devm_input_allocate_device(dev); if (!data || !input) { dev_err(&client->dev, "insufficient memory\n"); - err = -ENOMEM; - goto err_free_mem; + return -ENOMEM; } data->client = client; @@ -185,19 +185,19 @@ static int qt1070_probe(struct i2c_client *client) qt1070_write(client, RESET, 1); msleep(QT1070_RESET_TIME); - err = request_threaded_irq(client->irq, NULL, qt1070_interrupt, - IRQF_TRIGGER_NONE | IRQF_ONESHOT, - client->dev.driver->name, data); + err = devm_request_threaded_irq(dev, client->irq, NULL, qt1070_interrupt, + IRQF_TRIGGER_NONE | IRQF_ONESHOT, + client->dev.driver->name, data); if (err) { dev_err(&client->dev, "fail to request irq\n"); - goto err_free_mem; + return err; } /* Register the input device */ err = input_register_device(data->input); if (err) { dev_err(&client->dev, "Failed to register input device\n"); - goto err_free_irq; + return err; } i2c_set_clientdata(client, data); @@ -206,24 +206,6 @@ static int qt1070_probe(struct i2c_client *client) qt1070_read(client, DET_STATUS); return 0; - -err_free_irq: - free_irq(client->irq, data); -err_free_mem: - input_free_device(input); - kfree(data); - return err; -} - -static void qt1070_remove(struct i2c_client *client) -{ - struct qt1070_data *data = i2c_get_clientdata(client); - - /* Release IRQ */ - free_irq(client->irq, data); - - input_unregister_device(data->input); - kfree(data); } static int qt1070_suspend(struct device *dev) @@ -272,7 +254,6 @@ static struct i2c_driver qt1070_driver = { }, .id_table = qt1070_id, .probe = qt1070_probe, - .remove = qt1070_remove, }; module_i2c_driver(qt1070_driver); From patchwork Fri Jul 14 08:06:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 703432 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DBE1EB64DA for ; Fri, 14 Jul 2023 08:09:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235056AbjGNIJi (ORCPT ); Fri, 14 Jul 2023 04:09:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233677AbjGNIJA (ORCPT ); Fri, 14 Jul 2023 04:09:00 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2114.outbound.protection.outlook.com [40.107.255.114]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97C8346AE; Fri, 14 Jul 2023 01:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W/d7OQh9ESy7BVVBe5oJZ2I+VYmrHxPL1exfJ/330j4eKnSNJ2z4nb3AFZGCNPGnTXjxxmW+13NuSIUqSOGotSfFTxeFY3J8RJHBSNOdCoILw49wxirN/UaA1qSFieaiJ82JRTKzjRR2MZKQ2VXP3gQwrpMws1LWG7jnxW4w3ye4XdtPPSzxBj5ZCn/14+vSwqkWliAFTsAkROLki+U4KQUBNz4w6E3MsGl4akQHiGrf9mmcGSjxgYrl7OVOPShY9nIWEHc8kf11H9eGujzhtoO3BFxtyJrxd9N3DhxoQSOAhF6xjPEfj+6SuHZk+B1ECvZWyTbab+IhsoPdyBiuGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=jqsTkL3/qOWLcMei4l6WVHfyAej9duTSmbc9tQGrdDg=; b=aJu8icG67PEWkhtoqrIIlA8Sa8JiJ497ZnB4dUfPJoivYgQtokxvKJ1ukNYlh/ZbMBGvbNkRFOHWx4wxF5BGmPF5pjaWjdGGuWzxL6nn/iogItPjo3Bl5sW99MhUOnairLyUl+sitkWLPQNZ5WFWsM/3UM2QcBR9oR9zjDk3SxUHXrpsKMT/bQ+1Vr1YNWffzRDzY4PmcgXgv4cjL59qPV4p+VpfCA6+Ar7fy8+vCI8UT+12HhRMCJ48EYwHakkwk+J7oygaV6/49ULiwEnvVayNbfc2XKAlJcAE5ww3KrpbtDLjLtsH4zlIVocIcmJ4fSN8mwISE+bOhCYZ5yK5JQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jqsTkL3/qOWLcMei4l6WVHfyAej9duTSmbc9tQGrdDg=; b=pZ8Uw9i1obj6NS3BrbkRP/8j1QsR6M7kTzDcnQBcNFKQiHO29wfho6EItDCCAL9GwL0kCucHgUKruODy4f9Niwjuc36SuO6lLU2qQbRFGKRP2OSGbd+1vWs6amkuMCU27JUZOqLVKeVIk++MCGDJRGhxdx5Zwo/RGFHcaf4lM8tA3vsSE8PtY7lxkfX0GPcG1N6IjS9cQ9DxZEo4StLltZRlSz9Ck5+3U/1bvqrKDLnL4n6W5HtvqBpS4rNtL1dpP/ZOZ+FHrYjLtiJ7FN6q84T1YSCN199ZS9gfdHNRa/4zUr1JY2qyPjyT0umHmiZBuvLlQqVCcPpv/wWXLNb4pg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by SI2PR06MB4059.apcprd06.prod.outlook.com (2603:1096:4:f4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.27; Fri, 14 Jul 2023 08:06:28 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c%5]) with mapi id 15.20.6565.028; Fri, 14 Jul 2023 08:06:28 +0000 From: Yangtao Li To: Dmitry Torokhov Cc: Yangtao Li , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/8] Input: sh-keysc - convert to use devm_* api Date: Fri, 14 Jul 2023 16:06:09 +0800 Message-Id: <20230714080611.81302-6-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230714080611.81302-1-frank.li@vivo.com> References: <20230714080611.81302-1-frank.li@vivo.com> X-ClientProxiedBy: TYCPR01CA0108.jpnprd01.prod.outlook.com (2603:1096:405:4::24) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SI2PR06MB4059:EE_ X-MS-Office365-Filtering-Correlation-Id: cd876983-03b3-4417-c318-08db844139a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Fz69zHx2zoW7YKiEsoqTf3GkwzQlCnqdSxgXEYvmP3jrOkHCRUqUN+VXyn+CoTTlULIdmEbTisZVdvo8DHzTWHWLQsTgrJ5kCFsGE/kNShuHi2KoP4d0i4hHVX4q1KJcLsXCNGTsU2Mghb14vqiAvNC5VHk951bdQIV5MX0LkJkziuPrjEDxcHnuwHixpDUkz4Tjo90rEVYVVCWW/D4AdyTRVomGDB87PQlBLEh37kjod7tSTmzeniQcp2WijtWOQI2xZHkTGUwTu6S3heZmKhQWnjWsFjGa37uLwSiF0NlRUyODsU+eH8crOcCQUq/jUV3dD2nRDNqhIK+kg1oWecKqDEuoM8vdwxS2NX7sFuTzo9jFzbtaJgQq+tiUB3jUKR6ldBzxKwRfr/T2xc1569umEhVKOGdJeTUJVGsH2Ap859eE0JBTi1ijfumLzffoNNeXBV3928+5mdhN95axJCbcFeyfGGTH+VgK/mghQcA5t1IA6jLOCsOuR2UQvV8PEbdP8+5S2l2MDV80kOf2l3NPhiYInWI2J6sfMqeI7xtk5zknFZM/mUX7Oo7TQGs6brWrUcnh87jJadm+FdASEq/TnID3L7TUcSCwx2YqL0SqFDfD/SCcVIzYfUINIE5l X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SEZPR06MB5269.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(376002)(136003)(346002)(366004)(396003)(39860400002)(451199021)(52116002)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(86362001)(2906002)(26005)(186003)(1076003)(6506007)(6512007)(316002)(38100700002)(38350700002)(66556008)(66476007)(6916009)(4326008)(66946007)(41300700001)(8936002)(8676002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uefcU7vm4vfYFgaGc6WUJdS6Ibpk1HEZVq/LC99e1FLR+9gbg/cjJolJuEJbp004KRXzUqPrnflpfax0rTUel6zyFabVUm9f7Ha42LdCt+KjOzwmwC6+jmJR9nImlr0JEqcUmpLCis/Hu8n4IaW+Jbs/GYepmVcaZchfcDOguInow1e42xSMmM9h/w8+aKBRijQ+iafSUDYD7CppJGQG25ZlfT0I8NPcdbWbhLCdz0M8ueO8K22Ysvzu+Xh46TB8GXsi+uBBCbMPJ0DnY03B6WvMq6OqJz43r/w5fE9it8Iku8aRvU/ICiw8yE2IN+x+IPtHS6PhEa2hGk8klk5kMuzBu+9QWDOPi0HHds9FqLXHYciJYviuDcSLXas5HiWz6FVL4nBT4GnlBQeEe5srp/saBsaATnNI3/ghFvogHYu1qbUcoBWfrk2JB75x2V396tn+9AE81dA9MIX9VscG4NI8TZyo/fbIRC6wpoqcXbp+0ivMj9YmscOdzr/7aMhjv3EQlkz41cPF07lP+7i94cRZr7I+hg479I3hfRmhBpB/W/ezuvULyBtmvxS0LMK2PlHGmsgB/9Km0uwT9cpu4qjOHjc0ST4uO4NIYzNLqIEesNzxTvQe6j/dmJQCrA9CtUB86rItN+3a50jQbYfVmnlwyw6yN9RploF3hRJByimPyJzwUX+3NLqQhps1RnsCuc9mdYDDY8gfUkRI8TOec65LflBXN3xFy/PiW9bEdQqvaSlgX1Mex9G0AhEdBftd1PBQyE4fboVKKIpTzSY2ueSncdevw4zPfdVpUCuDKFh1zWvExRjvyaeuT3kSZFbxeGDRWg+tgfAI/35bHBR7fPGIaGY0m39bc49qqk77XQ4EeZviGndpDStmHYD2E49obqTPnlIzOulE5orfhaAmRs1n88dNdnV6FA7VEAvIjkk+kjWHDKMNzN5mIBs3ynXGH1PMApPC67rf9eYRlpTnI1ErZaeHt0acxYNYWIPkNnJ2m1F4F00zrnfI9aPkogg1r9730mSwN2++0m2kw5xOaH3U0CCOGxWNDkcrQnD2lmeoB6/IomykWMDa1amMGE+uV9/r4u8HusR0/oNnSvviQADKsjXaVGZPxIOSZfaXQA8DcPp9O7kJd1abV3YhvH3my22Km8d/FMBv2F5txUTpDikF/ck23IQ7CBEc7I6oSny+/pCGsKotwquxOU8YSEyc+9JojTg72QtIYdmvWrcomXEyFQEAZ9i5mnMRMcBpIRAVjJpDGPds6weXYIurI5k3KhWIDTXLhbe3mA2Nwhm2ou1xfY4Dt0wMWBLFwQbKXeMrDqQQGXyTQ0BKcBbt9EJkKfGH22Fpz8zLInfbXjGWmqnUGOduIXVnweaP0zUcYZgdSuHLWGG6k428Ck6olmDnZosjMVCTe55u3+LWu6qhAIFqsixtvg9gyj/ZInVc3OMYuq5qFsdTEPiyTrLG1eju1ER9r82BMQL40g4jcCKSFnElGucfMELZocT9BbaBwY4+qbkoxNl8zo20acuKeqgNVL1r8Z1vClFxhtV43DQc3Mh8CJ0Hy9cSguuaLlKy4hAGOIMGnJOX9XFsmM1YSbSw X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd876983-03b3-4417-c318-08db844139a9 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 08:06:27.9666 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uaSdY/QwJ8XqiCDo5azsGY7GAmDbZyqC2OluOZnYbFvKKpVwHt2fg2B+YSl3fUW/mO0iiwppjynxan2WbhesBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR06MB4059 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use devm_* api to simplify code, this makes it unnecessary to explicitly release resources. Signed-off-by: Yangtao Li --- drivers/input/keyboard/sh_keysc.c | 50 +++++++++---------------------- 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c index 2c00320f739f..388fb87f9e56 100644 --- a/drivers/input/keyboard/sh_keysc.c +++ b/drivers/input/keyboard/sh_keysc.c @@ -160,6 +160,7 @@ static irqreturn_t sh_keysc_isr(int irq, void *dev_id) static int sh_keysc_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct sh_keysc_priv *priv; struct sh_keysc_info *pdata; struct resource *res; @@ -169,44 +170,39 @@ static int sh_keysc_probe(struct platform_device *pdev) if (!dev_get_platdata(&pdev->dev)) { dev_err(&pdev->dev, "no platform data defined\n"); - error = -EINVAL; - goto err0; + return -EINVAL; } - error = -ENXIO; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { dev_err(&pdev->dev, "failed to get I/O memory\n"); - goto err0; + return -ENXIO; } irq = platform_get_irq(pdev, 0); if (irq < 0) - goto err0; + return irq; - priv = kzalloc(sizeof(*priv), GFP_KERNEL); + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (priv == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); - error = -ENOMEM; - goto err0; + return -ENOMEM; } platform_set_drvdata(pdev, priv); memcpy(&priv->pdata, dev_get_platdata(&pdev->dev), sizeof(priv->pdata)); pdata = &priv->pdata; - priv->iomem_base = ioremap(res->start, resource_size(res)); + priv->iomem_base = devm_ioremap(dev, res->start, resource_size(res)); if (priv->iomem_base == NULL) { dev_err(&pdev->dev, "failed to remap I/O memory\n"); - error = -ENXIO; - goto err1; + return -ENXIO; } - priv->input = input_allocate_device(); + priv->input = devm_input_allocate_device(dev); if (!priv->input) { dev_err(&pdev->dev, "failed to allocate input device\n"); - error = -ENOMEM; - goto err2; + return -ENOMEM; } input = priv->input; @@ -225,11 +221,11 @@ static int sh_keysc_probe(struct platform_device *pdev) input->keycodesize = sizeof(pdata->keycodes[0]); input->keycodemax = ARRAY_SIZE(pdata->keycodes); - error = request_threaded_irq(irq, NULL, sh_keysc_isr, IRQF_ONESHOT, - dev_name(&pdev->dev), pdev); + error = devm_request_threaded_irq(dev, irq, NULL, sh_keysc_isr, IRQF_ONESHOT, + dev_name(&pdev->dev), pdev); if (error) { dev_err(&pdev->dev, "failed to request IRQ\n"); - goto err3; + return error; } for (i = 0; i < SH_KEYSC_MAXKEYS; i++) @@ -239,7 +235,7 @@ static int sh_keysc_probe(struct platform_device *pdev) error = input_register_device(input); if (error) { dev_err(&pdev->dev, "failed to register input device\n"); - goto err4; + return error; } pm_runtime_enable(&pdev->dev); @@ -252,17 +248,6 @@ static int sh_keysc_probe(struct platform_device *pdev) device_init_wakeup(&pdev->dev, 1); return 0; - - err4: - free_irq(irq, pdev); - err3: - input_free_device(input); - err2: - iounmap(priv->iomem_base); - err1: - kfree(priv); - err0: - return error; } static int sh_keysc_remove(struct platform_device *pdev) @@ -270,16 +255,9 @@ static int sh_keysc_remove(struct platform_device *pdev) struct sh_keysc_priv *priv = platform_get_drvdata(pdev); sh_keysc_write(priv, KYCR2, KYCR2_IRQ_DISABLED); - - input_unregister_device(priv->input); - free_irq(platform_get_irq(pdev, 0), pdev); - iounmap(priv->iomem_base); - pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); - kfree(priv); - return 0; } From patchwork Fri Jul 14 08:06:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 703026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 704B0C001B0 for ; Fri, 14 Jul 2023 08:09:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235371AbjGNIJn (ORCPT ); Fri, 14 Jul 2023 04:09:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235093AbjGNIJE (ORCPT ); Fri, 14 Jul 2023 04:09:04 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2114.outbound.protection.outlook.com [40.107.255.114]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 421143ABD; Fri, 14 Jul 2023 01:06:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TGGfURbNU1t7V8A86NyBj4BS+/El9bcDntrr4Hg4CZQfsmNy7HPsPNzyAxF1DcAeF314H5MFZ3gRb08IfiHXntcw/AwsZR02YiV9Y0Qd+JMKBuft14If9pQB85xHq2nGFuN9xwGCSFMB9rNgGNLBthvlbv2DIBWblqQL3ozA9cm1sr2ACmasyV3ge9VNAFUsFFWL4E85xuDmUXQCJfGpbObAZFWSpUOAN/h6cYsE4aTzk7Uyj7FAckY485xrd45qpTmgEl4KM+WiA1EmOysT3GP2lAmJr5wbyoJx1yhUuL8ur/WFj7abkmRuuV2Nth8kqkEUjjrY1yaJuna/Uj2XIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=9re4Q/gFRNAj1/PcQBh25BKohWB/YpuBuRQVOHii2Jg=; b=dAW9h74EiVKxl1+YAjdgJj3jKt4EoO4gVxbLE0TTexSxSF5v0VrVKrE3JtweFpwN24v8xkw3y3I3O9wfaPhDvkz+J+rTu2EGEzuqA1urX/vj+WW/6pnLC7+ERz5p9ZG8sa25H9dvizxY9q3hAnZA9d5eWUAoQxooYraGikNy7Mk3Yqip4sq7eRS88RwyAiUNMIK4hDCbNpTDXDsUONvVLZ01OYc1DG/dC8z4NQhCWA0M5B0syfHFjF/m45zsKERWlNg2yJTwWi39d7sPkQFA5qmxooR8ajYKH9LXFKkviYklnKEvJkXWadjY6H4E+dEBM7J9NpswYQuLDIBT1r4MsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9re4Q/gFRNAj1/PcQBh25BKohWB/YpuBuRQVOHii2Jg=; b=EjX5b6a+SNEYIxFaKFO35Zqgundj7Nnnm/JkRvTSoZVM+SCiDCszQ2V9V+hmmluCT+5RCjHf1dC7XkRzavyzYgh9wOvr9ub+om06Bt4UjiDCK4ZueDfIN7AfoqDyet8amcyicmhAejfI9a4WKWC5SQjA7+y0nX/qIK6q11Xc2HFPF6otIkxa/OkQkQy5hAcWK8lhBENOHeKmVMRBjlGQBbmsA3rh9JSlB3UouZwBwSEwPpS7h3AqcrsYyhN0neT76hlCX3qYwyN9Cuy58VZYMnVHn5Pe9W7lJhTlc0BgoYd5XWMtG5eT3df313l8RRl2EX7O/COb7xaBqlneQ7iJyw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by SI2PR06MB4059.apcprd06.prod.outlook.com (2603:1096:4:f4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.27; Fri, 14 Jul 2023 08:06:29 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c%5]) with mapi id 15.20.6565.028; Fri, 14 Jul 2023 08:06:29 +0000 From: Yangtao Li To: Dmitry Torokhov Cc: Yangtao Li , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/8] Input: qt2160 - convert to use devm_* api Date: Fri, 14 Jul 2023 16:06:10 +0800 Message-Id: <20230714080611.81302-7-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230714080611.81302-1-frank.li@vivo.com> References: <20230714080611.81302-1-frank.li@vivo.com> X-ClientProxiedBy: TYCPR01CA0108.jpnprd01.prod.outlook.com (2603:1096:405:4::24) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SI2PR06MB4059:EE_ X-MS-Office365-Filtering-Correlation-Id: c1fe677b-081c-44d4-db32-08db84413a4b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xITJtHK0mdxG8AJuUA+ACoYUH8DjnYML8bOK77yCgHFZkuiowFl/2l6X1+EQzrnX1G5LwEGhDn3l7GPJiSY7prbQ643WNxkq6qW+MVtBP8rwbc4PeqettTrGw1U+G+Gl+WxNPap/L7sU6kYRHd0GkTdQ1XpEdugHK0go1+GHIh4Skl8jqEDf4Ge1vzCeQexquU5FA05g9MEK93L3Mg98P6XbHONQMetjH3lgdZ+/ZSz2pzav1Y8aaZr0Kt3MXj9xm0rb96b84WOHDvGGMGAQ9qgX1/qmsoGtTtOt+5jJrTnyZ8i7h7itv5fKYejN/RdmRhQPU5GGZGOUC97tgl0fyQ4bAPf3b8XPVxF2JjbKf5oFSyzxtYdAXnrJ3M2yQFF7m6wdYv75sElyzmuKmIgX/yPFCFsES7Isyqzorawwa3H9fzWQJ03gnM7ngz4AsmJB7hhSwveBUi3k3GgGEG7VziYZtp5Rvf8UYg4ab9486HcBscK8vq/Z5ChsX1mdKZsQgSuXp0IqbNBCMO1IYk1LUDDu6+MizYE7QeaEN2mKoA+O/BJNqRbD1Yi+Tq/W4sk1FlnBMqif1xqR5pJGYwFB7KZ2ZdHLpH6u0XmiJIvpcEKMPrJQWXZDFIuhcupZm3wQ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SEZPR06MB5269.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(376002)(136003)(346002)(366004)(396003)(39860400002)(451199021)(52116002)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(86362001)(2906002)(26005)(186003)(1076003)(6506007)(6512007)(316002)(38100700002)(38350700002)(66556008)(66476007)(6916009)(4326008)(66946007)(41300700001)(8936002)(8676002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: i0pMh7e7Nh6qAnY5GtwgFM7bgbnzE0UCaUA78G8nLXFXdl8OVd4Ugj1EiagjGRhQi3iHf7jh7yRvskr540mM+NJawPVTSN3WdrngM7gpLcfpQxNfUHHtvt2RR2IIm0eU/UksogDNFSbdTo5DXAfr0xPnvcOZ9yb2+pFLx+I0uzqN73pH7LrWWvTgM9ZF/y+SMu/lK0APhtEI4nv2P/oGe8SLRkePaWwp9FnzCN6zkLqiRWUSmC7ZQhrV2EqZuhEavnqt6pf49fcaxBPPZ3eOE1mfsDG41aMk+XtP2QvBLaqO6JB+6BHnkJl6IwHYJGbAebSYpxl0zeqyxObI349Qh7IDk3rwg3GB0ovvwH0vr4gvJh6Ic/dP2T1E9dzvTZGBh3JfSeT563kd9t2KIrfUeHa2EfizPvv/wy/dQt7xai4EkCvyqFU/xUyKfPVLlERF4m514KkF3OgZM1em+XC2oQ1i120l57wtfJsAKTc74id4rbCytGu+8Av3JoocTZeMO+hYU8DPCxEhNmRfDmjFy5kJvxln6kEi8PY0cItHLCBMiNYFTWBmCB3CSCrbYo6xJs9zf0DH9fE3WhthpEOV++0bypEm46hIx+0uh0Yp71PYKYFtHvJfXa7Vhxgf6zmcu6NtVBR+Y69u+KD5Yum3tefzYX66johQheOZFJWwr4XiI4XQz6XDMogWs5E3Y7YelYPd5/jg9YOxH/79N9KPPVLJcYbKGIw4AVL1svurG/etZznoiJRFDGjt0laZg1RNRE/lRkHSvdAbRdyM+yICJsMHf2VDJ4bxH/ENJq/Gp6vOt5cZOuqyVhUaHj1Ox2HJHKVPIDhUJgknQLifKEujqe5CWYxbypv2yUAZ2/65W0P8n7ZGaDVpq/q3C6/EDdFGJtXGQ6ifB/CAOUsU4AvkFg535wiz7xzG333zR+dJRlk5iM8ClEdnt4lxDTcciRN6pgnTNiW+d03YnRzGgNYnHalBB5P8MPKJ2Xy4LTzJY+Nd+bP0tJdEzQxl+CG4QxkY20LfHoU/bo+CZv6wQgL3ofApvi4jlO3CJ00NvvWdK2hotPRKYIkRgxACxA2uWBFreQlsiWxbpNvZ/yeNhZxBeB9tziK8N6RuYw65RDr2pxWo14ZWIoIiQXWgImOSA3MwFW7ZstB7CzLOV5tLvJ/IKake1at+H35Eb31xuc15b4fGJpzeLj6YAH1rBex9p8DUGTnjyQOj2EUTQRXnNJml+In//93fdYfdGYJylLfJRLcZNVrE/tPCZUxGBkGaTzmRG4WwxXg5+0CxFKs/l+dMRn/TLfsirZ8vsKjhrlQsuRLmjlbY6/nEVnBNOtekb7JPUGbnmymEELp/6LBLlwFONx++JwQXe1lQTSl/7ZHSqjV7V2iOAmKIoOGEyU3COQY8JjPK35GFka3ROqBo4DWKIa+yGW3hSoJvsg+0776u5EUHy2iYc7bY4D+n8g4AkZlD4dCYzXppGflKJHSzweuZ4KjTgaE+Lc86Y9x7JZ1GjWTGJot2NKqx3JN0vlz+ve/QTSt8Kk2SJ6S2MXUgKEjLys6U6AhXTJnDdjf2s/S6dTusigUSdqHtD+n4F0WPYoUB X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1fe677b-081c-44d4-db32-08db84413a4b X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 08:06:29.0419 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: b9yYkJikc4tEcfYvUO/OvRyLBTDLymFbYz025RBaaR9kdJDm0YuVbXq0RZm7lnpIHLzaRpuwZRGxTM+3sJFW1Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR06MB4059 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use devm_* api to simplify code, this makes it unnecessary to explicitly release resources. Signed-off-by: Yangtao Li --- drivers/input/keyboard/qt2160.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/input/keyboard/qt2160.c b/drivers/input/keyboard/qt2160.c index 599ea85cfd30..218ef92b8c2b 100644 --- a/drivers/input/keyboard/qt2160.c +++ b/drivers/input/keyboard/qt2160.c @@ -340,6 +340,7 @@ static bool qt2160_identify(struct i2c_client *client) static int qt2160_probe(struct i2c_client *client) { + struct device *dev = &client->dev; struct qt2160_data *qt2160; struct input_dev *input; int i; @@ -358,12 +359,11 @@ static int qt2160_probe(struct i2c_client *client) return -ENODEV; /* Chip is valid and active. Allocate structure */ - qt2160 = kzalloc(sizeof(struct qt2160_data), GFP_KERNEL); - input = input_allocate_device(); + qt2160 = devm_kzalloc(dev, sizeof(struct qt2160_data), GFP_KERNEL); + input = devm_input_allocate_device(dev); if (!qt2160 || !input) { dev_err(&client->dev, "insufficient memory\n"); - error = -ENOMEM; - goto err_free_mem; + return -ENOMEM; } qt2160->client = client; @@ -389,23 +389,23 @@ static int qt2160_probe(struct i2c_client *client) error = qt2160_write(client, QT2160_CMD_CALIBRATE, 1); if (error) { dev_err(&client->dev, "failed to calibrate device\n"); - goto err_free_mem; + return error; } if (client->irq) { - error = request_irq(client->irq, qt2160_irq, - IRQF_TRIGGER_FALLING, "qt2160", qt2160); + error = devm_request_irq(dev, client->irq, qt2160_irq, + IRQF_TRIGGER_FALLING, "qt2160", qt2160); if (error) { dev_err(&client->dev, "failed to allocate irq %d\n", client->irq); - goto err_free_mem; + return error; } } error = qt2160_register_leds(qt2160); if (error) { dev_err(&client->dev, "Failed to register leds\n"); - goto err_free_irq; + return error; } error = input_register_device(qt2160->input); @@ -422,29 +422,21 @@ static int qt2160_probe(struct i2c_client *client) err_unregister_leds: qt2160_unregister_leds(qt2160); -err_free_irq: - if (client->irq) - free_irq(client->irq, qt2160); -err_free_mem: - input_free_device(input); - kfree(qt2160); return error; } static void qt2160_remove(struct i2c_client *client) { struct qt2160_data *qt2160 = i2c_get_clientdata(client); + struct device *dev = &client->dev; qt2160_unregister_leds(qt2160); /* Release IRQ so no queue will be scheduled */ if (client->irq) - free_irq(client->irq, qt2160); + devm_free_irq(dev, client->irq, qt2160); cancel_delayed_work_sync(&qt2160->dwork); - - input_unregister_device(qt2160->input); - kfree(qt2160); } static const struct i2c_device_id qt2160_idtable[] = { From patchwork Fri Jul 14 08:06:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 703430 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 321BDEB64DC for ; Fri, 14 Jul 2023 08:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235405AbjGNIJp (ORCPT ); Fri, 14 Jul 2023 04:09:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234549AbjGNIJF (ORCPT ); Fri, 14 Jul 2023 04:09:05 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2114.outbound.protection.outlook.com [40.107.255.114]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 036F83C3C; Fri, 14 Jul 2023 01:06:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ecQZH+5oOoSCkvBqb0h5OR04mIcXixXgNGsdiXSaChQ1YoJ5Xe7NMLSy1oWUFQtRVaHWboB+zzTZT/NXgu/IkcbBWzFYvHtC2H+4T/f5YMzEzMEpn93Qz29nnC1PUeTNDfHWeN9PLNMV+lbts8F9DdPWFYuT1njjHA9S2nnhHO6Va6zx1L7eV2I9wMbtto7mYoxKsVfGiSuiI25ZLE+sbmx0QFKfGtQot+qxTjneQnLVD74yhBQHEDsOoIc+papmvzjOfZU6GJRTtKGjlsEZPqUwOrfpt2NF+ksVLRKhz+pa52TPPm835+n7wzy5woc5KuxiBPwYU51IBUTtVU0TEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=XYvLDm/pKKUutNnQiuINiUO7YGK/iWMOkQoVBqqH2OI=; b=D431eI1VRkLfGWfSLHjAqvyh2CXGzUZGPt+6hK7CbBgyDAgIV6KtseJ8FzjFoNid+puoYh4Jvk4eFdtcjmubtj5oqjf3RPNGyekY/iFUK8YIHiex5z+l+oSIB7ET7RqiRaJae+LhI9inYhcuVHaJJVqoIMcMtjMV310zakaCmYG4XxCjVvfs6OLo8CE8L9t1SIbvBa2/unTRgAXXK7oEjOoTp9GIXvzvgpK9RWDwmW9dIJFAo98AWVmpBXiKLtIZ21cQ+f1/2JZ7N59qlmon91RwUCQw30EswREjild8yKTRHJxMoU0tDYeQYgSvcN8UbB3Ue5AyxuH65mQCnAhchw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XYvLDm/pKKUutNnQiuINiUO7YGK/iWMOkQoVBqqH2OI=; b=KJH9+z0x2BnDbYxyxrI+kWOzqvjcwcgiDBk/4f72mHHLEuuTc5ShV4DdjLZp9qZBScYrPnlEW+HNarOWHkfVWYIsQnOVtwyOx+PIW+WpoHRoBgwdY0RilDbhPt4TVYRub5vjSpYnYS9yiJ8zNkHb/1AzuL1aEwNZIK9V0CUrlPyYcSUWfPOwDtZ5iJWxWdjBqGPScyhZJZ5/eU/q+qIepTHmwPkvJYb1ZKiSyROfHxnhU2ynIg4mGQ3oxhxRz2B8B4igJy0wqxEwZngktjc7FFh+zMC0U2oUs7nCy1iB8STwNEGqufcn8qS/KrM7wqIbuZdowdpdAeKyLrraBhMmvw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by SI2PR06MB4059.apcprd06.prod.outlook.com (2603:1096:4:f4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.27; Fri, 14 Jul 2023 08:06:30 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::fa0e:6c06:7474:285c%5]) with mapi id 15.20.6565.028; Fri, 14 Jul 2023 08:06:30 +0000 From: Yangtao Li To: Dmitry Torokhov Cc: Yangtao Li , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 8/8] Input: lm8323 - convert to use devm_* api Date: Fri, 14 Jul 2023 16:06:11 +0800 Message-Id: <20230714080611.81302-8-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230714080611.81302-1-frank.li@vivo.com> References: <20230714080611.81302-1-frank.li@vivo.com> X-ClientProxiedBy: TYCPR01CA0108.jpnprd01.prod.outlook.com (2603:1096:405:4::24) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SI2PR06MB4059:EE_ X-MS-Office365-Filtering-Correlation-Id: 4a00ad3a-11b6-451a-f6e7-08db84413aed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /cdqYTyD/DaekipDicjJSwTo1T1+08mjFU6DdYzJWK1UQ5slinLwxnDcpN8wP8VEI+PVOog6yCKz2IEeKN2zzdJm5hK619cVEhcKu/P+UPrvB4JUvPXIzXbE5N5XN8FCEX1w1MAyW7JB1qht95eEl/tknZ9LyMcCIXE8yugSrW2AIPNYSK1lsXcMaY4L/6oQSOYy7l5j+bfNXX4Oy9+6DxnJxfy8oDL/LaE0zeCuE2gbC8ztczMrV/NB5g6GltT8scntEVHN9gDa523adEwTkaDQ8YsGFwJZSz8Nnqk+blG9j2eAXBxtGfDW6Vk67NySb48rJ1FYPLRgnLa++0GiH2pcgI72qH1DQ1LMIPNFsFPWYwEg++njpA/qRXTUKq1uSCcNgFQl6rCM3OR1xDeKp1X3fAsLFGerwWzhx16GyOsBSgwWfPJRri4lXq56tUYkXoJ+A2b4JySjzElH325JIfI/15/tgcDkxnxVL72Jgq2RYMl3yXTD9sinVc7QzgVAts0jx3xGsaQOMFP/USALBF9qs4N2UPSYqAfrOaNqa6N0fVvfvQrBGo9Y8enxjE7JoDK2wAd0VpdVIe8eNTJsEokF47DwfRVBS/q28tO80Ec4iWrCme+vUDtSlfBchsXd X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SEZPR06MB5269.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(376002)(136003)(346002)(366004)(396003)(39860400002)(451199021)(52116002)(6486002)(6666004)(478600001)(2616005)(83380400001)(36756003)(86362001)(2906002)(26005)(186003)(1076003)(6506007)(6512007)(316002)(38100700002)(38350700002)(66556008)(66476007)(6916009)(4326008)(66946007)(41300700001)(8936002)(8676002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0gmXTj38e/u9IFdO55QhtleawSuFqOC0/2QK8KKwv9wlhtJZol76n+foiDicQIdLxxgQH+hAndCeo7l/JEMIrLBJIaodiwrLW52O2e7D70daOp27nu88e1QWUpM25CfZ7SrqSUOQWHKm3PUjViZCJtPUiUMhMZbXD1gJnlerGJO3m1m1TAWgmi+zmMqhNzre4QwaBHOxBWPRg+YI/614ZKVcrTVELYu3kRJ0DFazFSHa9mSiP8SChfX1AMpapYRF+C7C7oN+NC/bhbKFd92wUI5zJ67AEII6V4W7G+TNL/bQTgw47H1zjqCMAL7pDUQX6YR032t4gcdbq6ZvdYHQ6OZ81uP2BMobALovkFDsNnYC2xeJrsusiydnCbKLy2RwLIsWn27SG09hdeSlYWdMHJoKAGzsQNDKdnW/a362gdC8jotA6NaNY5OhiL6uuBnWp+zXhy7tmNmO6ZSfqtzkGOQ9qPg0qqayKQwU4r35pACsZRSri4n0fyVvuaeGKsS+//xBPhjRXyiDKkAbLtLMTTvTESDfpQU0Ura0TJex5x7rRQ4xpgRaTGDmV5w7MA3iZ+YZ0wTTo2Tnxm/6sViQAxnx1zRcycUHsQFU+KY7tkbm0H7UP1ZjiaeJ1Pt6nGPSQUU3DFFf8GFISG8vVWeApGmeVenIMINJmCr/qxqsSMNL4+ywN9vq/bLruTzJlXnDKCr6dEFQJQI1sh8UIAMgHCIrOikWT3Af9ybf3j9aXd7EX5118xr/teZ5w8DB84B+v3ZRxbH/LjMoyji8NOB+olX3LfgVHlRt/jzv+axoIO0mttCHhF+ZNbTsDqVg4th6dldGvs2R+t/bEngfrcIZ6KZB2pi1CWl1CaO5Rp/NfGDHRxFZY3Nz9qQ/RgMQlGJJ6WC/0rp3gonUjLe+Qs45MQnJ7ARLjBpBOaYjlF1l7I9URCFd6j9gxyk15TgngVqaFFh6XfETzTC+UvL1YhuN9leJLLc26gCbwW+rWiZ/vC3pEP2OAj5Yzi9iJgiydX88apxoPVplVPfATLaG0uZOEIoU5d2atyKYHACiAoGAPIEZSmORpOjQrxgwgeLSaVCMRufeaqbcwkuFLSiuH0+A37kPPIOXmrtWY/Q4BrHUP6gtRe5VBkqY8uSMQutwkxnelUF1XU0vef9J+A61BfdHyBdgUG5X1xG4D9/fksMX73VX3Q4EB9uwqYqYl9Oo4ALAXSFcXmDeQ0fU4VtWNYMio7fjIBg+Zbs1ncJ3LSZ6Pf9rVNmkOzrYLvs7vDTLS5oXXkF0+g3BfsEiMhYAvy7kSTuRR+aGQ7eC0rNvDoTy1BcE049h1OilAovbVmq8t8GOa4Zzu+LL26acHUdvqnjkwZCI4VSmkhQY2r/C3hRTdXI/zdvSjdz7wX/zm089PIhYqAEC8oS0SC5x0WK2n1CRbFo0vlHVU8bJGpLWh2NK3FYFaFjphKHjZgUU1kDgTceHuHMBiGuig8EYEtqC5vWGvadvhlxdlhTLM7MwB55Z5YT8G6nlQPUiIDc3h7k4s3RE4Wbj9qrTXg4l7a19ItAQy+pq9JVaKr5I97GoSc+ACWaaXerB8pA9XXbMUduRN1TI X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4a00ad3a-11b6-451a-f6e7-08db84413aed X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 08:06:30.0976 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Zvp//BzT1wK1sKkQtafs35lsyVZRMbKujMZDq+B8jxzlXbsnG0xqOP25VkBv11EVfPv3rkSos3cWeBqZvG8uxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR06MB4059 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use devm_* api to simplify code, this makes it unnecessary to explicitly release resources. Signed-off-by: Yangtao Li --- drivers/input/keyboard/lm8323.c | 41 +++++++++++---------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/drivers/input/keyboard/lm8323.c b/drivers/input/keyboard/lm8323.c index 3964f6e0f6af..d6aa4daad3ef 100644 --- a/drivers/input/keyboard/lm8323.c +++ b/drivers/input/keyboard/lm8323.c @@ -618,6 +618,7 @@ static DEVICE_ATTR(disable_kp, 0644, lm8323_show_disable, lm8323_set_disable); static int lm8323_probe(struct i2c_client *client) { struct lm8323_platform_data *pdata = dev_get_platdata(&client->dev); + struct device *dev = &client->dev; struct input_dev *idev; struct lm8323_chip *lm; int pwm; @@ -642,12 +643,10 @@ static int lm8323_probe(struct i2c_client *client) return -EINVAL; } - lm = kzalloc(sizeof *lm, GFP_KERNEL); - idev = input_allocate_device(); - if (!lm || !idev) { - err = -ENOMEM; - goto fail1; - } + lm = devm_kzalloc(dev, sizeof(*lm), GFP_KERNEL); + idev = devm_input_allocate_device(dev); + if (!lm || !idev) + return -ENOMEM; lm->client = client; lm->idev = idev; @@ -684,21 +683,20 @@ static int lm8323_probe(struct i2c_client *client) /* If a true probe check the device */ if (lm8323_read_id(lm, data) != 0) { dev_err(&client->dev, "device not found\n"); - err = -ENODEV; - goto fail1; + return -ENODEV; } for (pwm = 0; pwm < LM8323_NUM_PWMS; pwm++) { err = init_pwm(lm, pwm + 1, &client->dev, pdata->pwm_names[pwm]); if (err < 0) - goto fail2; + goto fail1; } lm->kp_enabled = true; err = device_create_file(&client->dev, &dev_attr_disable_kp); if (err < 0) - goto fail2; + goto fail1; idev->name = pdata->name ? : "LM8323 keypad"; snprintf(lm->phys, sizeof(lm->phys), @@ -719,14 +717,14 @@ static int lm8323_probe(struct i2c_client *client) err = input_register_device(idev); if (err) { dev_dbg(&client->dev, "error registering input device\n"); - goto fail3; + goto fail2; } - err = request_threaded_irq(client->irq, NULL, lm8323_irq, - IRQF_TRIGGER_LOW|IRQF_ONESHOT, "lm8323", lm); + err = devm_request_threaded_irq(dev, client->irq, NULL, lm8323_irq, + IRQF_TRIGGER_LOW|IRQF_ONESHOT, "lm8323", lm); if (err) { dev_err(&client->dev, "could not get IRQ %d\n", client->irq); - goto fail4; + goto fail2; } i2c_set_clientdata(client, lm); @@ -736,18 +734,12 @@ static int lm8323_probe(struct i2c_client *client) return 0; -fail4: - input_unregister_device(idev); - idev = NULL; -fail3: - device_remove_file(&client->dev, &dev_attr_disable_kp); fail2: + device_remove_file(&client->dev, &dev_attr_disable_kp); +fail1: while (--pwm >= 0) if (lm->pwm[pwm].enabled) led_classdev_unregister(&lm->pwm[pwm].cdev); -fail1: - input_free_device(idev); - kfree(lm); return err; } @@ -757,17 +749,12 @@ static void lm8323_remove(struct i2c_client *client) int i; disable_irq_wake(client->irq); - free_irq(client->irq, lm); - - input_unregister_device(lm->idev); device_remove_file(&lm->client->dev, &dev_attr_disable_kp); for (i = 0; i < 3; i++) if (lm->pwm[i].enabled) led_classdev_unregister(&lm->pwm[i].cdev); - - kfree(lm); } /*