drivers/leds/leds-ss4200.c
Source file repositories/reference/linux-study-clean/drivers/leds/leds-ss4200.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/leds-ss4200.c- Extension
.c- Size
- 14456 bytes
- Lines
- 561
- Domain
- Driver Families
- Bucket
- drivers/leds
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/dmi.hlinux/init.hlinux/ioport.hlinux/kernel.hlinux/leds.hlinux/module.hlinux/pci.hlinux/types.hlinux/uaccess.h
Detected Declarations
struct nasgpio_ledfunction ss4200_led_dmi_callbackfunction led_classdev_to_nasgpio_ledfunction __nasgpio_led_set_attrfunction nasgpio_led_set_attrfunction nasgpio_led_get_attrfunction nasgpio_led_set_brightnessfunction nasgpio_led_set_blinkfunction ich7_gpio_initfunction ich7_lpc_cleanupfunction ich7_lpc_probefunction ich7_lpc_removefunction set_power_light_amber_noblinkfunction blink_showfunction blink_storefunction register_nasgpio_ledfunction unregister_nasgpio_ledfunction nas_gpio_initfunction nas_gpio_exitmodule init nas_gpio_init
Annotated Snippet
static struct pci_driver nas_gpio_pci_driver = {
.name = KBUILD_MODNAME,
.id_table = ich7_lpc_pci_id,
.probe = ich7_lpc_probe,
.remove = ich7_lpc_remove,
};
static struct led_classdev *get_classdev_for_led_nr(int nr)
{
struct nasgpio_led *nas_led = &nasgpio_leds[nr];
struct led_classdev *led = &nas_led->led_cdev;
return led;
}
static void set_power_light_amber_noblink(void)
{
struct nasgpio_led *amber = get_led_named("power:amber:power");
struct nasgpio_led *blue = get_led_named("power:blue:power");
if (!amber || !blue)
return;
/*
* LED_OFF implies disabling future blinking
*/
pr_debug("setting blue off and amber on\n");
nasgpio_led_set_brightness(&blue->led_cdev, LED_OFF);
nasgpio_led_set_brightness(&amber->led_cdev, LED_FULL);
}
static ssize_t blink_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct led_classdev *led = dev_get_drvdata(dev);
int blinking = 0;
if (nasgpio_led_get_attr(led, GPO_BLINK))
blinking = 1;
return sprintf(buf, "%d\n", blinking);
}
static ssize_t blink_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{
int ret;
struct led_classdev *led = dev_get_drvdata(dev);
unsigned long blink_state;
ret = kstrtoul(buf, 10, &blink_state);
if (ret)
return ret;
nasgpio_led_set_attr(led, GPO_BLINK, blink_state);
return size;
}
static DEVICE_ATTR_RW(blink);
static struct attribute *nasgpio_led_attrs[] = {
&dev_attr_blink.attr,
NULL
};
ATTRIBUTE_GROUPS(nasgpio_led);
static int register_nasgpio_led(int led_nr)
{
struct nasgpio_led *nas_led = &nasgpio_leds[led_nr];
struct led_classdev *led = get_classdev_for_led_nr(led_nr);
led->name = nas_led->name;
led->brightness = LED_OFF;
if (nasgpio_led_get_attr(led, GP_LVL))
led->brightness = LED_FULL;
led->brightness_set = nasgpio_led_set_brightness;
led->blink_set = nasgpio_led_set_blink;
led->groups = nasgpio_led_groups;
return led_classdev_register(&nas_gpio_pci_dev->dev, led);
}
static void unregister_nasgpio_led(int led_nr)
{
struct led_classdev *led = get_classdev_for_led_nr(led_nr);
led_classdev_unregister(led);
}
/*
* module load/initialization
*/
Annotation
- Immediate include surface: `linux/dmi.h`, `linux/init.h`, `linux/ioport.h`, `linux/kernel.h`, `linux/leds.h`, `linux/module.h`, `linux/pci.h`, `linux/types.h`.
- Detected declarations: `struct nasgpio_led`, `function ss4200_led_dmi_callback`, `function led_classdev_to_nasgpio_led`, `function __nasgpio_led_set_attr`, `function nasgpio_led_set_attr`, `function nasgpio_led_get_attr`, `function nasgpio_led_set_brightness`, `function nasgpio_led_set_blink`, `function ich7_gpio_init`, `function ich7_lpc_cleanup`.
- Atlas domain: Driver Families / drivers/leds.
- Implementation status: pattern 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.