drivers/macintosh/via-pmu-led.c
Source file repositories/reference/linux-study-clean/drivers/macintosh/via-pmu-led.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/macintosh/via-pmu-led.c- Extension
.c- Size
- 3199 bytes
- Lines
- 119
- Domain
- Driver Families
- Bucket
- drivers/macintosh
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/kernel.hlinux/device.hlinux/leds.hlinux/adb.hlinux/pmu.hlinux/of.h
Detected Declarations
function pmu_req_donefunction pmu_led_setfunction via_pmu_led_init
Annotated Snippet
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/leds.h>
#include <linux/adb.h>
#include <linux/pmu.h>
#include <linux/of.h>
static spinlock_t pmu_blink_lock;
static struct adb_request pmu_blink_req;
/* -1: no change, 0: request off, 1: request on */
static int requested_change;
static void pmu_req_done(struct adb_request * req)
{
unsigned long flags;
spin_lock_irqsave(&pmu_blink_lock, flags);
/* if someone requested a change in the meantime
* (we only see the last one which is fine)
* then apply it now */
if (requested_change != -1 && !pmu_sys_suspended)
pmu_request(&pmu_blink_req, NULL, 4, 0xee, 4, 0, requested_change);
/* reset requested change */
requested_change = -1;
spin_unlock_irqrestore(&pmu_blink_lock, flags);
}
static void pmu_led_set(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
unsigned long flags;
spin_lock_irqsave(&pmu_blink_lock, flags);
switch (brightness) {
case LED_OFF:
requested_change = 0;
break;
case LED_FULL:
requested_change = 1;
break;
default:
goto out;
break;
}
/* if request isn't done, then don't do anything */
if (pmu_blink_req.complete && !pmu_sys_suspended)
pmu_request(&pmu_blink_req, NULL, 4, 0xee, 4, 0, requested_change);
out:
spin_unlock_irqrestore(&pmu_blink_lock, flags);
}
static struct led_classdev pmu_led = {
.name = "pmu-led::front",
#ifdef CONFIG_ADB_PMU_LED_DISK
.default_trigger = "disk-activity",
#endif
.brightness_set = pmu_led_set,
};
static int __init via_pmu_led_init(void)
{
struct device_node *dt;
const char *model;
/* only do this on keylargo based models */
if (pmu_get_model() != PMU_KEYLARGO_BASED)
return -ENODEV;
dt = of_find_node_by_path("/");
if (dt == NULL)
return -ENODEV;
model = of_get_property(dt, "model", NULL);
if (!model)
goto put_node;
if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 &&
strncmp(model, "iBook", strlen("iBook")) != 0 &&
strcmp(model, "PowerMac7,2") != 0 &&
strcmp(model, "PowerMac7,3") != 0)
goto put_node;
of_node_put(dt);
spin_lock_init(&pmu_blink_lock);
/* no outstanding req */
pmu_blink_req.complete = 1;
pmu_blink_req.done = pmu_req_done;
return led_classdev_register(NULL, &pmu_led);
Annotation
- Immediate include surface: `linux/types.h`, `linux/kernel.h`, `linux/device.h`, `linux/leds.h`, `linux/adb.h`, `linux/pmu.h`, `linux/of.h`.
- Detected declarations: `function pmu_req_done`, `function pmu_led_set`, `function via_pmu_led_init`.
- Atlas domain: Driver Families / drivers/macintosh.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.