drivers/video/backlight/platform_lcd.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/platform_lcd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/platform_lcd.c- Extension
.c- Size
- 3151 bytes
- Lines
- 143
- Domain
- Driver Families
- Bucket
- drivers/video
- 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/module.hlinux/platform_device.hlinux/lcd.hlinux/slab.hvideo/platform_lcd.h
Detected Declarations
struct platform_lcdfunction platform_lcd_get_powerfunction platform_lcd_set_powerfunction platform_lcd_controls_devicefunction platform_lcd_probefunction platform_lcd_suspendfunction platform_lcd_resume
Annotated Snippet
struct platform_lcd {
struct device *us;
struct lcd_device *lcd;
struct plat_lcd_data *pdata;
unsigned int power;
unsigned int suspended:1;
};
static inline struct platform_lcd *to_our_lcd(struct lcd_device *lcd)
{
return lcd_get_data(lcd);
}
static int platform_lcd_get_power(struct lcd_device *lcd)
{
struct platform_lcd *plcd = to_our_lcd(lcd);
return plcd->power;
}
static int platform_lcd_set_power(struct lcd_device *lcd, int power)
{
struct platform_lcd *plcd = to_our_lcd(lcd);
int lcd_power = 1;
if (power == LCD_POWER_OFF || plcd->suspended)
lcd_power = 0;
plcd->pdata->set_power(plcd->pdata, lcd_power);
plcd->power = power;
return 0;
}
static bool platform_lcd_controls_device(struct lcd_device *lcd, struct device *display_device)
{
struct platform_lcd *plcd = to_our_lcd(lcd);
return plcd->us->parent == display_device;
}
static const struct lcd_ops platform_lcd_ops = {
.get_power = platform_lcd_get_power,
.set_power = platform_lcd_set_power,
.controls_device = platform_lcd_controls_device,
};
static int platform_lcd_probe(struct platform_device *pdev)
{
struct plat_lcd_data *pdata;
struct platform_lcd *plcd;
struct device *dev = &pdev->dev;
int err;
pdata = dev_get_platdata(&pdev->dev);
if (!pdata) {
dev_err(dev, "no platform data supplied\n");
return -EINVAL;
}
if (pdata->probe) {
err = pdata->probe(pdata);
if (err)
return err;
}
plcd = devm_kzalloc(&pdev->dev, sizeof(struct platform_lcd),
GFP_KERNEL);
if (!plcd)
return -ENOMEM;
plcd->us = dev;
plcd->pdata = pdata;
plcd->lcd = devm_lcd_device_register(&pdev->dev, dev_name(dev), dev,
plcd, &platform_lcd_ops);
if (IS_ERR(plcd->lcd)) {
dev_err(dev, "cannot register lcd device\n");
return PTR_ERR(plcd->lcd);
}
platform_set_drvdata(pdev, plcd);
platform_lcd_set_power(plcd->lcd, LCD_POWER_REDUCED);
return 0;
}
#ifdef CONFIG_PM_SLEEP
static int platform_lcd_suspend(struct device *dev)
{
Annotation
- Immediate include surface: `linux/module.h`, `linux/platform_device.h`, `linux/lcd.h`, `linux/slab.h`, `video/platform_lcd.h`.
- Detected declarations: `struct platform_lcd`, `function platform_lcd_get_power`, `function platform_lcd_set_power`, `function platform_lcd_controls_device`, `function platform_lcd_probe`, `function platform_lcd_suspend`, `function platform_lcd_resume`.
- Atlas domain: Driver Families / drivers/video.
- 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.