drivers/hwmon/ftsteutates.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/ftsteutates.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/ftsteutates.c- Extension
.c- Size
- 16167 bytes
- Lines
- 660
- 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.
- 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/err.hlinux/hwmon.hlinux/i2c.hlinux/init.hlinux/jiffies.hlinux/math.hlinux/module.hlinux/slab.hlinux/watchdog.h
Detected Declarations
struct fts_dataenum WATCHDOG_RESOLUTIONfunction fts_read_bytefunction fts_write_bytefunction fts_update_devicefunction fts_wd_set_resolutionfunction fts_wd_set_timeoutfunction fts_wd_startfunction fts_wd_stopfunction fts_watchdog_initfunction fts_is_visiblefunction fts_readfunction fts_writefunction fts_detectfunction fts_probe
Annotated Snippet
struct fts_data {
struct i2c_client *client;
unsigned long last_updated; /* in jiffies */
struct watchdog_device wdd;
enum WATCHDOG_RESOLUTION resolution;
bool valid; /* false until following fields are valid */
u8 volt[FTS_NO_VOLT_SENSORS];
u8 temp_input[FTS_NO_TEMP_SENSORS];
u8 temp_alarm;
u8 fan_present;
u8 fan_input[FTS_NO_FAN_SENSORS]; /* in rps */
u8 fan_source[FTS_NO_FAN_SENSORS];
u8 fan_alarm;
};
#define FTS_REG_FAN_INPUT(idx) ((idx) + 0x20)
#define FTS_REG_FAN_SOURCE(idx) ((idx) + 0x30)
#define FTS_REG_FAN_CONTROL(idx) (((idx) << 16) + 0x4881)
#define FTS_REG_TEMP_INPUT(idx) ((idx) + 0x40)
#define FTS_REG_TEMP_CONTROL(idx) (((idx) << 16) + 0x0681)
#define FTS_REG_VOLT(idx) ((idx) + 0x18)
/*****************************************************************************/
/* I2C Helper functions */
/*****************************************************************************/
static int fts_read_byte(struct i2c_client *client, unsigned short reg)
{
int ret;
unsigned char page = reg >> 8;
dev_dbg(&client->dev, "page select - page: 0x%.02x\n", page);
ret = i2c_smbus_write_byte_data(client, FTS_PAGE_SELECT_REG, page);
if (ret < 0)
return ret;
reg &= 0xFF;
ret = i2c_smbus_read_byte_data(client, reg);
dev_dbg(&client->dev, "read - reg: 0x%.02x: val: 0x%.02x\n", reg, ret);
return ret;
}
static int fts_write_byte(struct i2c_client *client, unsigned short reg,
unsigned char value)
{
int ret;
unsigned char page = reg >> 8;
dev_dbg(&client->dev, "page select - page: 0x%.02x\n", page);
ret = i2c_smbus_write_byte_data(client, FTS_PAGE_SELECT_REG, page);
if (ret < 0)
return ret;
reg &= 0xFF;
dev_dbg(&client->dev,
"write - reg: 0x%.02x: val: 0x%.02x\n", reg, value);
ret = i2c_smbus_write_byte_data(client, reg, value);
return ret;
}
/*****************************************************************************/
/* Data Updater Helper function */
/*****************************************************************************/
static int fts_update_device(struct fts_data *data)
{
int i, err;
if (!time_after(jiffies, data->last_updated + 2 * HZ) && data->valid)
return 0;
err = fts_read_byte(data->client, FTS_DEVICE_STATUS_REG);
if (err < 0)
return err;
data->valid = !!(err & 0x02); /* Data not ready yet */
if (unlikely(!data->valid))
return -EAGAIN;
err = fts_read_byte(data->client, FTS_FAN_PRESENT_REG);
if (err < 0)
return err;
data->fan_present = err;
err = fts_read_byte(data->client, FTS_FAN_EVENT_REG);
if (err < 0)
return err;
Annotation
- Immediate include surface: `linux/err.h`, `linux/hwmon.h`, `linux/i2c.h`, `linux/init.h`, `linux/jiffies.h`, `linux/math.h`, `linux/module.h`, `linux/slab.h`.
- Detected declarations: `struct fts_data`, `enum WATCHDOG_RESOLUTION`, `function fts_read_byte`, `function fts_write_byte`, `function fts_update_device`, `function fts_wd_set_resolution`, `function fts_wd_set_timeout`, `function fts_wd_start`, `function fts_wd_stop`, `function fts_watchdog_init`.
- 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.