From patchwork Tue Jan 24 16:44:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manuel Traut X-Patchwork-Id: 47780 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2263966wrn; Tue, 24 Jan 2023 09:03:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXuYNbZrvIpAlTA8xcSA3mmdEvR6gpfcacLkkW8r8G5HdtGlAK8q0wdbKH/uDRzD0NFaoa5z X-Received: by 2002:a17:907:8b98:b0:84d:44dd:e03a with SMTP id tb24-20020a1709078b9800b0084d44dde03amr33877323ejc.57.1674579807188; Tue, 24 Jan 2023 09:03:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674579807; cv=pass; d=google.com; s=arc-20160816; b=yMyGadEtzlZhSwOzkTbNUhlasZbKfMm+ttJGy178KBC743Upzscrbc0VzE25LBJdZL Gs98KoWbyrBoZCtUHQ+MlQd1n6qw+8o1KZMQbmEch/V2tBCzUua8rV0ImhHPVYDQXtCR p4acau6VJGhG4VRuSWnYNOb1vEwQ4IJ8kdsRdmLOPtXYPdYNhKl7uT+MbRLLYjBO5WKD 03K7YDjDDgBxgRQQXqii2/ZMBo2e7TUfwunZMib3QX143mmc4YFZ3wleR9bkJ7RFGkx1 GSt+0GCK5N31CZK4qaUagjye2daSfgeb/hCiefnqX8JpeIBJuGIxm14DAI/IsLb2gwFW C04w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-disposition:message-id :subject:cc:to:from:date:dkim-signature; bh=MPJNZHYLnRKCBG/xVFcDHq+Eqy5RvEbA+M00/mDWA4A=; b=0czNd/pUvkAkYvYeMmpx6VH90g0qvSRIO1AIA4N66Nmo4aLblsYAXQNQjBUXDeWgCU TG7KxU7mfoCvBwwZoZpceCHZHy1Pfh7qEYuz0BObmsaWkUpINIio70wh6oZ5DdYDt/mg vkp5huvjLN2R35rdS6ZxBtHRY00XalCcQZw3aniVLJ/HeCje8akr8QUGVD+B4BzrdvU+ etJ5odyvdIn0MCol6vSzS+h7iiqCEKRvElnHTKKyq0i86XY0j44hcko3+AfZjQ6WsAow ql29JPQbGj2A+btuAnxeqwQJ37ehJXqXi7XgkS6BwOxWEXXFgyHz2PnfLeYu8xwNqrr2 pIlQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mt.com header.s=selector2 header.b=sGWSP621; arc=pass (i=1 spf=pass spfdomain=mt.com dkim=pass dkdomain=mt.com dmarc=pass fromdomain=mt.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 30-20020a17090600de00b00871a4e8d7c4si2859810eji.767.2023.01.24.09.03.02; Tue, 24 Jan 2023 09:03:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mt.com header.s=selector2 header.b=sGWSP621; arc=pass (i=1 spf=pass spfdomain=mt.com dkim=pass dkdomain=mt.com dmarc=pass fromdomain=mt.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234312AbjAXQoh (ORCPT + 99 others); Tue, 24 Jan 2023 11:44:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233843AbjAXQog (ORCPT ); Tue, 24 Jan 2023 11:44:36 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2138.outbound.protection.outlook.com [40.107.20.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ABF0172B; Tue, 24 Jan 2023 08:44:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zcu+tPwNzaeX+/SayU5fPOZiGVaVTd4aEjJkia6668se/09B0QlkqXnqj8Fim+20bvZzGOMGxKUEGOCDz++y13udcOZ+4ULZ2WLaO4dL6/CJk4lViAWRbKFhOzQHQg/DJVLDhsJrT2qXcLpqDXSIyq3HxJ4zup8LabR6/3NxqyH6Ew/K+DTvdWgrjuW5n6ZUe+rPORsEUnYO1aUAjrkXS/3ATiP/esfjPvpTwRcvTpS72yXW4pTdSaTH2DhyUqx4D7jirXheJfJsBG2Psx0mfnLJrwHu02r4KiUEjzyWFbTdRNuKkGuGe7LRPX0JMBYZIHH11B1vksV1KJD8xwP9JA== 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=MPJNZHYLnRKCBG/xVFcDHq+Eqy5RvEbA+M00/mDWA4A=; b=ab80QRK48xRAkh/Qmhvx1Mb9dk8S1YSaf9b2ijY21f8tYvup4Xl4tN6RD4aC8zSdrrZAA8X1BJGmIYknNJjktN9ew7kkyKwX4/qScSIr3wibKlNLx584t+M1VxfGWPogSsjkQ3Dhoe7Za8BDjYWBOusdkmIUTU2aqsKq+sC9HNohPqXAYKLDZaUMF3sf3jvoM2KZWC24aPunIeo3/gob0zwTLx84RM8ewzArSa7E28lAnzITi2n3yTz8Mln3kcKLHMqTF85tBig52elB+0pnAK4yqB1LwUGQr8M2oaBFACZfk6OO0Fentg/Ix7HcOZ9HNhbHUcM8L1VV2g9xJ0zYLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mt.com; dmarc=pass action=none header.from=mt.com; dkim=pass header.d=mt.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mt.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MPJNZHYLnRKCBG/xVFcDHq+Eqy5RvEbA+M00/mDWA4A=; b=sGWSP621tGtfS2Wa3ntyWBpJSr3V7Elll6qLiLip/h5TFi+p9D1NtrS/YACXlyOrnP4Q9ZhTglbmdkq9Bd4igaL6IFuqbEy0Curyedsdw/b5JfTle3EludV9A/D3BRBImiMtcK2a/yTnb02PUiV/yyRXZQDOJuxEvNu2z6p+eQ8AfORmEvKTKH1bWVZdxY8pVLhqbSs+VL1tdCrv5jyjb1B1XcWxAwAxbSrz9DhhVLVMNqAqSd0V7Rx2jndJ/tgIyOgunkodSZLG+c2MB/8WGEIpcKUHsjWW3Fe0vtgbXAyWc1ZGUNpwyWCEUlnQ4GnpyQpGSmWdRfR9DO7NPER99g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=mt.com; Received: from AS8PR03MB7621.eurprd03.prod.outlook.com (2603:10a6:20b:345::20) by PAXPR03MB7981.eurprd03.prod.outlook.com (2603:10a6:102:21b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.28; Tue, 24 Jan 2023 16:44:33 +0000 Received: from AS8PR03MB7621.eurprd03.prod.outlook.com ([fe80::b42f:82f8:24cb:a225]) by AS8PR03MB7621.eurprd03.prod.outlook.com ([fe80::b42f:82f8:24cb:a225%5]) with mapi id 15.20.6002.033; Tue, 24 Jan 2023 16:44:33 +0000 Date: Tue, 24 Jan 2023 17:44:31 +0100 From: Manuel Traut To: linux-kernel@vger.kernel.org Cc: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Frieder Schrempf , linux-input@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 5/5 v7] input: pwm-beeper: handle module unloading properly Message-ID: Content-Disposition: inline X-ClientProxiedBy: FR2P281CA0020.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::7) To AS8PR03MB7621.eurprd03.prod.outlook.com (2603:10a6:20b:345::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR03MB7621:EE_|PAXPR03MB7981:EE_ X-MS-Office365-Filtering-Correlation-Id: c9b26b8f-6e43-4bd8-7204-08dafe2a4554 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XaPdC4ffOIqXhad7C4pIxXbSltKuxB3SMn6BwWPFyrNg9u/EBlYjpmVl6gB6ZoFYfo0b3zCPDpxj91NxDICQlZYLh94DrCYIvmTw14UAbQf4MD+nE3puts1PyhDPvVLzgMtWE3eCN8WOYQa9fCYQnh5x/7ARXzEqRESSTXdj3xnAleaHptsiZsm6JNpPrifrIQLik1ZtIcDZKFu7vtkWu2WKZT5AqepbhR1p8/ufP5ZwL9E/3JkNZjRwBEpy9be7/+d2cN9rP9V4U+KerSe0hUsp5DTnR5lYEvpRbit05hTkElrfhBC45oDwgMyve3ZoDMk0MFMgI597lNgpVW5D6mcwMfuEM4Sh+vZyIJMtXS9C5HObuabjrOoFDf/0ZDQdIMU8GTo0Mkv1yCXqaoxnw25VLthACgoji6u8GSCvGY+yl0Ain5DABP+aIoFIqaGHj+VQj8Oq0+WgaS6kOUqdqD06p4XWQGvC4OnTeB0KefbNyRkpYNkei2ajlPUCAgFqVUu6ckP4IoZr8sXD3kW/lZWkpngSl4W8iPhZarVYMCqQZjG65AT61+wMojzBsAY9JL5M68ucd/tareq13tuq5BKi9wX+i7pKst0n2eXgugMaMcHKEG1nZSeEDqXmIAAjzWM0xPs6Z28ylqdSdx/rx6uXXnZJqjCgE06ii7JISKLNNovmewqnU5CPP8bUInz0xr8yToX2pOwV6D44HFwruAfU0z1Be/Ov51g0vY7mOik= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR03MB7621.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(376002)(346002)(136003)(396003)(39860400002)(451199015)(36756003)(66476007)(44832011)(6916009)(66946007)(4326008)(86362001)(5660300002)(8676002)(8936002)(66556008)(2906002)(38350700002)(38100700002)(316002)(478600001)(52116002)(54906003)(6486002)(6506007)(41300700001)(186003)(83380400001)(2616005)(6512007)(26005)(67856001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?fH3HDqNo5XnNQYdgNmiSdQyD5odO?= =?utf-8?q?hdgUvLC128aptqGCH4HEm8AWyvro474409+a5bQ2Xl93JAUwwYfHgsM37eb2KV3im?= =?utf-8?q?WPA7hR+tZmGz+kTXUwUd5z9nZ+EPscYt/mOHNIJbkNLtfIB3XMw55xBs8PK3leE6I?= =?utf-8?q?/kr9+D0E5il62Pj3//8M7zs8wYdnX8IAOCIubupECPMzsZVhifjxS2HtWCQgh8Zsn?= =?utf-8?q?UMH+iD2Ub/7p1d4cuhSOOKDR1qHf884b/+HSb1JxFuefjqXyfc+7mJfkA9GyP1Pwn?= =?utf-8?q?X9aIprFxOYkWzxsQ40dlwKJmYt5J2HGjyHW43llTno5S34rNnK0VwZMYXp63+EFS7?= =?utf-8?q?9QZ4EP+pxrR4zXw9oCw4QfFotzXWnZEcLlVFTO2my9I3c/INCvFjxeyoxu0HCj2Yd?= =?utf-8?q?/kt19XNBmhUzL4S9DYSrsfk5xgUk8V6S4KfHu9bmHAVc3PhmE7fBEQiC6Uy1YFrFF?= =?utf-8?q?G3FKyvk3A9hRAw/NuUriHgv1V0Ngiy1+yak9xWGcQvMClJk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bBoWUYxEAvmxVxALdLaB4?= =?utf-8?q?s/XMsIhnC3hvJmIqmF4zQMDGIQFTZ6snvUkE0CL4kMm3pHHvj1ULcF1FpTXuJHgyE?= =?utf-8?q?j3RJ+A1KMz2Mya1+elR1NYOaJ8Q7RmzR7aPXh+6wyQ3SkM2mPc5vn+OJWrtDshVL7?= =?utf-8?q?1vqRjokcToxP?= X-OriginatorOrg: mt.com X-MS-Exchange-CrossTenant-Network-Message-Id: c9b26b8f-6e43-4bd8-7204-08dafe2a4554 X-MS-Exchange-CrossTenant-AuthSource: AS8PR03MB7621.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 16:44:33.2683 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fb4c0aee-6cd2-482f-a1a5-717e7c02496b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dzmWVYX/+auwnbYlTratqUOOkxdoc/3QRwJFMEDl9AP6VrzyaV39eO8slhGrcMdNfuSIxzvuFZz6wFi+SzyimQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR03MB7981 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755924195426891993?= X-GMAIL-MSGID: =?utf-8?q?1755924195426891993?= 'input: pwm-beeper: add feature to set volume via sysfs' adds device attributes without removing them on error or if the module is unloaded. This change removes the device attributes on module unloading or if registering on the input subsystem fails. If the module will be unloaded and loaded again it fails: [ 1007.918180] sysfs: cannot create duplicate filename '/devices/platform/buzzer/volume' Signed-off-by: Manuel Traut --- drivers/input/misc/pwm-beeper.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c index fe543c4151d6..8ef2937e8f21 100644 --- a/drivers/input/misc/pwm-beeper.c +++ b/drivers/input/misc/pwm-beeper.c @@ -300,6 +300,7 @@ static int pwm_beeper_probe(struct platform_device *pdev) error = input_register_device(beeper->input); if (error) { + sysfs_remove_group(&pdev->dev.kobj, &pwm_beeper_attribute_group); dev_err(dev, "Failed to register input device: %d\n", error); return error; } @@ -309,6 +310,17 @@ static int pwm_beeper_probe(struct platform_device *pdev) return 0; } +static int pwm_beeper_remove(struct platform_device *pdev) +{ + struct pwm_beeper *beeper; + + beeper = platform_get_drvdata(pdev); + input_unregister_device(beeper->input); + sysfs_remove_group(&pdev->dev.kobj, &pwm_beeper_attribute_group); + + return 0; +} + static int __maybe_unused pwm_beeper_suspend(struct device *dev) { struct pwm_beeper *beeper = dev_get_drvdata(dev); @@ -354,6 +366,7 @@ MODULE_DEVICE_TABLE(of, pwm_beeper_match); static struct platform_driver pwm_beeper_driver = { .probe = pwm_beeper_probe, + .remove = pwm_beeper_remove, .driver = { .name = "pwm-beeper", .pm = &pwm_beeper_pm_ops,