Skip to content

Commit 3035a6d

Browse files
kuu-rtrafaeljw
authored andcommitted
ACPI: platform_profile: Optimize _aggregate_choices()
Choices aggregates passed to _aggregate_choices() are already filled with ones, therefore we can avoid copying a new bitmap on the first iteration. This makes setting the PLATFORM_PROFILE_LAST bit on aggregates unnecessary, so drop it as well. While at it, add a couple empty lines to improve style. Reviewed-by: Armin Wolf <W_Armin@gmx.de> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Kurt Borja <kuurtb@gmail.com> Link: https://patch.msgid.link/20250325-pprof-opt-v2-1-736291e6e66b@gmail.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 21e0ff5 commit 3035a6d

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

drivers/acpi/platform_profile.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ static const struct class platform_profile_class = {
245245
/**
246246
* _aggregate_choices - Aggregate the available profile choices
247247
* @dev: The device
248-
* @arg: struct aggregate_choices_data
248+
* @arg: struct aggregate_choices_data, with it's aggregate member bitmap
249+
* initially filled with ones
249250
*
250251
* Return: 0 on success, -errno on failure
251252
*/
@@ -256,12 +257,10 @@ static int _aggregate_choices(struct device *dev, void *arg)
256257
struct platform_profile_handler *handler;
257258

258259
lockdep_assert_held(&profile_lock);
260+
259261
handler = to_pprof_handler(dev);
260262
bitmap_or(tmp, handler->choices, handler->hidden_choices, PLATFORM_PROFILE_LAST);
261-
if (test_bit(PLATFORM_PROFILE_LAST, data->aggregate))
262-
bitmap_copy(data->aggregate, tmp, PLATFORM_PROFILE_LAST);
263-
else
264-
bitmap_and(data->aggregate, tmp, data->aggregate, PLATFORM_PROFILE_LAST);
263+
bitmap_and(data->aggregate, tmp, data->aggregate, PLATFORM_PROFILE_LAST);
265264
data->count++;
266265

267266
return 0;
@@ -305,7 +304,6 @@ static ssize_t platform_profile_choices_show(struct kobject *kobj,
305304
};
306305
int err;
307306

308-
set_bit(PLATFORM_PROFILE_LAST, data.aggregate);
309307
scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
310308
err = class_for_each_device(&platform_profile_class, NULL,
311309
&data, _aggregate_choices);
@@ -422,7 +420,7 @@ static ssize_t platform_profile_store(struct kobject *kobj,
422420
i = sysfs_match_string(profile_names, buf);
423421
if (i < 0 || i == PLATFORM_PROFILE_CUSTOM)
424422
return -EINVAL;
425-
set_bit(PLATFORM_PROFILE_LAST, data.aggregate);
423+
426424
scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
427425
ret = class_for_each_device(&platform_profile_class, NULL,
428426
&data, _aggregate_choices);
@@ -502,7 +500,6 @@ int platform_profile_cycle(void)
502500
enum platform_profile_option profile = PLATFORM_PROFILE_LAST;
503501
int err;
504502

505-
set_bit(PLATFORM_PROFILE_LAST, data.aggregate);
506503
scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
507504
err = class_for_each_device(&platform_profile_class, NULL,
508505
&profile, _aggregate_profiles);

0 commit comments

Comments
 (0)