drivers/leds/flash/leds-max77693.c
Source file repositories/reference/linux-study-clean/drivers/leds/flash/leds-max77693.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/flash/leds-max77693.c- Extension
.c- Size
- 27597 bytes
- Lines
- 1058
- 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/led-class-flash.hlinux/mfd/max77693.hlinux/mfd/max77693-common.hlinux/mfd/max77693-private.hlinux/module.hlinux/mutex.hlinux/platform_device.hlinux/regmap.hlinux/slab.hmedia/v4l2-flash-led-class.h
Detected Declarations
struct max77693_led_config_datastruct max77693_sub_ledstruct max77693_led_deviceenum max77693_fledenum max77693_led_modefunction max77693_led_iout_to_regfunction max77693_flash_timeout_to_regfunction max77693_led_vsys_to_regfunction max77693_led_vout_to_regfunction max77693_fled_usedfunction max77693_set_mode_regfunction max77693_add_modefunction max77693_clear_modefunction max77693_add_allowed_modesfunction max77693_distribute_currentsfunction max77693_set_torch_currentfunction max77693_set_flash_currentfunction max77693_set_timeoutfunction max77693_get_strobe_statusfunction max77693_get_flash_faultsfunction max77693_setupfunction max77693_led_brightness_setfunction max77693_led_flash_brightness_setfunction max77693_led_flash_strobe_setfunction max77693_led_flash_fault_getfunction max77693_led_flash_strobe_getfunction max77693_led_flash_timeout_setfunction max77693_led_parse_dtfunction for_each_available_child_of_node_scopedfunction clamp_alignfunction max77693_align_iout_currentfunction max77693_led_validate_configurationfunction max77693_led_get_configurationfunction max77693_init_flash_settingsfunction max77693_led_external_strobe_setfunction max77693_init_v4l2_flash_configfunction max77693_init_v4l2_flash_configfunction max77693_init_fled_cdevfunction max77693_register_ledfunction max77693_led_probefunction max77693_led_remove
Annotated Snippet
struct max77693_led_config_data {
const char *label[2];
u32 iout_torch_max[2];
u32 iout_flash_max[2];
u32 flash_timeout_max[2];
u32 num_leds;
u32 boost_mode;
u32 boost_vout;
u32 low_vsys;
};
struct max77693_sub_led {
/* corresponding FLED output identifier */
int fled_id;
/* corresponding LED Flash class device */
struct led_classdev_flash fled_cdev;
/* V4L2 Flash device */
struct v4l2_flash *v4l2_flash;
/* brightness cache */
unsigned int torch_brightness;
/* flash timeout cache */
unsigned int flash_timeout;
/* flash faults that may have occurred */
u32 flash_faults;
};
struct max77693_led_device {
/* parent mfd regmap */
struct regmap *regmap;
/* platform device data */
struct platform_device *pdev;
/* secures access to the device */
struct mutex lock;
/* sub led data */
struct max77693_sub_led sub_leds[2];
/* maximum torch current values for FLED outputs */
u32 iout_torch_max[2];
/* maximum flash current values for FLED outputs */
u32 iout_flash_max[2];
/* current flash timeout cache */
unsigned int current_flash_timeout;
/* ITORCH register cache */
u8 torch_iout_reg;
/* mode of fled outputs */
unsigned int mode_flags;
/* recently strobed fled */
int strobing_sub_led_id;
/* bitmask of FLED outputs use state (bit 0. - FLED1, bit 1. - FLED2) */
u8 fled_mask;
/* FLED modes that can be set */
u8 allowed_modes;
/* arrangement of current outputs */
bool iout_joint;
};
static u8 max77693_led_iout_to_reg(u32 ua)
{
if (ua < FLASH_IOUT_MIN)
ua = FLASH_IOUT_MIN;
return (ua - FLASH_IOUT_MIN) / FLASH_IOUT_STEP;
}
static u8 max77693_flash_timeout_to_reg(u32 us)
{
return (us - FLASH_TIMEOUT_MIN) / FLASH_TIMEOUT_STEP;
}
static inline struct max77693_sub_led *flcdev_to_sub_led(
struct led_classdev_flash *fled_cdev)
{
return container_of(fled_cdev, struct max77693_sub_led, fled_cdev);
}
static inline struct max77693_led_device *sub_led_to_led(
struct max77693_sub_led *sub_led)
{
return container_of(sub_led, struct max77693_led_device,
sub_leds[sub_led->fled_id]);
}
static inline u8 max77693_led_vsys_to_reg(u32 mv)
{
return ((mv - MAX_FLASH1_VSYS_MIN) / MAX_FLASH1_VSYS_STEP) << 2;
}
Annotation
- Immediate include surface: `linux/led-class-flash.h`, `linux/mfd/max77693.h`, `linux/mfd/max77693-common.h`, `linux/mfd/max77693-private.h`, `linux/module.h`, `linux/mutex.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct max77693_led_config_data`, `struct max77693_sub_led`, `struct max77693_led_device`, `enum max77693_fled`, `enum max77693_led_mode`, `function max77693_led_iout_to_reg`, `function max77693_flash_timeout_to_reg`, `function max77693_led_vsys_to_reg`, `function max77693_led_vout_to_reg`, `function max77693_fled_used`.
- 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.