From patchwork Thu Jan 26 09:18:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manuel Traut X-Patchwork-Id: 13116812 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 2D9B8C54EAA for ; Thu, 26 Jan 2023 09:19:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236768AbjAZJTX (ORCPT ); Thu, 26 Jan 2023 04:19:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236836AbjAZJTK (ORCPT ); Thu, 26 Jan 2023 04:19:10 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2123.outbound.protection.outlook.com [40.107.247.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DB3E6DB11; Thu, 26 Jan 2023 01:18:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OsAmPtZwIYilyABwT/VcQ9M1D9A2r/zvPK9kEAJtkPLoD/QzklunXknMxC1qt89gmKOzKWYYuuoDpPjbeVA3umquj/+dSYrypmOsE1AZ86owuudqCcDv2mPU0ZBd0DSwXE26KMXTXxkMRnDdplGTCOvLe9ihWI65103LZg7/7E2cCL/fpMpEcS4Ip5AoJk8RPk3LYqo2NeqqXnYulGwcgpltGPGhbMsclxojoEu9WQ1ft9yGBEHe7r/fKxfRKof0OXa8O6pcMA7Q7AYZJ5Pmjro6fF9MQprKvzcRTOwmKr1Aj9VYFmnSSwjbhFZbmZLlE6AjVwdLH+OReLiUo4oS8Q== 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=b09xNOJk8UPM1c1cvNP2Dg32225UmVsv0xJZ3OX4H5o=; b=fYUWoZGw8fUu350QYAIo5HwHIZm7z751x6siQmHyIfjEcrB4FJqI+Yz2Z/G9+yQRffKaRrsuBXfTQc83joH77FMsqfKfnJYATQRIraLEQ5WyajGTn2uOKOQcseiI08F0vPWWeV6Vyv6mRg975yjMAQeTeCyIAJ2yEQ2m3EV8gwdii+l9dnD+3ET36tsuTFHTuHAxmgyJkv/rDB4rVmO80Fy6Gc7eTJrvcWIi5hI+ctyIPKJICk5bVPMFDdL09IjV23CSe8dFKVH+OGz8bJZoWi8QxsBPbmEKgwg6Go49bJ5s0U4iOTu5kESdO8Yhx0Fjx0u85YQeImfGXdt9siwZtQ== 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=b09xNOJk8UPM1c1cvNP2Dg32225UmVsv0xJZ3OX4H5o=; b=m7tWo6WKmBZl3qd54txkhQCMXoDZmOLaHw5B9XAnwug0mxjVR80cRJ8zh4hz9ZFZcmEbA/gBV9gGe5IqMmGfzt0qMLpv27AASbiqI/GecbdhpltBgn+XLyzLmGB71KQjrYRlemiRs9E0bjR+y5vUO/W2NdN7mmArZjJvikDlI170a6XnSviZ8xLdYTfVMK4MaAYrhp4uwYcO+t1075keWl8MvjSdwfpdnY2cZGWgAhfZ7qJBa2tMmDLxDmkXwa74fLgjmBtUmdhhNdomdqD3XgHr35wGlohBDfTv4l7/hPZ7j4byD4F3FC4p1o4XwcMBOMYxZHsU8DBI5fnZMU5bVg== 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 AS2PR03MB9516.eurprd03.prod.outlook.com (2603:10a6:20b:598::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22; Thu, 26 Jan 2023 09:18:48 +0000 Received: from AS8PR03MB7621.eurprd03.prod.outlook.com ([fe80::b42f:82f8:24cb:a225]) by AS8PR03MB7621.eurprd03.prod.outlook.com ([fe80::b42f:82f8:24cb:a225%9]) with mapi id 15.20.6043.022; Thu, 26 Jan 2023 09:18:48 +0000 From: Manuel Traut To: linux-kernel@vger.kernel.org Cc: Manuel Traut , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Frieder Schrempf , linux-input@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v8 1/5] dt-bindings: input: pwm-beeper: Convert txt bindings to yaml Date: Thu, 26 Jan 2023 10:18:21 +0100 Message-Id: <20230126091825.220646-2-manuel.traut@mt.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230126091825.220646-1-manuel.traut@mt.com> References: <20230126091825.220646-1-manuel.traut@mt.com> X-ClientProxiedBy: FR2P281CA0141.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9e::20) To AS8PR03MB7621.eurprd03.prod.outlook.com (2603:10a6:20b:345::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR03MB7621:EE_|AS2PR03MB9516:EE_ X-MS-Office365-Filtering-Correlation-Id: 170e5c76-ed1f-4805-e5cb-08daff7e551e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oTsXuc5pMDXWiivY9vCWNOJrrrSvTaG44hEemy9VdXZ5QN/WSh49Lj3DmXsq005jiH+30PB6PqUYUOGhCV9KoNSlIUtdu+bH1n1Jp/SxRfs2m4dMh+d2EjoUsOA6QuksBSrIazr/ZaIE/MwWBLOQDEokVPUdAvqCe8CT2Ylu0rpplUcYIORkf5ziLMlgyYtUYO1q4zVTrgVrKm7JaNWtb0mB+3H19CllAKvtcfV3l6aU84ThUPmRkLwSM8Q+fIPC6pHmJVB8NkJrTGsX6sfw8CAd5VMeDQct0GZVjT6ULiPHN2Wgqe0axCtRu6yq93R1vSXsA7ylco6kBK9wHuCMpCXbCefxrD18jhzjugtcpsV6aWWGq3ANIvqBWid+vSpinz/U5q0foCrQU/8/nzT6FCgC12RqAbO/dCcNea6B/8B7oiGV/jKhL+ClF/bzJZ2b2tmiyoN9g5P1CfxuJxle1BaYoWMTut07jtnCO7E+jeuIqZgQgeF/gss3DC/wNNkkUXyE5O5CBhA99PFAT/tRoPs08bApJjtIvJBXGFNZ3HS95/307itzlpCAPvoUc7eNeq8REfHzniW5V0cPFoNlKh2kRFowAAL24+0+d0MtIZ38sPNkSYuNiOigHHpm7vrcPZ0xs6dNXyP2H9itgJctIeLJvAg2bWHTc+KIlIwAk8Y6Dr5eMjlwnKdKqAu4wGyheIBE7jOJRYNlrdirUCdjlImkrytiSD0jPbI++TwBTJM= 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:(13230025)(39860400002)(346002)(366004)(396003)(136003)(376002)(451199018)(44832011)(2906002)(38350700002)(38100700002)(2616005)(1076003)(6666004)(6506007)(6512007)(186003)(26005)(86362001)(83380400001)(66556008)(66476007)(6916009)(66946007)(8676002)(4326008)(5660300002)(36756003)(41300700001)(8936002)(52116002)(6486002)(478600001)(316002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0iwx0g/Z+YWgwbqu2T5V6y1C8JVXQ8G0GKSoHcOTBSKcrvabESfZL1dkzDwUrkc0lvnU4L8yVDHww05/eqNqcLhrb0f0c0eXOEWiaO0bViGh45BGKKBDKX69N2n/E7bitjGYL0tY0ukWV8ihWr4m6vD253fgX8Wtx7jnOfbbbg0xI0rQLrVEdF5v+LBxpVv57czModX0cakw0mM1+RTOFKRcGCEFmbAgtYOwzxhn/L48BsulVzdjUM5B6BghtkLrmk8My3W31PbUXKrH7OV5Y4qNkLnyES1BewwWlgR/8N3oyLHj+HPiNMpvgHEYJhE2fpU8DC9ZvJfMVDF4sEdRJ6JcQBwSFRNCv+5BkBj5rhotiaM2X2h+UmSf2/4Pne1lZokO+s3mg9Qt/EhpxwYz3yVx/387SlM2Z8WeICFLBeO7idVLAFyQQwDeCiy7jFNSVW4M7dQG431ynl2KJaf9d+eFfTxhAX4/11pqB4snk7EdBSpHO1r9tj/bO8Ldw53Q2OgaOu+r/CY17VVsZWrQG4gIHxTliXaWn4gnLCrxpZ72gc79OTKNYv01wwe2wtnY6pKriJ1OS0N5pYnOETL6MSHSL41A4IaQm7tW/p+NAohgit452+rs8ECzi3IEQnM3Z7u7LBKThHrzYKTs91AddEJkgJC9rAMCvrIwus9ZUiLIKyrsFH/6yBU/3x+nS+0gkSbZEFlUDxLWaXR0j00m6XyVtzJ/98im7yUru6tGIoW5nuJwSJzPV7oHAhushw5SPrWH5VL2eLwaJUk21QcehWs4HBQdWgoLchKV0nY6fmcC7cDgnOVktJ/Q7cegKeB4WnFyi/wpABBvFeqIc0d01VKW2WT2umshKmDU7yEk33G9HN3MH4YPdKEIfi1tW8mnnxXjzS/LOwPhKJrHL7ghMVaeNWq75pxPQoF2uLw+RIaeU8jelvwArCXqSa/J9YtJDD5+FEfxtNWvN8QpnMSsmltPLdSG3are0s7SjBvucyYy3hBVNp5JjXVGcqX98xyAGlYIECyjwqHTypQDwgPxIErDb307KtcQ7gSGXPXtEvi4p73t8tlBngelqGZPTVCLKyn1MeXmA3j8M+sYDaEw55JvByW1n5ffUgdp7V2IgurKAAyfuw8wDsnalTK9uto4yrRmNpzJt44h6bg6OxrRnOUjLe6OhWC8IvcwGMQaDLR4llf0/HXAoxlVZS/iyX4j+1NLWbffUo7Zlx7O+bag390kUSmuB+XEgyW6AATs62FQ63URYnBBSg5gk5mHJp/hAtDwmGEOOhmWitVhLgiZsx3MRFhws2jgCDTdsWf0ReCCpemqn6+UEsFXanj+5UohbkZFDn8qI6NiQ6J2TqODXCR9nN93bfUfByTwfjwmBAwMp4nG2V3dUrFKLyVDniyLeQCk1FIIvJJjU6yZomh3dNdjRLLPGOg7p0NqOUJ13F3+SJBNYjgkNvWgDu/e59CBwJTLLNZFq5AlduVo/jy15CaHGH8VBZanuLXl3V8eRPo1A5dBlXLit4oaYT/oMR3oMad2K/OauCICNitjpSlcaIq/nhT5Jk09QSsEMo0/nt2Sr0sgruXYgc5nGTmhq9QW X-OriginatorOrg: mt.com X-MS-Exchange-CrossTenant-Network-Message-Id: 170e5c76-ed1f-4805-e5cb-08daff7e551e X-MS-Exchange-CrossTenant-AuthSource: AS8PR03MB7621.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2023 09:18:48.6178 (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: yvo/T5yPlQy0Rk1cWSJlS5mjnBrtprWDji7XhNpRVV3mnNx1DeBlH9p0vZpWIx66IjdYAktvhHQn+onefUViog== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR03MB9516 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Converts txt binding to new YAML format. Signed-off-by: Manuel Traut --- .../devicetree/bindings/input/pwm-beeper.txt | 24 ---------- .../devicetree/bindings/input/pwm-beeper.yaml | 48 +++++++++++++++++++ 2 files changed, 48 insertions(+), 24 deletions(-) delete mode 100644 Documentation/devicetree/bindings/input/pwm-beeper.txt create mode 100644 Documentation/devicetree/bindings/input/pwm-beeper.yaml diff --git a/Documentation/devicetree/bindings/input/pwm-beeper.txt b/Documentation/devicetree/bindings/input/pwm-beeper.txt deleted file mode 100644 index 8fc0e48c20db..000000000000 --- a/Documentation/devicetree/bindings/input/pwm-beeper.txt +++ /dev/null @@ -1,24 +0,0 @@ -* PWM beeper device tree bindings - -Registers a PWM device as beeper. - -Required properties: -- compatible: should be "pwm-beeper" -- pwms: phandle to the physical PWM device - -Optional properties: -- amp-supply: phandle to a regulator that acts as an amplifier for the beeper -- beeper-hz: bell frequency in Hz - -Example: - -beeper_amp: amplifier { - compatible = "fixed-regulator"; - gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>; -}; - -beeper { - compatible = "pwm-beeper"; - pwms = <&pwm0>; - amp-supply = <&beeper_amp>; -}; diff --git a/Documentation/devicetree/bindings/input/pwm-beeper.yaml b/Documentation/devicetree/bindings/input/pwm-beeper.yaml new file mode 100644 index 000000000000..351df83d5cbe --- /dev/null +++ b/Documentation/devicetree/bindings/input/pwm-beeper.yaml @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/input/pwm-beeper.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: PWM beeper + +maintainers: + - Dmitry Torokhov + +description: Registers a PWM device as beeper. + +properties: + compatible: + const: pwm-beeper + + pwms: + maxItems: 1 + + amp-supply: + description: > + phandle to a regulator that acts as an amplifier for + the beeper + + beeper-hz: + description: bell frequency in Hz + +required: + - compatible + - pwms + +additionalProperties: false + +examples: + - | + #include + + beeper_amp: amplifier { + compatible = "fixed-regulator"; + gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>; + }; + + beeper { + compatible = "pwm-beeper"; + pwms = <&pwm0>; + amp-supply = <&beeper_amp>; + }; From patchwork Thu Jan 26 09:18:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manuel Traut X-Patchwork-Id: 13116813 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 49965C61DA3 for ; Thu, 26 Jan 2023 09:19:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236786AbjAZJTZ (ORCPT ); Thu, 26 Jan 2023 04:19:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236801AbjAZJTL (ORCPT ); Thu, 26 Jan 2023 04:19:11 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2123.outbound.protection.outlook.com [40.107.247.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA80E6DB14; Thu, 26 Jan 2023 01:18:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ts1j73u6yCokLSghILYKzhv2CbswEGE6sAy25iCtcFKIZuW2tGlIVIAkrv6FJR1Q49O6qCZRbRTxGfn55uGHu9xgGI2TvQzmJRw/XoOnL0I98DwxR4mQDdzrtiIZEwaZfIjSRhW8RqGXtDewnwBxR5TXNV96HfCuUAQX0yKrfMMJ4PU9joVndM2wsvnlkeh3kUUVFy6G95VzsRPaDHu4BsFR9BrTS6UuSKd5VEuVRzQcBZpAIaVcWk4V1qCvF/Wf8fKle1vwxUQmsHIydjLGMH8xjytyV8x80EE5sTOKcSs+TP1Q5jj16Kjdd5rigFQ8sKov2+3nsAWkLFkFApT5GQ== 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=5qZ+QAPBkkp6i4N/ZgKEFvHq4ipLNJJbcuwCaeCLOdk=; b=dAR+BmahHX63Y3xmRwvnu8wq+zhRf7SZpqx5BwQu0fV1jNy6AzVrD1g0HnGTXIP8MvzLKhOVDA23zpgadNWbLTwBjsdSsQ6CBxDcPGTa9z8JACnjQQ8KoioRdcvqQ0ZBwPp4wgxcDK71BW/6z38zHt7Gcp92jfZEd+VggX5ICEghEO8u3YkuFP3Yf/u8/EvZUpWVThHWbPLmN8qU7LtAd+r5NpY80VBQnzfHcIxf2Nqc+uI2W7Kk8WVdwydSU7T1XXRZaE0xkgR5kkR0mhTKxGIuhp6AsvkZoU3Cg9L5gSmza+RAW7lqp8lA+fE8r+RBHnaaq0jIx0JH/1/jU+fkqg== 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=5qZ+QAPBkkp6i4N/ZgKEFvHq4ipLNJJbcuwCaeCLOdk=; b=H+hNOrhAdyHFoLTE6NEm0IlUKrGhPKvL3InOHiCjYogQpj+vgIVaEveJbi1pOPTifS3is4iHYaiW1vdvIOGXphLo4N17grGOifNCa7Zh/oBa9e1DMEtupbNoheC0krtmY5xuHSOd5Un2ZNsrSw+FfhmsMhotdBOBPaOAxBBlqB8HLrIG2lQc/4ulKisiRKsXV2OgeSCBXFuy60eJpPGd6W/qtqU+Z/gG9emy4h/PbAVYG7v0oz6aKroEtQH/Rp3S06dMqW0PZeKLFnYTDmjhgy5+2zdQMwddWB4WTJ1q3lUcFjAbrHZ0DCdDujL/vtaTKFqG2yaSHCgI7DFQ7aNDvA== 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 AS2PR03MB9516.eurprd03.prod.outlook.com (2603:10a6:20b:598::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22; Thu, 26 Jan 2023 09:18:50 +0000 Received: from AS8PR03MB7621.eurprd03.prod.outlook.com ([fe80::b42f:82f8:24cb:a225]) by AS8PR03MB7621.eurprd03.prod.outlook.com ([fe80::b42f:82f8:24cb:a225%9]) with mapi id 15.20.6043.022; Thu, 26 Jan 2023 09:18:50 +0000 From: Manuel Traut To: linux-kernel@vger.kernel.org Cc: Frieder Schrempf , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Manuel Traut , linux-input@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v8 2/5] input: pwm-beeper: add feature to set volume via sysfs Date: Thu, 26 Jan 2023 10:18:22 +0100 Message-Id: <20230126091825.220646-3-manuel.traut@mt.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230126091825.220646-1-manuel.traut@mt.com> References: <20230126091825.220646-1-manuel.traut@mt.com> X-ClientProxiedBy: FR2P281CA0136.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9e::18) To AS8PR03MB7621.eurprd03.prod.outlook.com (2603:10a6:20b:345::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR03MB7621:EE_|AS2PR03MB9516:EE_ X-MS-Office365-Filtering-Correlation-Id: 2cdc028c-31d6-4b42-9b71-08daff7e55be X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cWhvEMT4c2QiWAg6e6BKS5E9eCyeL+NL0LHA5I7JMzSu1rQ4jiuQBlR23z4wKO7QU36jolttbsfESC5WSmQdKkZnbZtdH0UhnhWcgei8ZRlQdrnpPQb6AU/BpSHwcytWI0um/uCEDaq4BQhZcSICk/nmJNWJqFnrJ8Fr5GNlY4z0BK2VjMW2j9TDmJPnX+vRcJq/JEWoENiOpMvCC28CK9UjFczMOHI2j4jqw9uS88PoZ/Thc1NtKXHXl+bbs2bQM6n9dYV5P7VA5jhi5XKsdJnHrlBfKLylQVWntExUzqjNOdDNB9QDCsKzaUaDGF4BR5vMaRPnf0oZkoJkZO7s0CNJ3hFjuCDtS10abslUdW/Q40OvOFEzewK7tE+kHUAwowECuSdZrOpCHUVRBSpKL8xhskQT4xoBksS46ZJkuXSFwOPvXrwv2r9pN9CH4KU7EhtxzPeS+HDdtz9nWiVGQt3OlRlNTgDxHfXu8dU7VAKGHABVJgUSyDH7hWLvzi9x9qBlneqVR4o8i9oHdUE1MhdojzfYcZFFA+8DFqtan73LnlZ0wA4vh/YxACE7oOmZ5AB+ahBBhZFJCGAHi0ndOqkX1k7orddnrKWucbjo14218HBP+4WWXoCj7BXG5GT0BYxE33IMreZrFQU12rT3GAMIluy8Tvs6SXLDLObO8SGeLyxBi0Ve6lzzYMI7u6JGg55lDFqVIFEWaptGlGPzKQ== 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:(13230025)(39860400002)(346002)(366004)(396003)(136003)(376002)(451199018)(44832011)(2906002)(38350700002)(38100700002)(2616005)(1076003)(6666004)(6506007)(6512007)(186003)(26005)(86362001)(83380400001)(66556008)(66476007)(6916009)(66946007)(8676002)(4326008)(5660300002)(36756003)(41300700001)(8936002)(52116002)(6486002)(478600001)(316002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LRejyvnxgnm5Whf0ZFrR6kzok95QMxbHsPuh95Pw0XcNcPKKI6LQyU8NI36llyx6jKa1vpUpWbt0GI2ltX5knT4dB5W+LCJc73GMPzBkx69Y9IE7Ks2YCjKG/e61kkoNW28qEGWcRhAjvHttRobAwdviPVS1/8Zd6W+Gd3ef3IvAjoj/IQWWv92JKZVRRh9VP9JdUCDgQefPTXg/uLml7gE2cGGmymW8w915Uh/W7mu8w1OVEzTbw+6fFsuMStfmlL373MxRu0NK7JYAgm4Jtaedz2Nes+899oQG8yqwnYRfk+UQo/VVhBubZuF7yxNkuGyFu2FmfVEx8junYe+Io9mgcfr2gExA0QUUgU+UWgtakdH6wAVUM496ZM72fUnadrJirEuQvsWoVdp4bmUGyOIe7jDwhRs6rjKyPLz6guYd8eogK+KPhd3hHBRj5MfznWNo89wLbNJYkaDLcv9gWpum/T8+UOyieV2TRR9nBtOYuA24mZklavhPRzIDRwxIov549igyx6G7wa4MA4b9cfP9VVXH0rx1lYpS9VUD8VNeIHIorNjw+3/s7XlpcvA4bV+T2ue63R/0aM4CjKFJF4oXhsPNN3LEfcswqYCllUuv20bMGn2Vjf/MbvVT91jqYPb0XcNuxOH6VXKxtWGWHwXjwbcBj2y3QHAS1UJJLbT+QWFSNAm1rjalzSEXWMyJG0SDnaxcENEqgebx1Kfj/Rnbh2c3GBqmUA+OFEPeHNnOD33OFk2kF76xLN4hJlznZr9wamIka0qa+IFbEm/iti3TNKF2xZ+K3F9jk4vMwrm1bb2TN9MHYFso4wK0LTMv4iIhMBn2xGd5x1fjeicG65gn4AV/1doCCW0eckr6l/LsYLdiIv7fD7vK2SETW/B/zKM5RI7T8TeR2peh0kaeNjPPOCEJLDL40i5atXVenpBNQDdaXg1ey5TGLFBkEu+XcaMzwjTtAxsdgIl9XgXeg6og5ScIPSTlRZt6k0EG1LK9T0CxmZzdD+o9aukGZ+nGsh/m1VaFhUPGOsglksqu8MllNoUhiCyg+utf+frGxk6tOLGpzzTLLLB/Wn5yMZ8QLqIpAYYqTRtvZIB+Z+P7iaCze4pC7M9IR79g7d4PMv/M+f7L+y8s1d/CkEZZxVAvDMPnh8pLFStrkPTWyBQP2KSlz3Y6l81l6AgD08qPRlKhTqGMld7jdKWHsr5yhi0+A5L2bLFt/lWl6i3jW6BV0bc+6BeWhwFcfc+mYPTYGerKZWaMMN5zkjfG9q67/s2TB9cA4jK5f+mC1euxL5KlPADv1nWhyCYGjvC8Wc+Ri5eaSDaw2NmRPsZROF+hid5v885vAy/ukvwqX1KRKdGq5Adk6tqX5GTTDttTgOkwK7co02WnuLY5gU5+wpsSWElkPTrl/PfIuQOFw/oPTnPayL0zAN69VcR+R+4b2rNkd4FupICf+SA66p3GhkK00BwWc/kNmMABVcqOG+ofkE2nDS5dXwYNX/W/qd1OrdE/2wct6Ya+of4ccgXOZJ0BUsQEuVzQ32iTHkXuF4xVbWx2OfuUWHaiwKmc325MehoNfSobznB7/jaExY2WeYKxcr7c X-OriginatorOrg: mt.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2cdc028c-31d6-4b42-9b71-08daff7e55be X-MS-Exchange-CrossTenant-AuthSource: AS8PR03MB7621.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2023 09:18:49.9456 (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: jZEFnC/eATQoNK1o6TjC9fFW1ZhVjHj+tZL5CcNFGF+x2i+UtZxZlnEkYSH/zHHxtVH5Go6/gJcy0aEIg1M6KQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR03MB9516 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Frieder Schrempf Make the driver accept switching volume levels via sysfs. This can be helpful if the beep/bell sound intensity needs to be adapted to the environment of the device. The volume adjustment is done by changing the duty cycle of the pwm signal. Add a sysfs interface with 5 default volume levels: 0 - mute .. 4 - max. volume Signed-off-by: Frieder Schrempf Signed-off-by: Manuel Traut Tested-by: Manuel Traut --- .../ABI/testing/sysfs-devices-pwm-beeper | 17 ++++ drivers/input/misc/pwm-beeper.c | 83 ++++++++++++++++++- 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-devices-pwm-beeper diff --git a/Documentation/ABI/testing/sysfs-devices-pwm-beeper b/Documentation/ABI/testing/sysfs-devices-pwm-beeper new file mode 100644 index 000000000000..d2a22516f31d --- /dev/null +++ b/Documentation/ABI/testing/sysfs-devices-pwm-beeper @@ -0,0 +1,17 @@ +What: /sys/devices/.../pwm-beeper/volume +Date: January 2023 +KernelVersion: +Contact: Frieder Schrempf +Description: + Control the volume of this pwm-beeper. Values + are between 0 and max_volume. This file will also + show the current volume level stored in the driver. + +What: /sys/devices/.../pwm-beeper/max_volume +Date: February 2023 +KernelVersion: +Contact: Frieder Schrempf +Description: + This file shows the maximum volume level that can be + assigned to volume. + diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c index d6b12477748a..865e1ec5c39d 100644 --- a/drivers/input/misc/pwm-beeper.c +++ b/drivers/input/misc/pwm-beeper.c @@ -1,9 +1,14 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (C) 2010, Lars-Peter Clausen + * + * Copyright (C) 2016, Frieder Schrempf + * (volume support) + * * PWM beeper driver */ +#include #include #include #include @@ -24,10 +29,61 @@ struct pwm_beeper { unsigned int bell_frequency; bool suspended; bool amplifier_on; + unsigned int volume; + unsigned int *volume_levels; + unsigned int max_volume; }; #define HZ_TO_NANOSECONDS(x) (1000000000UL/(x)) +static ssize_t volume_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct pwm_beeper *beeper = dev_get_drvdata(dev); + + return sprintf(buf, "%d\n", beeper->volume); +} + +static ssize_t max_volume_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct pwm_beeper *beeper = dev_get_drvdata(dev); + + return sprintf(buf, "%d\n", beeper->max_volume); +} + +static ssize_t volume_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + int rc; + struct pwm_beeper *beeper = dev_get_drvdata(dev); + unsigned int volume; + + rc = kstrtouint(buf, 0, &volume); + if (rc) + return rc; + + if (volume > beeper->max_volume) + return -EINVAL; + pr_debug("set volume to %u\n", volume); + beeper->volume = volume; + + return count; +} + +static DEVICE_ATTR_RW(volume); +static DEVICE_ATTR_RO(max_volume); + +static struct attribute *pwm_beeper_attributes[] = { + &dev_attr_volume.attr, + &dev_attr_max_volume.attr, + NULL, +}; + +static struct attribute_group pwm_beeper_attribute_group = { + .attrs = pwm_beeper_attributes, +}; + static int pwm_beeper_on(struct pwm_beeper *beeper, unsigned long period) { struct pwm_state state; @@ -37,7 +93,7 @@ static int pwm_beeper_on(struct pwm_beeper *beeper, unsigned long period) state.enabled = true; state.period = period; - pwm_set_relative_duty_cycle(&state, 50, 100); + pwm_set_relative_duty_cycle(&state, beeper->volume_levels[beeper->volume], 1000); error = pwm_apply_state(beeper->pwm, &state); if (error) @@ -126,6 +182,7 @@ static int pwm_beeper_probe(struct platform_device *pdev) struct pwm_state state; u32 bell_frequency; int error; + size_t size; beeper = devm_kzalloc(dev, sizeof(*beeper), GFP_KERNEL); if (!beeper) @@ -171,6 +228,24 @@ static int pwm_beeper_probe(struct platform_device *pdev) beeper->bell_frequency = bell_frequency; + beeper->max_volume = 4; + + size = sizeof(*beeper->volume_levels) * + (beeper->max_volume + 1); + + beeper->volume_levels = devm_kzalloc(&(pdev->dev), size, + GFP_KERNEL); + if (!beeper->volume_levels) + return -ENOMEM; + + beeper->volume_levels[0] = 0; + beeper->volume_levels[1] = 8; + beeper->volume_levels[2] = 20; + beeper->volume_levels[3] = 40; + beeper->volume_levels[4] = 500; + + beeper->volume = beeper->max_volume; + beeper->input = devm_input_allocate_device(dev); if (!beeper->input) { dev_err(dev, "Failed to allocate input device\n"); @@ -192,6 +267,12 @@ static int pwm_beeper_probe(struct platform_device *pdev) input_set_drvdata(beeper->input, beeper); + error = sysfs_create_group(&pdev->dev.kobj, &pwm_beeper_attribute_group); + if (error) { + dev_err(&pdev->dev, "Failed to create sysfs group: %d\n", error); + return error; + } + error = input_register_device(beeper->input); if (error) { dev_err(dev, "Failed to register input device: %d\n", error); From patchwork Thu Jan 26 09:18:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manuel Traut X-Patchwork-Id: 13116817 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 B1D55C54E94 for ; Thu, 26 Jan 2023 09:19:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236803AbjAZJT2 (ORCPT ); Thu, 26 Jan 2023 04:19:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236841AbjAZJTL (ORCPT ); Thu, 26 Jan 2023 04:19:11 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2123.outbound.protection.outlook.com [40.107.247.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19E6216ADD; Thu, 26 Jan 2023 01:19:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dJhd3LjZ/C65cnShPqd7EX/QeI+vNEetXKKAaqFaoyRnZImbzFpsWnu1h4NyaEQY7NUWhy/K+vlnpXqv7hHmR3v1xKeg856RjkznlNNpNaNM5DA0aW/xPdKSWSYQtOukDBdn3EECG58roufcxbJbkRn47jrNt89Tx8EiTtP4SiBIdKAAZRn4g/eYvD8Hn38fl/21mlN6bP/nyVCmbXQE0mvSx8OMp8+m+mAzsbBSu3IuvWnEYG1b/hRe/8xs4bEKQ7cNDDwajKZK30OkcYhwPNBDLja0aMiJpZdAwFap4NbA+hqDVb9H9Bm84kNbfSjwhwY2zhx4uENCd7yJpPo/3Q== 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=6wRsHZtWcsVDbpLif8cJQpKMKocgCvOdl+7dr9GHNuY=; b=Lm3UM5rSCs7LRh/59wGdc+4zW5a7rELtf1Gu/osZyZR9VyjaDMl52MF+gnms1rBA5iwl7qJVGGgNKzVWfBQGFy4KNEmgy0SYPIrpY+gdNqpIp0GCt45qq8MvCCx0VwdcCqx7j50laziaRF6b9TQUFbv/ZSZY4kaS0c5MgQpB8YKuaBNXsPwFy6RBjaqAs+wUgzo9RVkI2pTvheQfnyJMxlFGmMlFZLcEKtopINX16HNo9wsD0CkEiyx3TU6GooaIvH4uYR0j78DH+NVeDKGPdZWphZEHTnUgzQug/aWC9n38hsAx2vmlewUwegc6rr5YiUojzAXfcwIaK8Kw0o+lBA== 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=6wRsHZtWcsVDbpLif8cJQpKMKocgCvOdl+7dr9GHNuY=; b=MUucOLiY21EngF2CxoZmcfO6gZ2z6P9LhY+TQlRDezKiDmfu8Mt/sLs067DbklY16PUOQTGr0Fte6dSNrEthwUoBDyIaWLb8rtXeCnkVXoU1TRMdTubpp9i9PxoOaI3lQwtxtPpOrhBqRws/vFk6ngomsTeih7xqnqO9AhP6/u2a9oTCKQ4XwHnOaPfP1YkcK0iFQnx4xejsMAxtq/twLcMlFUblLQzIua39Ri2VMiu7XEPaVwZsx3GvbtKHPv6Ri4woNKSGAmtCjALV9VP/KSbVezl9hiFsqKCgNwwmAM8jTFA8JkfbePa9QqWdQPa0YGqBK95tH5f+e+wpWAY/cA== 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 AS2PR03MB9516.eurprd03.prod.outlook.com (2603:10a6:20b:598::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22; Thu, 26 Jan 2023 09:18:51 +0000 Received: from AS8PR03MB7621.eurprd03.prod.outlook.com ([fe80::b42f:82f8:24cb:a225]) by AS8PR03MB7621.eurprd03.prod.outlook.com ([fe80::b42f:82f8:24cb:a225%9]) with mapi id 15.20.6043.022; Thu, 26 Jan 2023 09:18:51 +0000 From: Manuel Traut To: linux-kernel@vger.kernel.org Cc: Frieder Schrempf , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Manuel Traut , linux-input@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v8 3/5] input: pwm-beeper: set volume levels by devicetree Date: Thu, 26 Jan 2023 10:18:23 +0100 Message-Id: <20230126091825.220646-4-manuel.traut@mt.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230126091825.220646-1-manuel.traut@mt.com> References: <20230126091825.220646-1-manuel.traut@mt.com> X-ClientProxiedBy: FR2P281CA0131.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9e::14) To AS8PR03MB7621.eurprd03.prod.outlook.com (2603:10a6:20b:345::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR03MB7621:EE_|AS2PR03MB9516:EE_ X-MS-Office365-Filtering-Correlation-Id: aae706f1-5643-4ffe-80c6-08daff7e567d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tJ1GSxyrmysgbdFWirjRg9TA7d5rI1c+GpiZqxz2IHplYbjIACgHdALu6fD01Sm5fWuCA81aYw65B1m+lsmoSZ8mhRD1t8cPy4cqFfF19V83e3SbaJvV4aIepbhLMA9fU6LnXzaVZqg+BaiDq7GoQlHFnWPPkP9CBHhIbkFALlDl4+5n6kPTtPO7QHd+ZPcsUGudKCOB0rjZnPFjha0VKIxsKg40lqytZbsQpfy4K8CzsP9AXDhdvCq7oKUUgcRaoxI8/Na3IQligxV1Y/a5BUAcbqiY/TP3AQ2ejFPh7vQ5YJh5dQY25nMxNWkuuemlnpNN+9cr0EAfxoUkzKH6EF0kDOn8sjA/rxseCIM/uxyjn7Q04BehZ94UxhuuRL+9+DFE2QEEAt4aCJnc7fr97vxlgJr5rkG9vfjX3bF03PIcqRe8MqgyEndN8Gz3mDZtadWAl7pcn8Xy2djhCnoBiDfdWhJHgn7UKGvGPRynjJIihPdBS4r0nXneZDHfgyxhVBhiXxSAiUm6Xu2LoxOKpGAiAd1grZC+opXhJIYQveL6OXNyqOIzAsAMYqCU8SThZAjcZiNOQX3ykMf+VA8EwiOGtZ1951e4kV/79aEN6W5a1vdxDP/XY15HL/C0O52UOc9CkwK1WifWBOMix/tzAj5c4Q8hKw6zdWbG4TImDoQYM6JHhihglFdVzbWW0qbc6btcvfDWO+QXxLTa/19a6Q== 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:(13230025)(39860400002)(346002)(366004)(396003)(136003)(376002)(451199018)(44832011)(2906002)(38350700002)(38100700002)(2616005)(1076003)(6666004)(6506007)(6512007)(186003)(26005)(86362001)(83380400001)(66556008)(66476007)(6916009)(66946007)(8676002)(4326008)(5660300002)(36756003)(41300700001)(8936002)(52116002)(6486002)(478600001)(316002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kqAWAsm84KDP9ChgQ+MY8jiaGqoNALLl4jO3hjPKCkeU+UcbiP0p11rb4Jixw5kzHcYiJ34PGu3+e4MjdNvawxPOeohrhlW72Miz5h1zmemY26bVwCERgvMz4LZ20SYmmuji0hkTF0TUBy0w1DFX2cxZuYLFE1IRdGzCsJCNfESO/Wwt+AkoupzMiH611/YdRwwirTS20b88CDWRLCYnMsw7DfsXgn6i7phOkRHUQUBpoaTEPUZ9znyYWYVciPtPZGpx5aX6vOj3NPCOKcWhTrzS4SyoLEPhPTfCi8049MXKXZvjzrMbfev21S5FPGqmbBc6TlkThNEQR+SGyOCWl6EV33Gq0pXA415PY6mFqtGH52CnqWyCNG+3L0m747ixyLtc4gK0AqhzE+x86FWRotdL9L9lwFfAT6WuJjg3g9MdqmBqnGJdXnLsHbzEAZJ4kwwP9KSvULIjo+N2mFVLiH9ELWaBTEox2BVXJiS4hmtiBjpb0CpBQPGAkRHk+Al9V9/Gr5NaOodSW+nk//5NP2r6L6k4u3jUORfNi2wwWRbSImmE21DUWZ11oI133xOQg9Fwpmk1VMW806bVDJ91c8OjMK4T/m7McrXj2zM7eq4DFqfGHf1aYUC0fdyYYQElvNM+i86tMLvqQG17+zMOA3HaqIEBEXVWZHsbiR08iQoqNssN57mF9PQIx5rIt4BwwoYmY8BWHHh8WLRITDN+IsZY2JSbfnD/MsSJhvPH6gj9YdvCiDsjzG0mwitufhZuN68xF4bb/O04eTA/N7qn1KfB9NHLqHblDukNLf7Q+mAhjPnR4aRHGtvmCC1lMvYpWPNbezOqiSfTUPm/EFL+xdrzCZGPdmjdHzMVQ/XTPTPhtuqYdWvaty0Smv+B6kwWJsGL0d/wyKyjKsZh+/i5xci46mGxyPUSzxRK5iHr3D/5SdBvZvS2HlZUvDOajw/IdoASMdaZ0Ls+FNxsgQoSnsC//BeqY1wmv2oNHY877W8htKaxX0i5cMz9Ve5QSXm3AynFYrTtFs6dCdMuTFacnOoVgSGA6eR/tZzou+MGH5bzV6idSdBuH7et3R1ZhZZfOjZ/ConvwrRNMJ4qfRRf0PphYktdTSPuu3BIk93eOf5WCtq43eVMASeVBSXr242M9BBnurdtmOp6rpS1p+eRCL9fc5ofOtcn1Ayp7vv1w9Z0isv0/FXjUdpIeqwaNj9r1Y++sccZAMHZcP0a5uV+PqcVttzfWs4EK+kYrIC7+gQZqcVCBTp1wYsmJvg97Cqba0uWjMVqyjCaYequFsHIJTClUIbgbXoi3Z92BgHWJZ3/noP6kTqPOt/XRIgacGekKPSU3XGsp3XyezneZDc4aE/2zswm5mzWeX8J29WICkXhl/DMcyjtmfPBCmLk6Ni72sSC3t5TGvAeFL21lzNKMSzCyAzSkN/Tr791fZTJrBOzAqPYiGNhgF6+YlaK2Ald7zSFkQ3d3L2E9a2iYW7jIr1HMYs9X5Y7o6boZy0TB5U4qPzzI8Yi2jTX/XKGAbrzka3ztu85Ioz547jgc6m6onqRL2sxu5uVL0iwcETh4nT1LxeAN7LgyZ/fjzCcAIpD X-OriginatorOrg: mt.com X-MS-Exchange-CrossTenant-Network-Message-Id: aae706f1-5643-4ffe-80c6-08daff7e567d X-MS-Exchange-CrossTenant-AuthSource: AS8PR03MB7621.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2023 09:18:50.9467 (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: ZoQwFjQiLuAT4tU8/XHidCVGj50qnkZZp1T8slS4F7vABxnkH4X0ASMDFfGhQLKqTU2Y+FHe/sfZq04B7I1RiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR03MB9516 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Frieder Schrempf Add devicetree bindings to define supported volume levels and the default volume level. Signed-off-by: Frieder Schrempf Signed-off-by: Manuel Traut Tested-by: Manuel Traut --- drivers/input/misc/pwm-beeper.c | 58 +++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c index 865e1ec5c39d..82b05f7f4c70 100644 --- a/drivers/input/misc/pwm-beeper.c +++ b/drivers/input/misc/pwm-beeper.c @@ -181,8 +181,9 @@ static int pwm_beeper_probe(struct platform_device *pdev) struct pwm_beeper *beeper; struct pwm_state state; u32 bell_frequency; - int error; + int error, length; size_t size; + u32 value; beeper = devm_kzalloc(dev, sizeof(*beeper), GFP_KERNEL); if (!beeper) @@ -228,23 +229,46 @@ static int pwm_beeper_probe(struct platform_device *pdev) beeper->bell_frequency = bell_frequency; - beeper->max_volume = 4; - - size = sizeof(*beeper->volume_levels) * - (beeper->max_volume + 1); - - beeper->volume_levels = devm_kzalloc(&(pdev->dev), size, - GFP_KERNEL); - if (!beeper->volume_levels) - return -ENOMEM; - - beeper->volume_levels[0] = 0; - beeper->volume_levels[1] = 8; - beeper->volume_levels[2] = 20; - beeper->volume_levels[3] = 40; - beeper->volume_levels[4] = 500; + /* determine the number of volume levels */ + length = device_property_read_u32_array(&pdev->dev, "volume-levels", NULL, 0); + if (length <= 0) { + dev_dbg(&pdev->dev, "no volume levels specified, using max volume\n"); + beeper->max_volume = 1; + } else + beeper->max_volume = length; + + /* read volume levels from DT property */ + if (beeper->max_volume > 0) { + size = sizeof(*beeper->volume_levels) * beeper->max_volume; + + beeper->volume_levels = devm_kzalloc(&(pdev->dev), size, + GFP_KERNEL); + if (!beeper->volume_levels) + return -ENOMEM; + + if (length > 0) { + error = device_property_read_u32_array(&pdev->dev, "volume-levels", + beeper->volume_levels, + beeper->max_volume); + + if (error < 0) + return error; + + error = device_property_read_u32(&pdev->dev, "default-volume-level", + &value); + + if (error < 0) { + dev_dbg(&pdev->dev, "no default volume specified, using max volume\n"); + value = beeper->max_volume - 1; + } + } else { + beeper->volume_levels[0] = 500; + value = 0; + } - beeper->volume = beeper->max_volume; + beeper->volume = value; + beeper->max_volume--; + } beeper->input = devm_input_allocate_device(dev); if (!beeper->input) { From patchwork Thu Jan 26 09:18:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manuel Traut X-Patchwork-Id: 13116816 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 0A3A4C61DA7 for ; Thu, 26 Jan 2023 09:19:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236770AbjAZJT1 (ORCPT ); Thu, 26 Jan 2023 04:19:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236843AbjAZJTL (ORCPT ); Thu, 26 Jan 2023 04:19:11 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2123.outbound.protection.outlook.com [40.107.247.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C4141D924; Thu, 26 Jan 2023 01:19:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iooiU9DScfZ0t2AAL65XOiXF3gs99kN/f3KQcid6z5jYBQbKC0c89gyfTgCCx9A0hZasVpTVaXEsy5a7OgWlM1BrizWcjxer4pQ3VAUmWZptgjscrwlkd13uYGvbUFlPA340AR1QMaqhsAXLRZKM1zfXYYjoq4zL8eMxFcbsDl1edeK7byDEEfMSLhfzw5iaaCk6M+wJ8Gx3e9AhQyg3o1/wR+bdpYobXmFcIPI8zaIAvTdpzvFszQyvZAOWeQmL+V148bKkQnnFpT27JYk3E38G6z+b3Wu+bGwGP9Z1U672/YkqH3tgct1SHs/I52sWUj+h6Cg3/muZjx+cwixbqA== 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=QIB5zj7E27IDWEDHyY0jFQ3/Le3f/bBRm/eOqWzpGbQ=; b=A1l5n1RV3VD2aJWzda0f+DNbFf7QbacNXbGMrwmWmKL6B7wM+xmVS3mkQ7kLKLyBcWcrUlCExx5O9WZQZJ27pkiD132JtxrGD4lGRfnxA+HDfHViko+KyoCmPZHy2cz1GZNQW9B+rCGDMN4EcuwTcjr89R7wYm+NgjzpBgW1907I8hQnTGJ/RVOX/cPJZW/oRfl0e6m/5vPfciOYQV6M94J74/+rmsuqxxI1bRGVpNvMOKoNN7dfNytZ6x4ITI/8oh7DzolUX9VSfLSYv74MJ32sqFYUfDFb1izhDHg6Azlq9EIWIx+XZbxmd22baiKmNcs2YI+wtK11UfZDZ3gCjw== 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=QIB5zj7E27IDWEDHyY0jFQ3/Le3f/bBRm/eOqWzpGbQ=; b=wGPSQ7PV2O3E0sJICJ4j8sIZXFT40P0x8rZLZ8jB3lOLMrO/+xkzqfq5g9xNvqfC+ukivDc3G5Kd08OTa8lGLRWo8Y8QCFGViGOHYN4FfnMMjyGEbuoasg/3bweezrQbpgC155eztCphX37i1xTsPRzovU+zOUsw45tNVluqy/YRaYboAqcOzLIUc7gZ9wcarGWDxhmhOmYTc5Oz+XLM6KRsSwwaNTq96q3j946isTknGNGCPXZUrjDOmJnPGkQJcKoU9vvkDK91juMHA49SzOFBKBD6R0SIMM1Hoppx6BsYPCGEUrb+u790gjtLaQklYSgKrLjHYQV7WDEsoLWwrw== 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 AS2PR03MB9516.eurprd03.prod.outlook.com (2603:10a6:20b:598::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22; Thu, 26 Jan 2023 09:18:52 +0000 Received: from AS8PR03MB7621.eurprd03.prod.outlook.com ([fe80::b42f:82f8:24cb:a225]) by AS8PR03MB7621.eurprd03.prod.outlook.com ([fe80::b42f:82f8:24cb:a225%9]) with mapi id 15.20.6043.022; Thu, 26 Jan 2023 09:18:52 +0000 From: Manuel Traut To: linux-kernel@vger.kernel.org Cc: Manuel Traut , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Frieder Schrempf , linux-input@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v8 4/5] dt-bindings: input: pwm-beeper: add volume Date: Thu, 26 Jan 2023 10:18:24 +0100 Message-Id: <20230126091825.220646-5-manuel.traut@mt.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230126091825.220646-1-manuel.traut@mt.com> References: <20230126091825.220646-1-manuel.traut@mt.com> X-ClientProxiedBy: FR2P281CA0022.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::9) To AS8PR03MB7621.eurprd03.prod.outlook.com (2603:10a6:20b:345::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR03MB7621:EE_|AS2PR03MB9516:EE_ X-MS-Office365-Filtering-Correlation-Id: 560d7c50-2e23-4b7d-98d6-08daff7e571f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p1w/J4O4CN9jtS4XenrH6ylfLdWnOwiUzzF0kUY1lRLHvkrzpV8J/63HG70GvDjCFqrK3G/cfRXE8L7Hvn+vzRg0wYA6x6+22y+WC8Zz3Awun7/UeJWajULh9DD/sCcoH8WxZr/XJ8tABSxPIgUWTIMNQfRfi3WZOeQJsHiKPxkeO4cQSCv+f8J387ujuH3kS1JVxjmV0P8bh2UKV8pKCA9668FEBVvFpXXvL8dQ3hzpeZ4nyb+fQ970XLbBZ9VhwSBi35+taaGPzabXP3Tsz2p8e5OTxubcbI6kO/MDDd/th/J5AtWI7WSCouYj6swEdPQNjtuFAffjvjEnIYGXenMHgNS9Nhrq6qVTnQnpzk7FSTkzFrNfMUDMGlqrxDp58ATr6cZNUWw/mEjNfoEcdtdp75EgcEG/MJ2boQKNny2ncy7tIxDuagVCtm6JUoCuVfVBMyjheVDv2gENWueG08ElylQpw7wLkZK2T7aRUm57qN51FXURecgMDcN/1/ilwliVU+VlYzsAXT05/hSOqUruooQQASyPqdqHsluOtdwhM2Drsy1fsDu87atokxvL87mdLjiyYafmD5b84amKdZr2oZNGYQ5E5Mdbxm+CE8ykupPY2MBxHYRlS/4BmaxV0l6YBIGcbL3ym4ROUhYgefSvyubbKXHIL5D/fgsP456fier8iYddckDtckPJ3T9G2cHmewJwQXcPRy+w8xXz2g== 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:(13230025)(39860400002)(346002)(366004)(396003)(136003)(376002)(451199018)(44832011)(2906002)(38350700002)(38100700002)(2616005)(1076003)(6666004)(6506007)(6512007)(186003)(26005)(86362001)(66556008)(66476007)(6916009)(66946007)(8676002)(4326008)(5660300002)(36756003)(41300700001)(8936002)(52116002)(6486002)(478600001)(316002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pUCEZXaBy7h06WakU3QcNysNo5rYkKzoirgxKs8wUCE8pERkY++dLuEfNNvTSX4tSMcbgZbeRZFYGBrY6XlA0I/EaH5/6MG/Fm21b/s23favnb6XBzv93vzgeWBVePjxXNbeHfFmbWo8vhXXeSJTx4TwO0xn21mc3Q07T3cc+IIGSCQP2hntMI4pxtT43f0eP560xSk9vdqUQTU3OHiah0QwfMoH4gCCmbf2znpKriXpXNC9vgaSjUrbEno0RSMy1Q4MeRoWyYGoB6ANXMjYGNBmYCyzF7WEmseZW9G6bFGNO2TFm908/hBnVw/bcTPCV4wlCil8FJD5p/q9PTPAGHb4TXtrOPlKSou3Y5mASrKAdUia9MbFri4yG3HxOX5vg9CDPucNPOdZOIp9znueHjjXA6pY/o/dR/4yycXhOC9nNzGAeVsSNIG1qoYLsVRYauonYdGZBEECgOgnxSODW0lnlS2wxBtjCOFpEUjIu4AT4QByrSTSu7MXnVl0qeMIXx8y/CbkgPJD51hzOkBdMlLG/sjoG1BQA8Vd1lO2wvzCmVmfouz05wRHdCraKms+rb+L8sVkDL9g6mKd5hQGxq0XVKhXM9MA2wvMtbZdhZhUNdHAc/fQjZDY4+BrJ3A8BvOMKcIZMCJEGQ11oblju2lZ88lGnkEoZ9LeRaNm5Do/137eYzK+lKjqoHICtGCJFPQW8H2PKvFcx8ouVmqIxoKXQlIZBLXOUmpq0A1UT5B9I4GOqwtBFlLnhu+GXg/SG505u+jQCidOgVc/eKfXWwgWusGlj7Ejmgx05Xe2pNjSCjdW+lhUZ14V+kqjGhzgXyF+uMLHPdyAKO6c4RZ7BWazDsC+g50BEqUYg/O0/6SoN3PdBJKKYPHk4F2Ixl1z7C28yhUOFtPSDbWAqyzlp5GCayFEruhZk30k892V/Mt6y8d390FonoDQfJCIRW4cvBXVa3CtKTxZp8rGnN9+/4sjRLtApCWqGXIsLl/iBhQUTdb5qurCMRxhjkefHMqQMe5e1EG3qAk4pvPkMBHGtpV7cpSiyZNpMHe5115g5KNEhO9E4iQyaSFnd/ucupe2lFdrdmNBIU91yy2gdsenVnKK8660lv3qnsDoMytrUtsk+VriuVEQDarodQKUbnpJmUEW/V18bjBytX6QWpuT1OJFXe2/F8IwtkzVJmodKkJ7AlAck0L4zTmCTv+eO9YADcKrymlue3XS3oXKH9iF29f1g4nOPDrOb8WPzCmE0rLiWdm7O1UNsQqy1DFciakwRdLDqoLU483FqKGSRyxLpbFhmeSYrCyjleVE2dRTyCJfD2fjFNBbbSMVxyZqJsyqtAmboupbgYHXws8V6MqJ8f9cstXmznpsK3B1DrpOX9QbZVNyVcx8CJABVpxEVDeyoxhSXZOKP7fHsCGkapjKRP8v5S2sj0ejtUwGnd1E09QA92A+ewlAp/rq+gOi9v4rRxYOKP+GIQl85jdwfZlnxzRnh7xGePPWIi+Xe1r9O8g/madLdx1/TipHkz0KMjWCxHRzKZobdv0PTjdouce/PkhGYNiHid4xX/stCEEf+1OhnMwpFvfFc4RELGBrijsx X-OriginatorOrg: mt.com X-MS-Exchange-CrossTenant-Network-Message-Id: 560d7c50-2e23-4b7d-98d6-08daff7e571f X-MS-Exchange-CrossTenant-AuthSource: AS8PR03MB7621.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2023 09:18:52.0090 (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: omsdnCZQRUnWxhVWRA9vl23w5Uj60eBk4+IFuR5jt63GTA3Pp6NIBLhOpvTqhHvbU+T5TGPGwFDSjWdp6JKZJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR03MB9516 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Adds an array of supported volume levels and a default volume level. Signed-off-by: Manuel Traut --- .../devicetree/bindings/input/pwm-beeper.yaml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Documentation/devicetree/bindings/input/pwm-beeper.yaml b/Documentation/devicetree/bindings/input/pwm-beeper.yaml index 351df83d5cbe..f1f9283ca855 100644 --- a/Documentation/devicetree/bindings/input/pwm-beeper.yaml +++ b/Documentation/devicetree/bindings/input/pwm-beeper.yaml @@ -26,6 +26,24 @@ properties: beeper-hz: description: bell frequency in Hz + volume-levels: + description: > + Array of PWM duty cycle values that correspond to + linear volume levels. These need to be in the range of + 0 to 500, while 0 means 0% duty cycle (mute) and 500 + means 50% duty cycle (max volume). + Please note that the actual volume of most beepers is + highly non-linear, which means that low volume levels + are probably somewhere in the range of 1 to 30 (0.1-3% + duty cycle). + $ref: /schemas/types.yaml#/definitions/uint32-array + + default-volume-level: + description: > + The default volume level (index into the array defined + by the "volume-levels" property). + $ref: /schemas/types.yaml#/definitions/uint32 + required: - compatible - pwms @@ -45,4 +63,6 @@ examples: compatible = "pwm-beeper"; pwms = <&pwm0>; amp-supply = <&beeper_amp>; + volume-levels = <0 8 20 40 500>; + default-volume-level = <4>; }; From patchwork Thu Jan 26 09:18:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manuel Traut X-Patchwork-Id: 13116815 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 CFA39C05027 for ; Thu, 26 Jan 2023 09:19:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236684AbjAZJT0 (ORCPT ); Thu, 26 Jan 2023 04:19:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236802AbjAZJTL (ORCPT ); Thu, 26 Jan 2023 04:19:11 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2123.outbound.protection.outlook.com [40.107.247.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FA2517CF7; Thu, 26 Jan 2023 01:19:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X6sa+sKjmO+2KkmUDYJfbnpJilnwT3LEyn2pi4Hb9yO2yjPei+05VcA6T0z9Bemn0powVZatx8KZ2kWtYnBrkZ4v/JSTVOlsHGmDEmwv4TNcQuh82HtReVz+VyFx3zYMmVojoDiTeMTdvzTe7Hboz6tBdhfeBE2xt89sS2J1u9Ub4KF5B67mrFPxqIxm5aDv0n9CsQDxh1377oAjK4Q7/FCWJvngyeu8nhZRDOkW4D8oFP/qqMPHZSguGm0JGzQNgkXjAo8aD1NOoY3GZOkgh6vVr+byyhb8JrCHlSMNIUNWbh8gzl59brYHVX1kuVGt0yS2XPIucx38363ETr6etQ== 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=UWEkzbCpBJZ1J6AGtrB4vzIydngUMIOXRQJ2gnoyK40=; b=nOvGygV8QBT2VTpXZN58zBIiG4Jxtyh7b8rMVwz25hD7TJveJHp1doV/vkHZCKf7+Sc0myY8Wzcc9TrnA0Nu1W0HihFI0e567fh+S3dUtJMpQcC+Dv+6NlWig6xx4UTak1mp7Mk+1sLOnkvXW/8nsPSGUKIbmU2Gwmlh8CwUaDZ5ImofeYvzcVsucjxZbN12rBIqltFFt+aqtEJPPUMkl+IjYrwZzxORDjoMaD8HAI+7rhnGB93n7K4Ijdsw0sEExNBTm2zAtclkZ4P9XPYvWTs1SBTrF47N/6GgsgcoYp5A8I/9giYIxHBbI1vk65nDDnCwXEyp7eG0yN46RKqcNg== 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=UWEkzbCpBJZ1J6AGtrB4vzIydngUMIOXRQJ2gnoyK40=; b=h+CmQX+F7eQi9oFqmsIFFApG2v7eV79/NywulZbEX+aJPQF/7vRpkyKoK6gFS09ysOyRTt8aUUAXOVzhPpjaezuYYOBLLjmp3goL97s6JqdBJ4Gjzdwcuxm/ebs6a69XhRkttHCSiN6iWiuJ+en+YIPIk09e0J1dPSwHUpjMgOqTBw0bHIauffyCUHB3oeWA2aymgyBy31PHy/VtJyyfXlx7a2ejUPslH6GeL22IsBw1zeKcGzsclYENRrmwmK6vrkbZvlnhjM0F3a27BBB3kZCP3FYLDK+kw8GJ+lY84wPSWbeHMKSf5teaeGc4RMQUDYhMNihydSlkeGC6x2xQ2A== 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 AS2PR03MB9516.eurprd03.prod.outlook.com (2603:10a6:20b:598::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22; Thu, 26 Jan 2023 09:18:53 +0000 Received: from AS8PR03MB7621.eurprd03.prod.outlook.com ([fe80::b42f:82f8:24cb:a225]) by AS8PR03MB7621.eurprd03.prod.outlook.com ([fe80::b42f:82f8:24cb:a225%9]) with mapi id 15.20.6043.022; Thu, 26 Jan 2023 09:18:53 +0000 From: Manuel Traut To: linux-kernel@vger.kernel.org Cc: Manuel Traut , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Frieder Schrempf , linux-input@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v8 5/5] input: pwm-beeper: handle module unloading properly Date: Thu, 26 Jan 2023 10:18:25 +0100 Message-Id: <20230126091825.220646-6-manuel.traut@mt.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230126091825.220646-1-manuel.traut@mt.com> References: <20230126091825.220646-1-manuel.traut@mt.com> X-ClientProxiedBy: FRYP281CA0008.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10::18) To AS8PR03MB7621.eurprd03.prod.outlook.com (2603:10a6:20b:345::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR03MB7621:EE_|AS2PR03MB9516:EE_ X-MS-Office365-Filtering-Correlation-Id: 0df6ba51-1538-4936-6cd6-08daff7e57ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j1hmOApjRY4HdKIelEO3yYp+BED7XfPAeptHLBjS7sEFcnChlBXewlowrCq/flGOABegEUAS0PxsY66ALkbKz4ZFWR3gfzRn+ONGbRbofIHPZUe9lFNBZcwTiUkLiiQ93FeHWGIyBMZoJr8Ib8LDnt7oQ8sRj9o/SoOZhFEUfxSCxpC6FlNA4XHXOkYfMiwSRZBIwrzfiOkxuCDXR5WhhC6+YQ5N9WVNR9skcnhv99/cYqF44fimlc913LR77oCvY42cLBnBYnsNnLe7AeNoGJIZsp2W0f8koU/MMkuqLxM14cdVIIBBxY42Y8tUyAExPj8m5MAt3WRkIu0KHZaiKG4uRwAr20Gu+B5zYqQwghWhG7tdDp66IjQvUKa3eekhINdBEhnnn5XrAo+++UlGZl80nB0xQjvAfYVuDMzXu9bLRLVo7evp8EkEOdQX8LjcXdADg4lBGj/m6mc5tUDfy8b8+dndRZ47EDXpI5n7BHEIPsyzeE9siUOhBekR9SG5y3ZRI1SPBwkDZhO+1YdtUOgxBo1HyZkt/GunND04r0r0qBWFLJu+33U5oKId4XnwErx+jqmQVnRWEAB7vAjcq2EW+TCv08r6isJD7JhHaT2oJWm7fBXYTDjJAhQ3uqP6tkb5mu4wiXwFFjKnK89b7cvY9hEY/zy5EarQcV72L8W3PYzFHMIekrrn2xWXdB7tUNCEtURvhRUilfWbByxofg== 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:(13230025)(39860400002)(346002)(366004)(396003)(136003)(376002)(451199018)(44832011)(2906002)(38350700002)(38100700002)(2616005)(1076003)(6666004)(6506007)(6512007)(186003)(26005)(86362001)(83380400001)(66556008)(66476007)(6916009)(66946007)(8676002)(4326008)(5660300002)(36756003)(41300700001)(8936002)(52116002)(6486002)(478600001)(316002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /zXILcEhhvleoKW1/gKlCaFiyQAejEBygnReGxZOcr4UfXhfIuZKweoZ7mhukRXqFaRU0R3g/MacxjZMjOer/Y9c90W2HQt8VZyM7qky4iRKZYRMMbvjxMUq6eC75x9MoRDrVSrvRl+yeeAsYFNddOsQYH1XVOBJTt3NqGvqvBK7puOIFnEYACtmD/9bTwE8+708VBtIkmJoYHto/T3Tl6nfJvY6AzcgUIajjXUjIkLukQsv7x5KrNoW02CrtFUhBKWjiryOkvb/M8ixoe/VWDJ1VPdToofFsfcebow8vnuacEpkhXvRj7TZlQj6xt7AkJHyYYgGAoUV7vdjbCLYaiVZfD2wcJp/mhDEVdcWFcXOVAlX1IkgNcjgJeB/jpBLZMKlMbJazSYKF7Ln+yW6DrkR7THNoIfpQAfCNq15TBwzQgPbzrs0nPIsZQGcv7kgzTUn5cGYX1jdHySnepEQnjIT2c/nJ/FC6GmzMy2fS8nzEj7+Kyjh8ZmB8L1bcHmdUztqhQlt040hjUObEOuucMZwG/oLmDGzg2kJvNK6AwZ5kLWF1wRzCT+A5xrXmHhb6YKp5P/nn8uKEu75DI0Mg5aUTzCuahSzRBRuItA2dVDskcSndMC3lJpBtFg+1m1FROboF7engOHGLdB7Sfyu8mZGA+m6Ki7jKiXn5ui8nGzmkUZus5pFV0/Tqmd59RLGRhQ1feL9EPFYq2b28aDPrCxRg+6T2bkXs9/ZVg0gQvjTnvm7AMytzqrab1c07NZjnvhaEBaFE3qMWSps223vBJE7bOb5kVDfxa87jtQVF1ZzfjZrcOzkJwO3lkxQ2n/cJD4aC32TO6ghDHTOER9Wk83aUZiB4bvnz87NjACQH/Ca7aKuLmryfiNqptNEyO0Fuqdi9nHkHO3YRa54OSPVc59WELW9UkyJ0du/GB2sivpUEK+OO+WJgWgEoMJEHDI+Wh8ZggBftorKac+2e8kwAgje4Xs568gYA0AZYHIvRQ1ei6th69uOzXDdJdAMi4g3la/cLk5uJEPLvCncMwPQuFsyR6wTdwO5Ldc+4Jn8Je6jZVt+cBa4buTBXBkZed3D55l6Q9b9NNEBRhdIvlELJBOEGx+q6gd2cvjDSyqFDHms1r3KnEB0Ynq6i1/YKOYmMmNsnt7Cp5vtmwa7XMZwLWltTLXN3QIvNHmz/DeRwU5L9Ja/Q6pIjezwMcCvHNC0GgbtBcYUwMJVojXJA1cZl0a/sVQwv1V+LCO0BJuvbJ0mL8jDR3jMzZpWvvOMjZi+ePNFMZPtIy0JytirpK2bPU5wu6DGHL8sZazkH3BnPqIVVsTwYxFoTwT0T5ow6XETwDvOPu9hDh48wRNI2fTS/rZ2SEXPfR+xSpb8mDL8Zx0aAoT1m/gRfAN8oVdU0D1fI1K1JvQddb/lgiqu5LqxTFDWDHvQLKVqQTVmEFMpM2qjw895h+A4fXgElMFzG3EGtC+8YcydDPJ862Cc7koXxWeZOqpTNnxKD5MKir80EhDq7pNhPtNo32+egAWlga991YcCEu3xG4FnUhh3UYJP9LRAw51EPOt2fQOShF9gnQiv89+ytGssXHjfp15DUkiG X-OriginatorOrg: mt.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0df6ba51-1538-4936-6cd6-08daff7e57ba X-MS-Exchange-CrossTenant-AuthSource: AS8PR03MB7621.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2023 09:18:53.0081 (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: XEwsX7IlK08OcPNUvGVMOX+7JVHs548958vDbACKimT5w1A2F/+hvizLnrBtMaB6zG66Rnn0hbBK83G5La47/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR03MB9516 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 'input: pwm-beeper: add feature to set volume via sysfs' adds device attributes without removing them on error or if the module is unloaded. If the module will be unloaded and loaded again it fails: [ 1007.918180] sysfs: cannot create duplicate filename '/devices/platform/buzzer/volume' Therefore remove device attributes on module unloading and in case registration at the input subsystem fails. 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 82b05f7f4c70..736b89bd1b42 100644 --- a/drivers/input/misc/pwm-beeper.c +++ b/drivers/input/misc/pwm-beeper.c @@ -299,6 +299,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; } @@ -308,6 +309,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); @@ -353,6 +365,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,