Skip to content

Commit 6cd225c

Browse files
committed
Merge branch 'bits/002-backports' into asahi-wip
2 parents bb99aff + 58eebe0 commit 6cd225c

4 files changed

Lines changed: 66 additions & 19 deletions

File tree

drivers/acpi/platform_profile.c

Lines changed: 55 additions & 13 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
}
@@ -435,7 +449,7 @@ static ssize_t platform_profile_store(struct kobject *kobj,
435449
return ret;
436450
}
437451

438-
sysfs_notify(acpi_kobj, NULL, "platform_profile");
452+
profile_notify_legacy();
439453

440454
return count;
441455
}
@@ -472,6 +486,22 @@ static const struct attribute_group platform_profile_group = {
472486
.is_visible = profile_class_is_visible,
473487
};
474488

489+
/**
490+
* profile_update_legacy - Update the legacy sysfs interface
491+
*
492+
* This wrapper takes care of only updating the legacy sysfs interface
493+
* if it was registered during module initialization.
494+
*
495+
* Return: 0 on success or error code on failure.
496+
*/
497+
static int profile_update_legacy(void)
498+
{
499+
if (!acpi_kobj)
500+
return 0;
501+
502+
return sysfs_update_group(acpi_kobj, &platform_profile_group);
503+
}
504+
475505
/**
476506
* platform_profile_notify - Notify class device and legacy sysfs interface
477507
* @dev: The class device
@@ -481,7 +511,7 @@ void platform_profile_notify(struct device *dev)
481511
scoped_cond_guard(mutex_intr, return, &profile_lock) {
482512
_notify_class_profile(dev, NULL);
483513
}
484-
sysfs_notify(acpi_kobj, NULL, "platform_profile");
514+
profile_notify_legacy();
485515
}
486516
EXPORT_SYMBOL_GPL(platform_profile_notify);
487517

@@ -529,7 +559,7 @@ int platform_profile_cycle(void)
529559
return err;
530560
}
531561

532-
sysfs_notify(acpi_kobj, NULL, "platform_profile");
562+
profile_notify_legacy();
533563

534564
return 0;
535565
}
@@ -603,9 +633,9 @@ struct device *platform_profile_register(struct device *dev, const char *name,
603633
goto cleanup_ida;
604634
}
605635

606-
sysfs_notify(acpi_kobj, NULL, "platform_profile");
636+
profile_notify_legacy();
607637

608-
err = sysfs_update_group(acpi_kobj, &platform_profile_group);
638+
err = profile_update_legacy();
609639
if (err)
610640
goto cleanup_cur;
611641

@@ -639,8 +669,8 @@ void platform_profile_remove(struct device *dev)
639669
ida_free(&platform_profile_ida, pprof->minor);
640670
device_unregister(&pprof->dev);
641671

642-
sysfs_notify(acpi_kobj, NULL, "platform_profile");
643-
sysfs_update_group(acpi_kobj, &platform_profile_group);
672+
profile_notify_legacy();
673+
profile_update_legacy();
644674
}
645675
EXPORT_SYMBOL_GPL(platform_profile_remove);
646676

@@ -695,16 +725,28 @@ static int __init platform_profile_init(void)
695725
if (err)
696726
return err;
697727

698-
err = sysfs_create_group(acpi_kobj, &platform_profile_group);
699-
if (err)
700-
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+
}
701741

702-
return err;
742+
return 0;
703743
}
704744

705745
static void __exit platform_profile_exit(void)
706746
{
707-
sysfs_remove_group(acpi_kobj, &platform_profile_group);
747+
if (acpi_kobj)
748+
sysfs_remove_group(acpi_kobj, &platform_profile_group);
749+
708750
class_unregister(&platform_profile_class);
709751
}
710752
module_init(platform_profile_init);

drivers/hid/Kconfig

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

598598
config HID_LENOVO
599599
tristate "Lenovo / Thinkpad devices"
600-
depends on ACPI
601-
select ACPI_PLATFORM_PROFILE
600+
select ACPI_PLATFORM_PROFILE if ACPI
602601
select NEW_LEDS
603602
select LEDS_CLASS
604603
help

drivers/hid/hid-lenovo.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,11 @@ static int lenovo_raw_event_TP_X12_tab(struct hid_device *hdev, u32 raw_data)
734734
report_key_event(input, KEY_RFKILL);
735735
return 1;
736736
}
737-
platform_profile_cycle();
738-
return 1;
737+
if (IS_ENABLED(CONFIG_ACPI_PLATFORM_PROFILE)) {
738+
platform_profile_cycle();
739+
return 1;
740+
}
741+
return 0;
739742
case TP_X12_RAW_HOTKEY_FN_F10:
740743
/* TAB1 has PICKUP Phone and TAB2 use Snipping tool*/
741744
(hdev->product == USB_DEVICE_ID_LENOVO_X12_TAB) ?

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)