drivers/hwmon/pmbus/inspur-ipsps.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/inspur-ipsps.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/pmbus/inspur-ipsps.c- Extension
.c- Size
- 5874 bytes
- Lines
- 228
- 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/debugfs.hlinux/device.hlinux/fs.hlinux/i2c.hlinux/module.hlinux/pmbus.hlinux/hwmon-sysfs.hpmbus.h
Detected Declarations
enum ipsps_indexfunction ipsps_string_showfunction ipsps_fw_version_showfunction ipsps_mode_showfunction ipsps_mode_storefunction ipsps_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright 2019 Inspur Corp.
*/
#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/pmbus.h>
#include <linux/hwmon-sysfs.h>
#include "pmbus.h"
#define IPSPS_REG_VENDOR_ID 0x99
#define IPSPS_REG_MODEL 0x9A
#define IPSPS_REG_FW_VERSION 0x9B
#define IPSPS_REG_PN 0x9C
#define IPSPS_REG_SN 0x9E
#define IPSPS_REG_HW_VERSION 0xB0
#define IPSPS_REG_MODE 0xFC
#define MODE_ACTIVE 0x55
#define MODE_STANDBY 0x0E
#define MODE_REDUNDANCY 0x00
#define MODE_ACTIVE_STRING "active"
#define MODE_STANDBY_STRING "standby"
#define MODE_REDUNDANCY_STRING "redundancy"
enum ipsps_index {
vendor,
model,
fw_version,
part_number,
serial_number,
hw_version,
mode,
num_regs,
};
static const u8 ipsps_regs[num_regs] = {
[vendor] = IPSPS_REG_VENDOR_ID,
[model] = IPSPS_REG_MODEL,
[fw_version] = IPSPS_REG_FW_VERSION,
[part_number] = IPSPS_REG_PN,
[serial_number] = IPSPS_REG_SN,
[hw_version] = IPSPS_REG_HW_VERSION,
[mode] = IPSPS_REG_MODE,
};
static ssize_t ipsps_string_show(struct device *dev,
struct device_attribute *devattr,
char *buf)
{
u8 reg;
int rc;
char *p;
char data[I2C_SMBUS_BLOCK_MAX + 1];
struct i2c_client *client = to_i2c_client(dev->parent);
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
reg = ipsps_regs[attr->index];
rc = i2c_smbus_read_block_data(client, reg, data);
if (rc < 0)
return rc;
/* filled with printable characters, ending with # */
p = memscan(data, '#', rc);
*p = '\0';
return sysfs_emit(buf, "%s\n", data);
}
static ssize_t ipsps_fw_version_show(struct device *dev,
struct device_attribute *devattr,
char *buf)
{
u8 reg;
int rc;
u8 data[I2C_SMBUS_BLOCK_MAX] = { 0 };
struct i2c_client *client = to_i2c_client(dev->parent);
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
reg = ipsps_regs[attr->index];
rc = i2c_smbus_read_block_data(client, reg, data);
if (rc < 0)
return rc;
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/device.h`, `linux/fs.h`, `linux/i2c.h`, `linux/module.h`, `linux/pmbus.h`, `linux/hwmon-sysfs.h`, `pmbus.h`.
- Detected declarations: `enum ipsps_index`, `function ipsps_string_show`, `function ipsps_fw_version_show`, `function ipsps_mode_show`, `function ipsps_mode_store`, `function ipsps_probe`.
- 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.