Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp244302pxf; Wed, 10 Mar 2021 05:32:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBeiaC/SLnizSPqF0MntrTBjCpdAIs5cqeBxpJ5dOZFNIatiUnQjxEF38EIQIkN2Ag9Mb1 X-Received: by 2002:a05:6402:5244:: with SMTP id t4mr3339448edd.87.1615383127048; Wed, 10 Mar 2021 05:32:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615383127; cv=none; d=google.com; s=arc-20160816; b=KvkLmQdcDYPU2/EWN6QZ2/gHK5wA+b80Ib8k5C+O/WkAvGorjMcYYQZmDdg3VFd9GQ BSCOAITzQLfD7tBlyk/AOmwqV3h482yYRB+kH8naA4g5wJ/SpVe1ElQbzKr0O0cyLue6 VzKwN3jVGgMR6sFgj92NGEwfRiZdfHiFF+ni6NVh7igQiEZvdr6NctPij8+JqccYC8Bu mDzTtyZAdTN24RRUr9je+vAIfMiokDUIjQN3lvWBWTXfFKS5HIF5dSpgDPNSsZKbyYEk G4JTW2q8Vy43O+hWOX+1G2aj2xkIhop1pBTxoGZGTHtu7E9Lcj6RHLp337NZMpCQxB3c 3xcQ== 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=Iu6DCmRxWi3dnHJFoXHaN63lNitYybZ/3WX/RZHRQuo=; b=YxMSmMIEOrvVO518NR69k1MS8PPtRULCyZEClxq3DbRbPlTwot41mYafoUVJ+50w6U Osf7Vy5T6pDQk+sxSV9JUiqS44Y9Ll8TIbvkzRpPYTDXWYAW3YJUtWKG7uiPKFg1sLDu 1D1n57K2eFM+U+uDFaPjAsPNLlrJ58PUl8hS597IG0yS38ZNDNtpWhHFEbrPpxWeUOoR 6WTZ/wDmnGSD5lQqCidQHOTvG6svbuFFrQSOEgcA5DBDpGqsmSTb7hBAFHKjA5k6iZ9H qMH6QegjTLsl/i12qkt3JN6EmzR9UYFc5ciJq06l/VrH6TlgNEVKtXnfraJSCr7wJJ9y ZWoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mHAy0jtJ; 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 bl4si11394322ejb.691.2021.03.10.05.31.42; Wed, 10 Mar 2021 05:32: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=mHAy0jtJ; 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 S234394AbhCJNap (ORCPT + 99 others); Wed, 10 Mar 2021 08:30:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:46706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233338AbhCJNZY (ORCPT ); Wed, 10 Mar 2021 08:25:24 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7058965093; Wed, 10 Mar 2021 13:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382722; bh=7f6XdJJ1Zynu2jUey9mfRLbPvQ68aAgy++Bhz9RJ0Jk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mHAy0jtJ+dp284tC4GPCrCpoD3AS0RXld8UXw/Uyp5Q+usqXUimzp+/OzeIQeCU8f nNkuBT9rJay+ZgEmjBTqzRpLIbLDhZZ4ms8lEbc7P9PYp9xaYbfsmtD8R08wuuSGQ5 qrbA+gQkTET+RLmqxlJr9WTjFHv9vT40SWvGw4lo= 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.14 13/20] platform/x86: acer-wmi: Cleanup accelerometer device handling Date: Wed, 10 Mar 2021 14:24:50 +0100 Message-Id: <20210310132320.952294233@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132320.512307035@linuxfoundation.org> References: <20210310132320.512307035@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 41311c1526a0..445e9c17f4a8 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -223,7 +223,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 @@ -1528,7 +1527,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); @@ -1937,8 +1936,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; @@ -1964,11 +1961,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; @@ -2123,7 +2115,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; @@ -2331,8 +2323,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; } @@ -2342,8 +2334,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