Skip to content

Commit 6a1c497

Browse files
committed
Merge branch 'bits/002-backports' into asahi-wip
2 parents 761d0c1 + fdcbc56 commit 6a1c497

4 files changed

Lines changed: 62 additions & 19 deletions

File tree

drivers/acpi/platform_profile.c

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,20 @@ static ssize_t profile_show(struct device *dev,
190190
return sysfs_emit(buf, "%s\n", profile_names[profile]);
191191
}
192192

193+
/**
194+
* profile_notify_legacy - Notify the legacy sysfs interface
195+
*
196+
* This wrapper takes care of only notifying the legacy sysfs interface
197+
* if it was registered during module initialization.
198+
*/
199+
static void profile_notify_legacy(void)
200+
{
201+
if (!acpi_kobj)
202+
return;
203+
204+
sysfs_notify(acpi_kobj, NULL, "platform_profile");
205+
}
206+
193207
/**
194208
* profile_store - Set the profile for a class device
195209
* @dev: The device
@@ -215,7 +229,7 @@ static ssize_t profile_store(struct device *dev,
215229
return ret;
216230
}
217231

218-
sysfs_notify(acpi_kobj, NULL, "platform_profile");
232+
profile_notify_legacy();
219233

220234
return count;
221235
}
@@ -437,7 +451,7 @@ static ssize_t platform_profile_store(struct kobject *kobj,
437451
return ret;
438452
}
439453

440-
sysfs_notify(acpi_kobj, NULL, "platform_profile");
454+
profile_notify_legacy();
441455

442456
return count;
443457
}
@@ -474,6 +488,22 @@ static const struct attribute_group platform_profile_group = {
474488
.is_visible = profile_class_is_visible,
475489
};
476490

491+
/**
492+
* profile_update_legacy - Update the legacy sysfs interface
493+
*
494+
* This wrapper takes care of only updating the legacy sysfs interface
495+
* if it was registered during module initialization.
496+
*
497+
* Return: 0 on success or error code on failure.
498+
*/
499+
static int profile_update_legacy(void)
500+
{
501+
if (!acpi_kobj)
502+
return 0;
503+
504+
return sysfs_update_group(acpi_kobj, &platform_profile_group);
505+
}
506+
477507
/**
478508
* platform_profile_notify - Notify class device and legacy sysfs interface
479509
* @dev: The class device
@@ -483,7 +513,7 @@ void platform_profile_notify(struct device *dev)
483513
scoped_cond_guard(mutex_intr, return, &profile_lock) {
484514
_notify_class_profile(dev, NULL);
485515
}
486-
sysfs_notify(acpi_kobj, NULL, "platform_profile");
516+
profile_notify_legacy();
487517
}
488518
EXPORT_SYMBOL_GPL(platform_profile_notify);
489519

@@ -532,7 +562,7 @@ int platform_profile_cycle(void)
532562
return err;
533563
}
534564

535-
sysfs_notify(acpi_kobj, NULL, "platform_profile");
565+
profile_notify_legacy();
536566

537567
return 0;
538568
}
@@ -606,9 +636,9 @@ struct device *platform_profile_register(struct device *dev, const char *name,
606636
goto cleanup_ida;
607637
}
608638

609-
sysfs_notify(acpi_kobj, NULL, "platform_profile");
639+
profile_notify_legacy();
610640

611-
err = sysfs_update_group(acpi_kobj, &platform_profile_group);
641+
err = profile_update_legacy();
612642
if (err)
613643
goto cleanup_cur;
614644

@@ -640,9 +670,8 @@ int platform_profile_remove(struct device *dev)
640670
device_unregister(&pprof->dev);
641671
ida_free(&platform_profile_ida, id);
642672

643-
sysfs_notify(acpi_kobj, NULL, "platform_profile");
644-
645-
sysfs_update_group(acpi_kobj, &platform_profile_group);
673+
profile_notify_legacy();
674+
profile_update_legacy();
646675

647676
return 0;
648677
}
@@ -696,16 +725,28 @@ static int __init platform_profile_init(void)
696725
if (err)
697726
return err;
698727

699-
err = sysfs_create_group(acpi_kobj, &platform_profile_group);
700-
if (err)
701-
class_unregister(&platform_profile_class);
728+
/*
729+
* The ACPI kobject can be missing if ACPI was disabled during booting.
730+
* We thus skip the initialization of the legacy sysfs interface in such
731+
* cases to allow the platform profile class to work on ARM64 notebooks
732+
* without ACPI support.
733+
*/
734+
if (acpi_kobj) {
735+
err = sysfs_create_group(acpi_kobj, &platform_profile_group);
736+
if (err < 0) {
737+
class_unregister(&platform_profile_class);
738+
return err;
739+
}
740+
}
702741

703-
return err;
742+
return 0;
704743
}
705744

706745
static void __exit platform_profile_exit(void)
707746
{
708-
sysfs_remove_group(acpi_kobj, &platform_profile_group);
747+
if (acpi_kobj)
748+
sysfs_remove_group(acpi_kobj, &platform_profile_group);
749+
709750
class_unregister(&platform_profile_class);
710751
}
711752
module_init(platform_profile_init);

drivers/hid/Kconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,7 @@ config HID_LED
570570

571571
config HID_LENOVO
572572
tristate "Lenovo / Thinkpad devices"
573-
depends on ACPI
574-
select ACPI_PLATFORM_PROFILE
573+
select ACPI_PLATFORM_PROFILE if ACPI
575574
select NEW_LEDS
576575
select LEDS_CLASS
577576
help

drivers/hid/hid-lenovo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ static int lenovo_raw_event_TP_X12_tab(struct hid_device *hdev, u32 raw_data)
728728
if (hdev->product == USB_DEVICE_ID_LENOVO_X12_TAB) {
729729
report_key_event(input, KEY_RFKILL);
730730
return 1;
731-
} else {
731+
} else if (IS_ENABLED(CONFIG_ACPI_PLATFORM_PROFILE)) {
732732
platform_profile_cycle();
733733
return 1;
734734
}

drivers/watchdog/apple_wdt.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,12 @@ static int apple_wdt_ping(struct watchdog_device *wdd)
9595
static int apple_wdt_set_timeout(struct watchdog_device *wdd, unsigned int s)
9696
{
9797
struct apple_wdt *wdt = to_apple_wdt(wdd);
98+
u32 actual;
9899

99100
writel_relaxed(0, wdt->regs + APPLE_WDT_WD1_CUR_TIME);
100-
writel_relaxed(wdt->clk_rate * s, wdt->regs + APPLE_WDT_WD1_BITE_TIME);
101+
102+
actual = min(s, wdd->max_hw_heartbeat_ms / 1000);
103+
writel_relaxed(wdt->clk_rate * actual, wdt->regs + APPLE_WDT_WD1_BITE_TIME);
101104

102105
wdd->timeout = s;
103106

@@ -177,7 +180,7 @@ static int apple_wdt_probe(struct platform_device *pdev)
177180

178181
wdt->wdd.ops = &apple_wdt_ops;
179182
wdt->wdd.info = &apple_wdt_info;
180-
wdt->wdd.max_timeout = U32_MAX / wdt->clk_rate;
183+
wdt->wdd.max_hw_heartbeat_ms = U32_MAX / wdt->clk_rate * 1000;
181184
wdt->wdd.timeout = APPLE_WDT_TIMEOUT_DEFAULT;
182185

183186
wdt_ctrl = readl_relaxed(wdt->regs + APPLE_WDT_WD1_CTRL);

0 commit comments

Comments
 (0)