From patchwork Tue Jan 24 16:40:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manuel Traut X-Patchwork-Id: 47778 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2262360wrn; Tue, 24 Jan 2023 09:01:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXvtR4QH+YenV5nE1etU7kBYoVw5DMR2jhVY5unfQHzcjNTC6IAgiMne9f9Ku11KF/B8ZOtN X-Received: by 2002:a50:ff08:0:b0:49b:7416:e3ff with SMTP id a8-20020a50ff08000000b0049b7416e3ffmr29843664edu.5.1674579679294; Tue, 24 Jan 2023 09:01:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674579679; cv=pass; d=google.com; s=arc-20160816; b=V1wK7WMkHXrM3DI5UQppuX6nptA+cz+kcCoEHZ/mPWI7iMNkTzfqFROx4KbstJCnJR nqAePwEVBqStgtK4yAtCjE1//E8kOACTwHKnjWjVd3xE7AbgU3s8FpZ9b6CPQdSORAJ1 1S6vEyJWp4DNiQOomJ9Ur8SY0zZOQFYSwwpK1WVZwGP6Mn7LyhUpggo+9h1nxiu1lHi8 fU6H+7lTBQGGz23UQKkCTJfNJAkX2dcf6plk58tPvib8D9vNf2eLGjtsYz5pOvgezj7g bfZ2Rye3VKfPm/HkZkX44PVD+MXKJrKITQkHO8ssnHEBjGHThpuly4OnDdh4vJuOJeft llUA== 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:to:from:date:dkim-signature; bh=PGGzLFLmfnBZaHGdccMyfAmnrSmSHgOf2zOPUT8XUpY=; b=MkVZ2sYUDXLjF0NrZXzCwHcQgnkGD8E7ymHrGQ3G9q2bKIgx1zWwNg8XeVsc7JEV73 6YYxWgbhqDX590Wkna0UnnRA495WxoEihmfwfHNdMG1CjKHbvKbnDfn3EXINGUbSjL1w Li5kfJfh8/UffPUVTTmIsZswoQjDFsuSOMiL/6yxvqOHESSiQBlundXK7gSPN6CPh3LK NCbZIFjOKETpSr+rtjcKRc5ZasxC7FLRBr3hxLuez3gnfD8prvIrc+ntkOTVDFERMPYc nvFFht2irfdxBEAgXf97l/3Eg7CwSBRBUXOrMG8/bAwEJUHyvantVkeeWwT7l5Oly2/k CHhw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mt.com header.s=selector2 header.b="RV/ZVv9K"; 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.00.54; Tue, 24 Jan 2023 09:01:19 -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="RV/ZVv9K"; 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 S234454AbjAXQlO (ORCPT + 99 others); Tue, 24 Jan 2023 11:41:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234494AbjAXQlJ (ORCPT ); Tue, 24 Jan 2023 11:41:09 -0500 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2122.outbound.protection.outlook.com [40.107.241.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C59F249020 for ; Tue, 24 Jan 2023 08:41:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LMm4Dl4UVIHfu+iZhufNxmzDeBcUGIf0GsWQyq2jdtpW/Ln2Gt2f6H6tImkF4egJh9w256jpFeWmt3GfNpM1LYorz+3xQk68mxDXP5LzXsWjjFHYd7bHPc9GNSg2SZXvuaJI72RjJiopPR9nassUbX/IRveJpdCVVLuUzKyD5XHtlnhg/UUFq+/OhwihPMz0Q4UFjYlpOLZF46HM1Dny9YX6BoFOcW3uAzcJxgIDT+almE3Wur+vsWr11GrDiLmyxdf7+nCVOqvGH/b2KR4TVk+JNjGxA58DfM6lTXy3fR2SzJdpADK4/+jPsSj7oDDfgIzBBUStQxF185mjU4jlwQ== 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=PGGzLFLmfnBZaHGdccMyfAmnrSmSHgOf2zOPUT8XUpY=; b=hgCtvsgqvFb5Nz/9Z1lpByYsx6GzhQHRymykOCgHhfl5fXa7d5m+Rx3OkcqDOqVty5RMEbLWbaT5JY1ePaVpuHmRUcUggShnr8MAPCb5wLAJH5lAEcCbKF+buxp6YEKiwJQ/rqh+XAWe4GZr6dTHa3LnPyHtCEbG4nLcUTBL40V/nNUKRr3uemtKhgRLa+RUFtIQW6PSYIuB3YKHD/2KuzyDUW3s8pzXDVbx0sDYsMmJvt7OQCV6KHLbtkTiGsBXtoQC+iHMF7diihGYzDpNEVB++9SvzhbRXxnrwbB8FxHwvMliLv7jood/2rB1Vp2vLP+FZBnlhtbMTPmMo0FK1w== 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=PGGzLFLmfnBZaHGdccMyfAmnrSmSHgOf2zOPUT8XUpY=; b=RV/ZVv9Kb6UknLqjQKOZxl1YTgsgZrcnqOnjRC8AcPp6THzV/rvm9F8hk5DZac+123KboOtOxQx50URjT93NXEcX4cFNTZQSDx1ABEr+94LuPHLSnhv7zqo/t+kI+J7vTnJGg/wsnYEBauyfF3e1jOEGViMIKQ88dgtwK79DuU6jBEqG42fBWobcLSoXWxBFPWqysObXCB21X9ONOwwKBqVdFRxzFFJ1nQTMfxOsaodU6qB+uL0Uy/LHMwAcyKDP+wM5sV9HsqOJTUSub+ZoDka+aVmuN48qXFU1Hbd7sSMXlPsXqrn6cbkQ5PADqAW6kehOqt2dPQJlWoff96HT9A== 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 PAVPR03MB9848.eurprd03.prod.outlook.com (2603:10a6:102:31c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Tue, 24 Jan 2023 16:40:58 +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:40:58 +0000 Date: Tue, 24 Jan 2023 17:40:56 +0100 From: Manuel Traut To: linux-kernel@vger.kernel.org Subject: [PATCH 2/5 v7] input: pwm-beeper: add feature to set volume via sysfs Message-ID: Content-Disposition: inline X-ClientProxiedBy: FR0P281CA0104.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::15) To AS8PR03MB7621.eurprd03.prod.outlook.com (2603:10a6:20b:345::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR03MB7621:EE_|PAVPR03MB9848:EE_ X-MS-Office365-Filtering-Correlation-Id: 52c29732-d1ed-420a-0e23-08dafe29c556 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Set//yFatKlcQRM7AkteKHBS6uuptFZhILhlAtc3WC2dxrlnc29F8+KA+4vZftPWPmFKXsT9dBNZ0QDeKMWHsvSOK4fEzDMwShd/Ccl4nTNSdfxA7A4w78bc3Ek0HepuKdQn2Q3/HwFm18XMVpchTSPs+blOdwO6qeClxjZ6uE7Yk0n3CKueGPJTuuUkem1d9m73dzotkt7YTamhL//xsvwMboSwpM07HERHG16n0c3yHQvZjrAr8yzz7O4UZOf4DQYOhpb7dt8eoEhNIefbl67TAxMMAI9sTms74/rvZrvSGv7/Wzk4e1DfWCAkbsgCtnFW9SCwERgtiSQjSRMTPwYWxDuLBF6VVbCXxjIrYXp2mzO/oIEBBa5xseOUi2KD9JWA1kNkLOk/tBtnlFaz6BlqcbpxuusfPEjVvmyQgZQbnl4V80AnVzYODK1r53RLz/+JG+MQxL3ypaiYD8xJxBhBUJVN3sVPxBPMcPhMWl8sopM8YkMVY+TcVQDjdOnlS4tfpLHb1cZS+hRaIoMzETvol5ryzj+3SXfdlnwEw09R3xREOJJofRZGm8p6LDCqNEOqyXZkV+GHX/C6GfATjqalfRP7uSnSbWZU+Kv2SINBsHY48cqrrUV7PpAlqzFCUJRH9hw03FpXB8ze8CQ5isHPgT6zTVElisqraLo68K7J1rRn0by9KuRoWSS1Qdr1pkiFWBXFraDmbtgwKmHKLw== 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)(396003)(376002)(136003)(346002)(39860400002)(451199015)(38350700002)(38100700002)(83380400001)(41300700001)(86362001)(44832011)(2906002)(8936002)(5660300002)(316002)(6916009)(26005)(6512007)(6506007)(8676002)(186003)(66476007)(66556008)(2616005)(478600001)(52116002)(6486002)(66946007)(36756003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?BdOM16YGcAYVrd9uXu9D+vxM6aSH?= =?utf-8?q?Qy0SR7le7+/ZehlOcKIqq29rzB8DQbGofrhfQqd4E/t+1JWlKhGJuKvOoin5OpVNm?= =?utf-8?q?piwh7HPpVb0R7hCp3uW80m1BxgywAxpjtfPoDObuLBSEbSBS0CrgdpzkU1/mruRDG?= =?utf-8?q?A3MJRCJvZ0cZyMqjzwuJc6xqEJ012cRIo62HxbKY6RNL70fCmI8L0PhddpUgC6VQk?= =?utf-8?q?bEgKXVMH41FqPGiLaw+uGoVvewPt4v7fixZ2g4HQxiQUytXcnxCg7mpnGdVmKx5Nf?= =?utf-8?q?JL6XUf7aaXKNp0CT9ocW16sE0qzB2KjpKKlNJ6rItIaye7iCQAYPDSsQFre2GY8hM?= =?utf-8?q?C/8vweHM5iaZukYdmI5zu5JTS+z6CBOSFp0XKJeQjRkfxfxRDU3xgm43+8CGbZ0oh?= =?utf-8?q?Nms8xhw/Ph3THN+iRYrNyfOMZ6ptjQz+id4KyPWfY9ln02xMIo/TmQNLJh0qONNRk?= =?utf-8?q?YSyaBRg3sbfP1bVoie+1bwjx+axU7NXEtRhWQuIZKoSiIRSMymQMYVzTnvxm1fIzq?= =?utf-8?q?sP11S/1Tqg8eCZd6+3/3MDhEw8vTFJT8SVY86+YPD+g2Ua30RzB6jqub1EPS9sy/a?= =?utf-8?q?0n1aRXP5Dv9AMz5sS89cjuj+ttbUjgEUQjIJ8IzIy6ZKD34uz8R3MJpcOZ1BguCBY?= =?utf-8?q?DmPWMCeQ0lmivyf9WVWvJe+S0FK69x+UipmobG9ok3q5hpml6yWHb1ARdd3KYao3h?= =?utf-8?q?q+F0/9zubfvE/5U34o/12qAjTS8cujfc9gUd7s8/JsMIJXd8dcs6/EdC7WXDX/zfi?= =?utf-8?q?i0eum4M3rSPlbghtEbYGc7rJ6WQD2HRjZ4junYMEeI975HPPrPpKE/oiffRHAE/5h?= =?utf-8?q?lbtDJnyn9rD79b6iOUP2uPEpbydtDhrlxH+MEuAPPAkW606HExHwf41Lu5SlCdyPp?= =?utf-8?q?LDOVLvDyiwEf83843R8kVrO0cxC3P5oh+J7a1sdxs2uNWZanTFrlP/BV0XZlFgz0O?= =?utf-8?q?c9DC4QkNHHPdupzOPK+DiHGIg/LycioptHY7ykfcGRUmh5QTLrRZQLA1uMFHZtFdM?= =?utf-8?q?fxTJWDMJFQ5MDxLjBcbi+PAWbFRovTyxxOFLdDQ4UCoYZvmVwT83OPnE3DtPQv2Hh?= =?utf-8?q?GQsFCRJnIAEiRXrJfDY/MzQZ+FBZL467hhg+JjhpKHJFuksk36rPdDKc9mSXoA2OR?= =?utf-8?q?NhobXDvDYoQGK17DxA7pm4yuYXmMh6fA5+lv2Yxcq08Bxa8qxx0fwGX73pw6yBaA0?= =?utf-8?q?C+sKjGeBe7gWDfLBuqNHWhPzL/Rq7EyWnRwXD8v5+DYPywiKS4oRNnImtUV43e2fg?= =?utf-8?q?5FM6iOjUmts2cuw7ruNMwSdvfJ6ZxzlkGnO5dn3jS0lU/tFE5DdH1hA6NsoX0XUPf?= =?utf-8?q?DLSVSs7/Mrm1vDAVBFML6XvHPGzXRCO6W7QeuimCknEK4Gv3Cvyjm1CM2tsc9pSbj?= =?utf-8?q?AbnXX5KC/V/IjkWRp+Ex7wGKNT1gKEUZ6mbGth9o9xPZnozWHfxKSCVyccFxzeo9+?= =?utf-8?q?N93Rbwodrr5V1EzLktmU9LB09Q2t/X1GNpsyO83B3dyaNxu+lQ2c4yqzx6NxqiCcJ?= =?utf-8?q?8Id+crG4uXrP?= X-OriginatorOrg: mt.com X-MS-Exchange-CrossTenant-Network-Message-Id: 52c29732-d1ed-420a-0e23-08dafe29c556 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:40:58.4993 (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: cX/88pO4yUnSUtVTBjJspqTZmq0XN0RULndfJ70ABazVBtpCeDZ+y/o713jz+voKXC3H+rY44D2SNSIzFfEeIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR03MB9848 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?1755924061879075146?= X-GMAIL-MSGID: =?utf-8?q?1755924061879075146?= 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. This patch adds the 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 | 84 ++++++++++++++++++- 2 files changed, 100 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..8424b6776ca9 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-devices-pwm-beeper @@ -0,0 +1,17 @@ +What: /sys/devices/.../pwm-beeper/volume +Date: February 2017 +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 2017 +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..fb7b377fee6a 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,8 @@ 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 +183,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 +229,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 +268,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);