drivers/net/ethernet/intel/igc/igc_leds.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/igc/igc_leds.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/igc/igc_leds.c- Extension
.c- Size
- 7795 bytes
- Lines
- 303
- Domain
- Driver Families
- Bucket
- drivers/net
- 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/bits.hlinux/leds.hlinux/netdevice.hlinux/pm_runtime.huapi/linux/uleds.higc.h
Detected Declarations
struct igc_led_classdevfunction igc_led_selectfunction igc_led_setfunction igc_led_getfunction igc_led_brightness_set_blockingfunction igc_led_hw_control_is_supportedfunction igc_led_hw_control_setfunction igc_led_hw_control_getfunction igc_led_get_namefunction igc_setup_ldevfunction igc_led_setupfunction igc_led_free
Annotated Snippet
struct igc_led_classdev {
struct net_device *netdev;
struct led_classdev led;
int index;
};
#define lcdev_to_igc_ldev(lcdev) \
container_of(lcdev, struct igc_led_classdev, led)
static void igc_led_select(struct igc_adapter *adapter, int led,
u32 *mask, u32 *shift, u32 *blink)
{
switch (led) {
case 0:
*mask = IGC_LEDCTL_LED0_MODE_MASK;
*shift = IGC_LEDCTL_LED0_MODE_SHIFT;
*blink = IGC_LEDCTL_LED0_BLINK;
break;
case 1:
*mask = IGC_LEDCTL_LED1_MODE_MASK;
*shift = IGC_LEDCTL_LED1_MODE_SHIFT;
*blink = IGC_LEDCTL_LED1_BLINK;
break;
case 2:
*mask = IGC_LEDCTL_LED2_MODE_MASK;
*shift = IGC_LEDCTL_LED2_MODE_SHIFT;
*blink = IGC_LEDCTL_LED2_BLINK;
break;
default:
*mask = *shift = *blink = 0;
netdev_err(adapter->netdev, "Unknown LED %d selected!\n", led);
}
}
static void igc_led_set(struct igc_adapter *adapter, int led, u32 mode,
bool blink)
{
u32 shift, mask, blink_bit, ledctl;
struct igc_hw *hw = &adapter->hw;
igc_led_select(adapter, led, &mask, &shift, &blink_bit);
pm_runtime_get_sync(&adapter->pdev->dev);
mutex_lock(&adapter->led_mutex);
/* Set mode */
ledctl = rd32(IGC_LEDCTL);
ledctl &= ~mask;
ledctl |= mode << shift;
/* Configure blinking */
if (blink)
ledctl |= blink_bit;
else
ledctl &= ~blink_bit;
wr32(IGC_LEDCTL, ledctl);
mutex_unlock(&adapter->led_mutex);
pm_runtime_put(&adapter->pdev->dev);
}
static u32 igc_led_get(struct igc_adapter *adapter, int led)
{
u32 shift, mask, blink_bit, ledctl;
struct igc_hw *hw = &adapter->hw;
igc_led_select(adapter, led, &mask, &shift, &blink_bit);
pm_runtime_get_sync(&adapter->pdev->dev);
mutex_lock(&adapter->led_mutex);
ledctl = rd32(IGC_LEDCTL);
mutex_unlock(&adapter->led_mutex);
pm_runtime_put(&adapter->pdev->dev);
return (ledctl & mask) >> shift;
}
static int igc_led_brightness_set_blocking(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
struct igc_led_classdev *ldev = lcdev_to_igc_ldev(led_cdev);
struct igc_adapter *adapter = netdev_priv(ldev->netdev);
u32 mode;
if (brightness)
mode = IGC_LEDCTL_MODE_ON;
else
mode = IGC_LEDCTL_MODE_OFF;
netdev_dbg(adapter->netdev, "Set brightness for LED %d to mode %u!\n",
Annotation
- Immediate include surface: `linux/bits.h`, `linux/leds.h`, `linux/netdevice.h`, `linux/pm_runtime.h`, `uapi/linux/uleds.h`, `igc.h`.
- Detected declarations: `struct igc_led_classdev`, `function igc_led_select`, `function igc_led_set`, `function igc_led_get`, `function igc_led_brightness_set_blocking`, `function igc_led_hw_control_is_supported`, `function igc_led_hw_control_set`, `function igc_led_hw_control_get`, `function igc_led_get_name`, `function igc_setup_ldev`.
- Atlas domain: Driver Families / drivers/net.
- 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.