drivers/hwmon/pmbus/ucd9000.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/ucd9000.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/pmbus/ucd9000.c- Extension
.c- Size
- 16176 bytes
- Lines
- 649
- 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/debugfs.hlinux/delay.hlinux/hex.hlinux/kernel.hlinux/module.hlinux/of.hlinux/init.hlinux/err.hlinux/slab.hlinux/i2c.hlinux/pmbus.hlinux/gpio/driver.hlinux/timekeeping.hpmbus.h
Detected Declarations
struct ucd9000_datastruct ucd9000_debugfs_entryenum chipsfunction ucd9000_get_fan_configfunction ucd9000_read_byte_datafunction ucd9000_gpio_read_configfunction ucd9000_gpio_getfunction ucd9000_gpio_setfunction ucd9000_gpio_get_directionfunction ucd9000_gpio_set_directionfunction ucd9000_gpio_direction_inputfunction ucd9000_gpio_direction_outputfunction ucd9000_probe_gpiofunction ucd9000_probe_gpiofunction ucd9000_debugfs_show_mfr_status_bitfunction ucd9000_debugfs_read_mfr_statusfunction ucd9000_init_debugfsfunction ucd9000_init_debugfsfunction ucd9000_probe
Annotated Snippet
static const struct file_operations ucd9000_debugfs_show_mfr_status_fops = {
.llseek = noop_llseek,
.read = ucd9000_debugfs_read_mfr_status,
.open = simple_open,
};
static int ucd9000_init_debugfs(struct i2c_client *client,
const struct i2c_device_id *mid,
struct ucd9000_data *data)
{
struct dentry *debugfs;
struct ucd9000_debugfs_entry *entries;
int i, gpi_count;
char name[UCD9000_DEBUGFS_NAME_LEN];
debugfs = pmbus_get_debugfs_dir(client);
if (!debugfs)
return -ENOENT;
data->debugfs = debugfs_create_dir(client->name, debugfs);
/*
* Of the chips this driver supports, only the UCD9090, UCD90160,
* UCD90320, and UCD90910 report GPI faults in their MFR_STATUS
* register, so only create the GPI fault debugfs attributes for those
* chips.
*/
if (mid->driver_data == ucd9090 || mid->driver_data == ucd90160 ||
mid->driver_data == ucd90320 || mid->driver_data == ucd90910) {
gpi_count = mid->driver_data == ucd90320 ? UCD90320_GPI_COUNT
: UCD9000_GPI_COUNT;
entries = devm_kcalloc(&client->dev,
gpi_count, sizeof(*entries),
GFP_KERNEL);
if (!entries)
return -ENOMEM;
for (i = 0; i < gpi_count; i++) {
entries[i].client = client;
entries[i].index = i;
scnprintf(name, UCD9000_DEBUGFS_NAME_LEN,
"gpi%d_alarm", i + 1);
debugfs_create_file(name, 0444, data->debugfs,
&entries[i],
&ucd9000_debugfs_mfr_status_bit);
}
}
scnprintf(name, UCD9000_DEBUGFS_NAME_LEN, "mfr_status");
debugfs_create_file(name, 0444, data->debugfs, client,
&ucd9000_debugfs_show_mfr_status_fops);
return 0;
}
#else
static int ucd9000_init_debugfs(struct i2c_client *client,
const struct i2c_device_id *mid,
struct ucd9000_data *data)
{
return 0;
}
#endif /* CONFIG_DEBUG_FS */
static int ucd9000_probe(struct i2c_client *client)
{
u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1];
struct ucd9000_data *data;
struct pmbus_driver_info *info;
const struct i2c_device_id *mid;
enum chips chip;
int i, ret;
if (!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_BYTE_DATA |
I2C_FUNC_SMBUS_BLOCK_DATA))
return -ENODEV;
ret = i2c_smbus_read_block_data(client, UCD9000_DEVICE_ID,
block_buffer);
if (ret < 0) {
dev_err(&client->dev, "Failed to read device ID\n");
return ret;
}
block_buffer[ret] = '\0';
dev_info(&client->dev, "Device ID %s\n", block_buffer);
for (mid = ucd9000_id; mid->name[0]; mid++) {
if (!strncasecmp(mid->name, block_buffer, strlen(mid->name)))
break;
}
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/delay.h`, `linux/hex.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/init.h`, `linux/err.h`.
- Detected declarations: `struct ucd9000_data`, `struct ucd9000_debugfs_entry`, `enum chips`, `function ucd9000_get_fan_config`, `function ucd9000_read_byte_data`, `function ucd9000_gpio_read_config`, `function ucd9000_gpio_get`, `function ucd9000_gpio_set`, `function ucd9000_gpio_get_direction`, `function ucd9000_gpio_set_direction`.
- 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.