Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5945997ybi; Wed, 31 Jul 2019 05:56:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwEAC3cXKQvowg7WxcgFBv/wWl9IPImWi3GnbObGazx4py49U5HzJyGKmES+JsL1Cxo2saG X-Received: by 2002:a62:7994:: with SMTP id u142mr48012351pfc.39.1564577785306; Wed, 31 Jul 2019 05:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564577785; cv=none; d=google.com; s=arc-20160816; b=LsXkopvycaWEEXcrHATeBmAP8pFJBjN+gLSAQlE8NqPqvwZ5DifaDbzBdSHCSpW6cL v5lu0BaqFODNyZllIfLyOpGTjmJtBiwN1PS6S34ftWy1N8bnetj1HWHwKpOCspofboL9 89ah8I6cy2YwcNhzxVYnj6znUrm6igZMfG8TNY8RyavfEuHvCDH5xEWgN2VVmvfgGgss VHnCEC8izcTrOEk2HPRhzLvNK5VqaYNvjNrQoOEbUbdGgLq+TuW87mnDeOF0ljp0yPtR 8i/e0FU+PeTHohFz/vqJ2jXriZmh9fdGXgneq76l8oQd7E+LgWb1JIrtsMHaQbJQJTow NJ/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kxOYsHIJ1torBrdEMEs5rH4UEUZXUYtb4Vzdt/twVUE=; b=TndrBi4/HUrl+VFQG+VE3lmpxyD9Q4R85OKz3ys46NCyIQ1q5v9kKEas6AChgYLYNU Aus0QI+GN39WRtzIj/3KkttQP+3QL0r85seIc4aqPNcYttHdwbV4GBuROHeam+E76kbK x77Z/8jpSo+TJ3RSN4vpAGkXfH+jLYsEu1uCh3808jkeilKFe2ONgTezlAX1Z/fkN0B5 7Es/DarwfftgctIQsDCTXhJFYD6hA+FSgwnToPZ/F3WgNdXn+ekFcovsl+fcgSdqaiVx FA/ZNsXPlfg3RKoC+EKjWpCw/wxTysjegQoRDu0tf+Og+gNGcYoptMEyXWBj7VPMt4Gy cw8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nZEmMe59; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si34087379pgv.577.2019.07.31.05.56.10; Wed, 31 Jul 2019 05:56:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nZEmMe59; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729008AbfGaMoZ (ORCPT + 99 others); Wed, 31 Jul 2019 08:44:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:36782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388055AbfGaMoV (ORCPT ); Wed, 31 Jul 2019 08:44:21 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 25B412089E; Wed, 31 Jul 2019 12:44:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564577060; bh=aQIf4vVZX+H6cS8o4sG55uCLuDksr6xmUzh8BYSCx/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nZEmMe59qpAGyZT3/9u4H0VSjvaPvJP54cRteRdT7XTTJpNYypcbAFV7wEx9477Av mpTUw42pxEjBfOZ5ojr8sGAvvrDKIWEjprJsRm1RtLCCPpad+N7BX4q1v0Pzgqx7Wh 28FiG7a8kxYf3po7Rd4YR7Oaa8HA6Gl17tZ+DovM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, Richard Gong , Dmitry Torokhov Cc: Greg Kroah-Hartman , Darren Hart , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, platform-driver-x86@vger.kernel.org, Andy Shevchenko Subject: [PATCH v2 07/10] platform: x86: hp-wmi: convert platform driver to use dev_groups Date: Wed, 31 Jul 2019 14:43:46 +0200 Message-Id: <20190731124349.4474-8-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190731124349.4474-1-gregkh@linuxfoundation.org> References: <20190731124349.4474-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Platform drivers now have the option to have the platform core create and remove any needed sysfs attribute files. So take advantage of that and do not register "by hand" a bunch of sysfs files. Cc: Darren Hart Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: x86@kernel.org Cc: platform-driver-x86@vger.kernel.org Acked-by: Andy Shevchenko Signed-off-by: Greg Kroah-Hartman --- drivers/platform/x86/hp-wmi.c | 47 +++++++++-------------------------- 1 file changed, 12 insertions(+), 35 deletions(-) diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index 2521e45280b8..6bcbbb375401 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c @@ -502,6 +502,17 @@ static DEVICE_ATTR_RO(dock); static DEVICE_ATTR_RO(tablet); static DEVICE_ATTR_RW(postcode); +static struct attribute *hp_wmi_attrs[] = { + &dev_attr_display.attr, + &dev_attr_hddtemp.attr, + &dev_attr_als.attr, + &dev_attr_dock.attr, + &dev_attr_tablet.attr, + &dev_attr_postcode.attr, + NULL, +}; +ATTRIBUTE_GROUPS(hp_wmi); + static void hp_wmi_notify(u32 value, void *context) { struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; @@ -678,16 +689,6 @@ static void hp_wmi_input_destroy(void) input_unregister_device(hp_wmi_input_dev); } -static void cleanup_sysfs(struct platform_device *device) -{ - device_remove_file(&device->dev, &dev_attr_display); - device_remove_file(&device->dev, &dev_attr_hddtemp); - device_remove_file(&device->dev, &dev_attr_als); - device_remove_file(&device->dev, &dev_attr_dock); - device_remove_file(&device->dev, &dev_attr_tablet); - device_remove_file(&device->dev, &dev_attr_postcode); -} - static int __init hp_wmi_rfkill_setup(struct platform_device *device) { int err, wireless; @@ -858,8 +859,6 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device) static int __init hp_wmi_bios_setup(struct platform_device *device) { - int err; - /* clear detected rfkill devices */ wifi_rfkill = NULL; bluetooth_rfkill = NULL; @@ -869,35 +868,12 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) if (hp_wmi_rfkill_setup(device)) hp_wmi_rfkill2_setup(device); - err = device_create_file(&device->dev, &dev_attr_display); - if (err) - goto add_sysfs_error; - err = device_create_file(&device->dev, &dev_attr_hddtemp); - if (err) - goto add_sysfs_error; - err = device_create_file(&device->dev, &dev_attr_als); - if (err) - goto add_sysfs_error; - err = device_create_file(&device->dev, &dev_attr_dock); - if (err) - goto add_sysfs_error; - err = device_create_file(&device->dev, &dev_attr_tablet); - if (err) - goto add_sysfs_error; - err = device_create_file(&device->dev, &dev_attr_postcode); - if (err) - goto add_sysfs_error; return 0; - -add_sysfs_error: - cleanup_sysfs(device); - return err; } static int __exit hp_wmi_bios_remove(struct platform_device *device) { int i; - cleanup_sysfs(device); for (i = 0; i < rfkill2_count; i++) { rfkill_unregister(rfkill2[i].rfkill); @@ -966,6 +942,7 @@ static struct platform_driver hp_wmi_driver = { .driver = { .name = "hp-wmi", .pm = &hp_wmi_pm_ops, + .dev_groups = hp_wmi_groups, }, .remove = __exit_p(hp_wmi_bios_remove), }; -- 2.22.0