From nobody Mon Jun 8 09:48:37 2026 Received: from mail-dy1-f175.google.com (mail-dy1-f175.google.com [74.125.82.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5DFE241C8C for ; Sat, 30 May 2026 05:52:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780120365; cv=none; b=gUFKXtUd3vF+67GGypf19PKXzBXClUC44aQIS39VvXaXNhP0JSVFsiRFCpGWRTZd+WdFW6wGe1ntcq5rdMaSUT202cDxugTisD4aj8+crDYtC0GT51umvrFZIUzDjYB4rs2HSnnaHcCq9AAjHZVua5/IH3Tyo3qkAiu3vSXEpy8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780120365; c=relaxed/simple; bh=g7Y7oSEQhRGSn1nosiSXABfXAj+1YCyjB+H+/LK3n5M=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=GXnQgqh18RqtIhUwq8O553tjQtqHK/KUNbbktG6HiDe2jLc1C2xZgV0tt+KBOKFFgBGeJNDDIxkA/6rQc8BrM5CosCsIaTAjiW+32pzh5+DvtHNbAHPoPSdP3xqDtpWASLGdarY4jnK63zyez6raq7AshC2LZdudcNr6svCdmYY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QlecdiVh; arc=none smtp.client-ip=74.125.82.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QlecdiVh" Received: by mail-dy1-f175.google.com with SMTP id 5a478bee46e88-304ffa40c5dso1194129eec.1 for ; Fri, 29 May 2026 22:52:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780120363; x=1780725163; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=qdQNgeZti+jbt/sPucXP21rO5FPFecMWYZ4eJpj7Cb8=; b=QlecdiVhJNHncNOAfi0sUPK3kzzJcwNpHlIOpddU+jDEWaTtlrdGZ1GxLPVkHISvFc zbU25DnFnduEliJ7OhcMeJkTGdFMfWJvr+o+DnRSlIL7tL7Tq6dG7PAKZRvTPjkvTEtt zEcTIrvG1u+uxLPs4pSLFUfCwWaij++Rw+sAD9oqXAhlUgjs8nY3GrOhh6BF+Bk/IZue hGTMaBRXTDaQTrgOST52UNKMHKSFppt/CvROs9MqploKi0dZILhM4p6gQGXFIvPJOPWT EfeKaFmUOJwbwmKjuieeBEjoIj3ZfNtmE9PRhDfbDFIVtJi3yq06MP8bWXAZGEmJvIUl /rJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780120363; x=1780725163; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qdQNgeZti+jbt/sPucXP21rO5FPFecMWYZ4eJpj7Cb8=; b=aQ5fWnTWSO/ZrVOZ2Y7brXk1A6s0bs40gCDbZ23RguhibV5WBX5hmjud9VtahHnxlV xsOwSXD1aYhmBOtLj/SsGrcUF3tmxCpqDqo5RPK7gB7UR+NgcjYPCpuyP8acUSb9f7nF uk62L/OnzNYyT54/n8aEdCNGbixaCmYLjxyOtVSfpEJnJVgUgHqKi7D4pfNORtkBn9Y/ Dxn1JOehvUjzfdyvV4CmtXW3I7JB/8dNgwEasmETjNAh2grY5wFUIqhtuWKQfTGUEyGd vmzY+WE/bB9flwT/hyChXiLLDtl6ppF4LrDV0AM8ToPliKEf8T6bj8Um62VsfJyyV7cd E6aw== X-Forwarded-Encrypted: i=1; AFNElJ9nyG5L3o/NXPcqRE4/KHa2yBuJqEyvEv7jxra3BgreQxRXNJo7KxWZDaGrAQ1gffPd1AgNUrev7cDogPE=@vger.kernel.org X-Gm-Message-State: AOJu0YwDLS/VUS5Ia5ns7J1z6xfja3Dl7htMP5+r5f4rb86rX35NPBTb yC6JPTlSPmCP9Z/5sy156lkK9qlTY+AGtP0baHHZU5cosPBUFJ0H7vPj X-Gm-Gg: Acq92OFPtYOvIjZ/YaZv15LAh6sljKjZ8gtfwIjNikNTAifghsmWihlqI3AaA/qOn0A dHn6ImF02dMtHnwkNCdrxFWssiBQ4QgI9ixFEe9fnir/w/ZZrVSGkr4pgDit6h8Gu/8vT1LG4wr x0YR0ER3ZMB1z/OIuIQ3MoYiaUtM2DMiPL4tap/WqWWMm0hpPNc6RU+n6X3RVDqAf1/MmM7y9GO jBBFSQLt85gk3Vmrj9eqFCBiRij0BVXl2pW3b2xuDaa68IKnnfBOAiKbJYvtgjtp3yn4sKbvwTp GLM+psWy/qjsT4+9wstsihMwi/GDIhY1gQl/RsN+ZkFhtLvg8okeaQ7VR1CxnTLtX7ZTRR14YNe wfwsuq+obbNr+If0o/gAOoGQQSDWEptzEPzItRAds+HD1FbnxoZUnfB8z4vcxq2wgVUZmjtgOSH XifSgNLnz9GjyLLE/VJCTlDlFawCv9g7lFL4O8mqJLOuQGmgoQwxNaTfDkr4XShGBfE7F4VJIt/ EQ= X-Received: by 2002:a05:7300:a191:b0:2f1:6252:f8fe with SMTP id 5a478bee46e88-304fa49edfcmr1238962eec.3.1780120362745; Fri, 29 May 2026 22:52:42 -0700 (PDT) Received: from google.com ([2a00:79e0:2ebe:8:307d:2a52:8823:4a01]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-304ed5d26d1sm3293012eec.30.2026.05.29.22.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2026 22:52:42 -0700 (PDT) Date: Fri, 29 May 2026 22:52:39 -0700 From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: "Rafael J. Wysocki" , linux-kernel@vger.kernel.org Subject: [PATCH] Input: atlas_btns - modernize the driver Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rework the driver to use modern style: - Remove global state by introducing a per-device structure - Use devm for resource management (input device allocation) - Use dev_err_probe() for error reporting in the probe path - Clean up unused definitions and headers. Assisted-by: Gemini:gemini-3.1-pro Signed-off-by: Dmitry Torokhov --- drivers/input/misc/atlas_btns.c | 109 ++++++++++++++++---------------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/drivers/input/misc/atlas_btns.c b/drivers/input/misc/atlas_btn= s.c index 835ad45a9d65..5805a1a3bb05 100644 --- a/drivers/input/misc/atlas_btns.c +++ b/drivers/input/misc/atlas_btns.c @@ -15,17 +15,18 @@ #include #include #include -#include =20 #define ACPI_ATLAS_NAME "Atlas ACPI" -#define ACPI_ATLAS_CLASS "Atlas" =20 -static unsigned short atlas_keymap[16]; -static struct input_dev *input_dev; +struct atlas_btns { + struct input_dev *input_dev; + unsigned short keymap[16]; +}; =20 /* button handling code */ static acpi_status acpi_atlas_button_setup(acpi_handle region_handle, - u32 function, void *handler_context, void **return_context) + u32 function, void *handler_context, + void **return_context) { *return_context =3D (function !=3D ACPI_REGION_DEACTIVATE) ? handler_context : NULL; @@ -34,33 +35,37 @@ static acpi_status acpi_atlas_button_setup(acpi_handle = region_handle, } =20 static acpi_status acpi_atlas_button_handler(u32 function, - acpi_physical_address address, - u32 bit_width, u64 *value, - void *handler_context, void *region_context) + acpi_physical_address address, + u32 bit_width, u64 *value, + void *handler_context, + void *region_context) { - acpi_status status; + struct atlas_btns *atlas =3D region_context; =20 if (function =3D=3D ACPI_WRITE) { int code =3D address & 0x0f; int key_down =3D !(address & 0x10); =20 - input_event(input_dev, EV_MSC, MSC_SCAN, code); - input_report_key(input_dev, atlas_keymap[code], key_down); - input_sync(input_dev); + input_event(atlas->input_dev, EV_MSC, MSC_SCAN, code); + input_report_key(atlas->input_dev, atlas->keymap[code], + key_down); + input_sync(atlas->input_dev); =20 - status =3D AE_OK; - } else { - pr_warn("shrugged on unexpected function: function=3D%x,address=3D%lx,va= lue=3D%x\n", - function, (unsigned long)address, (u32)*value); - status =3D AE_BAD_PARAMETER; + return AE_OK; } =20 - return status; + dev_warn(atlas->input_dev->dev.parent, + "unexpected function: function=3D%x,address=3D%lx,value=3D%x\n", + function, (unsigned long)address, (u32)*value); + + return AE_BAD_PARAMETER; } =20 static int atlas_acpi_button_probe(struct platform_device *pdev) { struct acpi_device *device; + struct atlas_btns *atlas; + struct input_dev *input_dev; acpi_status status; int i; int err; @@ -69,65 +74,62 @@ static int atlas_acpi_button_probe(struct platform_devi= ce *pdev) if (!device) return -ENODEV; =20 - input_dev =3D input_allocate_device(); - if (!input_dev) { - pr_err("unable to allocate input device\n"); + atlas =3D devm_kzalloc(&pdev->dev, sizeof(*atlas), GFP_KERNEL); + if (!atlas) return -ENOMEM; - } + + input_dev =3D devm_input_allocate_device(&pdev->dev); + if (!input_dev) + return -ENOMEM; + + atlas->input_dev =3D input_dev; =20 input_dev->name =3D "Atlas ACPI button driver"; input_dev->phys =3D "ASIM0000/atlas/input0"; input_dev->id.bustype =3D BUS_HOST; - input_dev->keycode =3D atlas_keymap; - input_dev->keycodesize =3D sizeof(unsigned short); - input_dev->keycodemax =3D ARRAY_SIZE(atlas_keymap); + input_dev->keycode =3D atlas->keymap; + input_dev->keycodesize =3D sizeof(atlas->keymap[0]); + input_dev->keycodemax =3D ARRAY_SIZE(atlas->keymap); =20 input_set_capability(input_dev, EV_MSC, MSC_SCAN); - __set_bit(EV_KEY, input_dev->evbit); - for (i =3D 0; i < ARRAY_SIZE(atlas_keymap); i++) { + for (i =3D 0; i < ARRAY_SIZE(atlas->keymap); i++) { if (i < 9) { - atlas_keymap[i] =3D KEY_F1 + i; - __set_bit(KEY_F1 + i, input_dev->keybit); - } else - atlas_keymap[i] =3D KEY_RESERVED; + atlas->keymap[i] =3D KEY_F1 + i; + input_set_capability(input_dev, EV_KEY, KEY_F1 + i); + } else { + atlas->keymap[i] =3D KEY_RESERVED; + } } =20 err =3D input_register_device(input_dev); - if (err) { - pr_err("couldn't register input device\n"); - input_free_device(input_dev); - return err; - } + if (err) + return dev_err_probe(&pdev->dev, err, + "couldn't register input device\n"); =20 /* hookup button handler */ status =3D acpi_install_address_space_handler(device->handle, - 0x81, &acpi_atlas_button_handler, - &acpi_atlas_button_setup, device); - if (ACPI_FAILURE(status)) { - pr_err("error installing addr spc handler\n"); - input_unregister_device(input_dev); - err =3D -EINVAL; - } + 0x81, + &acpi_atlas_button_handler, + &acpi_atlas_button_setup, + atlas); + if (ACPI_FAILURE(status)) + return dev_err_probe(&pdev->dev, -EINVAL, + "error installing addr spc handler\n"); =20 - return err; + return 0; } =20 static void atlas_acpi_button_remove(struct platform_device *pdev) { struct acpi_device *device =3D ACPI_COMPANION(&pdev->dev); - acpi_status status; =20 - status =3D acpi_remove_address_space_handler(device->handle, - 0x81, &acpi_atlas_button_handler); - if (ACPI_FAILURE(status)) - pr_err("error removing addr spc handler\n"); - - input_unregister_device(input_dev); + acpi_remove_address_space_handler(device->handle, 0x81, + &acpi_atlas_button_handler); } =20 static const struct acpi_device_id atlas_device_ids[] =3D { - {"ASIM0000", 0}, - {"", 0}, + { "ASIM0000" }, + { "" } }; MODULE_DEVICE_TABLE(acpi, atlas_device_ids); =20 @@ -144,4 +146,3 @@ module_platform_driver(atlas_acpi_driver); MODULE_AUTHOR("Jaya Kumar"); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Atlas button driver"); - --=20 2.54.0.823.g6e5bcc1fc9-goog --=20 Dmitry