drivers/staging/greybus/light.c
Source file repositories/reference/linux-study-clean/drivers/staging/greybus/light.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/greybus/light.c- Extension
.c- Size
- 33384 bytes
- Lines
- 1345
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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/kernel.hlinux/leds.hlinux/led-class-flash.hlinux/module.hlinux/slab.hlinux/greybus.hmedia/v4l2-flash-led-class.h
Detected Declarations
struct gb_channelstruct gb_lightstruct gb_lightsfunction is_channel_flashfunction __gb_lights_flash_intensity_setfunction __gb_lights_flash_brightness_setfunction led_lockfunction led_unlockfunction color_showfunction color_storefunction channel_attr_groups_setfunction gb_lights_fade_setfunction gb_lights_color_setfunction __gb_lights_led_brightness_setfunction __gb_lights_brightness_setfunction gb_brightness_setfunction gb_brightness_getfunction gb_blink_setfunction gb_lights_led_operations_setfunction __gb_lights_channel_v4l2_configfunction gb_lights_light_v4l2_registerfunction gb_lights_light_v4l2_unregisterfunction gb_lights_light_v4l2_registerfunction gb_lights_light_v4l2_unregisterfunction gb_lights_flash_intensity_getfunction gb_lights_flash_strobe_setfunction gb_lights_flash_strobe_getfunction gb_lights_flash_timeout_setfunction gb_lights_flash_fault_getfunction __gb_lights_channel_torch_attachfunction __gb_lights_flash_led_registerfunction __gb_lights_flash_led_unregisterfunction gb_lights_channel_flash_configfunction gb_lights_channel_flash_configfunction __gb_lights_flash_led_registerfunction __gb_lights_flash_led_unregisterfunction gb_lights_channel_registerfunction __gb_lights_led_unregisterfunction gb_lights_channel_unregisterfunction gb_lights_channel_configfunction gb_lights_light_configfunction gb_lights_light_registerfunction gb_lights_channel_freefunction gb_lights_channel_releasefunction gb_lights_light_releasefunction gb_lights_releasefunction gb_lights_get_countfunction gb_lights_create_all
Annotated Snippet
struct gb_channel {
u8 id;
u32 flags;
u32 color;
char *color_name;
u8 fade_in;
u8 fade_out;
u32 mode;
char *mode_name;
struct attribute **attrs;
struct attribute_group *attr_group;
const struct attribute_group **attr_groups;
struct led_classdev *led;
struct led_classdev_flash fled;
struct led_flash_setting intensity_uA;
struct led_flash_setting timeout_us;
struct gb_light *light;
bool is_registered;
bool releasing;
bool strobe_state;
bool active;
struct mutex lock;
};
struct gb_light {
u8 id;
char *name;
struct gb_lights *glights;
u32 flags;
u8 channels_count;
struct gb_channel *channels;
bool has_flash;
bool ready;
#if IS_REACHABLE(CONFIG_V4L2_FLASH_LED_CLASS)
struct v4l2_flash *v4l2_flash;
struct v4l2_flash *v4l2_flash_ind;
#endif
};
struct gb_lights {
struct gb_connection *connection;
u8 lights_count;
struct gb_light *lights;
struct mutex lights_lock;
};
static void gb_lights_channel_free(struct gb_channel *channel);
static struct gb_connection *get_conn_from_channel(struct gb_channel *channel)
{
return channel->light->glights->connection;
}
static struct gb_connection *get_conn_from_light(struct gb_light *light)
{
return light->glights->connection;
}
static bool is_channel_flash(struct gb_channel *channel)
{
return !!(channel->mode & (GB_CHANNEL_MODE_FLASH | GB_CHANNEL_MODE_TORCH
| GB_CHANNEL_MODE_INDICATOR));
}
static struct gb_channel *get_channel_from_cdev(struct led_classdev *cdev)
{
struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(cdev);
return container_of(fled_cdev, struct gb_channel, fled);
}
static struct led_classdev *get_channel_cdev(struct gb_channel *channel)
{
return &channel->fled.led_cdev;
}
static struct gb_channel *get_channel_from_mode(struct gb_light *light,
u32 mode)
{
struct gb_channel *channel;
int i;
for (i = 0; i < light->channels_count; i++) {
channel = &light->channels[i];
if (channel->mode == mode)
return channel;
}
return NULL;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/leds.h`, `linux/led-class-flash.h`, `linux/module.h`, `linux/slab.h`, `linux/greybus.h`, `media/v4l2-flash-led-class.h`.
- Detected declarations: `struct gb_channel`, `struct gb_light`, `struct gb_lights`, `function is_channel_flash`, `function __gb_lights_flash_intensity_set`, `function __gb_lights_flash_brightness_set`, `function led_lock`, `function led_unlock`, `function color_show`, `function color_store`.
- Atlas domain: Driver Families / drivers/staging.
- 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.