drivers/leds/flash/leds-as3645a.c
Source file repositories/reference/linux-study-clean/drivers/leds/flash/leds-as3645a.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/flash/leds-as3645a.c- Extension
.c- Size
- 19798 bytes
- Lines
- 771
- 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.
- 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/delay.hlinux/gpio/consumer.hlinux/i2c.hlinux/led-class-flash.hlinux/leds.hlinux/module.hlinux/mutex.hlinux/property.hlinux/slab.hmedia/v4l2-flash-led-class.h
Detected Declarations
struct as3645a_configstruct as3645aenum as_modefunction as3645a_writefunction as3645a_readfunction as3645a_set_currentfunction as3645a_set_timeoutfunction as3645a_set_controlfunction as3645a_get_faultfunction __as3645a_current_to_regfunction as3645a_current_to_regfunction as3645a_set_indicator_brightnessfunction as3645a_set_assist_brightnessfunction as3645a_set_flash_brightnessfunction as3645a_set_flash_timeoutfunction as3645a_set_strobefunction as3645a_setupfunction as3645a_detectfunction as3645a_parse_nodefunction device_for_each_child_node_scopedfunction as3645a_led_class_setupfunction as3645a_v4l2_setupfunction as3645a_probefunction as3645a_remove
Annotated Snippet
struct as3645a_config {
u32 flash_timeout_us;
u32 flash_max_ua;
u32 assist_max_ua;
u32 indicator_max_ua;
u32 voltage_reference;
u32 peak;
};
struct as3645a {
struct i2c_client *client;
struct mutex mutex;
struct led_classdev_flash fled;
struct led_classdev iled_cdev;
struct v4l2_flash *vf;
struct v4l2_flash *vfind;
struct fwnode_handle *flash_node;
struct fwnode_handle *indicator_node;
struct as3645a_config cfg;
enum as_mode mode;
unsigned int timeout;
unsigned int flash_current;
unsigned int assist_current;
unsigned int indicator_current;
enum v4l2_flash_strobe_source strobe_source;
};
#define fled_to_as3645a(__fled) container_of(__fled, struct as3645a, fled)
#define iled_cdev_to_as3645a(__iled_cdev) \
container_of(__iled_cdev, struct as3645a, iled_cdev)
/* Return negative errno else zero on success */
static int as3645a_write(struct as3645a *flash, u8 addr, u8 val)
{
struct i2c_client *client = flash->client;
int rval;
rval = i2c_smbus_write_byte_data(client, addr, val);
dev_dbg(&client->dev, "Write Addr:%02X Val:%02X %s\n", addr, val,
rval < 0 ? "fail" : "ok");
return rval;
}
/* Return negative errno else a data byte received from the device. */
static int as3645a_read(struct as3645a *flash, u8 addr)
{
struct i2c_client *client = flash->client;
int rval;
rval = i2c_smbus_read_byte_data(client, addr);
dev_dbg(&client->dev, "Read Addr:%02X Val:%02X %s\n", addr, rval,
rval < 0 ? "fail" : "ok");
return rval;
}
/* -----------------------------------------------------------------------------
* Hardware configuration and trigger
*/
/**
* as3645a_set_current - Set flash configuration registers
* @flash: The flash
*
* Configure the hardware with flash, assist and indicator currents, as well as
* flash timeout.
*
* Return 0 on success, or a negative error code if an I2C communication error
* occurred.
*/
static int as3645a_set_current(struct as3645a *flash)
{
u8 val;
val = (flash->flash_current << AS_CURRENT_FLASH_CURRENT_SHIFT)
| (flash->assist_current << AS_CURRENT_ASSIST_LIGHT_SHIFT)
| AS_CURRENT_LED_DET_ON;
return as3645a_write(flash, AS_CURRENT_SET_REG, val);
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/led-class-flash.h`, `linux/leds.h`, `linux/module.h`, `linux/mutex.h`, `linux/property.h`.
- Detected declarations: `struct as3645a_config`, `struct as3645a`, `enum as_mode`, `function as3645a_write`, `function as3645a_read`, `function as3645a_set_current`, `function as3645a_set_timeout`, `function as3645a_set_control`, `function as3645a_get_fault`, `function __as3645a_current_to_reg`.
- Atlas domain: Driver Families / drivers/leds.
- Implementation status: source implementation candidate.
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.