Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp240823pxf; Wed, 10 Mar 2021 05:27:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5SvMHXYGjmPZpE5D5gKxpnKodmmVwdy6h98Kw/A0DpEnMarjdi1OpwYZ8cTsvXDZTDR+l X-Received: by 2002:a17:906:228d:: with SMTP id p13mr3665898eja.412.1615382827591; Wed, 10 Mar 2021 05:27:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615382827; cv=none; d=google.com; s=arc-20160816; b=Q25dEoekK+35KYW16M8jULBp7sFz6Y76q1AuOP2qKLCvL6aTipFuLdEoJd1AYsPBhZ V6zyRtvlOeGxZO9zJIL2GvOkECTH/lwTI9AUd0u2N3z0AH11+N2xMtCi+tzh9d2dcZj6 3C2OM2CICsAbh0ZAAIzRWceLFisQvKjCqHYrHQkF7f0IsJlCXIyZNFhE0Oxx3RtmqE8X 1ikp9/l2B5ikN5evbfAxikR8S8pmk7FYOZCV9vEqVEh5NouRuMdwtmrp8h32Av8ZnDof RdNBRRzBzyAbsbFFeWVApLSQ5dk9CrVolr4KIH8Fa/5a0Z7KI2VGQOQXn2czGgyipJ30 U+Zg== 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=aaGKrZWmg+8gpWI00/vLkB3RAkUKvGiXVGthtAx93b4=; b=Ik4qIzqWW9ChKBOWR/FNkesHKXCX/ma22VopDHcIPTLESKMz0fW5Rrkx3DjhWY7+z6 L5kI5T1S9qTOa88vtVmro2cvw5cAZKZb3bo9woH5k4fka08I9HeFgFwDjiUI1ROGRDtx Nvj9oBT1ctYU43YYGcV7rD6d30/HErXE3UbmHvpkGZR1dLbYECwUasTEb4AuWS+OTKeR qJNjMNWmEBCSZvtrZpLS2u+X3yGkeyhqdetLzZPkzd5fLX8iRNljbQvg8z3YF5lTjFA3 UNPh4g0g92Pfk9aChwm8e5Eojg+ucqsKm4v8pykOsnpuaaXJr73e1Zpur1xkTSRIXDxp eKYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hzJO8onI; 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 y23si6204943ejp.249.2021.03.10.05.26.43; Wed, 10 Mar 2021 05:27:07 -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=hzJO8onI; 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 S233451AbhCJNZj (ORCPT + 99 others); Wed, 10 Mar 2021 08:25:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:45702 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232841AbhCJNYg (ORCPT ); Wed, 10 Mar 2021 08:24:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7D64764FEF; Wed, 10 Mar 2021 13:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382675; bh=JjlIU+rvSzZPnqj5dEbYj+4logLnkYApVGih9bwwn4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hzJO8onIS5qskLKn4Qiq1hu2cYiQn419vJH4QlFKt0JgvhvniRjRG45hojso1pAal GB5p3SdVTZz5uzL5hvdaBe3S9VSW3KztoXchIjO5uPwkbf1JyRGkYZe2O4V369l7CU 6oSX8c8/W/AwE60ZjHhh3p0iEX86STEjKE4vMKnU= 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.10 16/49] platform/x86: acer-wmi: Cleanup accelerometer device handling Date: Wed, 10 Mar 2021 14:23:27 +0100 Message-Id: <20210310132322.477968640@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132321.948258062@linuxfoundation.org> References: <20210310132321.948258062@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 75b1f6ceb76e..184ec08d02a4 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