drivers/hwmon/occ/sysfs.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/occ/sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/occ/sysfs.c- Extension
.c- Size
- 7326 bytes
- Lines
- 258
- Domain
- Driver Families
- Bucket
- drivers/hwmon
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/device.hlinux/export.hlinux/hwmon-sysfs.hlinux/kernel.hlinux/kstrtox.hlinux/sysfs.hcommon.h
Detected Declarations
function occ_active_storefunction occ_sysfs_showfunction occ_error_showfunction occ_sysfs_poll_donefunction occ_setup_sysfsfunction occ_shutdown_sysfs
Annotated Snippet
switch (sattr->index) {
case 0:
val = !!(header->status & OCC_STAT_MASTER);
break;
case 1:
val = 1;
break;
case 2:
val = !!(header->ext_status & OCC_EXT_STAT_DVFS_OT);
break;
case 3:
val = !!(header->ext_status & OCC_EXT_STAT_DVFS_POWER);
break;
case 4:
val = !!(header->ext_status &
OCC_EXT_STAT_MEM_THROTTLE);
break;
case 5:
val = !!(header->ext_status & OCC_EXT_STAT_QUICK_DROP);
break;
case 6:
val = header->occ_state;
break;
case 7:
if (header->status & OCC_STAT_MASTER)
val = hweight8(header->occs_present);
else
val = 1;
break;
case 8:
val = header->ips_status;
break;
case 9:
val = header->mode;
break;
case 10:
val = !!(header->ext_status & OCC_EXT_STAT_DVFS_VDD);
break;
case 11:
val = header->ext_status & OCC_EXT_STAT_GPU_THROTTLE;
break;
default:
return -EINVAL;
}
} else {
if (sattr->index == 1)
val = 0;
else if (sattr->index <= 11)
val = -ENODATA;
else
return -EINVAL;
}
return sysfs_emit(buf, "%d\n", val);
}
static ssize_t occ_error_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct occ *occ = dev_get_drvdata(dev);
occ_update_response(occ);
return sysfs_emit(buf, "%d\n", occ->error);
}
static SENSOR_DEVICE_ATTR(occ_master, 0444, occ_sysfs_show, NULL, 0);
static SENSOR_DEVICE_ATTR(occ_active, 0644, occ_sysfs_show, occ_active_store,
1);
static SENSOR_DEVICE_ATTR(occ_dvfs_overtemp, 0444, occ_sysfs_show, NULL, 2);
static SENSOR_DEVICE_ATTR(occ_dvfs_power, 0444, occ_sysfs_show, NULL, 3);
static SENSOR_DEVICE_ATTR(occ_mem_throttle, 0444, occ_sysfs_show, NULL, 4);
static SENSOR_DEVICE_ATTR(occ_quick_pwr_drop, 0444, occ_sysfs_show, NULL, 5);
static SENSOR_DEVICE_ATTR(occ_state, 0444, occ_sysfs_show, NULL, 6);
static SENSOR_DEVICE_ATTR(occs_present, 0444, occ_sysfs_show, NULL, 7);
static SENSOR_DEVICE_ATTR(occ_ips_status, 0444, occ_sysfs_show, NULL, 8);
static SENSOR_DEVICE_ATTR(occ_mode, 0444, occ_sysfs_show, NULL, 9);
static SENSOR_DEVICE_ATTR(occ_dvfs_vdd, 0444, occ_sysfs_show, NULL, 10);
static SENSOR_DEVICE_ATTR(occ_gpu_throttle, 0444, occ_sysfs_show, NULL, 11);
static DEVICE_ATTR_RO(occ_error);
static struct attribute *occ_attributes[] = {
&sensor_dev_attr_occ_master.dev_attr.attr,
&sensor_dev_attr_occ_active.dev_attr.attr,
&sensor_dev_attr_occ_dvfs_overtemp.dev_attr.attr,
&sensor_dev_attr_occ_dvfs_power.dev_attr.attr,
&sensor_dev_attr_occ_mem_throttle.dev_attr.attr,
&sensor_dev_attr_occ_quick_pwr_drop.dev_attr.attr,
&sensor_dev_attr_occ_state.dev_attr.attr,
&sensor_dev_attr_occs_present.dev_attr.attr,
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/device.h`, `linux/export.h`, `linux/hwmon-sysfs.h`, `linux/kernel.h`, `linux/kstrtox.h`, `linux/sysfs.h`, `common.h`.
- Detected declarations: `function occ_active_store`, `function occ_sysfs_show`, `function occ_error_show`, `function occ_sysfs_poll_done`, `function occ_setup_sysfs`, `function occ_shutdown_sysfs`.
- Atlas domain: Driver Families / drivers/hwmon.
- 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.