drivers/leds/flash/leds-mt6360.c
Source file repositories/reference/linux-study-clean/drivers/leds/flash/leds-mt6360.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/flash/leds-mt6360.c- Extension
.c- Size
- 22924 bytes
- Lines
- 896
- 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/bitops.hlinux/delay.hlinux/init.hlinux/interrupt.hlinux/kernel.hlinux/led-class-flash.hlinux/led-class-multicolor.hlinux/module.hlinux/mutex.hlinux/platform_device.hlinux/property.hlinux/regmap.hmedia/v4l2-flash-led-class.h
Detected Declarations
struct mt6360_ledstruct mt6360_privfunction mt6360_mc_brightness_setfunction mt6360_isnk_brightness_setfunction mt6360_torch_brightness_setfunction mt6360_flash_brightness_setfunction _mt6360_flash_brightness_setfunction mt6360_strobe_setfunction mt6360_strobe_getfunction mt6360_timeout_setfunction mt6360_fault_getfunction mt6360_isnk_init_default_statefunction mt6360_flash_init_default_statefunction mt6360_flash_external_strobe_setfunction mt6360_init_v4l2_flash_configfunction mt6360_init_v4l2_flash_configfunction clamp_alignfunction mt6360_init_isnk_propertiesfunction fwnode_for_each_child_nodefunction mt6360_init_flash_propertiesfunction mt6360_v4l2_flash_releasefunction mt6360_led_probefunction device_for_each_child_node_scopedfunction mt6360_led_remove
Annotated Snippet
struct mt6360_led {
union {
struct led_classdev isnk;
struct led_classdev_mc mc;
struct led_classdev_flash flash;
};
struct v4l2_flash *v4l2_flash;
struct mt6360_priv *priv;
u32 led_no;
enum led_default_state default_state;
};
struct mt6360_priv {
struct device *dev;
struct regmap *regmap;
struct mutex lock;
unsigned int fled_strobe_used;
unsigned int fled_torch_used;
unsigned int leds_active;
unsigned int leds_count;
struct mt6360_led leds[] __counted_by(leds_count);
};
static int mt6360_mc_brightness_set(struct led_classdev *lcdev,
enum led_brightness level)
{
struct led_classdev_mc *mccdev = lcdev_to_mccdev(lcdev);
struct mt6360_led *led = container_of(mccdev, struct mt6360_led, mc);
struct mt6360_priv *priv = led->priv;
u32 real_bright, enable_mask = 0, enable = 0;
int i, ret;
mutex_lock(&priv->lock);
led_mc_calc_color_components(mccdev, level);
for (i = 0; i < mccdev->num_colors; i++) {
struct mc_subled *subled = mccdev->subled_info + i;
real_bright = min(lcdev->max_brightness, subled->brightness);
ret = regmap_update_bits(priv->regmap, MT6360_REG_ISNK(i),
MT6360_ISNK_MASK, real_bright);
if (ret)
goto out;
enable_mask |= MT6360_ISNK_ENMASK(subled->channel);
if (real_bright)
enable |= MT6360_ISNK_ENMASK(subled->channel);
}
ret = regmap_update_bits(priv->regmap, MT6360_REG_RGBEN, enable_mask,
enable);
out:
mutex_unlock(&priv->lock);
return ret;
}
static int mt6360_isnk_brightness_set(struct led_classdev *lcdev,
enum led_brightness level)
{
struct mt6360_led *led = container_of(lcdev, struct mt6360_led, isnk);
struct mt6360_priv *priv = led->priv;
u32 enable_mask = MT6360_ISNK_ENMASK(led->led_no);
u32 val = level ? MT6360_ISNK_ENMASK(led->led_no) : 0;
int ret;
mutex_lock(&priv->lock);
ret = regmap_update_bits(priv->regmap, MT6360_REG_ISNK(led->led_no),
MT6360_ISNK_MASK, level);
if (ret)
goto out;
ret = regmap_update_bits(priv->regmap, MT6360_REG_RGBEN, enable_mask,
val);
out:
mutex_unlock(&priv->lock);
return ret;
}
static int mt6360_torch_brightness_set(struct led_classdev *lcdev,
enum led_brightness level)
{
struct mt6360_led *led =
container_of(lcdev, struct mt6360_led, flash.led_cdev);
struct mt6360_priv *priv = led->priv;
u32 enable_mask = MT6360_TORCHEN_MASK | MT6360_FLCSEN_MASK(led->led_no);
u32 val = level ? MT6360_FLCSEN_MASK(led->led_no) : 0;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/delay.h`, `linux/init.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/led-class-flash.h`, `linux/led-class-multicolor.h`, `linux/module.h`.
- Detected declarations: `struct mt6360_led`, `struct mt6360_priv`, `function mt6360_mc_brightness_set`, `function mt6360_isnk_brightness_set`, `function mt6360_torch_brightness_set`, `function mt6360_flash_brightness_set`, `function _mt6360_flash_brightness_set`, `function mt6360_strobe_set`, `function mt6360_strobe_get`, `function mt6360_timeout_set`.
- 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.