drivers/leds/leds-netxbig.c
Source file repositories/reference/linux-study-clean/drivers/leds/leds-netxbig.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/leds-netxbig.c- Extension
.c- Size
- 15995 bytes
- Lines
- 657
- Domain
- Driver Families
- Bucket
- drivers/leds
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/irq.hlinux/slab.hlinux/spinlock.hlinux/platform_device.hlinux/gpio/consumer.hlinux/leds.hlinux/of.hlinux/of_platform.h
Detected Declarations
struct netxbig_gpio_extstruct netxbig_led_timerstruct netxbig_ledstruct netxbig_led_platform_datastruct netxbig_led_dataenum netxbig_led_modefunction gpio_ext_set_addrfunction gpio_ext_set_datafunction gpio_ext_enable_selectfunction gpio_ext_set_valuefunction netxbig_led_get_timer_modefunction netxbig_led_blink_setfunction netxbig_led_setfunction sata_storefunction sata_showfunction create_netxbig_ledfunction netxbig_gpio_ext_removefunction netxbig_gpio_ext_getfunction netxbig_leds_get_of_pdatafunction netxbig_led_probe
Annotated Snippet
struct netxbig_gpio_ext {
struct gpio_desc **addr;
int num_addr;
struct gpio_desc **data;
int num_data;
struct gpio_desc *enable;
};
enum netxbig_led_mode {
NETXBIG_LED_OFF,
NETXBIG_LED_ON,
NETXBIG_LED_SATA,
NETXBIG_LED_TIMER1,
NETXBIG_LED_TIMER2,
NETXBIG_LED_MODE_NUM,
};
#define NETXBIG_LED_INVALID_MODE NETXBIG_LED_MODE_NUM
struct netxbig_led_timer {
unsigned long delay_on;
unsigned long delay_off;
enum netxbig_led_mode mode;
};
struct netxbig_led {
const char *name;
const char *default_trigger;
int mode_addr;
int *mode_val;
int bright_addr;
int bright_max;
};
struct netxbig_led_platform_data {
struct netxbig_gpio_ext *gpio_ext;
struct netxbig_led_timer *timer;
int num_timer;
struct netxbig_led *leds;
int num_leds;
};
/*
* GPIO extension bus.
*/
static DEFINE_SPINLOCK(gpio_ext_lock);
static void gpio_ext_set_addr(struct netxbig_gpio_ext *gpio_ext, int addr)
{
int pin;
for (pin = 0; pin < gpio_ext->num_addr; pin++)
gpiod_set_value(gpio_ext->addr[pin], (addr >> pin) & 1);
}
static void gpio_ext_set_data(struct netxbig_gpio_ext *gpio_ext, int data)
{
int pin;
for (pin = 0; pin < gpio_ext->num_data; pin++)
gpiod_set_value(gpio_ext->data[pin], (data >> pin) & 1);
}
static void gpio_ext_enable_select(struct netxbig_gpio_ext *gpio_ext)
{
/* Enable select is done on the raising edge. */
gpiod_set_value(gpio_ext->enable, 0);
gpiod_set_value(gpio_ext->enable, 1);
}
static void gpio_ext_set_value(struct netxbig_gpio_ext *gpio_ext,
int addr, int value)
{
unsigned long flags;
spin_lock_irqsave(&gpio_ext_lock, flags);
gpio_ext_set_addr(gpio_ext, addr);
gpio_ext_set_data(gpio_ext, value);
gpio_ext_enable_select(gpio_ext);
spin_unlock_irqrestore(&gpio_ext_lock, flags);
}
/*
* Class LED driver.
*/
struct netxbig_led_data {
struct netxbig_gpio_ext *gpio_ext;
struct led_classdev cdev;
Annotation
- Immediate include surface: `linux/module.h`, `linux/irq.h`, `linux/slab.h`, `linux/spinlock.h`, `linux/platform_device.h`, `linux/gpio/consumer.h`, `linux/leds.h`, `linux/of.h`.
- Detected declarations: `struct netxbig_gpio_ext`, `struct netxbig_led_timer`, `struct netxbig_led`, `struct netxbig_led_platform_data`, `struct netxbig_led_data`, `enum netxbig_led_mode`, `function gpio_ext_set_addr`, `function gpio_ext_set_data`, `function gpio_ext_enable_select`, `function gpio_ext_set_value`.
- Atlas domain: Driver Families / drivers/leds.
- 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.