From patchwork Tue Jan 14 15:37:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938892 Received: from mail-vk1-f170.google.com (mail-vk1-f170.google.com [209.85.221.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27186189B8C; Tue, 14 Jan 2025 15:38:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869092; cv=none; b=qWpZCgcs7CCr9Tjv9fgXZnyFuypt0HevXF8fA+CGelAl/WXYN/UIwbrRliMKsM/gkq2YS7PfA9vU93jYWMrsfBP/XZC0CIkK4lW6ZAKQYoW0Or79g77JzienGRE0buasWZjyN1O8B9lABjjlCRTCPsFfDxw/gqcTzwxayz0w4gw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869092; c=relaxed/simple; bh=HFk4lDSX5Cn06cr9o7eTBshvuZtxhybRjGsm5mM64IE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c8LNiirWzf9+BjVNqgvaXekIsmv7xZOkSZYPwh1dHHkOe3oxIxiQGozx0yeLq/PCN+BGhdnbPA2r0B+/s6tC4VZElOSMdj3ACwbwvGC6b2AJBoQZuF94HLIL4KWa6Mj5c+PvDQYSDG1xuUfCUhKl9TtT1LyaUiZ3KSOahzTe99c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OExNj7rz; arc=none smtp.client-ip=209.85.221.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OExNj7rz" Received: by mail-vk1-f170.google.com with SMTP id 71dfb90a1353d-51cccafb04aso566885e0c.1; Tue, 14 Jan 2025 07:38:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869090; x=1737473890; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3v+7fb9Mc4vSFklrQ/EkNnH9q794YIjKIyfQKma+ygc=; b=OExNj7rzmfvxY3t9ljWCKKQHXsybCcDYWSbtGzVThJltzrfl7AHhaPH//cVveM4n4U oer+vvJH6mxfpfSqeVIPRmE0Zg9qYIjJso/mLkFqEHoTZz5W7B+PGYRbURlBsg8CC4DC mbnQXaHN7bBb5JOE4iE5gTZn1xHnKlHXFanga6UftjsgyCYy4uni1BX/0mzOpEJsIO46 9VbixZOCifCwOlgkZu6qCHoxFi1TGfSan02KsPdcxGwv7/oWBS6mvT463izErLISdKU2 eFeJ07Fz83Y47XU4rHwfnl9fngkprDCj+I+yovQuRTkLA8FkwnZtChI3WyPb1NA+CPrJ A9xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869090; x=1737473890; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3v+7fb9Mc4vSFklrQ/EkNnH9q794YIjKIyfQKma+ygc=; b=cWqz9VUVtACmnQ96zk6nkyKR6P3gYLWTxj2UkCua/1LfkFnJj9IOQnDPVm+nI3e/Z1 GHdYT4iEnW9HhrStlAMszB3FdUI+KRHryk6s+DYSf8AVwE6sqgFjg47HSJlceubJnWX9 MQnjXJHqctuGCmfrvnXw+/v5uCniB70WYO1TczjSJZ4mUSJMlKq0VHG7qsuSb1+G/QSi vStyFvI1HmSIstw7mLQYormBHuuL5nDdl6eCEs57BthXEBVkczvRFoEJYovClXVZ8+bT o/OWD0iZhWNsUzQSjMNXN6u3zuzRhyhvS1g6gWnLRAGxtcWfPOxCqv9WTe1NuVse2lW4 ZhOw== X-Forwarded-Encrypted: i=1; AJvYcCUqj46SCWn02dtYM7KvVu1rwoljYiJfYAFZKvSwwkG6W7h9lxaOrpPC+jYTWuQkzvM88ip6inXbgTJc@vger.kernel.org, AJvYcCVz58Kpyon3giNTdV9O0ggUzgca2nzmnGBx9WMBbXF7SsfORqTlH5udt+RawCFlkYpAIeKbqucvbYQrAC7w@vger.kernel.org X-Gm-Message-State: AOJu0YxaqRGgnMbN0+w7mmzSruFpLPaZcDjhqF8O+cMsZx6coFlL/h2G VvnKh8dvvO7WN6Z63k72eZS311+Fz6I/mKlvTQJGiy5Syfvt80PIeyFdVg== X-Gm-Gg: ASbGncsKySAWdpc0CcMBpSs6ILE2EkrW9QAL7MunvkpJRIYHkg8i/83tnsBxJ11oinF D4933ET7sD6FnmcB1Kq3OcEKU04mU29EfQuHymhJ12RYkvUQLToHoyt21xScsOsPyr+jG1Ae86u mtE+o7XT2UzFLovniOTpQcwtph+oEbh1hxMgbZDsdS5IcgAvEsPfSIy/ODNZ/Hf5Vcw8byFSiGi MEQBEoK+Tl4f3qCI8jI6aoVLwnfQotHthXfvzoSJ/XHCRrwYRY1sL/TZmah0rXj X-Google-Smtp-Source: AGHT+IGgKrhuAi0NAhA7eSXJVtKxbrbcCUmIbvWEgU9DX8MVVKqBjFnVSLGPY2RpAo0mi6KTyreJoQ== X-Received: by 2002:a05:6122:4219:b0:51b:8949:c9a7 with SMTP id 71dfb90a1353d-51c6c304a14mr21474351e0c.8.1736869089667; Tue, 14 Jan 2025 07:38:09 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.38.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:38:08 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 01/18] ACPI: platform_profile: Replace *class_dev member with class_dev Date: Tue, 14 Jan 2025 10:37:09 -0500 Message-ID: <20250114153726.11802-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of holding a reference to the class device, embed it the platform_profile_handler. This involves manually creating and registering the device and replacing dev_get_drvdata() with the newly created to_pprof_handler() macro. Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/acpi/platform_profile.c | 36 ++++++++++++++++++-------------- include/linux/platform_profile.h | 3 ++- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 4c4200a0b1a6..a89f64f13e44 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -10,6 +10,8 @@ #include #include +#define to_pprof_handler(d) (container_of(d, struct platform_profile_handler, class_dev)) + static DEFINE_MUTEX(profile_lock); static const char * const profile_names[] = { @@ -60,7 +62,7 @@ static int _store_class_profile(struct device *dev, void *data) int *bit = (int *)data; lockdep_assert_held(&profile_lock); - handler = dev_get_drvdata(dev); + handler = to_pprof_handler(dev); if (!test_bit(*bit, handler->choices)) return -EOPNOTSUPP; @@ -76,11 +78,11 @@ static int _store_class_profile(struct device *dev, void *data) */ static int _notify_class_profile(struct device *dev, void *data) { - struct platform_profile_handler *handler = dev_get_drvdata(dev); + struct platform_profile_handler *handler = to_pprof_handler(dev); lockdep_assert_held(&profile_lock); - sysfs_notify(&handler->class_dev->kobj, NULL, "profile"); - kobject_uevent(&handler->class_dev->kobj, KOBJ_CHANGE); + sysfs_notify(&handler->class_dev.kobj, NULL, "profile"); + kobject_uevent(&handler->class_dev.kobj, KOBJ_CHANGE); return 0; } @@ -100,7 +102,7 @@ static int get_class_profile(struct device *dev, int err; lockdep_assert_held(&profile_lock); - handler = dev_get_drvdata(dev); + handler = to_pprof_handler(dev); err = handler->profile_get(handler, &val); if (err) { pr_err("Failed to get profile for handler %s\n", handler->name); @@ -124,7 +126,7 @@ static int get_class_profile(struct device *dev, */ static ssize_t name_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct platform_profile_handler *handler = dev_get_drvdata(dev); + struct platform_profile_handler *handler = to_pprof_handler(dev); return sysfs_emit(buf, "%s\n", handler->name); } @@ -142,7 +144,7 @@ static ssize_t choices_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct platform_profile_handler *handler = dev_get_drvdata(dev); + struct platform_profile_handler *handler = to_pprof_handler(dev); return _commmon_choices_show(handler->choices, buf); } @@ -229,7 +231,7 @@ static int _aggregate_choices(struct device *dev, void *data) unsigned long *aggregate = data; lockdep_assert_held(&profile_lock); - handler = dev_get_drvdata(dev); + handler = to_pprof_handler(dev); if (test_bit(PLATFORM_PROFILE_LAST, aggregate)) bitmap_copy(aggregate, handler->choices, PLATFORM_PROFILE_LAST); else @@ -410,7 +412,7 @@ static const struct attribute_group platform_profile_group = { void platform_profile_notify(struct platform_profile_handler *pprof) { scoped_cond_guard(mutex_intr, return, &profile_lock) { - _notify_class_profile(pprof->class_dev, NULL); + _notify_class_profile(&pprof->class_dev, NULL); } sysfs_notify(acpi_kobj, NULL, "platform_profile"); } @@ -476,11 +478,13 @@ int platform_profile_register(struct platform_profile_handler *pprof) pprof->minor = ida_alloc(&platform_profile_ida, GFP_KERNEL); if (pprof->minor < 0) return pprof->minor; - pprof->class_dev = device_create(&platform_profile_class, pprof->dev, - MKDEV(0, 0), pprof, "platform-profile-%d", - pprof->minor); - if (IS_ERR(pprof->class_dev)) { - err = PTR_ERR(pprof->class_dev); + + pprof->class_dev.class = &platform_profile_class; + pprof->class_dev.parent = pprof->dev; + dev_set_name(&pprof->class_dev, "platform-profile-%d", pprof->minor); + err = device_register(&pprof->class_dev); + if (err) { + put_device(&pprof->class_dev); goto cleanup_ida; } @@ -493,7 +497,7 @@ int platform_profile_register(struct platform_profile_handler *pprof) return 0; cleanup_cur: - device_unregister(pprof->class_dev); + device_unregister(&pprof->class_dev); cleanup_ida: ida_free(&platform_profile_ida, pprof->minor); @@ -508,7 +512,7 @@ int platform_profile_remove(struct platform_profile_handler *pprof) guard(mutex)(&profile_lock); id = pprof->minor; - device_unregister(pprof->class_dev); + device_unregister(&pprof->class_dev); ida_free(&platform_profile_ida, id); sysfs_notify(acpi_kobj, NULL, "platform_profile"); diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index f1cd4b65e351..8a9b8754f9ac 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -9,6 +9,7 @@ #ifndef _PLATFORM_PROFILE_H_ #define _PLATFORM_PROFILE_H_ +#include #include /* @@ -30,7 +31,7 @@ enum platform_profile_option { struct platform_profile_handler { const char *name; struct device *dev; - struct device *class_dev; + struct device class_dev; int minor; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, From patchwork Tue Jan 14 15:37:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938893 Received: from mail-ua1-f49.google.com (mail-ua1-f49.google.com [209.85.222.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB7511B2180; Tue, 14 Jan 2025 15:38:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869096; cv=none; b=t1CSluiIduNksJwROwG9inTuoZmcIApqs9eQkSo9ma4nmt/Ysgtc4GNet+vXv8m2zFwFnahsK+5NFz0HpOBbdD27CYMUSMeOzk/chYKwQ1z3d7HkwflwOaBD86+Am0wuTexNmFXFbOE6mtQSUxF9n801C2WNE1seyAE5VlYflgw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869096; c=relaxed/simple; bh=r+bsVlyFzFpbHqSj4c9OYq3GkNMBB/wpcgctc9O9CEI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R4poC+hzu0TERGhr90+zgWBICYcQii8+sIL18mZ1kISyaEVo1yStf2c75r6bph81yoa5juup7o8QutzpONUsl5FSHJFm8UYJib7TJ5jCgwz5zziqwHaiNkeRilBx/8n7QxFoxK68lBA3G7sEKO3IDAQTpV2QQYB6g/Q+Yaypau0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fu0gf5+j; arc=none smtp.client-ip=209.85.222.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fu0gf5+j" Received: by mail-ua1-f49.google.com with SMTP id a1e0cc1a2514c-85c5eb83a7fso2818820241.2; Tue, 14 Jan 2025 07:38:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869093; x=1737473893; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XxdIsyQy+fqhcIUx5D1/+V3snqo0VYYQ5aEbJ1vjIu0=; b=fu0gf5+jwSh23lGRghE/Rq4FN51N2BaIpptY8cm4qBYXePRaLevre0RJM+sOTXo/qi e8loVYqM1hUyXQmc6kShfVGFgZkNcHNsoYg1aJMMVF9n96B2glfsg56lwbwAbpQJhywC zdLWVmhVNarkgdPdtPvdO4OqTF9SL4vT7fo8PZU28Y/F2aEQK5xCaqv34/dnT2+/WJLC U687uI7R3QlebytiHbwZWiprEmA5muA70ndDsibS809fmBdBBQ9cHPtKLfxXT6ekV2am yf9Iz7oHEX1OuJobtahZ4dbDizoUw24o4KtlIMWYHEhEvL4Gp90V/p7bdLP1RTa/6wfS wyNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869093; x=1737473893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XxdIsyQy+fqhcIUx5D1/+V3snqo0VYYQ5aEbJ1vjIu0=; b=W159U+1ltCIyN3OVne7ZeFoJ692wqIkORCqzn0/cbPOHZHyMO/LiLUUjgtYELTOhA+ ZrLwz01SfjQaTlLogb+uvc7gWdgPoTaNJ5yA4A1dqhCEia2YPPttmiWFvQrMqD4GZeuZ CzenVkKg9du2PB2R7TTRIkxlZHx10afrWd8gUfx54twhtrDZgvv+y9EDBxod7pxN25+n qzZwRd/cxhMtaZAkunxvGUMZwcxkB48weHQTkvIliHqC7VNR56c+dV2vxU4QfGLg2zaL vOtG0soKbWOUJFQXyXF1jBBrcokeFePSuhr2AfmQunaEBe6CExx51UtrMlJiEXbd7/DL oJHw== X-Forwarded-Encrypted: i=1; AJvYcCULWsjRv1/jQy2ZzDc9FgpLEh9R6jfA8DHWVTxhi4yu0PIEOeK02foLCwlUirhXg4O6QvJJ6gfg57PdD/4I@vger.kernel.org, AJvYcCX9nmOLvz1+onoO66GXwgsu+xaL135+1dUD3sVvxTGWX4l6kxARoRiak9/s+GPkUpspTY2WwY6uM5yt@vger.kernel.org X-Gm-Message-State: AOJu0YzPPUzQI6aUYIYAIQbMO6ms6QehAgNs+ZFGGK0fsCr7y+TLWsyN /O11uYZqOr56JYPgXc20OgLX496HXFuo25fBl9W2r3KGD4KLRyKTwGq96w== X-Gm-Gg: ASbGncs45ugjMr3nUSYubU53MtSxWq75suNQkG5JBS4ThVXFx6CRPdLrkGKKZ1elu7k Cpz5nSg4Fe+DMhmkQrLF9AGiAQBH8Z7VrZmMNN2HGKK4he/Y+qIFd0ImvsOoxf7WiRXa5/UUZIv RdTtUwDeJtvl41H2n2fgBa4qYYQUiCTUCIL0LRB36lMaMeoTdnFFVCrJx7aR8mwo9oa7kU2AD3S gztixTbktt83/2yIuGlxpYoMmmb2DHT7bbTmM/y6ONjkG+ObkF5pIu/ehMFFSoo X-Google-Smtp-Source: AGHT+IEZdlokqZy+0PbZq4/IY2fHa2O0pDrMWEBQy/0cvoF2is6daIGIXNxBu8lM/2zDKFj+X/tfmg== X-Received: by 2002:a05:6122:c84:b0:518:9040:6700 with SMTP id 71dfb90a1353d-51c6c32df5emr21071908e0c.11.1736869093067; Tue, 14 Jan 2025 07:38:13 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.38.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:38:12 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 02/18] ACPI: platform_profile: Let drivers set drvdata to the class device Date: Tue, 14 Jan 2025 10:37:10 -0500 Message-ID: <20250114153726.11802-3-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add *drvdata to platform_profile_register() signature and assign it to the class device. While at it, pass specific driver state as drvdata to replace uses of container_of() with dev_get_drvdata(). Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/acpi/platform_profile.c | 7 ++++--- drivers/platform/surface/surface_platform_profile.c | 6 +++--- drivers/platform/x86/acer-wmi.c | 2 +- drivers/platform/x86/amd/pmf/sps.c | 6 +++--- drivers/platform/x86/asus-wmi.c | 6 +++--- drivers/platform/x86/dell/alienware-wmi.c | 2 +- drivers/platform/x86/dell/dell-pc.c | 2 +- drivers/platform/x86/hp/hp-wmi.c | 2 +- drivers/platform/x86/ideapad-laptop.c | 6 +++--- drivers/platform/x86/inspur_platform_profile.c | 8 +++----- drivers/platform/x86/thinkpad_acpi.c | 2 +- include/linux/platform_profile.h | 4 ++-- 12 files changed, 26 insertions(+), 27 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index a89f64f13e44..f8741201deea 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -461,7 +461,7 @@ int platform_profile_cycle(void) } EXPORT_SYMBOL_GPL(platform_profile_cycle); -int platform_profile_register(struct platform_profile_handler *pprof) +int platform_profile_register(struct platform_profile_handler *pprof, void *drvdata) { int err; @@ -481,6 +481,7 @@ int platform_profile_register(struct platform_profile_handler *pprof) pprof->class_dev.class = &platform_profile_class; pprof->class_dev.parent = pprof->dev; + dev_set_drvdata(&pprof->class_dev, drvdata); dev_set_name(&pprof->class_dev, "platform-profile-%d", pprof->minor); err = device_register(&pprof->class_dev); if (err) { @@ -530,7 +531,7 @@ static void devm_platform_profile_release(struct device *dev, void *res) platform_profile_remove(*pprof); } -int devm_platform_profile_register(struct platform_profile_handler *pprof) +int devm_platform_profile_register(struct platform_profile_handler *pprof, void *drvdata) { struct platform_profile_handler **dr; int ret; @@ -539,7 +540,7 @@ int devm_platform_profile_register(struct platform_profile_handler *pprof) if (!dr) return -ENOMEM; - ret = platform_profile_register(pprof); + ret = platform_profile_register(pprof, drvdata); if (ret) { devres_free(dr); return ret; diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 6c87e982bfc8..edb9362003a4 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -161,7 +161,7 @@ static int ssam_platform_profile_get(struct platform_profile_handler *pprof, enum ssam_tmp_profile tp; int status; - tpd = container_of(pprof, struct ssam_platform_profile_device, handler); + tpd = dev_get_drvdata(&pprof->class_dev); status = ssam_tmp_profile_get(tpd->sdev, &tp); if (status) @@ -181,7 +181,7 @@ static int ssam_platform_profile_set(struct platform_profile_handler *pprof, struct ssam_platform_profile_device *tpd; int tp; - tpd = container_of(pprof, struct ssam_platform_profile_device, handler); + tpd = dev_get_drvdata(&pprof->class_dev); tp = convert_profile_to_ssam_tmp(tpd->sdev, profile); if (tp < 0) @@ -224,7 +224,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, tpd->handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, tpd->handler.choices); - return platform_profile_register(&tpd->handler); + return platform_profile_register(&tpd->handler, tpd); } static void surface_platform_profile_remove(struct ssam_device *sdev) diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 57d6b680f5b9..4594beb4b9d7 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1939,7 +1939,7 @@ static int acer_platform_profile_setup(struct platform_device *device) set_bit(PLATFORM_PROFILE_LOW_POWER, platform_profile_handler.choices); - err = platform_profile_register(&platform_profile_handler); + err = platform_profile_register(&platform_profile_handler, NULL); if (err) return err; diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index bd2bd6cfc39a..259a598acd3e 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -285,7 +285,7 @@ bool is_pprof_balanced(struct amd_pmf_dev *pmf) static int amd_pmf_profile_get(struct platform_profile_handler *pprof, enum platform_profile_option *profile) { - struct amd_pmf_dev *pmf = container_of(pprof, struct amd_pmf_dev, pprof); + struct amd_pmf_dev *pmf = dev_get_drvdata(&pprof->class_dev); *profile = pmf->current_profile; return 0; @@ -366,7 +366,7 @@ int amd_pmf_power_slider_update_event(struct amd_pmf_dev *dev) static int amd_pmf_profile_set(struct platform_profile_handler *pprof, enum platform_profile_option profile) { - struct amd_pmf_dev *pmf = container_of(pprof, struct amd_pmf_dev, pprof); + struct amd_pmf_dev *pmf = dev_get_drvdata(&pprof->class_dev); int ret = 0; pmf->current_profile = profile; @@ -416,7 +416,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) set_bit(PLATFORM_PROFILE_PERFORMANCE, dev->pprof.choices); /* Create platform_profile structure and register */ - err = platform_profile_register(&dev->pprof); + err = platform_profile_register(&dev->pprof, dev); if (err) dev_err(dev->dev, "Failed to register SPS support, this is most likely an SBIOS bug: %d\n", err); diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index fdeebab96fc0..0c68635a0aa3 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3806,7 +3806,7 @@ static int asus_wmi_platform_profile_get(struct platform_profile_handler *pprof, struct asus_wmi *asus; int tp; - asus = container_of(pprof, struct asus_wmi, platform_profile_handler); + asus = dev_get_drvdata(&pprof->class_dev); tp = asus->throttle_thermal_policy_mode; switch (tp) { @@ -3832,7 +3832,7 @@ static int asus_wmi_platform_profile_set(struct platform_profile_handler *pprof, struct asus_wmi *asus; int tp; - asus = container_of(pprof, struct asus_wmi, platform_profile_handler); + asus = dev_get_drvdata(&pprof->class_dev); switch (profile) { case PLATFORM_PROFILE_PERFORMANCE: @@ -3887,7 +3887,7 @@ static int platform_profile_setup(struct asus_wmi *asus) set_bit(PLATFORM_PROFILE_PERFORMANCE, asus->platform_profile_handler.choices); - err = platform_profile_register(&asus->platform_profile_handler); + err = platform_profile_register(&asus->platform_profile_handler, asus); if (err == -EEXIST) { pr_warn("%s, a platform_profile handler is already registered\n", __func__); return 0; diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index b4b43f3e3fd9..28c39e25228e 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1129,7 +1129,7 @@ static int create_thermal_profile(struct platform_device *platform_device) pp_handler.name = "alienware-wmi"; pp_handler.dev = &platform_device->dev; - return devm_platform_profile_register(&pp_handler); + return devm_platform_profile_register(&pp_handler, NULL); } /* diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 3797a5721dbd..1a0a721d706f 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -271,7 +271,7 @@ static int thermal_init(void) set_bit(PLATFORM_PROFILE_PERFORMANCE, thermal_handler->choices); /* Clean up if failed */ - ret = platform_profile_register(thermal_handler); + ret = platform_profile_register(thermal_handler, NULL); if (ret) goto cleanup_thermal_handler; diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 6d6e13a0c6e2..8e5e1422e024 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1629,7 +1629,7 @@ static int thermal_profile_setup(struct platform_device *device) set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); - err = platform_profile_register(&platform_profile_handler); + err = platform_profile_register(&platform_profile_handler, NULL); if (err) return err; diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index dc98f862a06d..ed0d880a07a9 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -936,7 +936,7 @@ static int convert_profile_to_dytc(enum platform_profile_option profile, int *pe static int dytc_profile_get(struct platform_profile_handler *pprof, enum platform_profile_option *profile) { - struct ideapad_dytc_priv *dytc = container_of(pprof, struct ideapad_dytc_priv, pprof); + struct ideapad_dytc_priv *dytc = dev_get_drvdata(&pprof->class_dev); *profile = dytc->current_profile; return 0; @@ -989,7 +989,7 @@ static int dytc_cql_command(struct ideapad_private *priv, unsigned long cmd, static int dytc_profile_set(struct platform_profile_handler *pprof, enum platform_profile_option profile) { - struct ideapad_dytc_priv *dytc = container_of(pprof, struct ideapad_dytc_priv, pprof); + struct ideapad_dytc_priv *dytc = dev_get_drvdata(&pprof->class_dev); struct ideapad_private *priv = dytc->priv; unsigned long output; int err; @@ -1114,7 +1114,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->dytc->pprof.choices); /* Create platform_profile structure and register */ - err = platform_profile_register(&priv->dytc->pprof); + err = platform_profile_register(&priv->dytc->pprof, &priv->dytc); if (err) goto pp_reg_failed; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 53af73a7fbf7..471fca50d1c9 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -87,8 +87,7 @@ static int inspur_wmi_perform_query(struct wmi_device *wdev, static int inspur_platform_profile_set(struct platform_profile_handler *pprof, enum platform_profile_option profile) { - struct inspur_wmi_priv *priv = container_of(pprof, struct inspur_wmi_priv, - handler); + struct inspur_wmi_priv *priv = dev_get_drvdata(&pprof->class_dev); u8 ret_code[4] = {0, 0, 0, 0}; int ret; @@ -135,8 +134,7 @@ static int inspur_platform_profile_set(struct platform_profile_handler *pprof, static int inspur_platform_profile_get(struct platform_profile_handler *pprof, enum platform_profile_option *profile) { - struct inspur_wmi_priv *priv = container_of(pprof, struct inspur_wmi_priv, - handler); + struct inspur_wmi_priv *priv = dev_get_drvdata(&pprof->class_dev); u8 ret_code[4] = {0, 0, 0, 0}; int ret; @@ -186,7 +184,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) set_bit(PLATFORM_PROFILE_BALANCED, priv->handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->handler.choices); - return platform_profile_register(&priv->handler); + return platform_profile_register(&priv->handler, priv); } static void inspur_wmi_remove(struct wmi_device *wdev) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 22f871e9f53c..fe37c26891d8 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10640,7 +10640,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) dytc_profile.dev = &tpacpi_pdev->dev; /* Create platform_profile structure and register */ - err = platform_profile_register(&dytc_profile); + err = platform_profile_register(&dytc_profile, NULL); /* * If for some reason platform_profiles aren't enabled * don't quit terminally. diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 8a9b8754f9ac..1c8fdda51eaa 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -40,9 +40,9 @@ struct platform_profile_handler { enum platform_profile_option profile); }; -int platform_profile_register(struct platform_profile_handler *pprof); +int platform_profile_register(struct platform_profile_handler *pprof, void *drvdata); int platform_profile_remove(struct platform_profile_handler *pprof); -int devm_platform_profile_register(struct platform_profile_handler *pprof); +int devm_platform_profile_register(struct platform_profile_handler *pprof, void *drvdata); int platform_profile_cycle(void); void platform_profile_notify(struct platform_profile_handler *pprof); From patchwork Tue Jan 14 15:37:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938894 Received: from mail-vk1-f177.google.com (mail-vk1-f177.google.com [209.85.221.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E7501B86D5; Tue, 14 Jan 2025 15:38:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869100; cv=none; b=fhbfqUijRUeNfKdEEi2yiiG9IzhtpNw6L+ow5Ym/yXUljyyuEqqnMkJgS7HCTUThc5px8NHokF8oMOzjDYaQH9Os2AaDRihR0w0tZno6y5xb0rgSZijohxKLyrf+yiK46o8Z9v4+3LE+fQEO40jezKsc9TYadSNjvD+yTLa3qk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869100; c=relaxed/simple; bh=82eQC9klNSFqtGaT329SfgzrJxkXMUZBCWK1h1R6ST8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oomm6duQG/edTJzO38Y3Y6N8Zx8mjlq1kIKISVJw5ZJitbLyyJ3RvXtY8fpDOZIQoDfwBewLaIhdQWNsPzjbHNTe395ic+i21QJT6+O5rr7VTdM3q8SNmZ57F99PIEV5rZ9O8WrYO5M62I4Rx/ATEQjw40ELGaEA4aHK8Ud5pBw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RztDmSFx; arc=none smtp.client-ip=209.85.221.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RztDmSFx" Received: by mail-vk1-f177.google.com with SMTP id 71dfb90a1353d-51640f7bbd3so1964346e0c.2; Tue, 14 Jan 2025 07:38:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869097; x=1737473897; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ySI44wHMd6hWEJyphRfrgYl/KVBkiGy3++Z8m9ef+ig=; b=RztDmSFx0E5d7/u0vLnnUunWKnJ3WAXYi0Or9gfKterqXETS2iqC0nCmGX5xhBmaqs dOoYPC9NdbnVwi9+M2Lto2E1hn9rj3QODw06MLr5AGpqhoqbptkZRHJqiOIJfpJSoBVj cOtwjsysB32vk0oeKoy6e7EQ9PYwEdJKOmLYgCCCDVieLpv9Xx53dgmxT/ZY8KzbgCK2 zrqLPR2x6PpoC8LV5zr4Zt4pKubXQZKWW2M2NUxRcxpd3UvFniG1ZtXYiNHX6IiKJund EniKauBzoDjbel5+UWKyLrlC//12FOkAwZuuXAYd5DIF/erYrzIBn+k67GAxX2/K0sF1 4eUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869097; x=1737473897; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ySI44wHMd6hWEJyphRfrgYl/KVBkiGy3++Z8m9ef+ig=; b=R/GFGUm4mrz0+7wGQkqUJ39Zpjx0+TYsfDAk6/BMlcw0lusVpcyD+vE6JYfUkSy45o CxtIbSPmsWrlk9nmlcT5NI+6gUSQEHjVeJ6A/7z/8S4IAZOf8te3vSAiRLUnBNTexDJr 2F+h2d6po4kG8I2/v3HgzMaw7r4oVJk+39K0XzbwRyO2VhT/JFeOAWaw7qIhVca/6eEJ EDV56ufCBpPeGB0c9RyCPmmVZ2ro2k/YkZLV3omJU8zB+byJwPWACFLhLmwhHQaYaOjo rsXVdwjKlgVb5Ir2wzj9qSJesE6mhfcUfVEFQmo/wbJ5YawpO+3qJdLFH7ozhAfx2UhD /j/w== X-Forwarded-Encrypted: i=1; AJvYcCUdqUN18ljTWe7qg1LvdP3ceDPxpE06EjnTYM5qFCI+o27CQv7E3nUGnB2Os32GCPrwtHsw4MAdZBKOeBdZ@vger.kernel.org, AJvYcCX0+KWbaALdQHXWUq6/lSHWTU3PynMyQadGpF5T7bXIsVfhs9HhSDAL4WCXbBQ5CUQWGF2WLY/N1RAr@vger.kernel.org X-Gm-Message-State: AOJu0YzUCHua6A5KjiAN33mOTAw7uTAzUcOFNPMShDP5hd/s2r/zcRz6 BL4J3iv95IgnVUqQeIg5MC/eJNN2ocsWwfJldWFOll+za3CDf7Wrg9cLaw== X-Gm-Gg: ASbGncuLQ9gKG6bR6tWk8zRgTGWpKbulDlDIkpiKCirpmki+puOlzpZLZufRmVm5ZPc ffs9KJZroyh4xqBkMSr3JPCM4WmXNet4N9jcWxOmj+a7AIHAT/K7YJ5WjVBkIhZdjpKJNWWJKMU 9w9K+2+zdnEuX1inbYd0McYgNG0kZO+1PJoUL5L/jzNx/1aKCsWL471G1o1SvVsEVQ0MTyvnfAb qN8J3kRBPpnOr9sthVhazt7mFCg9AIrc/lAsByjVePKOUnFdgz50g/LH3qaYgBY X-Google-Smtp-Source: AGHT+IEHUlCP3LuXN1vX4qy3WDkCIQd+CmblebYqZ2uA8LzKrX9+rmFFDIdKYr5SQr1nK5zSx7VLqg== X-Received: by 2002:a1f:c743:0:b0:51c:c23e:8cd3 with SMTP id 71dfb90a1353d-51cc23e8d8bmr3850273e0c.4.1736869096554; Tue, 14 Jan 2025 07:38:16 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:38:16 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 03/18] ACPI: platform_profile: Remove platform_profile_handler from callbacks Date: Tue, 14 Jan 2025 10:37:11 -0500 Message-ID: <20250114153726.11802-4-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Devices can now set drvdata to the class device, thus passing the platform_profile_handler to callbacks is unnecessary. Instead pass the class device. Signed-off-by: Kurt Borja Reviewed-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 4 ++-- .../platform/surface/surface_platform_profile.c | 8 ++++---- drivers/platform/x86/acer-wmi.c | 4 ++-- drivers/platform/x86/amd/pmf/sps.c | 8 ++++---- drivers/platform/x86/asus-wmi.c | 8 ++++---- drivers/platform/x86/dell/alienware-wmi.c | 4 ++-- drivers/platform/x86/dell/dell-pc.c | 4 ++-- drivers/platform/x86/hp/hp-wmi.c | 14 +++++++------- drivers/platform/x86/ideapad-laptop.c | 8 ++++---- drivers/platform/x86/inspur_platform_profile.c | 8 ++++---- drivers/platform/x86/thinkpad_acpi.c | 4 ++-- include/linux/platform_profile.h | 6 ++---- 12 files changed, 39 insertions(+), 41 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index f8741201deea..66170fe436f0 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -66,7 +66,7 @@ static int _store_class_profile(struct device *dev, void *data) if (!test_bit(*bit, handler->choices)) return -EOPNOTSUPP; - return handler->profile_set(handler, *bit); + return handler->profile_set(dev, *bit); } /** @@ -103,7 +103,7 @@ static int get_class_profile(struct device *dev, lockdep_assert_held(&profile_lock); handler = to_pprof_handler(dev); - err = handler->profile_get(handler, &val); + err = handler->profile_get(dev, &val); if (err) { pr_err("Failed to get profile for handler %s\n", handler->name); return err; diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index edb9362003a4..26c1230e75df 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -154,14 +154,14 @@ static int convert_profile_to_ssam_fan(struct ssam_device *sdev, enum platform_p } } -static int ssam_platform_profile_get(struct platform_profile_handler *pprof, +static int ssam_platform_profile_get(struct device *dev, enum platform_profile_option *profile) { struct ssam_platform_profile_device *tpd; enum ssam_tmp_profile tp; int status; - tpd = dev_get_drvdata(&pprof->class_dev); + tpd = dev_get_drvdata(dev); status = ssam_tmp_profile_get(tpd->sdev, &tp); if (status) @@ -175,13 +175,13 @@ static int ssam_platform_profile_get(struct platform_profile_handler *pprof, return 0; } -static int ssam_platform_profile_set(struct platform_profile_handler *pprof, +static int ssam_platform_profile_set(struct device *dev, enum platform_profile_option profile) { struct ssam_platform_profile_device *tpd; int tp; - tpd = dev_get_drvdata(&pprof->class_dev); + tpd = dev_get_drvdata(dev); tp = convert_profile_to_ssam_tmp(tpd->sdev, profile); if (tp < 0) diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 4594beb4b9d7..d609bd105db3 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1843,7 +1843,7 @@ static int acer_toggle_turbo(void) } static int -acer_predator_v4_platform_profile_get(struct platform_profile_handler *pprof, +acer_predator_v4_platform_profile_get(struct device *dev, enum platform_profile_option *profile) { u8 tp; @@ -1878,7 +1878,7 @@ acer_predator_v4_platform_profile_get(struct platform_profile_handler *pprof, } static int -acer_predator_v4_platform_profile_set(struct platform_profile_handler *pprof, +acer_predator_v4_platform_profile_set(struct device *dev, enum platform_profile_option profile) { int tp; diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 259a598acd3e..cf2e51f67787 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -282,10 +282,10 @@ bool is_pprof_balanced(struct amd_pmf_dev *pmf) return (pmf->current_profile == PLATFORM_PROFILE_BALANCED) ? true : false; } -static int amd_pmf_profile_get(struct platform_profile_handler *pprof, +static int amd_pmf_profile_get(struct device *dev, enum platform_profile_option *profile) { - struct amd_pmf_dev *pmf = dev_get_drvdata(&pprof->class_dev); + struct amd_pmf_dev *pmf = dev_get_drvdata(dev); *profile = pmf->current_profile; return 0; @@ -363,10 +363,10 @@ int amd_pmf_power_slider_update_event(struct amd_pmf_dev *dev) return 0; } -static int amd_pmf_profile_set(struct platform_profile_handler *pprof, +static int amd_pmf_profile_set(struct device *dev, enum platform_profile_option profile) { - struct amd_pmf_dev *pmf = dev_get_drvdata(&pprof->class_dev); + struct amd_pmf_dev *pmf = dev_get_drvdata(dev); int ret = 0; pmf->current_profile = profile; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 0c68635a0aa3..9bed170abb92 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3800,13 +3800,13 @@ static ssize_t throttle_thermal_policy_store(struct device *dev, static DEVICE_ATTR_RW(throttle_thermal_policy); /* Platform profile ***********************************************************/ -static int asus_wmi_platform_profile_get(struct platform_profile_handler *pprof, +static int asus_wmi_platform_profile_get(struct device *dev, enum platform_profile_option *profile) { struct asus_wmi *asus; int tp; - asus = dev_get_drvdata(&pprof->class_dev); + asus = dev_get_drvdata(dev); tp = asus->throttle_thermal_policy_mode; switch (tp) { @@ -3826,13 +3826,13 @@ static int asus_wmi_platform_profile_get(struct platform_profile_handler *pprof, return 0; } -static int asus_wmi_platform_profile_set(struct platform_profile_handler *pprof, +static int asus_wmi_platform_profile_set(struct device *dev, enum platform_profile_option profile) { struct asus_wmi *asus; int tp; - asus = dev_get_drvdata(&pprof->class_dev); + asus = dev_get_drvdata(dev); switch (profile) { case PLATFORM_PROFILE_PERFORMANCE: diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 28c39e25228e..b8131b803368 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1026,7 +1026,7 @@ static int wmax_game_shift_status(u8 operation, u32 *out_data) return 0; } -static int thermal_profile_get(struct platform_profile_handler *pprof, +static int thermal_profile_get(struct device *dev, enum platform_profile_option *profile) { u32 out_data; @@ -1052,7 +1052,7 @@ static int thermal_profile_get(struct platform_profile_handler *pprof, return 0; } -static int thermal_profile_set(struct platform_profile_handler *pprof, +static int thermal_profile_set(struct device *dev, enum platform_profile_option profile) { if (quirks->gmode) { diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 1a0a721d706f..c86b05b5a1cb 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -185,7 +185,7 @@ static int thermal_set_mode(enum thermal_mode_bits state) return dell_send_request(&buffer, CLASS_INFO, SELECT_THERMAL_MANAGEMENT); } -static int thermal_platform_profile_set(struct platform_profile_handler *pprof, +static int thermal_platform_profile_set(struct device *dev, enum platform_profile_option profile) { switch (profile) { @@ -202,7 +202,7 @@ static int thermal_platform_profile_set(struct platform_profile_handler *pprof, } } -static int thermal_platform_profile_get(struct platform_profile_handler *pprof, +static int thermal_platform_profile_get(struct device *dev, enum platform_profile_option *profile) { int ret; diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 8e5e1422e024..b8e62dc9cecd 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1221,7 +1221,7 @@ static int platform_profile_omen_get_ec(enum platform_profile_option *profile) return 0; } -static int platform_profile_omen_get(struct platform_profile_handler *pprof, +static int platform_profile_omen_get(struct device *dev, enum platform_profile_option *profile) { /* @@ -1318,7 +1318,7 @@ static int platform_profile_omen_set_ec(enum platform_profile_option profile) return 0; } -static int platform_profile_omen_set(struct platform_profile_handler *pprof, +static int platform_profile_omen_set(struct device *dev, enum platform_profile_option profile) { int err; @@ -1345,7 +1345,7 @@ static int thermal_profile_set(int thermal_profile) sizeof(thermal_profile), 0); } -static int hp_wmi_platform_profile_get(struct platform_profile_handler *pprof, +static int hp_wmi_platform_profile_get(struct device *dev, enum platform_profile_option *profile) { int tp; @@ -1374,7 +1374,7 @@ static int hp_wmi_platform_profile_get(struct platform_profile_handler *pprof, return 0; } -static int hp_wmi_platform_profile_set(struct platform_profile_handler *pprof, +static int hp_wmi_platform_profile_set(struct device *dev, enum platform_profile_option profile) { int err, tp; @@ -1440,11 +1440,11 @@ static int platform_profile_victus_get_ec(enum platform_profile_option *profile) return 0; } -static int platform_profile_victus_get(struct platform_profile_handler *pprof, +static int platform_profile_victus_get(struct device *dev, enum platform_profile_option *profile) { /* Same behaviour as platform_profile_omen_get */ - return platform_profile_omen_get(pprof, profile); + return platform_profile_omen_get(dev, profile); } static int platform_profile_victus_set_ec(enum platform_profile_option profile) @@ -1472,7 +1472,7 @@ static int platform_profile_victus_set_ec(enum platform_profile_option profile) return 0; } -static int platform_profile_victus_set(struct platform_profile_handler *pprof, +static int platform_profile_victus_set(struct device *dev, enum platform_profile_option profile) { int err; diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index ed0d880a07a9..fc317f42bb82 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -933,10 +933,10 @@ static int convert_profile_to_dytc(enum platform_profile_option profile, int *pe * dytc_profile_get: Function to register with platform_profile * handler. Returns current platform profile. */ -static int dytc_profile_get(struct platform_profile_handler *pprof, +static int dytc_profile_get(struct device *dev, enum platform_profile_option *profile) { - struct ideapad_dytc_priv *dytc = dev_get_drvdata(&pprof->class_dev); + struct ideapad_dytc_priv *dytc = dev_get_drvdata(dev); *profile = dytc->current_profile; return 0; @@ -986,10 +986,10 @@ static int dytc_cql_command(struct ideapad_private *priv, unsigned long cmd, * dytc_profile_set: Function to register with platform_profile * handler. Sets current platform profile. */ -static int dytc_profile_set(struct platform_profile_handler *pprof, +static int dytc_profile_set(struct device *dev, enum platform_profile_option profile) { - struct ideapad_dytc_priv *dytc = dev_get_drvdata(&pprof->class_dev); + struct ideapad_dytc_priv *dytc = dev_get_drvdata(dev); struct ideapad_private *priv = dytc->priv; unsigned long output; int err; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 471fca50d1c9..47d2dbbf3392 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -84,10 +84,10 @@ static int inspur_wmi_perform_query(struct wmi_device *wdev, * 0x0: No Error * 0x1: Error */ -static int inspur_platform_profile_set(struct platform_profile_handler *pprof, +static int inspur_platform_profile_set(struct device *dev, enum platform_profile_option profile) { - struct inspur_wmi_priv *priv = dev_get_drvdata(&pprof->class_dev); + struct inspur_wmi_priv *priv = dev_get_drvdata(dev); u8 ret_code[4] = {0, 0, 0, 0}; int ret; @@ -131,10 +131,10 @@ static int inspur_platform_profile_set(struct platform_profile_handler *pprof, * 0x1: Performance Mode * 0x2: Power Saver Mode */ -static int inspur_platform_profile_get(struct platform_profile_handler *pprof, +static int inspur_platform_profile_get(struct device *dev, enum platform_profile_option *profile) { - struct inspur_wmi_priv *priv = dev_get_drvdata(&pprof->class_dev); + struct inspur_wmi_priv *priv = dev_get_drvdata(dev); u8 ret_code[4] = {0, 0, 0, 0}; int ret; diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index fe37c26891d8..47f87bb213a9 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10414,7 +10414,7 @@ static int convert_profile_to_dytc(enum platform_profile_option profile, int *pe * dytc_profile_get: Function to register with platform_profile * handler. Returns current platform profile. */ -static int dytc_profile_get(struct platform_profile_handler *pprof, +static int dytc_profile_get(struct device *dev, enum platform_profile_option *profile) { *profile = dytc_current_profile; @@ -10489,7 +10489,7 @@ static int dytc_cql_command(int command, int *output) * dytc_profile_set: Function to register with platform_profile * handler. Sets current platform profile. */ -static int dytc_profile_set(struct platform_profile_handler *pprof, +static int dytc_profile_set(struct device *dev, enum platform_profile_option profile) { int perfmode; diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 1c8fdda51eaa..5296d886c243 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -34,10 +34,8 @@ struct platform_profile_handler { struct device class_dev; int minor; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; - int (*profile_get)(struct platform_profile_handler *pprof, - enum platform_profile_option *profile); - int (*profile_set)(struct platform_profile_handler *pprof, - enum platform_profile_option profile); + int (*profile_get)(struct device *dev, enum platform_profile_option *profile); + int (*profile_set)(struct device *dev, enum platform_profile_option profile); }; int platform_profile_register(struct platform_profile_handler *pprof, void *drvdata); From patchwork Tue Jan 14 15:37:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938895 Received: from mail-vk1-f170.google.com (mail-vk1-f170.google.com [209.85.221.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C3481C331E; Tue, 14 Jan 2025 15:38:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869103; cv=none; b=UW3qZ712z1KJcFA8izRxHctUioeZwfYUebaWsen4NUSkSBImQgfY7EPd6feY+39zzRi3uiJ0+2SUHRL4xS8SLMT49C5bzY6P7Jd8NFwXI28IWGSCwHWowcTF9Cf93BoKz9vHy6aqPZBT3P3fR5cxsq9F1AWCMZPCkVw9vz0B+T4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869103; c=relaxed/simple; bh=T/QFTDFrJmix2FMos12pGVdJlsqCESYVneJp/YIiHcM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qd3GMJ+85LBRpL81Y6L96qWQLG6077Ji77x09t61tAepuMQj1pyPcy8FPALp9Ku4dz45s1it7kPVv6EjGgqeaH7s2heJ7VPs+rUMq47HGHErK+BqNwXE37r5Oxzgc50uImRtrwDeKE/HyqqAAkZNSIAO2XYPC6EqtozEYa4UO2A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=a6diHZC5; arc=none smtp.client-ip=209.85.221.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a6diHZC5" Received: by mail-vk1-f170.google.com with SMTP id 71dfb90a1353d-51878d9511bso2143514e0c.0; Tue, 14 Jan 2025 07:38:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869100; x=1737473900; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xXQB1DgR6Y5cIB8SHvgVESJb8wq8cSSgNO5tJthL7m4=; b=a6diHZC5LrxYHlVTYWYoqsFj703w8auG65LNfLY4QEpfZ54ZZYfqiEHfRmbQU0MtWS YBSYvSeipgY7kySj3Ey19Q1a+20VLdfeOPdX773/2rIj0tlJnfJm2OZqb6Vq0pBhM5Sc UD08tLL4wbz4nVNCK5sLsmMWEf3834r6pnCaMZbauAgnNoYPRyIC9g9wMBgAFLLlyJbj 5UZt7CBRO3RcDMvzyL26LYKwPxC5Rn7DYDHrtn4uXCoZFmgCYCIUlBVj0AGKl1jOAutd D3+BTyXfeFkU9xY85o+yMQwIgQGSGK+rKb3Daz3Qg6FKN0L8j5fh/eK7q6BdrTEegPBk WSXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869100; x=1737473900; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xXQB1DgR6Y5cIB8SHvgVESJb8wq8cSSgNO5tJthL7m4=; b=oot4M/jJZcyz6zZUZhzzV5jj9q1R18jj/bRXxnAGORt2R3J0o04nGcOUKXdTM2jLZB AO7/IS2YPxZesO0NEgmzPJb7t5bz2FSFuefbYBRAi8eA2l9FDlIE2ai9tvIOM/Vpg10M Qd1S+6e0ChrHuyWuKCuXVhJDdk196woBBk00rewut+93ElMqmCwrqkzrBJYCk5rCO1C5 sOTsD86Wgboo9WnSLva7Rljv+GmgpfFlRWj54n3FSYCJF7bw0fyxFTOMwE/penIusn+R M2vDwNY1QZ1CzQNeAGH/YNO5MqRARlqpbERP5hG0da75jYotb4CV7EpCFWtDlj4l4Mkj lxRw== X-Forwarded-Encrypted: i=1; AJvYcCWvvMIdCCyPEBXgGN9NP2V+EyVXWLudIZWN1F7QqEIOPQ1+L2UcSvCe4eHdog/GJwKDggqzbvjAcICn@vger.kernel.org, AJvYcCX9FrHvfffrFdtD/aw9+esHSavlJ3NC0fzvVL+1EXDMXbHYTwjHIo70CZHwdGvyHLpxey3PlaYJb5LTrHvJ@vger.kernel.org X-Gm-Message-State: AOJu0Yx9XWs9195oX80z2sZz6ZXcSDw0AALp2TVRlos/TkwxoBgEymuL U4G2wJUzrFEv3iDQmOiv7oCq+oUZDtdObLnQDs+e5vcryC2B/HQAFLcnOw== X-Gm-Gg: ASbGncs20R6plC6ZT1W9wL0b+T3ym1p4d3UOTFx74i8yZPZhpI+Rx8GNscy0xHkGHgZ 21r8rRpN+wJd8V4rspcIbZ3P13rzcLrY3dHFh70gjE4evqt1wvL8OP32h+UpIb9eP5BtVUY0V8j H5Agh+qT1ZaFrVgJluPrfKc1Yblo1aHs8iUgPG9MeBXx+fetMkROBpkrcF4QSdH5q7TmU8Bc/Vd a1h+vOwJNfM3fE944Ca5XGC1yLj49kKP+wPRizPBLtR6h8L/N1c0srXLFfGdjEN X-Google-Smtp-Source: AGHT+IHfhVqUpJVMJKgxiTP9F9AtVc0MS/hgNaWoEp2T+wzctJAJVzbnGBWtGwf3ePoIA1v+KZ41AQ== X-Received: by 2002:a05:6122:2a08:b0:516:18cd:c1fc with SMTP id 71dfb90a1353d-51c6c5259aemr18812538e0c.8.1736869099582; Tue, 14 Jan 2025 07:38:19 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.38.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:38:19 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 04/18] ACPI: platform_profile: Add `ops` member to handlers Date: Tue, 14 Jan 2025 10:37:12 -0500 Message-ID: <20250114153726.11802-5-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace *profile_get and *profile_set members with a general *ops member. Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/acpi/platform_profile.c | 6 ++--- .../surface/surface_platform_profile.c | 8 +++++-- drivers/platform/x86/acer-wmi.c | 11 +++++---- drivers/platform/x86/amd/pmf/sps.c | 8 +++++-- drivers/platform/x86/asus-wmi.c | 8 +++++-- drivers/platform/x86/dell/alienware-wmi.c | 8 +++++-- drivers/platform/x86/dell/dell-pc.c | 8 +++++-- drivers/platform/x86/hp/hp-wmi.c | 24 ++++++++++++++----- drivers/platform/x86/ideapad-laptop.c | 8 +++++-- .../platform/x86/inspur_platform_profile.c | 8 +++++-- drivers/platform/x86/thinkpad_acpi.c | 8 +++++-- include/linux/platform_profile.h | 10 ++++++-- 12 files changed, 84 insertions(+), 31 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 66170fe436f0..440654e21620 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -66,7 +66,7 @@ static int _store_class_profile(struct device *dev, void *data) if (!test_bit(*bit, handler->choices)) return -EOPNOTSUPP; - return handler->profile_set(dev, *bit); + return handler->ops->profile_set(dev, *bit); } /** @@ -103,7 +103,7 @@ static int get_class_profile(struct device *dev, lockdep_assert_held(&profile_lock); handler = to_pprof_handler(dev); - err = handler->profile_get(dev, &val); + err = handler->ops->profile_get(dev, &val); if (err) { pr_err("Failed to get profile for handler %s\n", handler->name); return err; @@ -467,7 +467,7 @@ int platform_profile_register(struct platform_profile_handler *pprof, void *drvd /* Sanity check the profile handler */ if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || - !pprof->profile_set || !pprof->profile_get) { + !pprof->ops->profile_set || !pprof->ops->profile_get) { pr_err("platform_profile: handler is invalid\n"); return -EINVAL; } diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 26c1230e75df..76967bfeeef8 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -201,6 +201,11 @@ static int ssam_platform_profile_set(struct device *dev, return tp; } +static const struct platform_profile_ops ssam_platform_profile_ops = { + .profile_get = ssam_platform_profile_get, + .profile_set = ssam_platform_profile_set, +}; + static int surface_platform_profile_probe(struct ssam_device *sdev) { struct ssam_platform_profile_device *tpd; @@ -214,8 +219,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->handler.name = "Surface Platform Profile"; tpd->handler.dev = &sdev->dev; - tpd->handler.profile_get = ssam_platform_profile_get; - tpd->handler.profile_set = ssam_platform_profile_set; + tpd->handler.ops = &ssam_platform_profile_ops; tpd->has_fan = device_property_read_bool(&sdev->dev, "has_fan"); diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index d609bd105db3..91ae48adf6cf 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1916,6 +1916,11 @@ acer_predator_v4_platform_profile_set(struct device *dev, return 0; } +static const struct platform_profile_ops acer_predator_v4_platform_profile_ops = { + .profile_get = acer_predator_v4_platform_profile_get, + .profile_set = acer_predator_v4_platform_profile_set, +}; + static int acer_platform_profile_setup(struct platform_device *device) { if (quirks->predator_v4) { @@ -1923,10 +1928,8 @@ static int acer_platform_profile_setup(struct platform_device *device) platform_profile_handler.name = "acer-wmi"; platform_profile_handler.dev = &device->dev; - platform_profile_handler.profile_get = - acer_predator_v4_platform_profile_get; - platform_profile_handler.profile_set = - acer_predator_v4_platform_profile_set; + platform_profile_handler.ops = + &acer_predator_v4_platform_profile_ops; set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index cf2e51f67787..6ae82ae86d22 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -387,6 +387,11 @@ static int amd_pmf_profile_set(struct device *dev, return 0; } +static const struct platform_profile_ops amd_pmf_profile_ops = { + .profile_get = amd_pmf_profile_get, + .profile_set = amd_pmf_profile_set, +}; + int amd_pmf_init_sps(struct amd_pmf_dev *dev) { int err; @@ -407,8 +412,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) dev->pprof.name = "amd-pmf"; dev->pprof.dev = dev->dev; - dev->pprof.profile_get = amd_pmf_profile_get; - dev->pprof.profile_set = amd_pmf_profile_set; + dev->pprof.ops = &amd_pmf_profile_ops; /* Setup supported modes */ set_bit(PLATFORM_PROFILE_LOW_POWER, dev->pprof.choices); diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 9bed170abb92..d88860dd028b 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3852,6 +3852,11 @@ static int asus_wmi_platform_profile_set(struct device *dev, return throttle_thermal_policy_write(asus); } +static const struct platform_profile_ops asus_wmi_platform_profile_ops = { + .profile_get = asus_wmi_platform_profile_get, + .profile_set = asus_wmi_platform_profile_set, +}; + static int platform_profile_setup(struct asus_wmi *asus) { struct device *dev = &asus->platform_device->dev; @@ -3878,8 +3883,7 @@ static int platform_profile_setup(struct asus_wmi *asus) asus->platform_profile_handler.name = "asus-wmi"; asus->platform_profile_handler.dev = dev; - asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get; - asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set; + asus->platform_profile_handler.ops = &asus_wmi_platform_profile_ops; set_bit(PLATFORM_PROFILE_QUIET, asus->platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_BALANCED, diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index b8131b803368..f7a854d40575 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1078,6 +1078,11 @@ static int thermal_profile_set(struct device *dev, return wmax_thermal_control(supported_thermal_profiles[profile]); } +static const struct platform_profile_ops awcc_platform_profile_ops = { + .profile_get = thermal_profile_get, + .profile_set = thermal_profile_set, +}; + static int create_thermal_profile(struct platform_device *platform_device) { enum platform_profile_option profile; @@ -1124,10 +1129,9 @@ static int create_thermal_profile(struct platform_device *platform_device) set_bit(PLATFORM_PROFILE_PERFORMANCE, pp_handler.choices); } - pp_handler.profile_get = thermal_profile_get; - pp_handler.profile_set = thermal_profile_set; pp_handler.name = "alienware-wmi"; pp_handler.dev = &platform_device->dev; + pp_handler.ops = &awcc_platform_profile_ops; return devm_platform_profile_register(&pp_handler, NULL); } diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index c86b05b5a1cb..9010a231f209 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -231,6 +231,11 @@ static int thermal_platform_profile_get(struct device *dev, return 0; } +static const struct platform_profile_ops dell_pc_platform_profile_ops = { + .profile_get = thermal_platform_profile_get, + .profile_set = thermal_platform_profile_set, +}; + static int thermal_init(void) { int ret; @@ -258,8 +263,7 @@ static int thermal_init(void) } thermal_handler->name = "dell-pc"; thermal_handler->dev = &platform_device->dev; - thermal_handler->profile_get = thermal_platform_profile_get; - thermal_handler->profile_set = thermal_platform_profile_set; + thermal_handler->ops = &dell_pc_platform_profile_ops; if (supported_modes & DELL_QUIET) set_bit(PLATFORM_PROFILE_QUIET, thermal_handler->choices); diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index b8e62dc9cecd..60328b35be74 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1565,6 +1565,21 @@ static inline void omen_unregister_powersource_event_handler(void) unregister_acpi_notifier(&platform_power_source_nb); } +static const struct platform_profile_ops platform_profile_omen_ops = { + .profile_get = platform_profile_omen_get, + .profile_set = platform_profile_omen_set, +}; + +static const struct platform_profile_ops platform_profile_victus_ops = { + .profile_get = platform_profile_victus_get, + .profile_set = platform_profile_victus_set, +}; + +static const struct platform_profile_ops hp_wmi_platform_profile_ops = { + .profile_get = hp_wmi_platform_profile_get, + .profile_set = hp_wmi_platform_profile_set, +}; + static int thermal_profile_setup(struct platform_device *device) { int err, tp; @@ -1582,8 +1597,7 @@ static int thermal_profile_setup(struct platform_device *device) if (err < 0) return err; - platform_profile_handler.profile_get = platform_profile_omen_get; - platform_profile_handler.profile_set = platform_profile_omen_set; + platform_profile_handler.ops = &platform_profile_omen_ops; set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices); } else if (is_victus_thermal_profile()) { @@ -1599,8 +1613,7 @@ static int thermal_profile_setup(struct platform_device *device) if (err < 0) return err; - platform_profile_handler.profile_get = platform_profile_victus_get; - platform_profile_handler.profile_set = platform_profile_victus_set; + platform_profile_handler.ops = &platform_profile_victus_ops; set_bit(PLATFORM_PROFILE_QUIET, platform_profile_handler.choices); } else { @@ -1617,8 +1630,7 @@ static int thermal_profile_setup(struct platform_device *device) if (err) return err; - platform_profile_handler.profile_get = hp_wmi_platform_profile_get; - platform_profile_handler.profile_set = hp_wmi_platform_profile_set; + platform_profile_handler.ops = &hp_wmi_platform_profile_ops; set_bit(PLATFORM_PROFILE_QUIET, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices); diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index fc317f42bb82..96e99513b0b5 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1063,6 +1063,11 @@ static const struct dmi_system_id ideapad_dytc_v4_allow_table[] = { {} }; +static const struct platform_profile_ops dytc_profile_ops = { + .profile_get = dytc_profile_get, + .profile_set = dytc_profile_set, +}; + static int ideapad_dytc_profile_init(struct ideapad_private *priv) { int err, dytc_version; @@ -1105,8 +1110,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) priv->dytc->pprof.name = "ideapad-laptop"; priv->dytc->pprof.dev = &priv->platform_device->dev; priv->dytc->priv = priv; - priv->dytc->pprof.profile_get = dytc_profile_get; - priv->dytc->pprof.profile_set = dytc_profile_set; + priv->dytc->pprof.ops = &dytc_profile_ops; /* Setup supported modes */ set_bit(PLATFORM_PROFILE_LOW_POWER, priv->dytc->pprof.choices); diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 47d2dbbf3392..d0a8e4eebffa 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -164,6 +164,11 @@ static int inspur_platform_profile_get(struct device *dev, return 0; } +static const struct platform_profile_ops inspur_platform_profile_ops = { + .profile_get = inspur_platform_profile_get, + .profile_set = inspur_platform_profile_set, +}; + static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) { struct inspur_wmi_priv *priv; @@ -177,8 +182,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) priv->handler.name = "inspur-wmi"; priv->handler.dev = &wdev->dev; - priv->handler.profile_get = inspur_platform_profile_get; - priv->handler.profile_set = inspur_platform_profile_set; + priv->handler.ops = &inspur_platform_profile_ops; set_bit(PLATFORM_PROFILE_LOW_POWER, priv->handler.choices); set_bit(PLATFORM_PROFILE_BALANCED, priv->handler.choices); diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 47f87bb213a9..9978fd36a3d1 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10538,12 +10538,16 @@ static int dytc_profile_set(struct device *dev, return err; } -static struct platform_profile_handler dytc_profile = { - .name = "thinkpad-acpi", +static const struct platform_profile_ops dytc_profile_ops = { .profile_get = dytc_profile_get, .profile_set = dytc_profile_set, }; +static struct platform_profile_handler dytc_profile = { + .name = "thinkpad-acpi", + .ops = &dytc_profile_ops, +}; + static void dytc_profile_refresh(void) { enum platform_profile_option profile; diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 5296d886c243..6013c05d7b86 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -28,14 +28,20 @@ enum platform_profile_option { PLATFORM_PROFILE_LAST, /*must always be last */ }; +struct platform_profile_handler; + +struct platform_profile_ops { + int (*profile_get)(struct device *dev, enum platform_profile_option *profile); + int (*profile_set)(struct device *dev, enum platform_profile_option profile); +}; + struct platform_profile_handler { const char *name; struct device *dev; struct device class_dev; int minor; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; - int (*profile_get)(struct device *dev, enum platform_profile_option *profile); - int (*profile_set)(struct device *dev, enum platform_profile_option profile); + const struct platform_profile_ops *ops; }; int platform_profile_register(struct platform_profile_handler *pprof, void *drvdata); From patchwork Tue Jan 14 15:37:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938896 Received: from mail-vk1-f176.google.com (mail-vk1-f176.google.com [209.85.221.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 048881CAA90; Tue, 14 Jan 2025 15:38:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869107; cv=none; b=bVMEzD0OQZNr2lC0uQ+BV83hGk2ElLqKDVDGZzQWaQZJFhmm9ybjWpYXXjm+lr9U7dtqBpfKJeygVM2A6SmQvEsEI2i8UyNa3coMu66i9nh6WRjfz8+bkbyGZo3JnusNcDCZjYD/SpMUHuUZY0sPsB2R3Uvo8Nsx1XlUtroBtqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869107; c=relaxed/simple; bh=mEwXOZCH3+G/rUK17saHA5YgYjBLs77mZ69hdLiCDs8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gPp9AE6Wi5zEYl87Al6ZXjKGRL12Qyel/dmQ5tMa2WyVpqwm12D9E67+O3vaBzS5mWd16wfLY+N6jqFMsllcSkav6EVLDDqJie0ExD7yyJ59w55CENzUWfhCOUjBeZd5YtMjI5/mK+mdVeC/H6BfVkG4mJTY7vkkFBllFq2oMuo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GhO29xhX; arc=none smtp.client-ip=209.85.221.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GhO29xhX" Received: by mail-vk1-f176.google.com with SMTP id 71dfb90a1353d-5162571e761so1925254e0c.2; Tue, 14 Jan 2025 07:38:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869103; x=1737473903; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5mpiSqmEhc4IxS4/FKGi2TgFCWP3KS1BKj0hDniWQHY=; b=GhO29xhXxqzIDsniRkF9Y4pTSCDSbwVUVOSgHBzZ2DL/kjKRzb1TFx2Q0+Mqnyv15V RZw6vKRlE+SqQOjOE2T7nGryysxubuu38DovRDpvBhyIxB5a4oPCne7w7SpaD5khzzHE Y6SudGxfJ48s9jlHBXJdPH0k/OEmUXrdHIUxsLRODwiD38qdVo9lWjAqvExQThMXkBWs 4HvetQisafUfZ/62lPwYREzJpyGeW5sUC+RDF3kl3B1PoeqzQM37VeeFIpAPSroB361y As/rdYN4Y3YPGvR0W8/0rKDnmfgeNKnk52IsgugcStt8fSR0h9vDYKxc5V4qhTdZmY7U ct4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869103; x=1737473903; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5mpiSqmEhc4IxS4/FKGi2TgFCWP3KS1BKj0hDniWQHY=; b=LhCUn8SFXo5yZRsb7ZvRkJov7FCM4zvPgHyrdAc6RyhKClSSWnS4l5TH95FcOMuO+m a9AG5JLlE5EO1wZltKAm2YDvR5zIIT0aJpDbvll3ejeaMnohZJAOahFimeUV0+KGCfiU 8uTwp+hH6QUqS3sigBesr/VvX2a10aYhAnmoUBvOIiXw9zoZdOA8qguKpjcJaOoSdYx9 HSIBB9z5f2X5l+NV4tbNXwvk75wRvtjaBGX9syWasmFjrsoCaoZiPHB0n/djzC+R6seO hSnhkCZBvbG/QUZzC3tNyZzKUr1DuicISsoRUvPmazHnjUfiiZmYew7afzHRgBji1YzR fQ2g== X-Forwarded-Encrypted: i=1; AJvYcCWXcGExYD7takC4DBLny2s51AR8eAvAZHWpm3chW7y0R4uM5dHHy+ILGgchb34+fqtvCweBOr0CnRlQ@vger.kernel.org, AJvYcCXjwM+zNxHx6XnqwUPXAAJeI9Vw4rk0nO2RxmUUtrXjCfZ8AaxiWhMKfRTI/YSZ1aqOMTK6YM6IixYyGawm@vger.kernel.org X-Gm-Message-State: AOJu0YxzGgCHYf2kFr/hktFCxWxNmUVRD7k8y75tJeaz7Xff+UeQFge3 nMFIjvZcblOKhPbvFlPycyyEIedpfXVOKHipan321wYJBboTRmDS23lAhg== X-Gm-Gg: ASbGncvPlPXADj57Edk5IIXXI4SoTGR8CxhqIQ3XWo2d1Sbk/setRzyMV47gIkV8yYU ZA3tkVsE7IzuscqCornxtHTQ85Q9ElgvKuy3UoL9t1Mrj8IbZ84LzA7f4NlqjAqcPFZZlh75k1C BE9I9k5txNwC33hxuvykisKWz7ugufDXlWEUFJwiTgekJ63y4l2+scQBrVFmrxISVa8Mzc61AFz /6SKXan41J6OxM7u6rZW2pqwGf+fFirXmKWm6qJeXIw+vxKEQIVj+rTLBZ+plh/ X-Google-Smtp-Source: AGHT+IGgjCt0bNOBR+KT6XaiTZevJo0blYLp7j1+G7ZCZo8c+9tiE7xeDzSQHNY3NNquxOxLhP5GPw== X-Received: by 2002:a05:6122:1a87:b0:51c:c23e:8cd4 with SMTP id 71dfb90a1353d-51cc23e8d69mr3892530e0c.4.1736869103491; Tue, 14 Jan 2025 07:38:23 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.38.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:38:22 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 05/18] ACPI: platform_profile: Add `probe` to platform_profile_ops Date: Tue, 14 Jan 2025 10:37:13 -0500 Message-ID: <20250114153726.11802-6-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a `probe` callback to platform_profile_ops, which lets drivers initialize the choices member manually. Signed-off-by: Kurt Borja --- drivers/acpi/platform_profile.c | 13 +++++++-- .../surface/surface_platform_profile.c | 16 ++++++---- drivers/platform/x86/acer-wmi.c | 24 ++++++++------- drivers/platform/x86/amd/pmf/sps.c | 15 ++++++---- drivers/platform/x86/asus-wmi.c | 16 ++++++---- drivers/platform/x86/dell/alienware-wmi.c | 24 +++++++++------ drivers/platform/x86/dell/dell-pc.c | 26 ++++++++++------- drivers/platform/x86/hp/hp-wmi.c | 29 +++++++++++++------ drivers/platform/x86/ideapad-laptop.c | 15 ++++++---- .../platform/x86/inspur_platform_profile.c | 14 ++++++--- drivers/platform/x86/thinkpad_acpi.c | 15 ++++++---- include/linux/platform_profile.h | 1 + 12 files changed, 137 insertions(+), 71 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 440654e21620..34e22b006ccc 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -466,12 +466,21 @@ int platform_profile_register(struct platform_profile_handler *pprof, void *drvd int err; /* Sanity check the profile handler */ - if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || - !pprof->ops->profile_set || !pprof->ops->profile_get) { + if (!pprof || !pprof->ops->profile_set || !pprof->ops->profile_get || + !pprof->ops->probe) { pr_err("platform_profile: handler is invalid\n"); return -EINVAL; } + err = pprof->ops->probe(drvdata, pprof->choices); + if (err < 0) + return err; + + if (bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST)) { + pr_err("platform_profile: no available profiles\n"); + return -EINVAL; + } + guard(mutex)(&profile_lock); /* create class interface for individual handler */ diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 76967bfeeef8..48cfe9cb89c8 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -201,7 +201,18 @@ static int ssam_platform_profile_set(struct device *dev, return tp; } +static int ssam_platform_profile_probe(void *drvdata, unsigned long *choices) +{ + set_bit(PLATFORM_PROFILE_LOW_POWER, choices); + set_bit(PLATFORM_PROFILE_BALANCED, choices); + set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); + + return 0; +} + static const struct platform_profile_ops ssam_platform_profile_ops = { + .probe = ssam_platform_profile_probe, .profile_get = ssam_platform_profile_get, .profile_set = ssam_platform_profile_set, }; @@ -223,11 +234,6 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->has_fan = device_property_read_bool(&sdev->dev, "has_fan"); - set_bit(PLATFORM_PROFILE_LOW_POWER, tpd->handler.choices); - set_bit(PLATFORM_PROFILE_BALANCED, tpd->handler.choices); - set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, tpd->handler.choices); - set_bit(PLATFORM_PROFILE_PERFORMANCE, tpd->handler.choices); - return platform_profile_register(&tpd->handler, tpd); } diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 91ae48adf6cf..6953e36dbfde 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1916,7 +1916,20 @@ acer_predator_v4_platform_profile_set(struct device *dev, return 0; } +static int +acer_predator_v4_platform_profile_probe(void *drvdata, unsigned long *choices) +{ + set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); + set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, choices); + set_bit(PLATFORM_PROFILE_BALANCED, choices); + set_bit(PLATFORM_PROFILE_QUIET, choices); + set_bit(PLATFORM_PROFILE_LOW_POWER, choices); + + return 0; +} + static const struct platform_profile_ops acer_predator_v4_platform_profile_ops = { + .probe = acer_predator_v4_platform_profile_probe, .profile_get = acer_predator_v4_platform_profile_get, .profile_set = acer_predator_v4_platform_profile_set, }; @@ -1931,17 +1944,6 @@ static int acer_platform_profile_setup(struct platform_device *device) platform_profile_handler.ops = &acer_predator_v4_platform_profile_ops; - set_bit(PLATFORM_PROFILE_PERFORMANCE, - platform_profile_handler.choices); - set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, - platform_profile_handler.choices); - set_bit(PLATFORM_PROFILE_BALANCED, - platform_profile_handler.choices); - set_bit(PLATFORM_PROFILE_QUIET, - platform_profile_handler.choices); - set_bit(PLATFORM_PROFILE_LOW_POWER, - platform_profile_handler.choices); - err = platform_profile_register(&platform_profile_handler, NULL); if (err) return err; diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 6ae82ae86d22..e710405b581f 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -387,7 +387,17 @@ static int amd_pmf_profile_set(struct device *dev, return 0; } +static int amd_pmf_profile_probe(void *drvdata, unsigned long *choices) +{ + set_bit(PLATFORM_PROFILE_LOW_POWER, choices); + set_bit(PLATFORM_PROFILE_BALANCED, choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); + + return 0; +} + static const struct platform_profile_ops amd_pmf_profile_ops = { + .probe = amd_pmf_profile_probe, .profile_get = amd_pmf_profile_get, .profile_set = amd_pmf_profile_set, }; @@ -414,11 +424,6 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) dev->pprof.dev = dev->dev; dev->pprof.ops = &amd_pmf_profile_ops; - /* Setup supported modes */ - set_bit(PLATFORM_PROFILE_LOW_POWER, dev->pprof.choices); - set_bit(PLATFORM_PROFILE_BALANCED, dev->pprof.choices); - set_bit(PLATFORM_PROFILE_PERFORMANCE, dev->pprof.choices); - /* Create platform_profile structure and register */ err = platform_profile_register(&dev->pprof, dev); if (err) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index d88860dd028b..3d77f7454953 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3852,7 +3852,17 @@ static int asus_wmi_platform_profile_set(struct device *dev, return throttle_thermal_policy_write(asus); } +static int asus_wmi_platform_profile_probe(void *drvdata, unsigned long *choices) +{ + set_bit(PLATFORM_PROFILE_QUIET, choices); + set_bit(PLATFORM_PROFILE_BALANCED, choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); + + return 0; +} + static const struct platform_profile_ops asus_wmi_platform_profile_ops = { + .probe = asus_wmi_platform_profile_probe, .profile_get = asus_wmi_platform_profile_get, .profile_set = asus_wmi_platform_profile_set, }; @@ -3885,12 +3895,6 @@ static int platform_profile_setup(struct asus_wmi *asus) asus->platform_profile_handler.dev = dev; asus->platform_profile_handler.ops = &asus_wmi_platform_profile_ops; - set_bit(PLATFORM_PROFILE_QUIET, asus->platform_profile_handler.choices); - set_bit(PLATFORM_PROFILE_BALANCED, - asus->platform_profile_handler.choices); - set_bit(PLATFORM_PROFILE_PERFORMANCE, - asus->platform_profile_handler.choices); - err = platform_profile_register(&asus->platform_profile_handler, asus); if (err == -EEXIST) { pr_warn("%s, a platform_profile handler is already registered\n", __func__); diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index f7a854d40575..0146d2f93be6 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1078,12 +1078,7 @@ static int thermal_profile_set(struct device *dev, return wmax_thermal_control(supported_thermal_profiles[profile]); } -static const struct platform_profile_ops awcc_platform_profile_ops = { - .profile_get = thermal_profile_get, - .profile_set = thermal_profile_set, -}; - -static int create_thermal_profile(struct platform_device *platform_device) +static int thermal_profile_probe(void *drvdata, unsigned long *choices) { enum platform_profile_option profile; enum wmax_thermal_mode mode; @@ -1116,19 +1111,30 @@ static int create_thermal_profile(struct platform_device *platform_device) profile = wmax_mode_to_platform_profile[mode]; supported_thermal_profiles[profile] = out_data; - set_bit(profile, pp_handler.choices); + set_bit(profile, choices); } - if (bitmap_empty(pp_handler.choices, PLATFORM_PROFILE_LAST)) + if (bitmap_empty(choices, PLATFORM_PROFILE_LAST)) return -ENODEV; if (quirks->gmode) { supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] = WMAX_THERMAL_MODE_GMODE; - set_bit(PLATFORM_PROFILE_PERFORMANCE, pp_handler.choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); } + return 0; +} + +static const struct platform_profile_ops awcc_platform_profile_ops = { + .probe = thermal_profile_probe, + .profile_get = thermal_profile_get, + .profile_set = thermal_profile_set, +}; + +static int create_thermal_profile(struct platform_device *platform_device) +{ pp_handler.name = "alienware-wmi"; pp_handler.dev = &platform_device->dev; pp_handler.ops = &awcc_platform_profile_ops; diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 9010a231f209..32b3be0723f8 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -24,6 +24,7 @@ #include "dell-smbios.h" static struct platform_device *platform_device; +static int supported_modes; static const struct dmi_system_id dell_device_table[] __initconst = { { @@ -231,7 +232,22 @@ static int thermal_platform_profile_get(struct device *dev, return 0; } +static int thermal_platform_profile_probe(void *drvdata, unsigned long *choices) +{ + if (supported_modes & DELL_QUIET) + set_bit(PLATFORM_PROFILE_QUIET, choices); + if (supported_modes & DELL_COOL_BOTTOM) + set_bit(PLATFORM_PROFILE_COOL, choices); + if (supported_modes & DELL_BALANCED) + set_bit(PLATFORM_PROFILE_BALANCED, choices); + if (supported_modes & DELL_PERFORMANCE) + set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); + + return 0; +} + static const struct platform_profile_ops dell_pc_platform_profile_ops = { + .probe = thermal_platform_profile_probe, .profile_get = thermal_platform_profile_get, .profile_set = thermal_platform_profile_set, }; @@ -239,7 +255,6 @@ static const struct platform_profile_ops dell_pc_platform_profile_ops = { static int thermal_init(void) { int ret; - int supported_modes; /* If thermal commands are not supported, exit without error */ if (!dell_smbios_class_is_supported(CLASS_INFO)) @@ -265,15 +280,6 @@ static int thermal_init(void) thermal_handler->dev = &platform_device->dev; thermal_handler->ops = &dell_pc_platform_profile_ops; - if (supported_modes & DELL_QUIET) - set_bit(PLATFORM_PROFILE_QUIET, thermal_handler->choices); - if (supported_modes & DELL_COOL_BOTTOM) - set_bit(PLATFORM_PROFILE_COOL, thermal_handler->choices); - if (supported_modes & DELL_BALANCED) - set_bit(PLATFORM_PROFILE_BALANCED, thermal_handler->choices); - if (supported_modes & DELL_PERFORMANCE) - set_bit(PLATFORM_PROFILE_PERFORMANCE, thermal_handler->choices); - /* Clean up if failed */ ret = platform_profile_register(thermal_handler, NULL); if (ret) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 60328b35be74..75bcd8460e7c 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1488,6 +1488,23 @@ static int platform_profile_victus_set(struct device *dev, return 0; } +static int hp_wmi_platform_profile_probe(void *drvdata, unsigned long *choices) +{ + if (is_omen_thermal_profile()) { + set_bit(PLATFORM_PROFILE_COOL, choices); + } else if (is_victus_thermal_profile()) { + set_bit(PLATFORM_PROFILE_QUIET, choices); + } else { + set_bit(PLATFORM_PROFILE_QUIET, choices); + set_bit(PLATFORM_PROFILE_COOL, choices); + } + + set_bit(PLATFORM_PROFILE_BALANCED, choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); + + return 0; +} + static int omen_powersource_event(struct notifier_block *nb, unsigned long value, void *data) @@ -1566,16 +1583,19 @@ static inline void omen_unregister_powersource_event_handler(void) } static const struct platform_profile_ops platform_profile_omen_ops = { + .probe = hp_wmi_platform_profile_probe, .profile_get = platform_profile_omen_get, .profile_set = platform_profile_omen_set, }; static const struct platform_profile_ops platform_profile_victus_ops = { + .probe = hp_wmi_platform_profile_probe, .profile_get = platform_profile_victus_get, .profile_set = platform_profile_victus_set, }; static const struct platform_profile_ops hp_wmi_platform_profile_ops = { + .probe = hp_wmi_platform_profile_probe, .profile_get = hp_wmi_platform_profile_get, .profile_set = hp_wmi_platform_profile_set, }; @@ -1598,8 +1618,6 @@ static int thermal_profile_setup(struct platform_device *device) return err; platform_profile_handler.ops = &platform_profile_omen_ops; - - set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices); } else if (is_victus_thermal_profile()) { err = platform_profile_victus_get_ec(&active_platform_profile); if (err < 0) @@ -1614,8 +1632,6 @@ static int thermal_profile_setup(struct platform_device *device) return err; platform_profile_handler.ops = &platform_profile_victus_ops; - - set_bit(PLATFORM_PROFILE_QUIET, platform_profile_handler.choices); } else { tp = thermal_profile_get(); @@ -1631,15 +1647,10 @@ static int thermal_profile_setup(struct platform_device *device) return err; platform_profile_handler.ops = &hp_wmi_platform_profile_ops; - - set_bit(PLATFORM_PROFILE_QUIET, platform_profile_handler.choices); - set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices); } platform_profile_handler.name = "hp-wmi"; platform_profile_handler.dev = &device->dev; - set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); - set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); err = platform_profile_register(&platform_profile_handler, NULL); if (err) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 96e99513b0b5..050919a28d2b 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1023,6 +1023,15 @@ static int dytc_profile_set(struct device *dev, return -EINTR; } +static int dytc_profile_probe(void *drvdata, unsigned long *choices) +{ + set_bit(PLATFORM_PROFILE_LOW_POWER, choices); + set_bit(PLATFORM_PROFILE_BALANCED, choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); + + return 0; +} + static void dytc_profile_refresh(struct ideapad_private *priv) { enum platform_profile_option profile; @@ -1064,6 +1073,7 @@ static const struct dmi_system_id ideapad_dytc_v4_allow_table[] = { }; static const struct platform_profile_ops dytc_profile_ops = { + .probe = dytc_profile_probe, .profile_get = dytc_profile_get, .profile_set = dytc_profile_set, }; @@ -1112,11 +1122,6 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) priv->dytc->priv = priv; priv->dytc->pprof.ops = &dytc_profile_ops; - /* Setup supported modes */ - set_bit(PLATFORM_PROFILE_LOW_POWER, priv->dytc->pprof.choices); - set_bit(PLATFORM_PROFILE_BALANCED, priv->dytc->pprof.choices); - set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->dytc->pprof.choices); - /* Create platform_profile structure and register */ err = platform_profile_register(&priv->dytc->pprof, &priv->dytc); if (err) diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index d0a8e4eebffa..06df3aae9a56 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -164,7 +164,17 @@ static int inspur_platform_profile_get(struct device *dev, return 0; } +static int inspur_platform_profile_probe(void *drvdata, unsigned long *choices) +{ + set_bit(PLATFORM_PROFILE_LOW_POWER, choices); + set_bit(PLATFORM_PROFILE_BALANCED, choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); + + return 0; +} + static const struct platform_profile_ops inspur_platform_profile_ops = { + .probe = inspur_platform_profile_probe, .profile_get = inspur_platform_profile_get, .profile_set = inspur_platform_profile_set, }; @@ -184,10 +194,6 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) priv->handler.dev = &wdev->dev; priv->handler.ops = &inspur_platform_profile_ops; - set_bit(PLATFORM_PROFILE_LOW_POWER, priv->handler.choices); - set_bit(PLATFORM_PROFILE_BALANCED, priv->handler.choices); - set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->handler.choices); - return platform_profile_register(&priv->handler, priv); } diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 9978fd36a3d1..5c250867678f 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10538,7 +10538,17 @@ static int dytc_profile_set(struct device *dev, return err; } +static int dytc_profile_probe(void *drvdata, unsigned long *choices) +{ + set_bit(PLATFORM_PROFILE_LOW_POWER, choices); + set_bit(PLATFORM_PROFILE_BALANCED, choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); + + return 0; +} + static const struct platform_profile_ops dytc_profile_ops = { + .probe = dytc_profile_probe, .profile_get = dytc_profile_get, .profile_set = dytc_profile_set, }; @@ -10584,11 +10594,6 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) { int err, output; - /* Setup supported modes */ - set_bit(PLATFORM_PROFILE_LOW_POWER, dytc_profile.choices); - set_bit(PLATFORM_PROFILE_BALANCED, dytc_profile.choices); - set_bit(PLATFORM_PROFILE_PERFORMANCE, dytc_profile.choices); - err = dytc_command(DYTC_CMD_QUERY, &output); if (err) return err; diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 6013c05d7b86..5ad1ab7b75e4 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -31,6 +31,7 @@ enum platform_profile_option { struct platform_profile_handler; struct platform_profile_ops { + int (*probe)(void *drvdata, unsigned long *choices); int (*profile_get)(struct device *dev, enum platform_profile_option *profile); int (*profile_set)(struct device *dev, enum platform_profile_option profile); }; From patchwork Tue Jan 14 15:37:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938897 Received: from mail-vk1-f180.google.com (mail-vk1-f180.google.com [209.85.221.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A01071A4AA1; Tue, 14 Jan 2025 15:38:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869110; cv=none; b=Mz+WHBgijiebsd9rAjMQJ5GIgAxiwHLp/9IDPR/xBNIqyq/TQTr2lm3xqBIhSE1UUzSH9dV0y7GxkymCEtwZopjnH8xm4ES1vETwT+qnEGUicIc+vCeMJbYjhzsHgBpzO51vtAGWZJYJvIf/fXdA8NlEtAKV3ftCsakY0z++iZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869110; c=relaxed/simple; bh=2+taimKyBEm1kRNAQ+szSIcVKCkO2CromD3iyu2qvtw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nMxhpUemmqm/hBXd1HdFyV8Vc1VmZ5CRF+WE4HIPq+lEp6MHszY506Ix3sGHtzRU3bU0xxNuucJdoBgs8iEO9QmvoRVOgbI8TUI243XXuZBCnFfU98tbPWn9goczZukFH1ltjbiUpBO/BsSx6Poi7kk1iTn+ryLkUYydRw7Jpvo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gW+SK6l+; arc=none smtp.client-ip=209.85.221.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gW+SK6l+" Received: by mail-vk1-f180.google.com with SMTP id 71dfb90a1353d-5187aa2c97dso2017364e0c.2; Tue, 14 Jan 2025 07:38:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869107; x=1737473907; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sjq2L0uePHNEIwDJxvOdyrSdiJEUOj2ZGOc/6PuIBm0=; b=gW+SK6l+DKi5PcLEdfO+yJHg1jkZtgf+vTDwmkbXB48Y1RoQqyI4wliKjiWu7wfKur 7NptoassUJGn7JC+BqXkvX2Zkh99bOggZ9ynLIOsQBZR3k+ykwPAFnFnUNX4DlC2m6zv Nv1dFMxsEG+OBBOYWWR1xBTsbdLuYTpOXm1CuoowFPVLUanaLj5tjmeH/N+Nj5Kj9NFN zDXAEK2HLGKpp+43/F/XwV+56m50GRvZWe9bHHjRvvfRX4atm/GpcHJXo/EbK+lPcnxX n2uoQtv/PCyEcGOUCDtoIdGIPa9+yDpAz3l61y/F94rRJwggArkGY896BqKHX9/jTlqw LIEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869107; x=1737473907; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sjq2L0uePHNEIwDJxvOdyrSdiJEUOj2ZGOc/6PuIBm0=; b=tR73oSBrAb9WOvv8aAGaG0qJNSEMTc7cQhQ0cL/Ib/8Di/tKufMvkNyTDS7PI/aP6m 3WzpVDsYPwgtkvk/eilhElSs+I1koAppbd0pCT8gRy0fgbs6eyB2JyzjfrAAqmiDyhiM yEB4WCWAen7OegTniY1SYGS/B4UN7hQJJyZgDJW6N8xiJ2OBMQk6PI2/Xp7JRNrYM4wj 49px4lemEC+gP4KuflBGMO594scj1edQiwoQK49MuPFEoCIN3VYpF1RwYPsZhdWKs8Gw hdeymlCAgycW2GvujZ7m68ktooNqrgS98/ueVh3AR8ZXjeKFi4C6We2VR+yaHByMOswc JoJg== X-Forwarded-Encrypted: i=1; AJvYcCUuJgi3fQxyB87vZ5YZRqm21UM6/2WgKt3ANuqNNhRWND35KAsKT5qxR0IVMFvat4R3Xnh6tElKzDF7@vger.kernel.org, AJvYcCX373cr3Esm4p65Lm5kbIn6YVfsrAOXuUxovRloATJk/Hbhl4tEaev/3fy8AMtDeUVMfzhVzTalv24hdZTG@vger.kernel.org X-Gm-Message-State: AOJu0Yyw5jvF7a1aR6tR6/rDDHJ5dgWLHzxXpEocnfE68Ji09M45qgDy 2J5Bg5ofwiAVY+vuO1Zz0SfZQrI3xbmjfjXYYGty9gENOBwhWpRc15xwVQ== X-Gm-Gg: ASbGncutRqntLPylsb6TnFlURL8h/DaEuFrXhIjXkjcf2zIxtBWyZSSDHGilNdU6hhY ct0NYvsXCV0dI5Qwsz7VadJP0Q8W3euUHcVL56B9ImPtokHvjV9jf1V/IadOfXUEvxnkCLlvGrV 791Nq6UUJhiBAD5xXgDRHMfsdphyk5TqOhAo6LdXeOP67k1ObuS9yTp5DeF6go+yeuSLr2uk2BO bUwhHqzZtinPD3J8V9JhS/0ccC5OO1FEmnc98lL4QKDdHUazkHjtocaCjf+HPVE X-Google-Smtp-Source: AGHT+IFmZFDY2y+/oTQyOlNMw68zLjvAGIijNhNMJI9bQH2N2Mohu0AAs5boNvYkOHpoxhVXoMBkBA== X-Received: by 2002:a05:6122:180d:b0:50d:5e21:ef39 with SMTP id 71dfb90a1353d-51c6c3570a4mr18788273e0c.1.1736869106904; Tue, 14 Jan 2025 07:38:26 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.38.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:38:26 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 06/18] platform/surface: surface_platform_profile: Use devm_platform_profile_register() Date: Tue, 14 Jan 2025 10:37:14 -0500 Message-ID: <20250114153726.11802-7-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace platform_profile_register() with it's device managed version. Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/platform/surface/surface_platform_profile.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 48cfe9cb89c8..bbdc873cb788 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -234,15 +234,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->has_fan = device_property_read_bool(&sdev->dev, "has_fan"); - return platform_profile_register(&tpd->handler, tpd); -} - -static void surface_platform_profile_remove(struct ssam_device *sdev) -{ - struct ssam_platform_profile_device *tpd; - - tpd = ssam_device_get_drvdata(sdev); - platform_profile_remove(&tpd->handler); + return devm_platform_profile_register(&tpd->handler, tpd); } static const struct ssam_device_id ssam_platform_profile_match[] = { @@ -253,7 +245,6 @@ MODULE_DEVICE_TABLE(ssam, ssam_platform_profile_match); static struct ssam_device_driver surface_platform_profile = { .probe = surface_platform_profile_probe, - .remove = surface_platform_profile_remove, .match_table = ssam_platform_profile_match, .driver = { .name = "surface_platform_profile", From patchwork Tue Jan 14 15:37:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938898 Received: from mail-vk1-f178.google.com (mail-vk1-f178.google.com [209.85.221.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B3E51D516A; Tue, 14 Jan 2025 15:38:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869114; cv=none; b=qbbnX9Zc7U4JmKkexPlvDEa7E525oPVjd1peXtreYYwsbIRuqbHnodN16gSCQaw2pOXl5LcBrOPzWPxkbjijF53E0MrDIBL0LlZCue9SSuJS7GYD9Ubogbt7TvGTvQZ7ZiVKVoUmZdLgfNad5pTiFSNNbSBYNvjO5PZFPWRAKM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869114; c=relaxed/simple; bh=NaOj6JLG8xbse3Z94sPWjBTSVxlI9dvAjjS2f2cWDkU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hlnnCm7YhlGXNSYC/J2tzN8/2zm/08muXMy89W5r6z6QFBKi+rhmZZ3ZsYCxoj3bSr9U69TM1ALxi57K+2gL8QKgSxO5CLPANFjPw62Dvk3hFtbm0XNAGQLJqDJjF6wTDlTvYXtVUrnuqUs+yxSCcUiYvQqFL8jK6cF+miYTNxo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=c+ziSngX; arc=none smtp.client-ip=209.85.221.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c+ziSngX" Received: by mail-vk1-f178.google.com with SMTP id 71dfb90a1353d-5189a440a65so3345107e0c.1; Tue, 14 Jan 2025 07:38:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869111; x=1737473911; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vXXOBPa9TmGwpH3xyz4lwnmEdjwxxKtQdouu9864DVY=; b=c+ziSngXHqHdGNLLVlBUxt0Ole9VZDuIDvZltme41A4FPwjK8ce3PsVWyjoBtYcTxx A+VEVrMcqVY8ksU1fDoSjVZKlWUpEvGvHUupTe7cli0eoTJ0losivTyyOKJN23mMWDxr ddKBuTxc8HSeRtfdSwWD7tze11Qts4YXvkbWHWUAuxVeD5pKAf0JlBm35ZU2elyyUMvr sKs9lZNkmNHzixQm4z8vNDp2vA1g58h80/cOcMsN2cUc9N8iTpFRCD3gdHWZRYXVB1EI 08K5SDiYR2DSqK9pFVnS25/tX378XGrSvLn0FzXwlMEUt2s/56ukp3efUG7rWrSwzfDe +6ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869111; x=1737473911; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vXXOBPa9TmGwpH3xyz4lwnmEdjwxxKtQdouu9864DVY=; b=u4SRv4JIhDEK9pdOXJPkJ5AVKEbqSjyMFVTwQ3P54qK8OpjeWrjaR0sv7sv2L5oNJR 8klll4bIJcNqCQAkiBVT0VfthTrBNygMzucNNgYAEUpIl3lZJPuSqytQ8NCz35TAFLDt 3gZy3Qhhk0w1BFPSZJvnHEIWdeiEsOFJQqo2a0Yw407yj8A+iINFoQbxdznoU5ZvrDfB OUcR/HfI32x27j4zjFQAAL+t5KawNwUG2S5tNIzvD4EWULT+d7r80oVA3Oe6UZOQNyOz rE92ezFFXtNSy1ER2vq7YgxCDK2WVse1XT1mVbSg8HI0Wbwys0UiOxMUWTvQwt7mTPNA dYEw== X-Forwarded-Encrypted: i=1; AJvYcCX8qo9VHJnw/DzwBsky9BRbw5ugjK41VmP7dLmVSK4NUuJxd9RLlmSOgCr3rdjzIhwfD4kqX9AiFs+negid@vger.kernel.org, AJvYcCXH0mAfsmJoDzNy+B7NZwNC2SyNnPqRmyb/G40xsto/peDWjtT2mCdopRMxNScyemTg8dr20WhMT0sQ@vger.kernel.org X-Gm-Message-State: AOJu0YyaZV2DWtdhTB6WT9/YLbvJC/f0Ove1wysYgeo9knUVr/IWNI/R 1w6P5QRSVPPHCEmA1an+n0SF55Xn3haFbJ7a4aKicj8ZTmDkC1HJwXk9Tg== X-Gm-Gg: ASbGncsYCQZsQe3D+agJoG0That/1wZF/MsLpNJHNnd2xfmWWtU2aHl5l9vXYkHeoeI RTgKHW/UFYZMmqa6HRVprRm02Pxm18vtBBPPktW0VDKuNosAj0pJPDfl1Yb22Hpug66HGuBVU74 G71oUzS+cHviMEZT8pH6vntP1mBw4F+gYN2DwBszyxmcGs05GAI1zbSqF2u8CEcMnmdeARcwkyF MIH+k/TRvmIDly7PJ5YL8gY+FvTNU62+RkduW39bZBnxfMel0nnYE7Ts3d4pcXY X-Google-Smtp-Source: AGHT+IGymxghO7z8dVU7Eu/b9OLkWgPwGI3fjmUa4U3Fe6h9wktGurAjv35UpLGhpIbvu3eOGVWekg== X-Received: by 2002:a1f:e286:0:b0:51c:c663:a338 with SMTP id 71dfb90a1353d-51cc663a358mr3941855e0c.4.1736869110818; Tue, 14 Jan 2025 07:38:30 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.38.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:38:30 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 07/18] platform/x86: acer-wmi: Use devm_platform_profile_register() Date: Tue, 14 Jan 2025 10:37:15 -0500 Message-ID: <20250114153726.11802-8-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace platform_profile_register() with it's device managed version. Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/platform/x86/acer-wmi.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 6953e36dbfde..39ec236b7cdb 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1944,7 +1944,7 @@ static int acer_platform_profile_setup(struct platform_device *device) platform_profile_handler.ops = &acer_predator_v4_platform_profile_ops; - err = platform_profile_register(&platform_profile_handler, NULL); + err = devm_platform_profile_register(&platform_profile_handler, NULL); if (err) return err; @@ -2591,8 +2591,6 @@ static int acer_platform_probe(struct platform_device *device) return 0; error_hwmon: - if (platform_profile_support) - platform_profile_remove(&platform_profile_handler); error_platform_profile: acer_rfkill_exit(); error_rfkill: @@ -2613,9 +2611,6 @@ static void acer_platform_remove(struct platform_device *device) acer_backlight_exit(); acer_rfkill_exit(); - - if (platform_profile_support) - platform_profile_remove(&platform_profile_handler); } #ifdef CONFIG_PM_SLEEP From patchwork Tue Jan 14 15:37:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938899 Received: from mail-ua1-f52.google.com (mail-ua1-f52.google.com [209.85.222.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA91A1B2199; Tue, 14 Jan 2025 15:38:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869117; cv=none; b=tIdvFsOoNcXKstWE2j4KII7r1C4I0rPCweREw+gH7AtsbVsouSu2H6lDRxO+A8W7vrI9pQY4f25e+Xqxa5+uAgeozL/r4g7Qre6+o/eK32nW6/rukAEVwPIsUXwGV9DTHTfNyWn5ODOV0DCIgGHyuLTS0dDzpfg7JWrD42JrvKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869117; c=relaxed/simple; bh=zkjAivanrILN0QwKTQomumxo5DHvP/B4R+arBJ3ZtKc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Drx520FdPBVXNr9dK+U5+RNRbTZL2CeKRi9X78iowM/ooXmaDgFKX7qXiC+iseAWaHElD+yayQqpUBtHSOHNnSmqMYOV8baHWcprxylb2olzXvO7ivqSJ206yzs3c57GJfqW8WIoF9KZ339qVSjXUpsJbq4K1iEZWE9GWMa5xmE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FJhzbCPz; arc=none smtp.client-ip=209.85.222.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FJhzbCPz" Received: by mail-ua1-f52.google.com with SMTP id a1e0cc1a2514c-85c559ed230so1284050241.0; Tue, 14 Jan 2025 07:38:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869114; x=1737473914; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DD4+zxqyF6rDN55QCqbXpu0oMdAVgFHxRkeXOF8oJvE=; b=FJhzbCPzceQ/RSkc+04VnCiEh6Z6Gj2FaAfI1K15FH/4Do2zmdPwJuiOSFyPs6MsXP f0PKclbXwBS802zTUtB/jwlWVnCH3UkQZhl6wpqbeyPvx83/oZmQ+Jak+CN86tXhmhNw O0XbEseeESl6bGhyysDkMLxjAnryT2xKitDcDQ81QLWGwslh7i7f46TMrCvH2MBaCcT/ guEP1h9gGWNtEx/pIVMpY545w2zWmcdXgd0GYacP92X7K2MrzSf4kGXwqbZ8DD6KHevE ia+kDZw6127M079Wb8U0ctHjAYQhk0L2fWzW5hiAPF+Eiq8QuDsYR3ZDnuuMxvhAXgyz rxCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869114; x=1737473914; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DD4+zxqyF6rDN55QCqbXpu0oMdAVgFHxRkeXOF8oJvE=; b=P3QTLQ73I1/5RPtSaHc7MpEVtVlVhXr601mekkgS/osthIZfVi+vPifYL64yfmKFM7 1oyJ1wmUDXi+f3MjBo5L1c4ouKEivbO3ajTGoE8/+junyKN4e4Yuea06nD6udSwnJ6Iy hhcbfmSCvRJIDvmXQbgUMihhiSOMYPaHQ83ZjUbJaSS0wmp+Gv6gpllHWa6t83mY6eWX TnDTJ2KJdsSL7W1Gkaf+NOMSruyFiW4SGiTDWTlgVeWEMK/CP0Gz2PKeJy3Ls/dKpDcb J92G6T0CzHl8DNCARL+jGjSRHpHOWbEcjdGTK79H9UUBDpz4ueiua3eKS4QIbm0J0q6g 0oig== X-Forwarded-Encrypted: i=1; AJvYcCWkY/QcasY9nD4uE/NudAvwLLINfnS7fPfPzIRBeEgaDjikIq1UnCAGkFHdMD6B6+11qQjVK06bgkX4HeTk@vger.kernel.org, AJvYcCX4l9T8j4N+OVum1wovOwTtAiDC3DdqmfhRRYuQuWo/IIMk4kg1BvrI8cnz3JuwSr86BE5SNVhjVNOC@vger.kernel.org X-Gm-Message-State: AOJu0Yw+e9Basro1v1POR8hUOTbmKLhMyqjViMSS5LwbBH1LIw9dtkpb doOv9G6NYV5CGx3a9caVGj2Mps5NN17yx/vhEKQq/3I/w/X0rJ3czNG3SQ== X-Gm-Gg: ASbGnctfgGh3Kjdfaoe0PSwXEoNVMZzVVAFT4Odlb9bWa7T8+GARgtkx46fgARfs636 HYmMO2ksXLYTWB1dmPv3EcR5Cbq4EXB+xLT9M6Q/pD1uW9CjbbgOFu/7hLwCEtf3yKw+D4vcbjG 3J/b4WezD3zLxlOXWRQTvdPk6QmBhKK5jI2xRYQ3LgIwbdmCzVKeh5FE0Y2WVIjcFr57OgViunb kfd5412RdvM56D9n+8ylB5KSVYSXKVY1+j7OBL1D2K1fcLdgznm20RTwoejeqey X-Google-Smtp-Source: AGHT+IGlPSc8xaym7V4UN0dZ4GF8gO3oMJ5nUCqxvkaKnzbl3wrr9CpllwxhQbjiRXMtVZLA75/O4g== X-Received: by 2002:a05:6122:3d04:b0:515:d2d1:7c0d with SMTP id 71dfb90a1353d-51c6c4691c4mr20013183e0c.5.1736869114289; Tue, 14 Jan 2025 07:38:34 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.38.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:38:33 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 08/18] platform/x86: amd: pmf: sps: Use devm_platform_profile_register() Date: Tue, 14 Jan 2025 10:37:16 -0500 Message-ID: <20250114153726.11802-9-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace platform_profile_register() with it's device managed version. Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/platform/x86/amd/pmf/core.c | 1 - drivers/platform/x86/amd/pmf/pmf.h | 1 - drivers/platform/x86/amd/pmf/sps.c | 7 +------ 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index 57ee95a327be..1211a753fee8 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -371,7 +371,6 @@ static void amd_pmf_deinit_features(struct amd_pmf_dev *dev) if (is_apmf_func_supported(dev, APMF_FUNC_STATIC_SLIDER_GRANULAR) || is_apmf_func_supported(dev, APMF_FUNC_OS_POWER_SLIDER_UPDATE)) { power_supply_unreg_notifier(&dev->pwr_src_notifier); - amd_pmf_deinit_sps(dev); } if (dev->smart_pc_enabled) { diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index 080818dd173b..d99b3556205b 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -780,7 +780,6 @@ int amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf); void amd_pmf_update_slider(struct amd_pmf_dev *dev, bool op, int idx, struct amd_pmf_static_slider_granular *table); int amd_pmf_init_sps(struct amd_pmf_dev *dev); -void amd_pmf_deinit_sps(struct amd_pmf_dev *dev); int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev, struct apmf_static_slider_granular_output *output); bool is_pprof_balanced(struct amd_pmf_dev *pmf); diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index e710405b581f..7c7ed2b9de01 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -425,15 +425,10 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) dev->pprof.ops = &amd_pmf_profile_ops; /* Create platform_profile structure and register */ - err = platform_profile_register(&dev->pprof, dev); + err = devm_platform_profile_register(&dev->pprof, dev); if (err) dev_err(dev->dev, "Failed to register SPS support, this is most likely an SBIOS bug: %d\n", err); return err; } - -void amd_pmf_deinit_sps(struct amd_pmf_dev *dev) -{ - platform_profile_remove(&dev->pprof); -} From patchwork Tue Jan 14 15:37:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938900 Received: from mail-ua1-f51.google.com (mail-ua1-f51.google.com [209.85.222.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37EF21B21AB; Tue, 14 Jan 2025 15:38:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869120; cv=none; b=f+0rQW/5Dq12w+lzSnTeHMDE1HSoYGIcV+gh+ZuOhyRpPyhwLuFLhGMn/VW/28XplvlDmrt/U3grx5JJI7q01GZtE3Y/F1ceagtykEvJN3ak7Xt9/NUdVzbJ5UyYVuEou9liiw03Rgu2j/RK+jmb2qb3bbK/Z2L/z0WRuQTatO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869120; c=relaxed/simple; bh=JxvVIpyZV1grpmaMFFZN95BrlRBdgJNNmmmCjxdlS4Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f8Z/m/QZPXZBQSrAC2l+tWUUwv46Yy0dM7tMnAHUI9yC/EYux0EVM16UbOUtXA1LdPd6brwDFdRNR4s5eJQb/VgK+f8//kiEHEIzDypLAHexr8E95aF/7vYBX1oPMyzockfMSS9D8d5+htJkOUa/sDzi1cJ8z1UQ6pJOfQfuw18= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=O4uWdzS5; arc=none smtp.client-ip=209.85.222.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O4uWdzS5" Received: by mail-ua1-f51.google.com with SMTP id a1e0cc1a2514c-85bad9e0214so2316593241.3; Tue, 14 Jan 2025 07:38:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869118; x=1737473918; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z2pWVrzJjBm06ENHhWY4kQXqQzfJ1Rq4okzDBvR+GD8=; b=O4uWdzS5jFERWZVo4GiA1M1zzcNYFvxdMZLlGAXqImU4kg7KfwGlj35iwwWZgxnx+K vJOEVjdsiwTdCTZ4NsRGbmldu3xuOQxkczQ/59GimZmZO2yFhoHPKitJIyqOnc/QSy0P 9WqbwGomWO90D3zq6YZ0joCnKSN3L9HPm7vIdUpwrfKs97qvUOcvR18t7ZGWIkK+kfQf Ht6aW4oFQEsZ08z2Sx6Im6JTnSA1QWLn8xEOUbx/r2vd1IiAUeXxXEZIFAsDnDO0MGrM 6MxVeOqedRvVGo/yI4W4ZDLVO7MfjVliDXIOc1ANqxVy0JldNZT2ZUVNBu/wcXo28AUb Jqow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869118; x=1737473918; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z2pWVrzJjBm06ENHhWY4kQXqQzfJ1Rq4okzDBvR+GD8=; b=VLoJvCeeTPiaT8BJnpso24wYKUF4maItRWJWgBiclO/brCP5fbrhWfb9rRXZypBe0h L7jdxhKqQd3udnQQLuEQsAKn+6BM5IyJUOcKShhRN2jsv0T5kZGnRtiu6WswnexErDJ3 UTGYutO/4TNHEGn9IiIkGTmCey+QEYJCnCRjjLTSlF6oQZABHHA9oJdjg00UME7qO7dC Knh1Qbq5eIi7qxy/TR0wYAf69vtNBNyLQKdwYrtOvaSnT8dQBy0x+h9ie2nGwGTC75Ch HBCGLAo4PxcGA/TggO4q+O9U50ooNfidMTH+KqY0O/40QMzlJD+AFITKoIR7eOi+zXq7 l5lg== X-Forwarded-Encrypted: i=1; AJvYcCUAxqxT11Ej2b93+Dy48QntPIWoZf6YmQ+muBD6WXBhj7ccMO+L57uXjsjy0W63EomrUslvA1AT4ouE@vger.kernel.org, AJvYcCVoakHPAOa8dM/+iDCwWo1eKLEV4IgXnsu28KqCjSWDgAsAKNbKB4rPiLkqJfk08LQvDiDyHXkOktAvBtDT@vger.kernel.org X-Gm-Message-State: AOJu0YxJTgjnuMkTexafw20iaAwGgCm4mrq9X5A3TrLdgczL2aWGIemy 9XspQALn2/vIRPq3aeFDbVTIOe4cZaF89VIx2UKLZZ99RyrlcLBQ6rAHKA== X-Gm-Gg: ASbGncu/KdE+07C4fRx1b2WAdr7YBkaG2hOUVehR0EtUuwnLTpw0ory2pS9iy1izUq1 s7wNVn4XuROJ5dDURdAjT8ifwWXCwmF3J2hKZuBhC5TJkCZI/Glh7qIT0LEw65WT9+vIcmxwJBa 5JlHki+J421pnBwNA/te6K9afjgYgGR7zvsQrDuWHdj3yLLtSrBIg2VJ3OFopDFaA6C6/Frz6wK lcracOY5o2/B934GFWH79IgJ0z+j3KEzSl4jYeDv3i8fqPrHi0i3XhGROiFwgw6 X-Google-Smtp-Source: AGHT+IGy0e4pp7Sd+xRs7NZ9RQYuiul8M4nm6R7Nsi9+12cpn/npe5cHxYFPkNfQ5WjVXbxHDP/J8Q== X-Received: by 2002:a05:6122:3bd6:b0:50d:6a43:d525 with SMTP id 71dfb90a1353d-51c6c22ea8fmr20290461e0c.1.1736869117642; Tue, 14 Jan 2025 07:38:37 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:38:37 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 09/18] platform/x86: asus-wmi: Use devm_platform_profile_register() Date: Tue, 14 Jan 2025 10:37:17 -0500 Message-ID: <20250114153726.11802-10-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace platform_profile_register() with it's device managed version. Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/platform/x86/asus-wmi.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 3d77f7454953..f8437cff66df 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3895,12 +3895,12 @@ static int platform_profile_setup(struct asus_wmi *asus) asus->platform_profile_handler.dev = dev; asus->platform_profile_handler.ops = &asus_wmi_platform_profile_ops; - err = platform_profile_register(&asus->platform_profile_handler, asus); + err = devm_platform_profile_register(&asus->platform_profile_handler, asus); if (err == -EEXIST) { pr_warn("%s, a platform_profile handler is already registered\n", __func__); return 0; } else if (err) { - pr_err("%s, failed at platform_profile_register: %d\n", __func__, err); + pr_err("%s, failed at devm_platform_profile_register: %d\n", __func__, err); return err; } @@ -4859,8 +4859,6 @@ static int asus_wmi_add(struct platform_device *pdev) fail_sysfs: fail_custom_fan_curve: fail_platform_profile_setup: - if (asus->platform_profile_support) - platform_profile_remove(&asus->platform_profile_handler); fail_fan_boost_mode: fail_platform: kfree(asus); @@ -4886,9 +4884,6 @@ static void asus_wmi_remove(struct platform_device *device) throttle_thermal_policy_set_default(asus); asus_wmi_battery_exit(asus); - if (asus->platform_profile_support) - platform_profile_remove(&asus->platform_profile_handler); - kfree(asus); } From patchwork Tue Jan 14 15:37:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938901 Received: from mail-ua1-f42.google.com (mail-ua1-f42.google.com [209.85.222.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDC041FA14A; Tue, 14 Jan 2025 15:38:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869124; cv=none; b=CDdoUr8BdRy3MqV5lPHrylBn+7rQwteUaNl3RUazyJA2J8Y880wEmoGIyI1an9vh+HBTn7caqTdfBav0pMVyPjcWrHvuT49MDLzg6vQO3m32NCqWCkE9BcqAXdOdk9McifBkQBrYjGr6S6I1LBy+CbaKK+sEP9vFTUyAbKj+VG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869124; c=relaxed/simple; bh=BpF7zlyobRyavklFqWh9FmkW1KIjC7GDvUvKS8Bn43Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZzBZpxzCruZFGIwBEowPIo7vRB2QPBeM7npgyOfGOMXLQLZZfwLcIxhmg0v5uvAIarUrTU9S1XopyAhbTr9cYDX1KjCqZD4W+mP+fcdjj9hwmaYRfFTp0i062Oa5v8CBXhGR156FxqD3mF0kdVi2V+urjuQlTZ+6Z4D3or38M6o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=V47QQHrd; arc=none smtp.client-ip=209.85.222.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V47QQHrd" Received: by mail-ua1-f42.google.com with SMTP id a1e0cc1a2514c-85c5adbca8eso1442907241.0; Tue, 14 Jan 2025 07:38:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869121; x=1737473921; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KwAs06+8NgwgClMQfbi9xdkvs7kEq0JRxnfd/0ekTaw=; b=V47QQHrdkPbr8XSWLa9IFu526/fqYkhOcAF5pZvoNBozxEsip4+rfuffzgYRKNvkyO fmffYGcgibmJeMSpRO6foTYlrKTo8czdHt936dyTUn027ejgE230nwpdM2NP83g5DVWL F1j2xNy4ah7qfXHirOAkfIsBsT/pOMPal/bxLdF7P0qQ1L9Py7mQh+t3FxfNynV1c7jW m21dvH2+g6mwZrfhPydbKZd9XboBF4VGxHcNec6UVXg7GQ3Yuj46QgGxZlv6S8kqsGtm qhzkbZxC34fAYKEzcLabEFoyxchz6NDAnmjgdqaYHvt6WfbNvqvW01e7hWyfHxFN2o3Y rTKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869121; x=1737473921; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KwAs06+8NgwgClMQfbi9xdkvs7kEq0JRxnfd/0ekTaw=; b=ILSSgvFJBkhQEFixW6l30vY4dKeCcT/hxdyrDAWB/768y3KNNdX0RAVVco8RSvQWja bYQy9x4uWaIYup+zAmgu3c/SSxUgWa+qvRFV640S8vlqXu0Su25Chbu+0VvkJh97bf/g avqzdZbeGUQCv0SgD2BOe0A/bqmGSACEsY2Acr8LpAIhaAtaff5vmlryeZ7IYYIkP/Kf EmF307oztaUStW5hqcmJnkEmtfZN8+EeDf3Tgi67Io2DjmCzWs3BVZ5piYtdju1qYfvN TR9aNDCDzGeQ9BRzVahaItWcoCgeLy1mbhP4CrZIki/pUKl1h1pkcbd6GY55dw/mzP9h 4c0A== X-Forwarded-Encrypted: i=1; AJvYcCWg9PkyD70hVUMvLrPFozjXfbQPesCNYblYvEi/+R3CE3ANglnyDGQUQmpyftqChqfVzLmDdEx1V8o4YnxQ@vger.kernel.org, AJvYcCXrFXvFEvEDPA6lBKL0EdFmh2d4f1krUKcOla1MNlX6bkoa9txlmeZvO3VGFoHCnNirxV8IzkYsDxBw@vger.kernel.org X-Gm-Message-State: AOJu0Yx8z8U1ll0Xn9ufnH4f0dxaKHK73/qY1kClWx5GIj2UMNY2/xWX z448rPdtisyBrjjyLrls7UKj+2aIF6HEOzyg3zQnTGzcelwAaDuL/dUokA== X-Gm-Gg: ASbGncvo38w+pqw8ESdmlAyIzwGN99PIi4+mLwYSsJtGHzWWV6JUi0EiYZl3DWZEAjE AhAOCQh1pOkG9OkRpOffvV+Uycrk3/+SgLXhg8kysfyPuA2XNBaSm1Sdk5aTmNLVj56j3VKZwLP rt2KQDoF/57d9tmvk4Ihds5yBfEL88Xp82GbxXfH2Y2xrd9OQBUYbZW8sHQDZlX8No57BR2Bw6h Zh57RIzGfbZlPK1mXf/UWL253daQHC1EYaAW3lq+aNPeKjqMg20T3XepitAZPQX X-Google-Smtp-Source: AGHT+IHBcnbPpkFftirE8nVnxE2mjw2KXz4jQXdTQM1rAV2q+e5KDuK4iRqdP76fFxdJdZi73OmAlQ== X-Received: by 2002:a05:6122:1788:b0:50a:b604:2bb2 with SMTP id 71dfb90a1353d-51c6c536deemr20595746e0c.11.1736869121464; Tue, 14 Jan 2025 07:38:41 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:38:40 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 10/18] platform/x86: dell-pc: Use devm_platform_profile_register() Date: Tue, 14 Jan 2025 10:37:18 -0500 Message-ID: <20250114153726.11802-11-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace platform_profile_register() with it's device managed version. Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/dell-pc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 32b3be0723f8..2759bb608b1a 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -281,7 +281,7 @@ static int thermal_init(void) thermal_handler->ops = &dell_pc_platform_profile_ops; /* Clean up if failed */ - ret = platform_profile_register(thermal_handler, NULL); + ret = devm_platform_profile_register(thermal_handler, NULL); if (ret) goto cleanup_thermal_handler; @@ -298,8 +298,6 @@ static int thermal_init(void) static void thermal_cleanup(void) { - if (thermal_handler) - platform_profile_remove(thermal_handler); platform_device_unregister(platform_device); } From patchwork Tue Jan 14 15:37:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938902 Received: from mail-ua1-f52.google.com (mail-ua1-f52.google.com [209.85.222.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 019C31FA827; Tue, 14 Jan 2025 15:38:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869127; cv=none; b=n99Qk3cddTQjUAwzoLAWPcwafmXxXlKnaYbmMJd3cC9/VkR9zt34lof3gKUCiFDBw0qPPMHnPN5W7LejBaN8CTekhjWmI1yDXZ4ead5bNrjt9mMQV/Lh5GIStC7ZIJLpS0D07kr113WmtHhbd0WPFIzTX4TYlNlzw0Fo9hDQ/cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869127; c=relaxed/simple; bh=gl/SOIC2X634UbiGuktHx/7A9X+vzhlckF6BTL92tHw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ANd4lr1c/KCEN3G95dYi0wGrJuGu0gChG5nligbFuO/AEuGzF/bvEcCCiUGsgduHce4iqhel4ALHZuxjiymzSjwSYq+RI1iYmvAY1ApioTy0p72snYIiJGJM4FjVgUu3sCpLJs1TGzAFc6VEJxbweZXYKmRkL8yLMxDnciJUWvI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LK+08hGD; arc=none smtp.client-ip=209.85.222.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LK+08hGD" Received: by mail-ua1-f52.google.com with SMTP id a1e0cc1a2514c-85c559ed230so1284089241.0; Tue, 14 Jan 2025 07:38:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869125; x=1737473925; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WFTbZ7iv7BPB/8NmRhAt6iNwWYwsczqikHPXY9Sa0mE=; b=LK+08hGDtJ4RA0+1SLzbTA2V49wh8L3pwto1qIgzqh6q5Kxrw57Be209eLQQnVgk+0 FkZKQ4ZqW5oc5nezQXdndtq+ya+Q30y/n2iwCKN5Yzd6WCMv4gKnqO5heudFaUx7tBQW dwEFgzhp9evm8a7YJDjPAyNTEOGLJRUqt/BHpthOzxnyM0K1oX3o4z7bTxdcItWLYZLx lVzUKZfAMhwTMcy98Xj4j3ZSsfgTzX8TbCWCkO4C6VVWlf/etuE4V+NdiEVvlYykcErm BrHuA56L9wuu4fhWAvhOO/JMMj+XynNKn9XlvF/0tR2osW5UlTPfmlLFB8xNFYnDL8mJ M9ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869125; x=1737473925; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WFTbZ7iv7BPB/8NmRhAt6iNwWYwsczqikHPXY9Sa0mE=; b=d8Fm2tVAMgU2Kxc+pR9J4PulzdDlaVp+nR1lcUiFKwZPdTZKnG+zBW3RUbITMKS8FG bd4x5gaDuOZ/bkBNhqVfwNOAJcfme8Y4szK14taMBvdkbstdksefFt4C1dnPgydTGIjm 4Osggg9ZyxKoIxqVi0+0tT8CqxhLGnYUldmqxBTVrz0DHFGDHcOvlGOrjftpPLTIsXTv fDvBjnZsh1lF+UwRL6NJGeif1lzHa+XVmxbYsvFPnNKDb/th31LT9nqIn7oiXzbFBzjP yP1xTvDMwRdIHonlduo0GQyqctcAEfHGvo5i4SAI1Ey+reLdGkvS2q/nF1E02ZU25LK5 4OwQ== X-Forwarded-Encrypted: i=1; AJvYcCUgMSOYW+YnBmp2UsUOtsUr4wj06Y9LDW9Ybz04SdH73W2upcmU/u41JByDTkal7v+SDXSF8x/YAQS2iMNT@vger.kernel.org, AJvYcCWCFJT7z14G0BXOrqok7L9Tojzurh9g5/q4PeCxQzWwqI/ugxPYDyVl25GKZnfOirGszMfSQ1hqHYKC@vger.kernel.org X-Gm-Message-State: AOJu0Ywp2j2iweVac0cqKZMhJcnVGcCl9lFKX9DI6HDLuG03n1aP5GHg fYAddQm9U9ChzmbcxU6wjbmbAByuD2ByAO7yovNKe6srhwu5CK+qa1vTzw== X-Gm-Gg: ASbGnct0vFxGifTjyIuVkYMDWeiP9awm9ZLpCoS0Zdo4w2tDq2GPU2c3sdDxoF46c8e dzzETq45AQWu9hZXXTb4dG4gw8kfL04nKFSZCtTO+9DW/088X0VbxhQr85gsz3h9rJN6Pb5E3Qr IMc1CJp4ylfyrZrggjTNgXEnd7z8NND61G5AO5sxvX8mDvftYX14l+iGH85YoIUduXyilUCtYWC UcCRsQJuVG4LBW3ptspSKZ4vQnreLnQkpRyhHY5mvt3sA+8drGBqJLsSgYz76TL X-Google-Smtp-Source: AGHT+IGvT/ZeMxJlA9rw4hi8w9QATsb1SxAYVSEiccQLYP7H0xAtv7k0009ktaRsCn4DtrRdOocP4Q== X-Received: by 2002:a05:6122:458b:b0:518:8bfe:d5f0 with SMTP id 71dfb90a1353d-51c6c2b3d25mr19271001e0c.0.1736869124740; Tue, 14 Jan 2025 07:38:44 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:38:44 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 11/18] platform/x86: ideapad-laptop: Use devm_platform_profile_register() Date: Tue, 14 Jan 2025 10:37:19 -0500 Message-ID: <20250114153726.11802-12-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace platform_profile_register() with it's device managed version. Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/platform/x86/ideapad-laptop.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 050919a28d2b..87c1e087770a 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1123,7 +1123,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) priv->dytc->pprof.ops = &dytc_profile_ops; /* Create platform_profile structure and register */ - err = platform_profile_register(&priv->dytc->pprof, &priv->dytc); + err = devm_platform_profile_register(&priv->dytc->pprof, &priv->dytc); if (err) goto pp_reg_failed; @@ -1145,7 +1145,6 @@ static void ideapad_dytc_profile_exit(struct ideapad_private *priv) if (!priv->dytc) return; - platform_profile_remove(&priv->dytc->pprof); mutex_destroy(&priv->dytc->mutex); kfree(priv->dytc); From patchwork Tue Jan 14 15:37:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938903 Received: from mail-ua1-f49.google.com (mail-ua1-f49.google.com [209.85.222.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EBA81FA8EA; Tue, 14 Jan 2025 15:38:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869131; cv=none; b=DrgMmuypa8m6hfg0uDUnpsyqeSHYr/wH+bp3UlsfhiGymJ63flLQLmOi24M6sjbunUJ19PII6Jq5dIyibrp9RQ6XlqXgRhSEHcIMfrQYyONv699Od7C7k6lXJkxY33GXgvs9NGzefB4yuHSdI9skdRRSUVHlwx/7d/mhL8rSHdM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869131; c=relaxed/simple; bh=OtaXeoTDZtrNzDBhk1xT4EjjrFvsnzfn6Nw03ExD3zg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fa7MGeRRIC98Je81McF9dHZitkoJJqE3aFd7uTtpklSczYKI8ZPUk7teJb7teabXtr3KRvbWm/YL6SNNYdmlMsKjGEDgGSkf7vI+ZqsCR9O4kG1K1nmuzZRqfPLBaDggWb23RVDnCtOmxrwQMjI8JW7Yu0jifTIjR2nJUl+pc8o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gKij4dNF; arc=none smtp.client-ip=209.85.222.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gKij4dNF" Received: by mail-ua1-f49.google.com with SMTP id a1e0cc1a2514c-85c559ed230so1284104241.0; Tue, 14 Jan 2025 07:38:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869128; x=1737473928; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MJniO3t7T19J4QvsezHavUaUIRpK6Ahe+WmaIyTfoGs=; b=gKij4dNFi0+nQ8NqZEXjlrrMocrG4wP2C13XLBa3ROtidn40go7LfaVFbXLtsuHmWh FoKOz+7HaR22WDcJDRskgbt7yrGb/JojEuMdAd5lSDwuhkoOxVRs7W2zaGsu5fy/fPlc DVmOgON0EqEq06S96l9Latoa+JaCaYcQTRrmU51GL9NOugUluh+ogwiK0pdH3/cecpL1 7VLMujCv1N5fV62PnCXogSdQVdDKmb2o2uPOfTKsP3d4q7u6fh/BCSlIOK1FrkKPvYlk TOodt7db+tvUwk5Zt4Rj2J9ApXLIRHQMlLt5j9KpOrD2B0II23TmCmCFz/K87IlQOIki 2SNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869128; x=1737473928; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MJniO3t7T19J4QvsezHavUaUIRpK6Ahe+WmaIyTfoGs=; b=B1Hr+bRVd/jangjW+En4zzFiGvuTSPQ9kiBc7JkQFNp87yllHpn1t/1ZKzxrOBwV2W hT0SLKHE0U/OXNOZDh9zYsDMpEQ9wMsNe8oSGL3nNHVcq7sloG5QKNExK7kAzQBND+Xc QYyfF4oaOF58NEJSlNODn7ZSSph9m+CRx3BlGo5PIClzTKN0PV+MH2k1CgkP3D1g8NfD 1QL5Thf1DWKyHWkiro6mCLG8LvgCqFQ5h6RbucaWKXWdW0mByBrr7A1tQlWunK61Rgj+ b27yiONuCfapyqoGtXqqzLLUdqfCPJRwjhCKYqBBphI9TZaMYnPjoqe0gJsqiU5n9ooO P37g== X-Forwarded-Encrypted: i=1; AJvYcCW2mqJllTX8SfPCf9F2UJGOMXtCvGfD7dSZ2ZeJqymO/XosAqCxmoFqk5aW0a763RDHsOD/Ev6snK2C1qJL@vger.kernel.org, AJvYcCXlqJc7mP7YAdyeHeGnOvkd9fC5azw2vaiyckf4Hxp6NEQGUsCxbxMbCPz51et66JEsd+cTZWNxfsrM@vger.kernel.org X-Gm-Message-State: AOJu0YwCJu5iXL43RjNVJ7tBkxZBLj7VpvbtfuLZqJ7iYOGyjxyUAVJw sJ+kepaPjrIbj5jANLqcSNJ85PKtwiXELDaY6dxxbardbX1XWFzK1aQPXQ== X-Gm-Gg: ASbGncvC50tQdC+e7Fx01CX9I65vVb71UGymNY3l9vTz09OuKcsxW3PFJ+Oa0XoK49U h0YjJRYakvgjzjbTQlt+dLIdch0bWKXmadm8cXCtmLQW3bVicjvloU8I6HEMnpJbqSqtEQ/je7l Jk7BV/ryWvkF34MF5Wy3E8vCoAZN4Bz5Cyht+rFKT9A3pG/GilFNHyFNQsrUNssQUYMcuqlYQSl vAXWhRG8WyUhfMVEXOmynbcHeDwUWbXqBCQjaxL5WxDQwXCuyDS7Us108XLCoy6 X-Google-Smtp-Source: AGHT+IGBpePlxFwHjDm+w/jjW/Mci8UAISuPb4mMsDfb14ZKKq/DFpc9Dpm6WVP3bGjTFVVbws5/Ng== X-Received: by 2002:a05:6122:32cb:b0:518:9dca:f0fb with SMTP id 71dfb90a1353d-51c6c535ebbmr20853048e0c.11.1736869128084; Tue, 14 Jan 2025 07:38:48 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.38.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:38:47 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 12/18] platform/x86: hp-wmi: Use devm_platform_profile_register() Date: Tue, 14 Jan 2025 10:37:20 -0500 Message-ID: <20250114153726.11802-13-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace platform_profile_register() with it's device managed version. Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/platform/x86/hp/hp-wmi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 75bcd8460e7c..1304dfc65aab 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1652,7 +1652,7 @@ static int thermal_profile_setup(struct platform_device *device) platform_profile_handler.name = "hp-wmi"; platform_profile_handler.dev = &device->dev; - err = platform_profile_register(&platform_profile_handler, NULL); + err = devm_platform_profile_register(&platform_profile_handler, NULL); if (err) return err; @@ -1714,9 +1714,6 @@ static void __exit hp_wmi_bios_remove(struct platform_device *device) rfkill_unregister(wwan_rfkill); rfkill_destroy(wwan_rfkill); } - - if (platform_profile_support) - platform_profile_remove(&platform_profile_handler); } static int hp_wmi_resume_handler(struct device *device) From patchwork Tue Jan 14 15:37:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938904 Received: from mail-vs1-f54.google.com (mail-vs1-f54.google.com [209.85.217.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D7BF1FAC58; Tue, 14 Jan 2025 15:38:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869134; cv=none; b=VES1DdRoUSWM16vlAqV1PBsEcV1hhSsRYmgTvg+R0U3H2IuA/P61YWvrNwP2N1lU/P0vj24hua9NFHg+YD16pGGrV/lOWhfWJtoILjfl7PzSgaEF+jWVytisHxewP2//SgBUCveNMYPAviRqkIgNRiL7GYzPD8/OjRbz/2IZNl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869134; c=relaxed/simple; bh=ocEPmb6v6CNCH626Ps0INYHmMydv0QIuVt2uKlkQjXI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UG19hm3x3BkK5YgUt6qJGG8nwvsPY772mls+I7Zz64ANALU4re7fFia95Wp4VCKMfjvbRZNUyQZ8HwdTa9R6+9LHTdrCDtrGPMPKWdPwiCPbwU+uTEf8MwRcHMtnxPQl1ulZT9qmpE6hDW/GxjVvol6VRFU3JaJJpCyypYQWPiQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VlyUUbfa; arc=none smtp.client-ip=209.85.217.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VlyUUbfa" Received: by mail-vs1-f54.google.com with SMTP id ada2fe7eead31-4afe4f1ce18so1803358137.3; Tue, 14 Jan 2025 07:38:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869132; x=1737473932; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JbX6zSYl+GrY6mSqcnAlyzx/v+yDl2thYqQomAWOUe8=; b=VlyUUbfaGZq1BdZueE+NwtVhzlxjTDrXrPGkz50UhCrGfst/W/GW2G16bJ14JqDJko I2MzTyLBO3lcwjoNSEHckeyIco/UNjizkI/OBfcOgAmonjROMvAN/8n9B0Oqs+51xkNQ VzpffkhXrQntPl90vJL/l7tGGRiwP9F3n01CnktQ5ozfvsbYm3iz+2zTWpokgHQHudD4 Bi1cyIo6xz6Qj++2RkcBWsZ9p/e363ESMrdQWYTDRDNKBPY0QIKREKd3jysG3K9TF7eI xLoTX6gvIP/lVTmErvslhqyHn2p1drSA6QuGlY12G0JEPnMH7hCAlYnIULOnu5gZK8vA zNqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869132; x=1737473932; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JbX6zSYl+GrY6mSqcnAlyzx/v+yDl2thYqQomAWOUe8=; b=lEbRK7Tps7i+3EVJeBMgewAB+R6w89Udp3QuYgG3zZ98qanzN5Lc0guV+N9gWmT0bQ 6CSQleCbbbkOC+qhuUWLw4Sbn5a8XUwqVQo+KxJ2K3jRm2qGZJcdPDEqwhpupNHo62NY Q2cADxJhyIKZ1VglBNxX8wH9kw6NuxdwJ19MGQuyCPSzsiiI2Yg3OIS4LlSTf4cLp2aW qd3uVrQVvC1VG3rhKe8BiCNsqS49h8adQm+2iQ2ej/QRgRILUhSVAl79vDsEeQHEBSVf Che4U4hnPDKR9qRhsWyvgkuX1CxUIgCNJVs0+2y1osgmuJDkpu+QkGMPnJ7DIHUEzdZ1 NQcQ== X-Forwarded-Encrypted: i=1; AJvYcCVhmYzS4RVZTYy2dlm3/W7JxhRJIj16ob1iYy7H0KobVa9mANBIVfQtCcXflGgtLkhpqfGlN36PtDD7mUIE@vger.kernel.org, AJvYcCWTOkj4jBIDAKMSYg+U+b+VWC14b+Aa3jA091b8La9qMh8/mtv9rbH/HLYWvnSTBzUp8+77cIn9/SUm@vger.kernel.org X-Gm-Message-State: AOJu0YzTC5vpl5/W4tCDvsiAqzGScombRCHRF9AVvdLBbCjNg2kA7lKJ SPxY04g2k3r1BN9Iu+79b0OUMynVnLe6QH2Bq3E47Dh9GjITm+arkPngwg== X-Gm-Gg: ASbGnctZO7tkXQ1ggrUNavcejquPfg1ut2Osl6IKz47AWtwAhrvVlg5PxPfrtZA2pyc YKh/zJXZ2nsR/nQKdfHgpRZdtUBc4nmEim4Eapmq2SmaePgoVvyYsJaUedbqcW3aDecSGArZxzh YQubnsDsvqU9CAh5je+duvw9ZqYd/8CqzfX9L+s8zbom2WqtsepELBpBb6WL1EJDPbjRpZ55m8I ARl792kIg/t1fDINF/bdbB33eok9V8FyxSu1CYYiipA89M6bkyUMyEVAQuaTEJP X-Google-Smtp-Source: AGHT+IH17vY8aKcAnlycPor9NYsRFSQumf8UVMZxmixyh6XYWHZ72ElG/BLvlthYhAavCP0WnzFiBw== X-Received: by 2002:a05:6122:1206:b0:51c:aa1a:2b5b with SMTP id 71dfb90a1353d-51caa1a2d10mr6543827e0c.4.1736869131902; Tue, 14 Jan 2025 07:38:51 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.38.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:38:51 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 13/18] platform/x86: inspur_platform_profile: Use devm_platform_profile_register() Date: Tue, 14 Jan 2025 10:37:21 -0500 Message-ID: <20250114153726.11802-14-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace platform_profile_register() with it's device managed version. While at it, pass inspur_wmi_priv to the class device as drvdata and replace uses of container_of() with dev_get_drvdata(). Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/platform/x86/inspur_platform_profile.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 06df3aae9a56..e1631de6ad86 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -194,15 +194,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) priv->handler.dev = &wdev->dev; priv->handler.ops = &inspur_platform_profile_ops; - return platform_profile_register(&priv->handler, priv); -} - -static void inspur_wmi_remove(struct wmi_device *wdev) -{ - struct inspur_wmi_priv *priv; - - priv = dev_get_drvdata(&wdev->dev); - platform_profile_remove(&priv->handler); + return devm_platform_profile_register(&priv->handler, priv); } static const struct wmi_device_id inspur_wmi_id_table[] = { @@ -219,7 +211,6 @@ static struct wmi_driver inspur_wmi_driver = { }, .id_table = inspur_wmi_id_table, .probe = inspur_wmi_probe, - .remove = inspur_wmi_remove, .no_singleton = true, }; From patchwork Tue Jan 14 15:37:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938905 Received: from mail-ua1-f43.google.com (mail-ua1-f43.google.com [209.85.222.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A6931FBE80; Tue, 14 Jan 2025 15:38:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869138; cv=none; b=MsW5VNhS6y02MqVDoL1qMybCyCVmcQ05oYiHP1xcoJsz4C+ZSTUx1ZFtLZ094y0oDHacowThS3XEFn8hTsDM6JdN2NTW7ggS9vdjEwd73SsEVd5VSSVtS7dzmsOHCyz+MvRhNZkyTnA4dcjmOZKP159O7aCXFNqxEZEhUaBKwH4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869138; c=relaxed/simple; bh=go7YGDo+/CPimM/t0Xx6B6Z816gFoIMzYFR5DY+X7JY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HJN0kft1hCkkZds/UMUR/QrHqzL0uXmogruHu1brOsafOpUfk3jRJYQK9Nh0lF4u/iZoCMTGEi0K+aN1GlQ13ro0buzI/4U8fAJ3H7zqvnQEg0ExUwbTi6tcZqkmKYeZZ64C2Q/PMwiFBTpDjd06h7n24Lm5fzVW1McKIsoyYIE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dWUECB8C; arc=none smtp.client-ip=209.85.222.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dWUECB8C" Received: by mail-ua1-f43.google.com with SMTP id a1e0cc1a2514c-85c4b4cf73aso1145374241.2; Tue, 14 Jan 2025 07:38:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869135; x=1737473935; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LiCnWXVueHQuao3N4A+VSfpdGCx4nAczUeSeIXuHHQQ=; b=dWUECB8CPX0MbYng/zy6bMoa1kluFPSHs8fOEkHkYrU3U6BQj8C3NPozk1MxBsQeUu zH9M4NpOcN6S3B6qXxs/wjPURFEIzzrdau5aE4kBWS2ZCFh9pSjY8U/vXmYrtiAh+2S+ JMJ4jq9SXCdOM0TdQFYXIA+ZPG59qJeguC89Mw+faZublrkIQxu6g5LYefFAwYmA4sSw pTidoYTtLc2uMUOI1n15Y6bO3gmU2eAc4bRv7Cs2O2M7Eqjc2uVUNpJ3WsMDUSd9mvqS s6ZVMcNVBdKvfZwyiaDCn4FX5OHmwYNuf6mK8M2Syylck6zyK7NlwyhJjwCukpBHo3tq QLRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869135; x=1737473935; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LiCnWXVueHQuao3N4A+VSfpdGCx4nAczUeSeIXuHHQQ=; b=lyRAOBYAY2GKgaGbriMi8JOampuuoeaY9PAa9ST0wGggpHBx6kLGvEHfYSluBxV8KK /TRS5+Xghx/E4DvIE4hxUz9p56gbI3yzpV0hSwW4dsh2SJsAeVB01Sd3BDfMZ8/2wVDW WRNVGly5tS3onVhG1ihAXpkiS7ukpIMLd+PGQOjgg9HBobiCnNMKmZxRjLCkUHvJQq88 pfOS7sZ0FHjqufSJOGt0WPhvOcyHezpJ2zcjzFisQvOg4Pq2u2wRy832bcE34+eLT+zH UbF927DAxU7d7YVHO5Cl7l1vbuEp3PhW5Xxu6okRHA06OurImhVai5AEgsBmeYWortKK b5iQ== X-Forwarded-Encrypted: i=1; AJvYcCU9BOaas4A5qeCedapfFtXMTLPTa02J9IBkvLxVOxhxkFgtBqXrETg0Wpa4XztExQFWJX6Pq3BpfqoDCGqQ@vger.kernel.org, AJvYcCW2FRuFAQFsLDQnRdyW68CSC92JZoshqpkb4zdG4Jng+eZr4URE07R41i3MT7aRcpT6jPIyITT+sPYe@vger.kernel.org X-Gm-Message-State: AOJu0Yz+tNReM3if90y2338abFgA7ofn68IpOuR8jvuB3wG/FeezDvxI pvz/JeysITPqskqwMksprLtmS89AODa/03YGlO9puQzbxHp3IF/gI0RJjw== X-Gm-Gg: ASbGnctKDN0TwzvapBpQO4R1m1cIQMO3boFJsm6SZUAhX1te5DpKkTxkB1kh01hm/dS FF6MlRW/8qpFUg2e0y7FgB2u2NDMgyxE/AyKaZMLNZwuAp04mictIau5ZMPX/ZHfUwASlez9q50 jfQjZ8809/LAbpmaGrcFkl1B9wXR38ZsMR2ap6LbmizHmQ3shLsmhuii+oGQwoYaSs/fzWoFjLq fHwANML+H0TDEZAsWqYto2vmpQxl6X6g4j3BDLAKTtQuX5af+EURx5apv8njYkW X-Google-Smtp-Source: AGHT+IFk7j4l7HPj8VxDCjftfQkzhJq9B3+Zw2zMzEnf/NJM23IVRxVCmlPlM4a1/jAdbvZMGX9XDg== X-Received: by 2002:a05:6122:1acf:b0:518:80fb:df24 with SMTP id 71dfb90a1353d-51c6c43aadcmr22112591e0c.3.1736869135265; Tue, 14 Jan 2025 07:38:55 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.38.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:38:54 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 14/18] platform/x86: thinkpad_acpi: Use devm_platform_profile_register() Date: Tue, 14 Jan 2025 10:37:22 -0500 Message-ID: <20250114153726.11802-15-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace platform_profile_register() with it's device managed version. Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/platform/x86/thinkpad_acpi.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 5c250867678f..54ff3e6b8b1a 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10649,7 +10649,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) dytc_profile.dev = &tpacpi_pdev->dev; /* Create platform_profile structure and register */ - err = platform_profile_register(&dytc_profile, NULL); + err = devm_platform_profile_register(&dytc_profile, NULL); /* * If for some reason platform_profiles aren't enabled * don't quit terminally. @@ -10667,14 +10667,8 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) return 0; } -static void dytc_profile_exit(void) -{ - platform_profile_remove(&dytc_profile); -} - static struct ibm_struct dytc_profile_driver_data = { .name = "dytc-profile", - .exit = dytc_profile_exit, }; /************************************************************************* From patchwork Tue Jan 14 15:37:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938906 Received: from mail-vs1-f43.google.com (mail-vs1-f43.google.com [209.85.217.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 181D21C5F05; Tue, 14 Jan 2025 15:39:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869143; cv=none; b=Dv95NoCZfGXPCAx5SGpaovAi6TBbQc3UUr6+gWJ7MulxBzGwpvkorUQgSWtpYBaiU4889tRtR4ggZj2AI+pwnIAXLtabwRcY8ca5kx+IOFRxPxrgvgoHJxPviP2/ihAfl0JqF4ndJPNTkPtprSZfuzrko5EWKVCHc4m0Gb8jyFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869143; c=relaxed/simple; bh=pTA1KT1omz6Jtu7hSa+/9bR4cO+DIqnOMm+HbwjeObk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LF3f68NwieoRzzg8C/qaghcBb65sIM8keL6a5tUcL8CJHU6zA2er1up4BV10ON7ZspfeDWLYryHWuiFbWCauh2jWMGAhqW7OyRMtYC7KAldzf6JeT1Xh1cKqsnbJBxctkCyhG34M0F6ZlfCJ2lWva3kPf+zuJZYze/7C9thMc2Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=avI04Bkw; arc=none smtp.client-ip=209.85.217.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="avI04Bkw" Received: by mail-vs1-f43.google.com with SMTP id ada2fe7eead31-4aff04f17c7so4084066137.0; Tue, 14 Jan 2025 07:39:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869139; x=1737473939; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7lzJTFhmN1BxMUX/j4LJQiLOaklLgy/NsQ51qNX2xpA=; b=avI04BkwRLwJ9rDJjN0wBIsiVUYizLXpxPhl1sV4bjROxrICD0iFpjuhwJO2DEn0A4 syb0z8Q6v41uE89a0W+WACkhymbQ8s4rdr4e8s+fXHo8beUn7IvrCLEAXfKHASt/WKoD 2jnZYj+nMNxMTDPS/fMIHDHidV0ssicFxOOUZ1hK/zsmSj49JaFHMbURGhjtFITfN2lp SplK4IBvB4xveLl7y5VFFApBrUNoYnTnPgcFGly290k+oSJH3eiYI0z+2kq255cvjW5N 06RVEs8hnMaMfJZrIOquipZYVJACZW8gxLuZN0YV/MDXRX5+h+mi0hoPAYkEOHC5W9lk TaPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869139; x=1737473939; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7lzJTFhmN1BxMUX/j4LJQiLOaklLgy/NsQ51qNX2xpA=; b=GHaxM+oxWjiV1TSqi7bkbrJTWRmXP8FH2NTGnWARQIHCZzwpJV3+zfIRQkx6R189Md Bak7ymRO5N1i44Vxp9XYhClW0J+cAAR/g+vHBns7P8SuoYRpu1KwbJRTz6phR2H1jUiC 4E3LjNr36JsWO4YYAoC1SQaoFMCAPf7oiIdHm0mHrLs0Q//7pVEpccZjHKl/FFVv0M3Z LogYKPDB+uiz6vtkqvKXSnZF+NuX/fiMHYQ3qizGCkLx2fWjakBniFYN+BRnUrJlP+OX 92DsLVsAsbm3m4uN9cfHF9BxxpNB/dPHHmNSdzUJl7/wIBwbX9J5TxmPmaJ5sqr+NIPz d5XA== X-Forwarded-Encrypted: i=1; AJvYcCW6jliPt+zCYWpwz+HpwcpOXjTG3C4i6zj7OKApe8YydylSdGJXP4+IEEEbwz8UvFTa4TMw3adYCr5ddu6n@vger.kernel.org, AJvYcCXN9wbuNa9qg91tyrA9t1ZLLvdV0CNzrrlb9VvINLShDdnY9LB4IEwV3l5jGhausvKwFyrRfnmPwNSd@vger.kernel.org X-Gm-Message-State: AOJu0YyM8NLiUJJ9hIlgAh1BszLjkNfhu0byD5YerDSUoj+5RR2kMtTI +YhT7/eL1bqEaNtwCM7amKOf0mOceXesvkQ3YZvRDar/S5F8rualPani6g== X-Gm-Gg: ASbGncsN7m0V2pYQv1U7wMaSMvXmike/i48riSUYn8MD1UXTWhnKtj+7DA651X+Y4FW OuZNfDNyWv0t577w7GWqD53Dqq+Xr2+EyZoX7O7Nf/H3kzMooIlJVFfTKjFSygDLxB0pxs4rKol HzEQqxnqY/qcsMlT52sjx3qiQzrme2jzXyE1/k9LXA4OID8xmVgSBnf1Uvz70s1fEMkeNFylQYh oSWMM6i/GQzm8B98ymGuCTNAstEv7f+1QMdj0+lcNeaohvmIqj2ZY7wPE9GDazl X-Google-Smtp-Source: AGHT+IHvmNRGPQQrYOgZO8LbA6ZBaBgFeTbW+nYp5dJ5rzV/j/cPEkwnmA5ckW7no7p0um9q7aHQBw== X-Received: by 2002:a05:6122:a14:b0:518:7d3a:dd13 with SMTP id 71dfb90a1353d-51c7c7d009dmr17172335e0c.7.1736869139225; Tue, 14 Jan 2025 07:38:59 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.38.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:38:58 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 15/18] ACPI: platform_profile: Remove platform_profile_handler from exported symbols Date: Tue, 14 Jan 2025 10:37:23 -0500 Message-ID: <20250114153726.11802-16-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In order to protect the platform_profile_handler from API consumers, allocate it in platform_profile_register() and modify it's signature accordingly. Remove the platform_profile_handler from all consumer drivers and replace them with a pointer to the class device, which is now returned from platform_profile_register(). Replace *pprof with a pointer to the class device in the rest of exported symbols. Signed-off-by: Kurt Borja Reviewed-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 87 ++++++++++++------- .../surface/surface_platform_profile.c | 11 ++- drivers/platform/x86/acer-wmi.c | 18 ++-- drivers/platform/x86/amd/pmf/pmf.h | 2 +- drivers/platform/x86/amd/pmf/sps.c | 17 ++-- drivers/platform/x86/asus-wmi.c | 20 ++--- drivers/platform/x86/dell/alienware-wmi.c | 9 +- drivers/platform/x86/dell/dell-pc.c | 22 ++--- drivers/platform/x86/hp/hp-wmi.c | 19 ++-- drivers/platform/x86/ideapad-laptop.c | 14 +-- .../platform/x86/inspur_platform_profile.c | 9 +- drivers/platform/x86/thinkpad_acpi.c | 14 ++- include/linux/platform_profile.h | 12 ++- 13 files changed, 125 insertions(+), 129 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 34e22b006ccc..2fae5e2fc962 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -213,9 +214,17 @@ static struct attribute *profile_attrs[] = { }; ATTRIBUTE_GROUPS(profile); +static void pprof_device_release(struct device *dev) +{ + struct platform_profile_handler *pprof = to_pprof_handler(dev); + + kfree(pprof); +} + static const struct class platform_profile_class = { .name = "platform-profile", .dev_groups = profile_groups, + .dev_release = pprof_device_release, }; /** @@ -409,10 +418,10 @@ static const struct attribute_group platform_profile_group = { .is_visible = profile_class_is_visible, }; -void platform_profile_notify(struct platform_profile_handler *pprof) +void platform_profile_notify(struct device *dev) { scoped_cond_guard(mutex_intr, return, &profile_lock) { - _notify_class_profile(&pprof->class_dev, NULL); + _notify_class_profile(dev, NULL); } sysfs_notify(acpi_kobj, NULL, "platform_profile"); } @@ -461,40 +470,51 @@ int platform_profile_cycle(void) } EXPORT_SYMBOL_GPL(platform_profile_cycle); -int platform_profile_register(struct platform_profile_handler *pprof, void *drvdata) +struct device *platform_profile_register(struct device *dev, const char *name, + void *drvdata, + const struct platform_profile_ops *ops) { + int minor; int err; - /* Sanity check the profile handler */ - if (!pprof || !pprof->ops->profile_set || !pprof->ops->profile_get || - !pprof->ops->probe) { + /* Sanity check */ + if (!dev || !name || !ops || !ops->profile_get || + !ops->profile_set || !ops->probe) { pr_err("platform_profile: handler is invalid\n"); - return -EINVAL; + return ERR_PTR(-EINVAL); } - err = pprof->ops->probe(drvdata, pprof->choices); + struct platform_profile_handler *pprof __free(kfree) = kzalloc( + sizeof(*pprof), GFP_KERNEL); + if (!pprof) + return ERR_PTR(-ENOMEM); + + err = ops->probe(drvdata, pprof->choices); if (err < 0) - return err; + return ERR_PTR(err); if (bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST)) { pr_err("platform_profile: no available profiles\n"); - return -EINVAL; + return ERR_PTR(-EINVAL); } guard(mutex)(&profile_lock); /* create class interface for individual handler */ - pprof->minor = ida_alloc(&platform_profile_ida, GFP_KERNEL); - if (pprof->minor < 0) - return pprof->minor; + minor = ida_alloc(&platform_profile_ida, GFP_KERNEL); + if (minor < 0) + return ERR_PTR(minor); + pprof->name = name; + pprof->ops = ops; + pprof->minor = minor; pprof->class_dev.class = &platform_profile_class; - pprof->class_dev.parent = pprof->dev; + pprof->class_dev.parent = dev; dev_set_drvdata(&pprof->class_dev, drvdata); dev_set_name(&pprof->class_dev, "platform-profile-%d", pprof->minor); err = device_register(&pprof->class_dev); if (err) { - put_device(&pprof->class_dev); + put_device(&no_free_ptr(pprof)->class_dev); goto cleanup_ida; } @@ -504,20 +524,21 @@ int platform_profile_register(struct platform_profile_handler *pprof, void *drvd if (err) goto cleanup_cur; - return 0; + return &no_free_ptr(pprof)->class_dev; cleanup_cur: - device_unregister(&pprof->class_dev); + device_unregister(&no_free_ptr(pprof)->class_dev); cleanup_ida: - ida_free(&platform_profile_ida, pprof->minor); + ida_free(&platform_profile_ida, minor); - return err; + return ERR_PTR(err); } EXPORT_SYMBOL_GPL(platform_profile_register); -int platform_profile_remove(struct platform_profile_handler *pprof) +int platform_profile_remove(struct device *dev) { + struct platform_profile_handler *pprof = to_pprof_handler(dev); int id; guard(mutex)(&profile_lock); @@ -535,30 +556,32 @@ EXPORT_SYMBOL_GPL(platform_profile_remove); static void devm_platform_profile_release(struct device *dev, void *res) { - struct platform_profile_handler **pprof = res; + struct device **ppdev = res; - platform_profile_remove(*pprof); + platform_profile_remove(*ppdev); } -int devm_platform_profile_register(struct platform_profile_handler *pprof, void *drvdata) +struct device *devm_platform_profile_register(struct device *dev, const char *name, + void *drvdata, + const struct platform_profile_ops *ops) { - struct platform_profile_handler **dr; - int ret; + struct device *ppdev; + struct device **dr; dr = devres_alloc(devm_platform_profile_release, sizeof(*dr), GFP_KERNEL); if (!dr) - return -ENOMEM; + return ERR_PTR(-ENOMEM); - ret = platform_profile_register(pprof, drvdata); - if (ret) { + ppdev = platform_profile_register(dev, name, drvdata, ops); + if (IS_ERR(dev)) { devres_free(dr); - return ret; + return ppdev; } - *dr = pprof; - devres_add(pprof->dev, dr); + *dr = ppdev; + devres_add(dev, dr); - return 0; + return ppdev; } EXPORT_SYMBOL_GPL(devm_platform_profile_register); diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index bbdc873cb788..275269a6efc1 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -40,7 +40,7 @@ struct ssam_tmp_profile_info { struct ssam_platform_profile_device { struct ssam_device *sdev; - struct platform_profile_handler handler; + struct device *ppdev; bool has_fan; }; @@ -228,13 +228,12 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->sdev = sdev; ssam_device_set_drvdata(sdev, tpd); - tpd->handler.name = "Surface Platform Profile"; - tpd->handler.dev = &sdev->dev; - tpd->handler.ops = &ssam_platform_profile_ops; - tpd->has_fan = device_property_read_bool(&sdev->dev, "has_fan"); - return devm_platform_profile_register(&tpd->handler, tpd); + tpd->ppdev = devm_platform_profile_register( + &sdev->dev, "Surface Platform Profile", tpd, &ssam_platform_profile_ops); + + return PTR_ERR_OR_ZERO(tpd->ppdev); } static const struct ssam_device_id ssam_platform_profile_match[] = { diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 39ec236b7cdb..3e39465b3783 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -758,7 +758,7 @@ static const struct dmi_system_id non_acer_quirks[] __initconst = { {} }; -static struct platform_profile_handler platform_profile_handler; +static struct device *platform_profile_device; static bool platform_profile_support; /* @@ -1937,16 +1937,10 @@ static const struct platform_profile_ops acer_predator_v4_platform_profile_ops = static int acer_platform_profile_setup(struct platform_device *device) { if (quirks->predator_v4) { - int err; - - platform_profile_handler.name = "acer-wmi"; - platform_profile_handler.dev = &device->dev; - platform_profile_handler.ops = - &acer_predator_v4_platform_profile_ops; - - err = devm_platform_profile_register(&platform_profile_handler, NULL); - if (err) - return err; + platform_profile_device = devm_platform_profile_register( + &device->dev, "acer-wmi", NULL, &acer_predator_v4_platform_profile_ops); + if (IS_ERR(platform_profile_device)) + return PTR_ERR(platform_profile_device); platform_profile_support = true; @@ -2033,7 +2027,7 @@ static int acer_thermal_profile_change(void) if (tp != ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO_WMI) last_non_turbo_profile = tp; - platform_profile_notify(&platform_profile_handler); + platform_profile_notify(platform_profile_device); } return 0; diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index d99b3556205b..41b2b91b8fdc 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -338,7 +338,7 @@ struct amd_pmf_dev { struct mutex lock; /* protects the PMF interface */ u32 supported_func; enum platform_profile_option current_profile; - struct platform_profile_handler pprof; + struct device *ppdev; /* platform profile class device */ struct dentry *dbgfs_dir; int hb_interval; /* SBIOS heartbeat interval */ struct delayed_work heart_beat; diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 7c7ed2b9de01..a96fc6887cf0 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -404,8 +404,6 @@ static const struct platform_profile_ops amd_pmf_profile_ops = { int amd_pmf_init_sps(struct amd_pmf_dev *dev) { - int err; - dev->current_profile = PLATFORM_PROFILE_BALANCED; if (is_apmf_func_supported(dev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) { @@ -420,15 +418,12 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) amd_pmf_set_sps_power_limits(dev); } - dev->pprof.name = "amd-pmf"; - dev->pprof.dev = dev->dev; - dev->pprof.ops = &amd_pmf_profile_ops; - /* Create platform_profile structure and register */ - err = devm_platform_profile_register(&dev->pprof, dev); - if (err) - dev_err(dev->dev, "Failed to register SPS support, this is most likely an SBIOS bug: %d\n", - err); + dev->ppdev = devm_platform_profile_register( + dev->dev, "amd-pmf", dev, &amd_pmf_profile_ops); + if (IS_ERR(dev->ppdev)) + dev_err(dev->dev, "Failed to register SPS support, this is most likely an SBIOS bug: %ld\n", + PTR_ERR(dev->ppdev)); - return err; + return PTR_ERR_OR_ZERO(dev->ppdev); } diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index f8437cff66df..4ad99cf9df1a 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -313,7 +313,7 @@ struct asus_wmi { bool mid_fan_curve_available; struct fan_curve_data custom_fan_curves[3]; - struct platform_profile_handler platform_profile_handler; + struct device *platform_profile_device; bool platform_profile_support; // The RSOC controls the maximum charging percentage. @@ -3789,7 +3789,7 @@ static ssize_t throttle_thermal_policy_store(struct device *dev, * Ensure that platform_profile updates userspace with the change to ensure * that platform_profile and throttle_thermal_policy_mode are in sync. */ - platform_profile_notify(&asus->platform_profile_handler); + platform_profile_notify(asus->platform_profile_device); return count; } @@ -3891,17 +3891,13 @@ static int platform_profile_setup(struct asus_wmi *asus) dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n"); - asus->platform_profile_handler.name = "asus-wmi"; - asus->platform_profile_handler.dev = dev; - asus->platform_profile_handler.ops = &asus_wmi_platform_profile_ops; + asus->platform_profile_device = devm_platform_profile_register( + dev, "asus-wmi", asus, &asus_wmi_platform_profile_ops); + if (IS_ERR(asus->platform_profile_device)) { + pr_err("%s, failed at devm_platform_profile_register: %ld\n", + __func__, PTR_ERR(asus->platform_profile_device)); - err = devm_platform_profile_register(&asus->platform_profile_handler, asus); - if (err == -EEXIST) { - pr_warn("%s, a platform_profile handler is already registered\n", __func__); - return 0; - } else if (err) { - pr_err("%s, failed at devm_platform_profile_register: %d\n", __func__, err); - return err; + return PTR_ERR(asus->platform_profile_device); } asus->platform_profile_support = true; diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 0146d2f93be6..99db93846a63 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1135,11 +1135,12 @@ static const struct platform_profile_ops awcc_platform_profile_ops = { static int create_thermal_profile(struct platform_device *platform_device) { - pp_handler.name = "alienware-wmi"; - pp_handler.dev = &platform_device->dev; - pp_handler.ops = &awcc_platform_profile_ops; + struct device *ppdev; - return devm_platform_profile_register(&pp_handler, NULL); + ppdev = devm_platform_profile_register( + &platform_device->dev, "alienware-wmi", NULL, &awcc_platform_profile_ops); + + return PTR_ERR_OR_ZERO(ppdev); } /* diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 2759bb608b1a..8d60e1b223de 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -109,8 +109,6 @@ MODULE_DEVICE_TABLE(dmi, dell_device_table); #define DELL_ACC_SET_FIELD GENMASK(11, 8) #define DELL_THERMAL_SUPPORTED GENMASK(3, 0) -static struct platform_profile_handler *thermal_handler; - enum thermal_mode_bits { DELL_BALANCED = BIT(0), DELL_COOL_BOTTOM = BIT(1), @@ -254,6 +252,7 @@ static const struct platform_profile_ops dell_pc_platform_profile_ops = { static int thermal_init(void) { + struct device *ppdev; int ret; /* If thermal commands are not supported, exit without error */ @@ -271,26 +270,17 @@ static int thermal_init(void) if (IS_ERR(platform_device)) return PTR_ERR(platform_device); - thermal_handler = devm_kzalloc(&platform_device->dev, sizeof(*thermal_handler), GFP_KERNEL); - if (!thermal_handler) { - ret = -ENOMEM; - goto cleanup_platform_device; - } - thermal_handler->name = "dell-pc"; - thermal_handler->dev = &platform_device->dev; - thermal_handler->ops = &dell_pc_platform_profile_ops; - /* Clean up if failed */ - ret = devm_platform_profile_register(thermal_handler, NULL); - if (ret) + ppdev = devm_platform_profile_register( + &platform_device->dev, "dell-pc", NULL, &dell_pc_platform_profile_ops); + if (IS_ERR(ppdev)) { + ret = PTR_ERR(ppdev); goto cleanup_thermal_handler; + } return 0; cleanup_thermal_handler: - thermal_handler = NULL; - -cleanup_platform_device: platform_device_unregister(platform_device); return ret; diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 1304dfc65aab..d1f9bd287986 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -273,7 +273,7 @@ static DEFINE_MUTEX(active_platform_profile_lock); static struct input_dev *hp_wmi_input_dev; static struct input_dev *camera_shutter_input_dev; static struct platform_device *hp_wmi_platform_dev; -static struct platform_profile_handler platform_profile_handler; +static struct device *platform_profile_device; static struct notifier_block platform_power_source_nb; static enum platform_profile_option active_platform_profile; static bool platform_profile_support; @@ -1602,6 +1602,7 @@ static const struct platform_profile_ops hp_wmi_platform_profile_ops = { static int thermal_profile_setup(struct platform_device *device) { + const struct platform_profile_ops *ops; int err, tp; if (is_omen_thermal_profile()) { @@ -1617,7 +1618,7 @@ static int thermal_profile_setup(struct platform_device *device) if (err < 0) return err; - platform_profile_handler.ops = &platform_profile_omen_ops; + ops = &platform_profile_omen_ops; } else if (is_victus_thermal_profile()) { err = platform_profile_victus_get_ec(&active_platform_profile); if (err < 0) @@ -1631,7 +1632,7 @@ static int thermal_profile_setup(struct platform_device *device) if (err < 0) return err; - platform_profile_handler.ops = &platform_profile_victus_ops; + ops = &platform_profile_victus_ops; } else { tp = thermal_profile_get(); @@ -1646,15 +1647,13 @@ static int thermal_profile_setup(struct platform_device *device) if (err) return err; - platform_profile_handler.ops = &hp_wmi_platform_profile_ops; + ops = &hp_wmi_platform_profile_ops; } - platform_profile_handler.name = "hp-wmi"; - platform_profile_handler.dev = &device->dev; - - err = devm_platform_profile_register(&platform_profile_handler, NULL); - if (err) - return err; + platform_profile_device = devm_platform_profile_register( + &device->dev, "hp-wmi", NULL, ops); + if (IS_ERR(platform_profile_device)) + return PTR_ERR(platform_profile_device); platform_profile_support = true; diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 87c1e087770a..6065a7421a02 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -142,7 +142,7 @@ enum { struct ideapad_dytc_priv { enum platform_profile_option current_profile; - struct platform_profile_handler pprof; + struct device *ppdev; /* platform profile device */ struct mutex mutex; /* protects the DYTC interface */ struct ideapad_private *priv; }; @@ -1050,7 +1050,7 @@ static void dytc_profile_refresh(struct ideapad_private *priv) if (profile != priv->dytc->current_profile) { priv->dytc->current_profile = profile; - platform_profile_notify(&priv->dytc->pprof); + platform_profile_notify(priv->dytc->ppdev); } } @@ -1117,15 +1117,15 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) mutex_init(&priv->dytc->mutex); - priv->dytc->pprof.name = "ideapad-laptop"; - priv->dytc->pprof.dev = &priv->platform_device->dev; priv->dytc->priv = priv; - priv->dytc->pprof.ops = &dytc_profile_ops; /* Create platform_profile structure and register */ - err = devm_platform_profile_register(&priv->dytc->pprof, &priv->dytc); - if (err) + priv->dytc->ppdev = devm_platform_profile_register( + &priv->platform_device->dev, "ideapad-laptop", &priv->dytc, &dytc_profile_ops); + if (IS_ERR(priv->dytc->ppdev)) { + err = PTR_ERR(priv->dytc->ppdev); goto pp_reg_failed; + } /* Ensure initial values are correct */ dytc_profile_refresh(priv); diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index e1631de6ad86..8b71c4242939 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -32,7 +32,7 @@ enum inspur_tmp_profile { struct inspur_wmi_priv { struct wmi_device *wdev; - struct platform_profile_handler handler; + struct device *ppdev; }; static int inspur_wmi_perform_query(struct wmi_device *wdev, @@ -190,11 +190,10 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) priv->wdev = wdev; dev_set_drvdata(&wdev->dev, priv); - priv->handler.name = "inspur-wmi"; - priv->handler.dev = &wdev->dev; - priv->handler.ops = &inspur_platform_profile_ops; + priv->ppdev = devm_platform_profile_register( + &wdev->dev, "inspur-wmi", priv, &inspur_platform_profile_ops); - return devm_platform_profile_register(&priv->handler, priv); + return PTR_ERR_OR_ZERO(priv->ppdev); } static const struct wmi_device_id inspur_wmi_id_table[] = { diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 54ff3e6b8b1a..2a3dd0d149a1 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -962,6 +962,7 @@ static const struct proc_ops dispatch_proc_ops = { static struct platform_device *tpacpi_pdev; static struct platform_device *tpacpi_sensors_pdev; static struct device *tpacpi_hwmon; +static struct device *tpacpi_pprof; static struct input_dev *tpacpi_inputdev; static struct mutex tpacpi_inputdev_send_mutex; static LIST_HEAD(tpacpi_all_drivers); @@ -10553,11 +10554,6 @@ static const struct platform_profile_ops dytc_profile_ops = { .profile_set = dytc_profile_set, }; -static struct platform_profile_handler dytc_profile = { - .name = "thinkpad-acpi", - .ops = &dytc_profile_ops, -}; - static void dytc_profile_refresh(void) { enum platform_profile_option profile; @@ -10586,7 +10582,7 @@ static void dytc_profile_refresh(void) err = convert_dytc_to_profile(funcmode, perfmode, &profile); if (!err && profile != dytc_current_profile) { dytc_current_profile = profile; - platform_profile_notify(&dytc_profile); + platform_profile_notify(tpacpi_pprof); } } @@ -10647,14 +10643,14 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) dbg_printk(TPACPI_DBG_INIT, "DYTC version %d: thermal mode available\n", dytc_version); - dytc_profile.dev = &tpacpi_pdev->dev; /* Create platform_profile structure and register */ - err = devm_platform_profile_register(&dytc_profile, NULL); + tpacpi_pprof = devm_platform_profile_register( + &tpacpi_pdev->dev, "thinkpad-acpi", NULL, &dytc_profile_ops); /* * If for some reason platform_profiles aren't enabled * don't quit terminally. */ - if (err) + if (IS_ERR(tpacpi_pprof)) return -ENODEV; /* Ensure initial values are correct */ diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 5ad1ab7b75e4..778d4c661c3c 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -45,10 +45,14 @@ struct platform_profile_handler { const struct platform_profile_ops *ops; }; -int platform_profile_register(struct platform_profile_handler *pprof, void *drvdata); -int platform_profile_remove(struct platform_profile_handler *pprof); -int devm_platform_profile_register(struct platform_profile_handler *pprof, void *drvdata); +struct device *platform_profile_register(struct device *dev, const char *name, + void *drvdata, + const struct platform_profile_ops *ops); +int platform_profile_remove(struct device *dev); +struct device *devm_platform_profile_register(struct device *dev, const char *name, + void *drvdata, + const struct platform_profile_ops *ops); int platform_profile_cycle(void); -void platform_profile_notify(struct platform_profile_handler *pprof); +void platform_profile_notify(struct device *dev); #endif /*_PLATFORM_PROFILE_H_*/ From patchwork Tue Jan 14 15:37:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938907 Received: from mail-vk1-f180.google.com (mail-vk1-f180.google.com [209.85.221.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C8A11FC7DC; Tue, 14 Jan 2025 15:39:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869146; cv=none; b=BFWdAfUdJ6xai4pVnkEB96u0yCnE8vIHVUclgQJfBP8dZbkV/SG1ozWyKXMPnT+lxnVBcjGvEHUfFsCjYvget6uqYH0rdzNkT3kmjH0l9P3LXXIdynuXgbe/cCv6Ijr9+bgkfckFdgemRgUC+/IZJScmbBHU24pkmqDhBH7xneA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869146; c=relaxed/simple; bh=ROyNfhHztIhHzZbMmoDMWDw1eW+LxDgmvN+AM24ykqs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aY7rXY0AQff2LWpENu1Mnft0YH95f7DGRsNo80PreWO+Y44zbqxmXK0pyiSvtTgskmDq6pgWxgiiWBzlZ1LBB7e20nhdNpeCOPkdFK9YV23rvwo718XyMnG7M5tS7GBxFhskVN3G0d7uHX9TCRE+ZKzSdJXe/La7VDvCT+FsgB0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TOu7auQn; arc=none smtp.client-ip=209.85.221.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TOu7auQn" Received: by mail-vk1-f180.google.com with SMTP id 71dfb90a1353d-518c46cc6e4so1854282e0c.3; Tue, 14 Jan 2025 07:39:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869142; x=1737473942; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NzP2hTHD0TqiTIAcB2t2QVINU/zqlmF+FkQkand+7x0=; b=TOu7auQnb/Y2uXRJM38+MXS/i9rsa+K9DW67rlBG61lUZ2NwFluRb34ozuGEFZIaDQ x5zZLor4R6MHIw5gMZpgCvl0TrqjIRIViNNHY4N1beCFsddQLQC4UBqm93Dze8J9MJ5b VmdeWzkPE1WgBA1oIPJ9GOOZ8pSuw+A/T7c53ByJbWN5Pv65jyLkh8sx1gp6vyrQJ0uV ks4XnsLyQRrZq4WGXJe9mTypMzgO/Vp5UAn8g8Ht1GrLjxR6fcvM0UymV3ISyF9Rj1J1 AWAqLls+Fc7IMugcQf8AoqEedR5Hbh2UrrR4stLqKUZejrVJN7iuI3edFA8aHkoLEwK9 A1pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869142; x=1737473942; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NzP2hTHD0TqiTIAcB2t2QVINU/zqlmF+FkQkand+7x0=; b=BBgbmeCIyqyZlmbjL2TN7NuWqD4F0S1pUEGvvh4aO0PoURuHiqE+mH7bYN4q6c6Nsx LU7Iuxm3y6gTyypcnFBq6W0RDMTjwPFZFBOyyKelHBLCuX0XZR3tkYCnVcOCZQ3CD7iL Y7ZZ9BPRPBfHK9iXGQY+rT61TKj+maz4vuPoOCrI7YtL0/ApXaem5PsJkyHlXr0UIQCU AcLEqRT5lVH5LwfCAH5+PBsHtK5Oe41raDy+fHlSGkpWxxMGAFaos6Yv/PhHOIJyJGY5 wM87GieL5G8KTEHByPyRoeOFV976pTeeqIyjLwZpesxi5dZjLmoEMRNowb3jkOkVUGow 9qWQ== X-Forwarded-Encrypted: i=1; AJvYcCU1sFpKkKGbKlsj8Fr4PQ86t+VKmQ/PdMjdf8Ckwo/0zwF93F9v9wgyv+PI8Qq7yPpJlyQBbaUF9uYJ@vger.kernel.org, AJvYcCWi1cigyg4DN2RhBXnFXDU68foG/ydPwnncdBqmCs2a1hPdrNqi/579aHERqX0t8gfGeBbHPK5qU0pSq6h2@vger.kernel.org X-Gm-Message-State: AOJu0YzSv3xJwAz04OpTOMNVDduPRvLACQRGO+Mg+toOHKAVAB88EEt7 ZEaZAdSxBkEeaU+c3aKQv0r8HNtYSZDPiSKp3jcMniq5ZvpgK1vNpXsawQ== X-Gm-Gg: ASbGncuMC5Tph0870KDeJnDbKtUGNhCf4BY8LW4VVfJ6X7yVuo19bOMz0Fxi497eSrR DSND+f66E+BY9G3HzMgGDbrtdYSaPSgwRPDtYDn1W1dK8CAMhzCVCS77BfUwOw+SJw2m3OnaBDa xWB/k0rdvHf1Gq8tite6QbBx7maErr/LfsM7Cf9M/7j16Q31ZukSVro7ZDL5wuWxhlgHnw0AC2z 2rCZ92eu90vKQ1S4xpAeOinv1ynNxN2DoZ029kh6EoUogdkHHnignPLS9jF692z X-Google-Smtp-Source: AGHT+IHSfnlrvlpRrJ7IMJQaExILy6q/8BPZZxDod0VoCG7AZ05EOEZtNjZCoJh/7uR6oK3GiBTooA== X-Received: by 2002:a05:6122:180d:b0:518:a2af:d666 with SMTP id 71dfb90a1353d-51c6c439cf2mr18935353e0c.1.1736869142594; Tue, 14 Jan 2025 07:39:02 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:39:01 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 16/18] ACPI: platform_profile: Move platform_profile_handler Date: Tue, 14 Jan 2025 10:37:24 -0500 Message-ID: <20250114153726.11802-17-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 platform_profile_handler is now an internal structure. Move it to platform_profile.c. Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/acpi/platform_profile.c | 9 +++++++++ include/linux/platform_profile.h | 11 ----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 2fae5e2fc962..f1749eb7b21b 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -15,6 +15,15 @@ static DEFINE_MUTEX(profile_lock); +struct platform_profile_handler { + const char *name; + struct device *dev; + struct device class_dev; + int minor; + unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; + const struct platform_profile_ops *ops; +}; + static const char * const profile_names[] = { [PLATFORM_PROFILE_LOW_POWER] = "low-power", [PLATFORM_PROFILE_COOL] = "cool", diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 778d4c661c3c..eea1daf85616 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -28,23 +28,12 @@ enum platform_profile_option { PLATFORM_PROFILE_LAST, /*must always be last */ }; -struct platform_profile_handler; - struct platform_profile_ops { int (*probe)(void *drvdata, unsigned long *choices); int (*profile_get)(struct device *dev, enum platform_profile_option *profile); int (*profile_set)(struct device *dev, enum platform_profile_option profile); }; -struct platform_profile_handler { - const char *name; - struct device *dev; - struct device class_dev; - int minor; - unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; - const struct platform_profile_ops *ops; -}; - struct device *platform_profile_register(struct device *dev, const char *name, void *drvdata, const struct platform_profile_ops *ops); From patchwork Tue Jan 14 15:37:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938908 Received: from mail-vk1-f172.google.com (mail-vk1-f172.google.com [209.85.221.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73EC91C5F0F; Tue, 14 Jan 2025 15:39:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869149; cv=none; b=uV8/ek9/colAsSFSeLO1Vcu2oIHnTOLXFKIw2LcvkjwiSL9MZcNanCFi/JaUpM00YiLzrniy3gl+IMq77rB7fvlh/OGvKRcA/K1N77M7fCPEUxp4H8f7pypvpntaU9EyV6UzWsR3wZql+FyDhzwKoRiNKA4Ell4HL0h5Ps/xoyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869149; c=relaxed/simple; bh=UNFLE3ouyw5oZJ+A8XYuo/S4UxIOzyEYBTcCMvSQJgc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aibuJGgyXcVS9jSGeFtfLampo1r4CZ5jCmJWPsdkS8N8lI7Rd016u/X+/Bd64K05tdJ0lWgpBSZ39Jec+P+S8l5aZfYR+o1I5MJB2RKqM050X0xQTyjR14Axv+/egai7pcN5NhqHA/5HRxlO3V1Ws8qpr9WoWUMqYa0ZGBioToE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JfC00FDQ; arc=none smtp.client-ip=209.85.221.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JfC00FDQ" Received: by mail-vk1-f172.google.com with SMTP id 71dfb90a1353d-518957b0533so1877497e0c.1; Tue, 14 Jan 2025 07:39:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869146; x=1737473946; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VuGQ1ZVbISV1fd4ChxW9sFDp4MUhOEtSl7slykO1SWs=; b=JfC00FDQhweQjFJ25Zb7uOU+yi3uCc//PUs7dtA/KncCvpZbi0LL4w4BAPQqNAr7zj E49yRgq5ttHZ9oTtarzjwxhkZAPgMqNIRk8s+b0sZH2jDJRU+nJp9MBdJRBRgTNy2QKB 3jO3+ls3szaYICQapANw7r4gkFnyvcgJI3dAum8Ss4Wb0V4KJIc0433IwjEJXDo2j16H JY0LxKYJsxTTPwjU+H/+wuuVj60H6B0cTzB46Jj5wglCDbHy2zblbwVjmAHf5FuYoKQp YTuscqlyjhAFHh4n67aWbiSn0XKVptRFZz76oUeOOP2x2AL9M/Adsw2St4n8RbIbV24G OnxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869146; x=1737473946; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VuGQ1ZVbISV1fd4ChxW9sFDp4MUhOEtSl7slykO1SWs=; b=oyzyByxVdT5ztP8PGhdaGIKi6fO2xc9tLZBn9XR4HQddvRmvfXhEqt8KMYHfhYOF/N k8+VlvkjCOM1KpuwQ3bjC5QdDfYK6mAabxe/m/ApL2mB6OrqwUP7ntFGD4ymfewPeWVn KINeHi8RsqjoYKkxrx06sg3+k4K3Xbe+DD6jme0qm7JmGomGj/E5WD8K4EPE/nrL5FjQ LCdc6DKtwVIrWRR/jMCK60cH7muytApOjugm7OlmZD/6qx4/v7qGxtPOhwUIfZEgQnho 19qTFeLieyhn8FpgNk8onN25+/2ldLzdDls2SIslZvLjOcB5JrkO5uN6RQyyAI4qO3Q6 JZmw== X-Forwarded-Encrypted: i=1; AJvYcCUWtRlSOgTFQZ5hLg4pltKBDllRYi8qyplXLaHjb7olgMk0YUDRGpMFd0JDLqBF3ijgw4fGzlcSIeYQ@vger.kernel.org, AJvYcCX9syRQcZDgro7Eb+HdAnD4z4v8ukU5ssmk2y7h7kiWFmUD7dl7C21QbUrG8YCYEMt732qv/ejMp1dh9oIb@vger.kernel.org X-Gm-Message-State: AOJu0YxK5b8bhq39Q/Npae/wfzTXyhW2nWfLtjxqJOFDUMSJPQOnB+HL HmXXjDLPewtNusKmpZCdn1fzpbMYKZQsg81i2JiKvuK8hAbzS6mBWeN2Iw== X-Gm-Gg: ASbGncuFFXliDdU2WWt3RsbZoILEJRBOBQuz40Gv52sk5102mEuWWOooxc8PYElExuE PCip23JkUMP/OPe5Z86QbfBYEXWHSuIpi9ebrDwazsyj/O5MsCp/r7YWKSA8nx0nIKFedEFQOnO uiTi0v8xyXzZc62TYqo94+bNvUdeCnvlhrmMWWSp5zF0W7s1Pb8i1q+fsNJVI2L3w0z/mSBiS32 eZRWou1rcnUgYgUmgDUtVwwePvwE15ayWQjd1T8EBZYVTy2fdLagdvhemuV8sa+ X-Google-Smtp-Source: AGHT+IF1jONKmPd5fYjh66MnEgs9+FR9HZ24HY+drnFS2W/9CvLzo68uJU5k6hwSn2/YoX2DGu44kg== X-Received: by 2002:a05:6122:8f82:b0:51b:8949:c996 with SMTP id 71dfb90a1353d-51c6c48f340mr19515173e0c.9.1736869146001; Tue, 14 Jan 2025 07:39:06 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.39.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:39:05 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 17/18] ACPI: platform_profile: Clean platform_profile_handler Date: Tue, 14 Jan 2025 10:37:25 -0500 Message-ID: <20250114153726.11802-18-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove parent device *dev from platform_profile_handler, as it's no longer accessed directly. Rename class_dev -> dev. Reviewed-by: Mario Limonciello Signed-off-by: Kurt Borja --- drivers/acpi/platform_profile.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index f1749eb7b21b..c44989801f8e 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -11,14 +11,13 @@ #include #include -#define to_pprof_handler(d) (container_of(d, struct platform_profile_handler, class_dev)) +#define to_pprof_handler(d) (container_of(d, struct platform_profile_handler, dev)) static DEFINE_MUTEX(profile_lock); struct platform_profile_handler { const char *name; - struct device *dev; - struct device class_dev; + struct device dev; int minor; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; const struct platform_profile_ops *ops; @@ -91,8 +90,8 @@ static int _notify_class_profile(struct device *dev, void *data) struct platform_profile_handler *handler = to_pprof_handler(dev); lockdep_assert_held(&profile_lock); - sysfs_notify(&handler->class_dev.kobj, NULL, "profile"); - kobject_uevent(&handler->class_dev.kobj, KOBJ_CHANGE); + sysfs_notify(&handler->dev.kobj, NULL, "profile"); + kobject_uevent(&handler->dev.kobj, KOBJ_CHANGE); return 0; } @@ -517,13 +516,13 @@ struct device *platform_profile_register(struct device *dev, const char *name, pprof->name = name; pprof->ops = ops; pprof->minor = minor; - pprof->class_dev.class = &platform_profile_class; - pprof->class_dev.parent = dev; - dev_set_drvdata(&pprof->class_dev, drvdata); - dev_set_name(&pprof->class_dev, "platform-profile-%d", pprof->minor); - err = device_register(&pprof->class_dev); + pprof->dev.class = &platform_profile_class; + pprof->dev.parent = dev; + dev_set_drvdata(&pprof->dev, drvdata); + dev_set_name(&pprof->dev, "platform-profile-%d", pprof->minor); + err = device_register(&pprof->dev); if (err) { - put_device(&no_free_ptr(pprof)->class_dev); + put_device(&no_free_ptr(pprof)->dev); goto cleanup_ida; } @@ -533,10 +532,10 @@ struct device *platform_profile_register(struct device *dev, const char *name, if (err) goto cleanup_cur; - return &no_free_ptr(pprof)->class_dev; + return &no_free_ptr(pprof)->dev; cleanup_cur: - device_unregister(&no_free_ptr(pprof)->class_dev); + device_unregister(&no_free_ptr(pprof)->dev); cleanup_ida: ida_free(&platform_profile_ida, minor); @@ -552,7 +551,7 @@ int platform_profile_remove(struct device *dev) guard(mutex)(&profile_lock); id = pprof->minor; - device_unregister(&pprof->class_dev); + device_unregister(&pprof->dev); ida_free(&platform_profile_ida, id); sysfs_notify(acpi_kobj, NULL, "platform_profile"); From patchwork Tue Jan 14 15:37:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 13938909 Received: from mail-vk1-f172.google.com (mail-vk1-f172.google.com [209.85.221.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 131551FC7DC; Tue, 14 Jan 2025 15:39:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869153; cv=none; b=T8Thfu7MbHXTKERctofGWi6pqVajs2xPF6ir2vQs4bSCvtKzsNCM8KWxJxAAcuqcxMM7VBFy7LMmc9CqBk2CzoZgjjf186mHKjLUheIvhuK88OtfA6BTmeTgfbjKa2aIexDh6ymODDfKFcxjlcW5r3i1REp7VoQ1DGcnu+Ti1fg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736869153; c=relaxed/simple; bh=LFD5HnUv6axyJM8IqskxceD+/1v3k1p/nSQV9BE4jMM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MCQ278nu/T3WINJGwZ2PElimUIg5z9xDJsUtqeYbKfNGFaUuj/migAmT1y7rQ09LFhUiYGTkqzRnsZF5fQSZ7LSHturbwQHWvoYwc2XkiqBMtOkisIIhGlpXZC9QMJz4zxNY1ACDZ7ESiSBfo+6Fp6dcuf+rQxk0nf/ufZzewSA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nKAlP3Rg; arc=none smtp.client-ip=209.85.221.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nKAlP3Rg" Received: by mail-vk1-f172.google.com with SMTP id 71dfb90a1353d-518954032b2so1876756e0c.0; Tue, 14 Jan 2025 07:39:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736869149; x=1737473949; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GI1j7X1Kt0Lk/pNjI2Hh5cyHCwMeZVYB/YjyicpVYZc=; b=nKAlP3RgqzYbbkalsNeskZE3ihzrnhgfwqJED3XdimA1Csmt1FcmKfpG9jGRnM8+qe V8Q6OYNEzztde2NQlQynVQVgN5Z4cfZOvNcib1so2w2iTJA2oDd6ajEimq5XNTOqVyzd vXVzGkPVOzFy0tckyS7ZdLx9yCwzAAHaryFqoCR5vS4rWpF1zzH54qT1fFBD7CrHBOc7 x6kHPIz+4U1HCiZS28f4Ey2Pu/gKMvdNdIjDCXLQw+MIOVcMXlO2DGDDj1cUh8xbRAi0 1CqDo9n/LeZOuSzYQO/A8rNsfDDaz72LAXjp8xVCv0BmEZLKbGgd7tukih0Km5Y5wIFU Ds6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736869149; x=1737473949; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GI1j7X1Kt0Lk/pNjI2Hh5cyHCwMeZVYB/YjyicpVYZc=; b=N0ykjdOYb/pbDEu3hDIcUJz9jwfFuCRcmX+E1fC2H+C0++fI/SC1zF99JGt4OxrBHn LdqdFEDwunRFKxynZK2G+ZjVDxvPgmqeHacP0JQUd+u+tOstwLVdXehIXkMcI8n+70Yc IdJc37OKeX14RvXIfwi6QeduMPX7hYhf8QJtKF/fDap4dNKdk8BDO9bUvQscVH+CJvWx gem5I4cGfu9NjSVvatlw9cVaYAlnwjj2+v8i8MK15gOangxOHo0AaEDtngLLm90j5yBO A9wl9ZY5czPkrBvPGZT39MBh0PfgUAFjlnF5bh6WfQsE8kgTDzP9bXBNUok/H05yhaWq lt9A== X-Forwarded-Encrypted: i=1; AJvYcCWXiFtVJcvU03WHI1kQjc2YPVp6y2sqenBs8VjUgLx0Os4feU5rT+AP9rUmEKWxJw99le1CH2KhRH2K@vger.kernel.org, AJvYcCXMMmnpxcK5JEG37fUsaJLCEHrPmpZwXs8J0dm98la2fYmschmstGHy9whxNbCEmDZY+OE5ZroRl4UPZLz6@vger.kernel.org X-Gm-Message-State: AOJu0YyeuITCjoRrzLXgLLUJOfkN8xhSYqSQeQ8Awlayhben3+lnDQRV twWwsW73joBU7j9LkU1OSotTZb3PV7gEIshNOLm+DlNH8BqyBXeo0RR/RA== X-Gm-Gg: ASbGncv/yNQ6qsw01UGpvKYaXPqoHaaitxCmEuAcgrdGbMsoGk+RJLWjW21P0i8cjda aQL1HDLgFbwwW3kL1NKW6xfcX45OnvKgWaGWArc4+c8fa4Q+gTNc2UiSRK3AAsY96nFZ1TTvZpM lRfmCOSEFtOo7CtBlQSw0Lh/5ZjbMaet7KkwiWKlW6h5GYWgmW5DZaEtRjV/w9ptOzFYOsgC6i/ NI4jdc3TO3nia93uB66iD8XDafAqfmBXMxMuzOyLHA8u4F8asgn5JQdK4lbWghy X-Google-Smtp-Source: AGHT+IGWjNg4O4IOHdix6orWFAznbRve1THMCUqMyQa/ychI5YFbMGSAl/AiMHif0ctQYondNL80+A== X-Received: by 2002:a05:6122:8f82:b0:51b:8949:c996 with SMTP id 71dfb90a1353d-51c6c48f340mr19515587e0c.9.1736869149474; Tue, 14 Jan 2025 07:39:09 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-51cd7c56d30sm277e0c.14.2025.01.14.07.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:39:08 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , "Len Brown" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , "Joshua Grisham" , "Derek J. Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , "Kurt Borja" , "Maximilian Luz" , "Lee, Chun-Yi" , "Shyam Sundar S K" , "Corentin Chary" , "Luke D. Jones" , "Lyndon Sanche" , "Ike Panhc" , "Henrique de Moraes Holschuh" , "Mark Pearson" , "Alexis Belmonte" , "Ai Chao" , "Gergo Koteles" , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH v2 18/18] ACPI: platform_profile: Add documentation Date: Tue, 14 Jan 2025 10:37:26 -0500 Message-ID: <20250114153726.11802-19-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250114153726.11802-1-kuurtb@gmail.com> References: <20250114153726.11802-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add kerneldoc and sysfs class documentation. Signed-off-by: Kurt Borja Reviewed-by: Mario Limonciello --- .../ABI/testing/sysfs-class-platform-profile | 44 +++++++++++++++++++ drivers/acpi/platform_profile.c | 33 ++++++++++++++ include/linux/platform_profile.h | 24 ++++++++++ 3 files changed, 101 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-platform-profile diff --git a/Documentation/ABI/testing/sysfs-class-platform-profile b/Documentation/ABI/testing/sysfs-class-platform-profile new file mode 100644 index 000000000000..b5a3600080bc --- /dev/null +++ b/Documentation/ABI/testing/sysfs-class-platform-profile @@ -0,0 +1,44 @@ +What: /sys/class/platform-profile/platform-profile-X/name +Date: January 2025 +Description: Name of the class device given by the driver. + + RO + +What: /sys/class/platform-profile/platform-profile-X/choices +Date: January 2025 +Description: This file contains a space-separated list of profiles supported for this device. + + Drivers must use the following standard profile-names: + + ==================== ======================================== + low-power Low power consumption + cool Cooler operation + quiet Quieter operation + balanced Balance between low power consumption + and performance + balanced-performance Balance between performance and low + power consumption with a slight bias + towards performance + performance High performance operation + custom Driver defined custom profile + ==================== ======================================== + + RO + +What: /sys/class/platform-profile/platform-profile-X/profile +Date: January 2025 +Description: Reading this file gives the current selected profile for this + device. Writing this file with one of the strings from + platform_profile_choices changes the profile to the new value. + + This file can be monitored for changes by polling for POLLPRI, + POLLPRI will be signaled on any changes, independent of those + changes coming from a userspace write; or coming from another + source such as e.g. a hotkey triggered profile change handled + either directly by the embedded-controller or fully handled + inside the kernel. + + This file may also emit the string 'custom' to indicate + that the driver is using a driver defined custom profile. + + RW diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index c44989801f8e..9caddac695b8 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -426,6 +426,10 @@ static const struct attribute_group platform_profile_group = { .is_visible = profile_class_is_visible, }; +/** + * platform_profile_notify - Notify class device and legacy sysfs interface + * @dev: The class device + */ void platform_profile_notify(struct device *dev) { scoped_cond_guard(mutex_intr, return, &profile_lock) { @@ -435,6 +439,11 @@ void platform_profile_notify(struct device *dev) } EXPORT_SYMBOL_GPL(platform_profile_notify); +/** + * platform_profile_cycle - Cycles profiles available on all registered class devices + * + * Return: 0 on success, -errno on failure + */ int platform_profile_cycle(void) { enum platform_profile_option next = PLATFORM_PROFILE_LAST; @@ -478,6 +487,15 @@ int platform_profile_cycle(void) } EXPORT_SYMBOL_GPL(platform_profile_cycle); +/** + * platform_profile_register - Creates and registers a platform profile class device + * @dev: Parent device + * @name: Name of the class device + * @drvdata: Driver data that will be attached to the class device + * @ops: Platform profile's mandatory operations + * + * Return: pointer to the new class device on success, ERR_PTR on failure + */ struct device *platform_profile_register(struct device *dev, const char *name, void *drvdata, const struct platform_profile_ops *ops) @@ -544,6 +562,12 @@ struct device *platform_profile_register(struct device *dev, const char *name, } EXPORT_SYMBOL_GPL(platform_profile_register); +/** + * platform_profile_remove - Unregisters a platform profile class device + * @dev: Class device + * + * Return: 0 + */ int platform_profile_remove(struct device *dev) { struct platform_profile_handler *pprof = to_pprof_handler(dev); @@ -569,6 +593,15 @@ static void devm_platform_profile_release(struct device *dev, void *res) platform_profile_remove(*ppdev); } +/** + * devm_platform_profile_register - Device managed version of platform_profile_register + * @dev: Parent device + * @name: Name of the class device + * @drvdata: Driver data that will be attached to the class device + * @ops: Platform profile's mandatory operations + * + * Return: pointer to the new class device on success, ERR_PTR on failure + */ struct device *devm_platform_profile_register(struct device *dev, const char *name, void *drvdata, const struct platform_profile_ops *ops) diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index eea1daf85616..eb4dc85dc18c 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -28,6 +28,30 @@ enum platform_profile_option { PLATFORM_PROFILE_LAST, /*must always be last */ }; +/** + * struct platform_profile_ops - platform profile operations + * @probe: Callback to setup choices available to the new class device. + * Parameters are: + * @drvdata: drvdata pointer passed to platform_profile_register. + * @choices: Empty choices bitmap which the driver has to manually + * setup, by using set_bit() in bits corresponding to + * platform_profile_option values. These values will only + * be enforced when a new profile is selected from + * user-space. + * @profile_get: Callback that will be called when showing the current platform + * profile. + * Parameters are: + * @dev: Class device. + * @profile: Pointer to the profile which will be read from + * user-space. Selected choices are not enforced when + * modifying this value. + * @profile_set: Callback that will be called when storing the new platform + * profile. + * Parameters are: + * @dev: Class device. + * @profile: New platform profile to be set. Guaranteed to be a + * value selected in the @probe callback. + */ struct platform_profile_ops { int (*probe)(void *drvdata, unsigned long *choices); int (*profile_get)(struct device *dev, enum platform_profile_option *profile);