drivers/platform/x86/sel3350-platform.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/sel3350-platform.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/sel3350-platform.c- Extension
.c- Size
- 7151 bytes
- Lines
- 250
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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/acpi.hlinux/gpio/consumer.hlinux/gpio/machine.hlinux/leds.hlinux/module.hlinux/platform_device.hlinux/power_supply.h
Detected Declarations
struct sel3350_power_cfg_datastruct sel3350_datafunction sel3350_power_get_propertyfunction sel3350_probefunction sel3350_remove
Annotated Snippet
struct sel3350_power_cfg_data {
struct gpio_desc *ps_detect;
struct gpio_desc *ps_good;
};
static int sel3350_power_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct sel3350_power_cfg_data *data = power_supply_get_drvdata(psy);
switch (psp) {
case POWER_SUPPLY_PROP_HEALTH:
if (gpiod_get_value(data->ps_detect)) {
if (gpiod_get_value(data->ps_good))
val->intval = POWER_SUPPLY_HEALTH_GOOD;
else
val->intval = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
} else {
val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
}
break;
case POWER_SUPPLY_PROP_PRESENT:
val->intval = gpiod_get_value(data->ps_detect);
break;
case POWER_SUPPLY_PROP_ONLINE:
val->intval = gpiod_get_value(data->ps_good);
break;
default:
return -EINVAL;
}
return 0;
}
static const enum power_supply_property sel3350_power_properties[] = {
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_ONLINE,
};
static const struct power_supply_desc sel3350_ps_a_desc = {
.name = SEL_PS_A,
.type = POWER_SUPPLY_TYPE_MAINS,
.properties = sel3350_power_properties,
.num_properties = ARRAY_SIZE(sel3350_power_properties),
.get_property = sel3350_power_get_property,
};
static const struct power_supply_desc sel3350_ps_b_desc = {
.name = SEL_PS_B,
.type = POWER_SUPPLY_TYPE_MAINS,
.properties = sel3350_power_properties,
.num_properties = ARRAY_SIZE(sel3350_power_properties),
.get_property = sel3350_power_get_property,
};
struct sel3350_data {
struct platform_device *leds_pdev;
struct power_supply *ps_a;
struct power_supply *ps_b;
struct sel3350_power_cfg_data ps_a_cfg_data;
struct sel3350_power_cfg_data ps_b_cfg_data;
};
static int sel3350_probe(struct platform_device *pdev)
{
int rs;
struct sel3350_data *sel3350;
struct power_supply_config ps_cfg = {};
sel3350 = devm_kzalloc(&pdev->dev, sizeof(struct sel3350_data), GFP_KERNEL);
if (!sel3350)
return -ENOMEM;
platform_set_drvdata(pdev, sel3350);
gpiod_add_lookup_table(&sel3350_leds_table);
gpiod_add_lookup_table(&sel3350_gpios_table);
sel3350->leds_pdev = platform_device_register_data(
NULL,
"leds-gpio",
PLATFORM_DEVID_NONE,
&sel3350_leds_pdata,
sizeof(sel3350_leds_pdata));
if (IS_ERR(sel3350->leds_pdev)) {
rs = PTR_ERR(sel3350->leds_pdev);
dev_err(&pdev->dev, "Failed registering platform device: %d\n", rs);
goto err_platform;
}
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/gpio/consumer.h`, `linux/gpio/machine.h`, `linux/leds.h`, `linux/module.h`, `linux/platform_device.h`, `linux/power_supply.h`.
- Detected declarations: `struct sel3350_power_cfg_data`, `struct sel3350_data`, `function sel3350_power_get_property`, `function sel3350_probe`, `function sel3350_remove`.
- Atlas domain: Driver Families / drivers/platform.
- 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.