Skip to content

Commit ee7f3e2

Browse files
kuu-rtij-intel
authored andcommitted
ACPI: platform_profile: Add documentation
Add kerneldoc and sysfs class documentation. Reviewed-by: Mario Limonciello <[email protected]> Signed-off-by: Kurt Borja <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Mark Pearson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent c4f7d25 commit ee7f3e2

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
What: /sys/class/platform-profile/platform-profile-X/name
2+
Date: March 2025
3+
KernelVersion: 6.14
4+
Description: Name of the class device given by the driver.
5+
6+
RO
7+
8+
What: /sys/class/platform-profile/platform-profile-X/choices
9+
Date: March 2025
10+
KernelVersion: 6.14
11+
Description: This file contains a space-separated list of profiles supported
12+
for this device.
13+
14+
Drivers must use the following standard profile-names:
15+
16+
==================== ========================================
17+
low-power Low power consumption
18+
cool Cooler operation
19+
quiet Quieter operation
20+
balanced Balance between low power consumption
21+
and performance
22+
balanced-performance Balance between performance and low
23+
power consumption with a slight bias
24+
towards performance
25+
performance High performance operation
26+
custom Driver defined custom profile
27+
==================== ========================================
28+
29+
RO
30+
31+
What: /sys/class/platform-profile/platform-profile-X/profile
32+
Date: March 2025
33+
KernelVersion: 6.14
34+
Description: Reading this file gives the current selected profile for this
35+
device. Writing this file with one of the strings from
36+
platform_profile_choices changes the profile to the new value.
37+
38+
This file can be monitored for changes by polling for POLLPRI,
39+
POLLPRI will be signaled on any changes, independent of those
40+
changes coming from a userspace write; or coming from another
41+
source such as e.g. a hotkey triggered profile change handled
42+
either directly by the embedded-controller or fully handled
43+
inside the kernel.
44+
45+
This file may also emit the string 'custom' to indicate
46+
that the driver is using a driver defined custom profile.
47+
48+
RW

drivers/acpi/platform_profile.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,10 @@ static const struct attribute_group platform_profile_group = {
425425
.is_visible = profile_class_is_visible,
426426
};
427427

428+
/**
429+
* platform_profile_notify - Notify class device and legacy sysfs interface
430+
* @dev: The class device
431+
*/
428432
void platform_profile_notify(struct device *dev)
429433
{
430434
scoped_cond_guard(mutex_intr, return, &profile_lock) {
@@ -434,6 +438,11 @@ void platform_profile_notify(struct device *dev)
434438
}
435439
EXPORT_SYMBOL_GPL(platform_profile_notify);
436440

441+
/**
442+
* platform_profile_cycle - Cycles profiles available on all registered class devices
443+
*
444+
* Return: 0 on success, -errno on failure
445+
*/
437446
int platform_profile_cycle(void)
438447
{
439448
enum platform_profile_option next = PLATFORM_PROFILE_LAST;
@@ -477,6 +486,15 @@ int platform_profile_cycle(void)
477486
}
478487
EXPORT_SYMBOL_GPL(platform_profile_cycle);
479488

489+
/**
490+
* platform_profile_register - Creates and registers a platform profile class device
491+
* @dev: Parent device
492+
* @name: Name of the class device
493+
* @drvdata: Driver data that will be attached to the class device
494+
* @ops: Platform profile's mandatory operations
495+
*
496+
* Return: pointer to the new class device on success, ERR_PTR on failure
497+
*/
480498
struct device *platform_profile_register(struct device *dev, const char *name,
481499
void *drvdata,
482500
const struct platform_profile_ops *ops)
@@ -546,6 +564,12 @@ struct device *platform_profile_register(struct device *dev, const char *name,
546564
}
547565
EXPORT_SYMBOL_GPL(platform_profile_register);
548566

567+
/**
568+
* platform_profile_remove - Unregisters a platform profile class device
569+
* @dev: Class device
570+
*
571+
* Return: 0
572+
*/
549573
int platform_profile_remove(struct device *dev)
550574
{
551575
struct platform_profile_handler *pprof = to_pprof_handler(dev);
@@ -571,6 +595,15 @@ static void devm_platform_profile_release(struct device *dev, void *res)
571595
platform_profile_remove(*ppdev);
572596
}
573597

598+
/**
599+
* devm_platform_profile_register - Device managed version of platform_profile_register
600+
* @dev: Parent device
601+
* @name: Name of the class device
602+
* @drvdata: Driver data that will be attached to the class device
603+
* @ops: Platform profile's mandatory operations
604+
*
605+
* Return: pointer to the new class device on success, ERR_PTR on failure
606+
*/
574607
struct device *devm_platform_profile_register(struct device *dev, const char *name,
575608
void *drvdata,
576609
const struct platform_profile_ops *ops)

include/linux/platform_profile.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ enum platform_profile_option {
2828
PLATFORM_PROFILE_LAST, /*must always be last */
2929
};
3030

31+
/**
32+
* struct platform_profile_ops - platform profile operations
33+
* @probe: Callback to setup choices available to the new class device. These
34+
* choices will only be enforced when setting a new profile, not when
35+
* getting the current one.
36+
* @profile_get: Callback that will be called when showing the current platform
37+
* profile in sysfs.
38+
* @profile_set: Callback that will be called when storing a new platform
39+
* profile in sysfs.
40+
*/
3141
struct platform_profile_ops {
3242
int (*probe)(void *drvdata, unsigned long *choices);
3343
int (*profile_get)(struct device *dev, enum platform_profile_option *profile);

0 commit comments

Comments
 (0)