Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions drivers/acpi/platform_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ static const char * const profile_names[] = {
static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST);

static DEFINE_IDA(platform_profile_ida);
static bool platform_profile_legacy_registered;

static void platform_profile_legacy_notify(void)
{
if (platform_profile_legacy_registered)
sysfs_notify(acpi_kobj, NULL, "platform_profile");
}

/**
* _commmon_choices_show - Show the available profile choices
Expand Down Expand Up @@ -216,7 +223,7 @@ static ssize_t profile_store(struct device *dev,
return ret;
}

sysfs_notify(acpi_kobj, NULL, "platform_profile");
platform_profile_legacy_notify();

return count;
}
Expand Down Expand Up @@ -436,7 +443,7 @@ static ssize_t platform_profile_store(struct kobject *kobj,
return ret;
}

sysfs_notify(acpi_kobj, NULL, "platform_profile");
platform_profile_legacy_notify();

return count;
}
Expand Down Expand Up @@ -473,6 +480,14 @@ static const struct attribute_group platform_profile_group = {
.is_visible = profile_class_is_visible,
};

static int platform_profile_legacy_update_group(void)
{
if (!platform_profile_legacy_registered)
return 0;

return sysfs_update_group(acpi_kobj, &platform_profile_group);
}

/**
* platform_profile_notify - Notify class device and legacy sysfs interface
* @dev: The class device
Expand All @@ -482,7 +497,7 @@ void platform_profile_notify(struct device *dev)
scoped_cond_guard(mutex_intr, return, &profile_lock) {
_notify_class_profile(dev, NULL);
}
sysfs_notify(acpi_kobj, NULL, "platform_profile");
platform_profile_legacy_notify();
}
EXPORT_SYMBOL_GPL(platform_profile_notify);

Expand Down Expand Up @@ -532,7 +547,7 @@ int platform_profile_cycle(void)
return err;
}

sysfs_notify(acpi_kobj, NULL, "platform_profile");
platform_profile_legacy_notify();

return 0;
}
Expand Down Expand Up @@ -605,9 +620,9 @@ struct device *platform_profile_register(struct device *dev, const char *name,
goto cleanup_ida;
}

sysfs_notify(acpi_kobj, NULL, "platform_profile");
platform_profile_legacy_notify();

err = sysfs_update_group(acpi_kobj, &platform_profile_group);
err = platform_profile_legacy_update_group();
if (err)
goto cleanup_cur;

Expand Down Expand Up @@ -641,8 +656,8 @@ void platform_profile_remove(struct device *dev)
ida_free(&platform_profile_ida, pprof->minor);
device_unregister(&pprof->dev);

sysfs_notify(acpi_kobj, NULL, "platform_profile");
sysfs_update_group(acpi_kobj, &platform_profile_group);
platform_profile_legacy_notify();
platform_profile_legacy_update_group();
}
EXPORT_SYMBOL_GPL(platform_profile_remove);

Expand Down Expand Up @@ -690,23 +705,26 @@ static int __init platform_profile_init(void)
{
int err;

if (acpi_disabled)
return -EOPNOTSUPP;

err = class_register(&platform_profile_class);
if (err)
return err;

if (acpi_disabled || !acpi_kobj)
return 0;

err = sysfs_create_group(acpi_kobj, &platform_profile_group);
if (err)
class_unregister(&platform_profile_class);
else
platform_profile_legacy_registered = true;

return err;
}

static void __exit platform_profile_exit(void)
{
sysfs_remove_group(acpi_kobj, &platform_profile_group);
if (platform_profile_legacy_registered)
sysfs_remove_group(acpi_kobj, &platform_profile_group);
class_unregister(&platform_profile_class);
}
module_init(platform_profile_init);
Expand Down
15 changes: 15 additions & 0 deletions drivers/platform/surface/surface_aggregator_registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ static const struct software_node ssam_node_tmp_perf_profile_with_fan = {
.properties = ssam_node_tmp_perf_profile_has_fan,
};

static const struct property_entry ssam_node_tmp_perf_profile_sp11_props[] = {
PROPERTY_ENTRY_BOOL("has_fan"),
PROPERTY_ENTRY_BOOL("default-low-power"),
PROPERTY_ENTRY_U32("low-power-max-frequency-khz", 2515000),
{ }
};

static const struct software_node ssam_node_tmp_perf_profile_sp11 = {
.name = "ssam:01:03:01:00:01",
.parent = &ssam_node_root,
.properties = ssam_node_tmp_perf_profile_sp11_props,
};

/* Thermal sensors. */
static const struct software_node ssam_node_tmp_sensors = {
.name = "ssam:01:03:01:00:02",
Expand Down Expand Up @@ -410,6 +423,8 @@ static const struct software_node *ssam_node_group_sp11[] = {
&ssam_node_hub_kip,
&ssam_node_bat_ac,
&ssam_node_bat_main,
&ssam_node_tmp_perf_profile_sp11,
&ssam_node_fan_speed,
&ssam_node_tmp_sensors,
&ssam_node_hid_kip_keyboard,
&ssam_node_hid_kip_penstash,
Expand Down
Loading