drivers/leds/leds-aw200xx.c
Source file repositories/reference/linux-study-clean/drivers/leds/leds-aw200xx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/leds-aw200xx.c- Extension
.c- Size
- 17496 bytes
- Lines
- 670
- 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/bitfield.hlinux/bits.hlinux/container_of.hlinux/gpio/consumer.hlinux/i2c.hlinux/leds.hlinux/mod_devicetable.hlinux/module.hlinux/mutex.hlinux/regmap.hlinux/time.hlinux/units.h
Detected Declarations
struct aw200xx_chipdefstruct aw200xx_ledstruct aw200xxfunction dim_showfunction dim_storefunction aw200xx_brightness_setfunction aw200xx_imax_from_globalfunction aw200xx_imax_to_globalfunction aw200xx_set_imaxfunction aw200xx_chip_resetfunction aw200xx_chip_initfunction aw200xx_chip_checkfunction aw200xx_enablefunction aw200xx_disablefunction aw200xx_probe_get_display_rowsfunction device_for_each_child_nodefunction aw200xx_probe_fwfunction device_for_each_child_node_scopedfunction aw200xx_chip_reset_actionfunction aw200xx_disable_actionfunction aw200xx_probe
Annotated Snippet
struct aw200xx_chipdef {
u32 channels;
u32 display_size_rows_max;
u32 display_size_columns;
};
struct aw200xx_led {
struct led_classdev cdev;
struct aw200xx *chip;
int dim;
u32 num;
};
struct aw200xx {
const struct aw200xx_chipdef *cdef;
struct i2c_client *client;
struct regmap *regmap;
struct mutex mutex;
u32 num_leds;
u32 display_rows;
struct gpio_desc *hwen;
struct aw200xx_led leds[] __counted_by(num_leds);
};
static ssize_t dim_show(struct device *dev, struct device_attribute *devattr,
char *buf)
{
struct led_classdev *cdev = dev_get_drvdata(dev);
struct aw200xx_led *led = container_of(cdev, struct aw200xx_led, cdev);
int dim = led->dim;
if (dim < 0)
return sysfs_emit(buf, "auto\n");
return sysfs_emit(buf, "%d\n", dim);
}
static ssize_t dim_store(struct device *dev, struct device_attribute *devattr,
const char *buf, size_t count)
{
struct led_classdev *cdev = dev_get_drvdata(dev);
struct aw200xx_led *led = container_of(cdev, struct aw200xx_led, cdev);
struct aw200xx *chip = led->chip;
u32 columns = chip->cdef->display_size_columns;
int dim;
ssize_t ret;
if (sysfs_streq(buf, "auto")) {
dim = -1;
} else {
ret = kstrtoint(buf, 0, &dim);
if (ret)
return ret;
if (dim > AW200XX_DIM_MAX)
return -EINVAL;
}
mutex_lock(&chip->mutex);
if (dim >= 0) {
ret = regmap_write(chip->regmap,
AW200XX_REG_DIM_PAGE1(led->num, columns),
dim);
if (ret)
goto out_unlock;
}
led->dim = dim;
ret = count;
out_unlock:
mutex_unlock(&chip->mutex);
return ret;
}
static DEVICE_ATTR_RW(dim);
static struct attribute *dim_attrs[] = {
&dev_attr_dim.attr,
NULL
};
ATTRIBUTE_GROUPS(dim);
static int aw200xx_brightness_set(struct led_classdev *cdev,
enum led_brightness brightness)
{
struct aw200xx_led *led = container_of(cdev, struct aw200xx_led, cdev);
struct aw200xx *chip = led->chip;
int dim;
u32 reg;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/container_of.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/leds.h`, `linux/mod_devicetable.h`, `linux/module.h`.
- Detected declarations: `struct aw200xx_chipdef`, `struct aw200xx_led`, `struct aw200xx`, `function dim_show`, `function dim_store`, `function aw200xx_brightness_set`, `function aw200xx_imax_from_global`, `function aw200xx_imax_to_global`, `function aw200xx_set_imax`, `function aw200xx_chip_reset`.
- 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.