drivers/misc/smpro-misc.c
Source file repositories/reference/linux-study-clean/drivers/misc/smpro-misc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/smpro-misc.c- Extension
.c- Size
- 3255 bytes
- Lines
- 146
- Domain
- Driver Families
- Bucket
- drivers/misc
- 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/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/regmap.h
Detected Declarations
struct smpro_miscfunction boot_progress_showfunction soc_power_limit_showfunction soc_power_limit_storefunction smpro_misc_probe
Annotated Snippet
struct smpro_misc {
struct regmap *regmap;
};
static ssize_t boot_progress_show(struct device *dev, struct device_attribute *da, char *buf)
{
struct smpro_misc *misc = dev_get_drvdata(dev);
u16 boot_progress[3] = { 0 };
u32 bootstage;
u8 boot_stage;
u8 cur_stage;
u32 reg_lo;
u32 reg;
int ret;
/* Read current boot stage */
ret = regmap_read(misc->regmap, CUR_BOOTSTAGE, ®);
if (ret)
return ret;
cur_stage = reg & 0xff;
ret = regmap_read(misc->regmap, BOOTSTAGE, &bootstage);
if (ret)
return ret;
boot_stage = (bootstage >> 8) & 0xff;
if (boot_stage > cur_stage)
return -EINVAL;
ret = regmap_read(misc->regmap, BOOTSTAGE_LO, ®_lo);
if (!ret)
ret = regmap_read(misc->regmap, BOOTSTAGE_HI, ®);
if (ret)
return ret;
/* Firmware to report new boot stage next time */
if (boot_stage < cur_stage) {
ret = regmap_write(misc->regmap, BOOTSTAGE, ((bootstage & 0xff00) | 0x1));
if (ret)
return ret;
}
boot_progress[0] = bootstage;
boot_progress[1] = swab16(reg);
boot_progress[2] = swab16(reg_lo);
return sysfs_emit(buf, "%*phN\n", (int)sizeof(boot_progress), boot_progress);
}
static DEVICE_ATTR_RO(boot_progress);
static ssize_t soc_power_limit_show(struct device *dev, struct device_attribute *da, char *buf)
{
struct smpro_misc *misc = dev_get_drvdata(dev);
unsigned int value;
int ret;
ret = regmap_read(misc->regmap, SOC_POWER_LIMIT, &value);
if (ret)
return ret;
return sysfs_emit(buf, "%d\n", value);
}
static ssize_t soc_power_limit_store(struct device *dev, struct device_attribute *da,
const char *buf, size_t count)
{
struct smpro_misc *misc = dev_get_drvdata(dev);
unsigned long val;
s32 ret;
ret = kstrtoul(buf, 0, &val);
if (ret)
return ret;
ret = regmap_write(misc->regmap, SOC_POWER_LIMIT, (unsigned int)val);
if (ret)
return -EPROTO;
return count;
}
static DEVICE_ATTR_RW(soc_power_limit);
static struct attribute *smpro_misc_attrs[] = {
&dev_attr_boot_progress.attr,
&dev_attr_soc_power_limit.attr,
NULL
Annotation
- Immediate include surface: `linux/mod_devicetable.h`, `linux/module.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct smpro_misc`, `function boot_progress_show`, `function soc_power_limit_show`, `function soc_power_limit_store`, `function smpro_misc_probe`.
- Atlas domain: Driver Families / drivers/misc.
- 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.