Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp243192pxf; Wed, 10 Mar 2021 05:30:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwasqJlNVu69Bka3KdXLWg3InCIC7AwMx9hkGHubu/hBsnY0MAnEIOocOh+cOl/LUzYEkUT X-Received: by 2002:aa7:d954:: with SMTP id l20mr3262783eds.1.1615383038017; Wed, 10 Mar 2021 05:30:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615383038; cv=none; d=google.com; s=arc-20160816; b=M7ozPmd56EeUek/60KMXJhcSytB299x90+ba5cQvTKq91aZ+HjSZ3L24UN665z4rVs KH+lDvhzf+Wmh/WllfvSZz9SQJM7Fsa4y0GAa31q1y7gjpEHV9GCMJmjBLYYnexjcCC4 tQdmycmQWIJfM7D7ik4L3mEP4z4idV4W/t1FpdTuf2D+ZhyMpzUyLwFAuDa+IGKZ8s98 TbTLIdmYAOKCQcout5naeIUHqKjt6/tLnT2NwK4oJTKes9ekbJSxJfQu92qmoMf6/l3V IxlcuKaP2ukgTNKMZr+vfaUSZvHzFl3JNBiDQi1HoeCoS8tXOqk02l2EWt87gYZxqjbT 4Hfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uSJYJnmaYlO0EqkDZMvCpcgw8NnoaayMnlzEbhFbu80=; b=Q23D1/TCaywMQl0oz1dkJB+ISRqXw+FcLEN8xIV/n0XNxh1OHowvghcaC238QtrIVh hA7DV//xackHJpr5NRIphMr+rfHomfNSAya5O2dxQiNE3SCIh4l2+l8/9lEY0rQWHOhG Ge5L3OSyQSbtr9DHgasKwhMtCfCOtg47XEtE99z4rodD9JYbn0ZUyJmsCy2gobJF+N6H 5LNBnQWyE6WAIt8FB/uMuPe7R7dz1a5zUj8M+EyzgBlZ2UritQUIz0yC48T/LzAzYKGx fNoEYvggG2oiFw+FCLQMSHayUHffb5YH4yeSqx9RoR1kzFSFjMHCUmacVJywjY9ShP90 m1gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="jRLJ71d/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z23si9098765eju.427.2021.03.10.05.30.13; Wed, 10 Mar 2021 05:30:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="jRLJ71d/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233130AbhCJN1N (ORCPT + 99 others); Wed, 10 Mar 2021 08:27:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:46424 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233120AbhCJNY4 (ORCPT ); Wed, 10 Mar 2021 08:24:56 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 22D6B64FF7; Wed, 10 Mar 2021 13:24:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382696; bh=kmdz5iAEnrtsvLj+hKc5HQ3LxXB7RPoDFjo2ozU22to=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jRLJ71d/vjTR4gRwYisXKOOJGQO553q/V9AZNG7tp58mBkV86Qyd6EhIhXPpzQGrK WAqpHWTKg9jJPPU2Jr/A8uXxLkWTgEwL+OsSgpJT9rURCKYDBcaQzxDD9V36nzEUMr K+7vetBAKhrNVKT8jjAJgkM5C9aCO7lHQrftcBGE= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , Hans de Goede , Sasha Levin Subject: [PATCH 5.4 09/24] platform/x86: acer-wmi: Cleanup accelerometer device handling Date: Wed, 10 Mar 2021 14:24:21 +0100 Message-Id: <20210310132320.834384334@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132320.550932445@linuxfoundation.org> References: <20210310132320.550932445@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Hans de Goede [ Upstream commit 9feb0763e4985ccfae632de3bb2f029cc8389842 ] Cleanup accelerometer device handling: -Drop acer_wmi_accel_destroy instead directly call input_unregister_device. -The information tracked by the CAP_ACCEL flag mirrors acer_wmi_accel_dev being NULL. Drop the CAP flag, this is a preparation change for allowing users to override the capability flags. Dropping the flag stops users from causing a NULL pointer dereference by forcing the capability. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20201019185628.264473-3-hdegoede@redhat.com Signed-off-by: Sasha Levin --- drivers/platform/x86/acer-wmi.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index daf692fe7f77..167d0446f560 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -211,7 +211,6 @@ struct hotkey_function_type_aa { #define ACER_CAP_BLUETOOTH BIT(2) #define ACER_CAP_BRIGHTNESS BIT(3) #define ACER_CAP_THREEG BIT(4) -#define ACER_CAP_ACCEL BIT(5) /* * Interface type flags @@ -1516,7 +1515,7 @@ static int acer_gsensor_event(void) struct acpi_buffer output; union acpi_object out_obj[5]; - if (!has_cap(ACER_CAP_ACCEL)) + if (!acer_wmi_accel_dev) return -1; output.length = sizeof(out_obj); @@ -1890,8 +1889,6 @@ static int __init acer_wmi_accel_setup(void) gsensor_handle = acpi_device_handle(adev); acpi_dev_put(adev); - interface->capability |= ACER_CAP_ACCEL; - acer_wmi_accel_dev = input_allocate_device(); if (!acer_wmi_accel_dev) return -ENOMEM; @@ -1917,11 +1914,6 @@ err_free_dev: return err; } -static void acer_wmi_accel_destroy(void) -{ - input_unregister_device(acer_wmi_accel_dev); -} - static int __init acer_wmi_input_setup(void) { acpi_status status; @@ -2076,7 +2068,7 @@ static int acer_resume(struct device *dev) if (has_cap(ACER_CAP_BRIGHTNESS)) set_u32(data->brightness, ACER_CAP_BRIGHTNESS); - if (has_cap(ACER_CAP_ACCEL)) + if (acer_wmi_accel_dev) acer_gsensor_init(); return 0; @@ -2266,8 +2258,8 @@ error_device_alloc: error_platform_register: if (wmi_has_guid(ACERWMID_EVENT_GUID)) acer_wmi_input_destroy(); - if (has_cap(ACER_CAP_ACCEL)) - acer_wmi_accel_destroy(); + if (acer_wmi_accel_dev) + input_unregister_device(acer_wmi_accel_dev); return err; } @@ -2277,8 +2269,8 @@ static void __exit acer_wmi_exit(void) if (wmi_has_guid(ACERWMID_EVENT_GUID)) acer_wmi_input_destroy(); - if (has_cap(ACER_CAP_ACCEL)) - acer_wmi_accel_destroy(); + if (acer_wmi_accel_dev) + input_unregister_device(acer_wmi_accel_dev); remove_debugfs(); platform_device_unregister(acer_platform_device); -- 2.30.1