Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2638596rdg; Mon, 16 Oct 2023 10:06:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzCdZ9e16lRtkYK166JjxRr0LI/nLM85AngUHBrwj1Wz9mHoXXfFVX9HHigOzQ08bKpvfi X-Received: by 2002:a17:90b:4ad1:b0:27d:72bb:3d92 with SMTP id mh17-20020a17090b4ad100b0027d72bb3d92mr5176661pjb.19.1697475986662; Mon, 16 Oct 2023 10:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697475986; cv=none; d=google.com; s=arc-20160816; b=h9D4gtOz+KlA9+MkhTsRQ5KmWqJd728XsaU0Qho/BEk9y53RlFsexOwww2JPt5AU4/ 79IpyPW03qUgUCveDWD13a9T/oTdkJuCZc+uzhNtbyWdcXx3NKvxI8L4mZEKkePr5yU0 sJjGHInnq0YW4dxvJ5/jLzuQVbklxsJHMFG/j/sUhREdAvEi52n/dTBrHBfMq5GEK3pZ ImYOehUGNp/6gEiY6LGnt5hTZ5k6wKZiu06u/h/Wd/sotObQSXPZlx0Vl4+z6R8QdcKG hDSW8kIF70mHIrKDD5CZpop+oZKW2QSEuFxNyHNTdBP0NEijTsPl0FJdz7u+yzgf5CTB GrCg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=so5MshlHz5DJ2eCnCbX57/qnmWD8VMX2NlAymYd4DM4=; fh=EvL1iI4ogoJvlluMcaToLiWwxTGXz8CU3B6zVv0I1qM=; b=CQ0Z55dEjrMfnxzqKWA1RphqlXQVGKRnj0+fgAvcow9TRshnH3Y2sNccfyJ9wyEvNJ 3kK85uUXKG5VHdzuwmdFLktdvxgE2SstOoGSozkfm49AWHZPB1u3vdeZOvYsWE1PLK6j 9CGwhTqXqjlF+HlbzEcbC7iAgoClncueRt387IJx7Fm74FdGlQqC/kzXAMu/vajRmu/6 8rP+A1vOBBl27rG5PrFrza9xC33b4et9xyJ5M1UEy3RW3Qk/E2YRCpVgtRieP3WWPdY7 lUsuJKpGuMXKESNie5eM8ssNP4/6c6M8cIZbrn5e6/FTrr1eWc7z2asb6WuufZgvKb5f LL6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KRnbaxOn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id kb13-20020a17090ae7cd00b002764fc15dd3si7134623pjb.37.2023.10.16.10.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 10:06:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KRnbaxOn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id EB6B880A282D; Mon, 16 Oct 2023 10:06:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234422AbjJPRF5 (ORCPT + 99 others); Mon, 16 Oct 2023 13:05:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234539AbjJPRFW (ORCPT ); Mon, 16 Oct 2023 13:05:22 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 190AC3254; Mon, 16 Oct 2023 10:01:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697475714; x=1729011714; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m3Z4WGrXG69PQDGxjpaL1h4E+zMeZMVLbMui312R5WQ=; b=KRnbaxOnN40z6z0rjnshn6txvvuUoOsvXmrBFc+TiWkKHuJhT34Issf3 bYSW+6uD/O79Nn3swsKM3ARdl42IiaHxPim4UBoTaQxHeULBiJs6FGIGr 6tkC5Omg2BQQqvrOUVMiPRRqRn8mo6qCB8IJs0XFcPcjssPxbxBjrCZgq eHVcpXmX2xNrAnH1yNCURX84OnBXRrJiuxblXm5soP+mQfqCdA3YFdWaN rd+ekVtdnnZ+fHhK7QKTbOQkEr2IQ13Vm6vnzGtTaCle5dhiYCT+4Mpsn mHXxbzjihOF+uaoqh+DDMg+wkfkTXKKCpeRcws0hILtD/HD+tQ+ccYP0J g==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="385427260" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="385427260" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 10:01:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="1087133904" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087133904" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 10:01:38 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rafael.j.wysocki@intel.com, andriy.shevchenko@linux.intel.com, lenb@kernel.org, Michal Wilczynski , Andy Shevchenko Subject: [PATCH v1 2/3] ACPI: acpi_pad: Use dev groups for sysfs Date: Mon, 16 Oct 2023 20:01:24 +0300 Message-ID: <20231016170125.576159-3-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231016170125.576159-1-michal.wilczynski@intel.com> References: <20231016170125.576159-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 16 Oct 2023 10:06:24 -0700 (PDT) Change the way sysfs files are created. Use dev_groups, as it's a better approach - it allows to declare attributes, and the core code would take care of the lifecycle of those objects. Suggested-by: Andy Shevchenko Signed-off-by: Michal Wilczynski --- drivers/acpi/acpi_pad.c | 42 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c index 36e1049833a3..2513028a0299 100644 --- a/drivers/acpi/acpi_pad.c +++ b/drivers/acpi/acpi_pad.c @@ -337,33 +337,14 @@ static ssize_t idlecpus_show(struct device *dev, static DEVICE_ATTR_RW(idlecpus); -static int acpi_pad_add_sysfs(struct acpi_device *device) -{ - int result; - - result = device_create_file(&device->dev, &dev_attr_idlecpus); - if (result) - return -ENODEV; - result = device_create_file(&device->dev, &dev_attr_idlepct); - if (result) { - device_remove_file(&device->dev, &dev_attr_idlecpus); - return -ENODEV; - } - result = device_create_file(&device->dev, &dev_attr_rrtime); - if (result) { - device_remove_file(&device->dev, &dev_attr_idlecpus); - device_remove_file(&device->dev, &dev_attr_idlepct); - return -ENODEV; - } - return 0; -} +static struct attribute *acpi_pad_attrs[] = { + &dev_attr_idlecpus.attr, + &dev_attr_idlepct.attr, + &dev_attr_rrtime.attr, + NULL +}; -static void acpi_pad_remove_sysfs(struct acpi_device *device) -{ - device_remove_file(&device->dev, &dev_attr_idlecpus); - device_remove_file(&device->dev, &dev_attr_idlepct); - device_remove_file(&device->dev, &dev_attr_rrtime); -} +ATTRIBUTE_GROUPS(acpi_pad); /* * Query firmware how many CPUs should be idle @@ -440,17 +421,12 @@ static int acpi_pad_probe(struct platform_device *pdev) strcpy(acpi_device_name(device), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_PROCESSOR_AGGREGATOR_CLASS); - if (acpi_pad_add_sysfs(device)) - return -ENODEV; - status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_pad_notify, dev); - if (ACPI_FAILURE(status)) { - acpi_pad_remove_sysfs(device); + if (ACPI_FAILURE(status)) return -ENODEV; - } return 0; } @@ -466,7 +442,6 @@ static void acpi_pad_remove(struct platform_device *pdev) acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_pad_notify); - acpi_pad_remove_sysfs(device); } static const struct acpi_device_id pad_device_ids[] = { @@ -479,6 +454,7 @@ static struct platform_driver acpi_pad_driver = { .probe = acpi_pad_probe, .remove_new = acpi_pad_remove, .driver = { + .dev_groups = acpi_pad_groups, .name = "processor_aggregator", .acpi_match_table = pad_device_ids, }, -- 2.41.0