drivers/macintosh/windfarm_fcu_controls.c
Source file repositories/reference/linux-study-clean/drivers/macintosh/windfarm_fcu_controls.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/macintosh/windfarm_fcu_controls.c- Extension
.c- Size
- 14396 bytes
- Lines
- 603
- Domain
- Driver Families
- Bucket
- drivers/macintosh
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/types.hlinux/errno.hlinux/kernel.hlinux/delay.hlinux/slab.hlinux/init.hlinux/wait.hlinux/i2c.hasm/machdep.hasm/io.hasm/sections.hwindfarm.hwindfarm_mpu.h
Detected Declarations
struct wf_fcu_privstruct wf_fcu_fanfunction wf_fcu_releasefunction wf_fcu_fan_releasefunction wf_fcu_read_regfunction wf_fcu_write_regfunction wf_fcu_fan_set_rpmfunction wf_fcu_fan_get_rpmfunction wf_fcu_fan_set_pwmfunction wf_fcu_fan_get_pwmfunction wf_fcu_fan_minfunction wf_fcu_fan_maxfunction wf_fcu_get_pump_minmaxfunction wf_fcu_get_rpmfan_minmaxfunction wf_fcu_add_fanfunction wf_fcu_lookup_fansfunction for_each_child_of_nodefunction wf_fcu_default_fansfunction wf_fcu_init_chipfunction wf_fcu_probefunction wf_fcu_remove
Annotated Snippet
struct wf_fcu_priv {
struct kref ref;
struct i2c_client *i2c;
struct mutex lock;
struct list_head fan_list;
int rpm_shift;
};
struct wf_fcu_fan {
struct list_head link;
int id;
s32 min, max, target;
struct wf_fcu_priv *fcu_priv;
struct wf_control ctrl;
};
static void wf_fcu_release(struct kref *ref)
{
struct wf_fcu_priv *pv = container_of(ref, struct wf_fcu_priv, ref);
kfree(pv);
}
static void wf_fcu_fan_release(struct wf_control *ct)
{
struct wf_fcu_fan *fan = ct->priv;
kref_put(&fan->fcu_priv->ref, wf_fcu_release);
kfree(fan);
}
static int wf_fcu_read_reg(struct wf_fcu_priv *pv, int reg,
unsigned char *buf, int nb)
{
int tries, nr, nw;
mutex_lock(&pv->lock);
buf[0] = reg;
tries = 0;
for (;;) {
nw = i2c_master_send(pv->i2c, buf, 1);
if (nw > 0 || (nw < 0 && nw != -EIO) || tries >= 100)
break;
msleep(10);
++tries;
}
if (nw <= 0) {
pr_err("Failure writing address to FCU: %d", nw);
nr = nw;
goto bail;
}
tries = 0;
for (;;) {
nr = i2c_master_recv(pv->i2c, buf, nb);
if (nr > 0 || (nr < 0 && nr != -ENODEV) || tries >= 100)
break;
msleep(10);
++tries;
}
if (nr <= 0)
pr_err("wf_fcu: Failure reading data from FCU: %d", nw);
bail:
mutex_unlock(&pv->lock);
return nr;
}
static int wf_fcu_write_reg(struct wf_fcu_priv *pv, int reg,
const unsigned char *ptr, int nb)
{
int tries, nw;
unsigned char buf[16];
buf[0] = reg;
memcpy(buf+1, ptr, nb);
++nb;
tries = 0;
for (;;) {
nw = i2c_master_send(pv->i2c, buf, nb);
if (nw > 0 || (nw < 0 && nw != -EIO) || tries >= 100)
break;
msleep(10);
++tries;
}
if (nw < 0)
pr_err("wf_fcu: Failure writing to FCU: %d", nw);
return nw;
}
static int wf_fcu_fan_set_rpm(struct wf_control *ct, s32 value)
Annotation
- Immediate include surface: `linux/types.h`, `linux/errno.h`, `linux/kernel.h`, `linux/delay.h`, `linux/slab.h`, `linux/init.h`, `linux/wait.h`, `linux/i2c.h`.
- Detected declarations: `struct wf_fcu_priv`, `struct wf_fcu_fan`, `function wf_fcu_release`, `function wf_fcu_fan_release`, `function wf_fcu_read_reg`, `function wf_fcu_write_reg`, `function wf_fcu_fan_set_rpm`, `function wf_fcu_fan_get_rpm`, `function wf_fcu_fan_set_pwm`, `function wf_fcu_fan_get_pwm`.
- Atlas domain: Driver Families / drivers/macintosh.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.