Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp245405pxf; Wed, 10 Mar 2021 05:33:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMxVmAMcQng6VyLY/TT6/LYoGknUZjyyelqAcWNSo6yaOXKWJ/r7/QcA/tNwvgcXz1dH+7 X-Received: by 2002:a17:907:b06:: with SMTP id h6mr3681128ejl.144.1615383222608; Wed, 10 Mar 2021 05:33:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615383222; cv=none; d=google.com; s=arc-20160816; b=n4e/RSRgiTsxmGnpe09F2Vr7PRlkMAmvoq6ZksfMy0tKIw9KjXy7oUq1aIls/sd6t5 3smAVQiQvFUS2AHsHu8VEdJVsx4g8waMoBji5QtiNBMcgz6hdhhlfnHSWh3LV6C+uzqL GyGSJv8si4dzBDw3J2jNCbYqueCCLLvHAsnnHA3DKihQm1ZGDE0dEbiD60R7FUjH1fsq HES4XFgbEOlPWHsacFk0xfsWvGtQH8C84kFGB6ZdxSiVcqv5od6xt5yOSoQH4uCVBdKy QmYWOUD56WWf/TwE3R+YV+rwFnaEZgPN1gVug+gPhNQKmCqON6CKVgK0WggIB4zCpKjr +k8A== 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=bgSyNQMMBCrcILCHSYxjfYDcGn5c9TL8df4tNpaZ7aQ=; b=kwKt51cc2LLcUeWKtcPzINkBVdk2ObILOTHDGn3SrV6fLMaAkHKTNqFOinsxyBp0le 9t06tbvzat6ED1LP6XElbU145pxQnrika2t7nDh/ZYNaJvmWIpFfl+g82XiO7Ipk6hNL jHBTe/nebl7LN6zC9j27fhw4SdmRsV7+fWVz27gc/+TWcDfI9x9NIfnc+UF+BOtEUAVU BhCTqiUXLfpl5J0gPGAOoSCF49m7/e4HMkvszW8r1xjObUeHSEAjry7pjQtqTlhlf643 GAU06/Nw7jlBw5bmUxIMRMUEh1ODlDpvefhCfaCtnFavlm3SvXpyHt6LbMVYBhZR/Adt vHMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="uUHDPCv/"; 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 os24si12293610ejb.729.2021.03.10.05.33.20; Wed, 10 Mar 2021 05:33:42 -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="uUHDPCv/"; 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 S234359AbhCJNaQ (ORCPT + 99 others); Wed, 10 Mar 2021 08:30:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:48628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233480AbhCJNZl (ORCPT ); Wed, 10 Mar 2021 08:25:41 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B1C2E64FDA; Wed, 10 Mar 2021 13:25:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382741; bh=wLklBr5q8q6e7TbB1MwTMrvQA84qaaYu38tHb7WlGLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uUHDPCv/X36GrAuK/MOXF+vGc4n1aqj0uKXi6Zs6eh806LPh8dmmbp7OGWRqc1qwB yvljyxc11pu1fjO5dQ/xPw9ElKmQtPqXslMV4JNoXohtAAEJEWVgIVq9GE5N1islQm tucORx1v9VTQ4Q5Ucdkq+gNhatvMByJlUVzb+sXg= 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 4.19 28/39] platform/x86: acer-wmi: Cleanup accelerometer device handling Date: Wed, 10 Mar 2021 14:24:36 +0100 Message-Id: <20210310132320.597353840@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132319.708237392@linuxfoundation.org> References: <20210310132319.708237392@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 8d06454f5915..b95dce2475ab 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -224,7 +224,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 @@ -1526,7 +1525,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); @@ -1935,8 +1934,6 @@ static int __init acer_wmi_accel_setup(void) if (err) return err; - interface->capability |= ACER_CAP_ACCEL; - acer_wmi_accel_dev = input_allocate_device(); if (!acer_wmi_accel_dev) return -ENOMEM; @@ -1962,11 +1959,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; @@ -2121,7 +2113,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; @@ -2329,8 +2321,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; } @@ -2340,8 +2332,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