drivers/hwmon/pmbus/ibm-cffps.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/ibm-cffps.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/pmbus/ibm-cffps.c- Extension
.c- Size
- 14883 bytes
- Lines
- 608
- Domain
- Driver Families
- Bucket
- drivers/hwmon
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/bitfield.hlinux/bitops.hlinux/debugfs.hlinux/device.hlinux/fs.hlinux/i2c.hlinux/jiffies.hlinux/leds.hlinux/module.hlinux/mutex.hlinux/of.hlinux/pmbus.hpmbus.h
Detected Declarations
struct ibm_cffpsenum versionsfunction ibm_cffps_debugfs_read_input_historyfunction ibm_cffps_debugfs_readfunction ibm_cffps_debugfs_writefunction ibm_cffps_read_byte_datafunction ibm_cffps_read_word_datafunction ibm_cffps_led_brightness_setfunction ibm_cffps_led_blink_setfunction ibm_cffps_create_led_classfunction ibm_cffps_probe
Annotated Snippet
static const struct file_operations ibm_cffps_input_history_fops = {
.llseek = noop_llseek,
.read = ibm_cffps_debugfs_read_input_history,
.open = simple_open,
};
static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
int i, rc;
int *idxp = file->private_data;
int idx = *idxp;
struct ibm_cffps *psu = to_psu(idxp, idx);
char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 };
rc = pmbus_lock_interruptible(psu->client);
if (rc)
return rc;
rc = pmbus_set_page(psu->client, 0, 0xff);
if (rc)
goto unlock;
switch (idx) {
case CFFPS_DEBUGFS_MAX_POWER_OUT:
if (psu->version == cffps1)
rc = i2c_smbus_read_word_swapped(psu->client, PMBUS_MFR_POUT_MAX);
else
rc = i2c_smbus_read_word_data(psu->client, PMBUS_MFR_POUT_MAX);
if (rc >= 0)
rc = snprintf(data, I2C_SMBUS_BLOCK_MAX, "%d", rc);
break;
case CFFPS_DEBUGFS_CCIN:
rc = i2c_smbus_read_word_swapped(psu->client, CFFPS_CCIN_CMD);
if (rc >= 0)
rc = snprintf(data, 5, "%04X", rc);
break;
case CFFPS_DEBUGFS_FW:
switch (psu->version) {
case cffps1:
for (i = 0; i < CFFPS1_FW_NUM_BYTES; ++i) {
rc = i2c_smbus_read_byte_data(psu->client, CFFPS_FW_CMD + i);
if (rc < 0)
goto unlock;
snprintf(&data[i * 2], 3, "%02X", rc);
}
rc = i * 2;
break;
case cffps2:
for (i = 0; i < CFFPS2_FW_NUM_WORDS; ++i) {
rc = i2c_smbus_read_word_data(psu->client, CFFPS_FW_CMD + i);
if (rc < 0)
goto unlock;
snprintf(&data[i * 4], 5, "%04X", rc);
}
rc = i * 4;
break;
default:
rc = -EOPNOTSUPP;
break;
}
break;
case CFFPS_DEBUGFS_ON_OFF_CONFIG:
rc = i2c_smbus_read_byte_data(psu->client, PMBUS_ON_OFF_CONFIG);
if (rc >= 0)
rc = snprintf(data, 3, "%02x", rc);
break;
default:
rc = -EINVAL;
break;
}
unlock:
pmbus_unlock(psu->client);
if (rc < 0)
return rc;
data[rc] = '\n';
rc += 2;
return simple_read_from_buffer(buf, count, ppos, data, rc);
}
static ssize_t ibm_cffps_debugfs_write(struct file *file,
const char __user *buf, size_t count,
loff_t *ppos)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitops.h`, `linux/debugfs.h`, `linux/device.h`, `linux/fs.h`, `linux/i2c.h`, `linux/jiffies.h`, `linux/leds.h`.
- Detected declarations: `struct ibm_cffps`, `enum versions`, `function ibm_cffps_debugfs_read_input_history`, `function ibm_cffps_debugfs_read`, `function ibm_cffps_debugfs_write`, `function ibm_cffps_read_byte_data`, `function ibm_cffps_read_word_data`, `function ibm_cffps_led_brightness_set`, `function ibm_cffps_led_blink_set`, `function ibm_cffps_create_led_class`.
- Atlas domain: Driver Families / drivers/hwmon.
- Implementation status: pattern 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.