drivers/s390/net/fsm.c
Source file repositories/reference/linux-study-clean/drivers/s390/net/fsm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/s390/net/fsm.c- Extension
.c- Size
- 4881 bytes
- Lines
- 212
- Domain
- Driver Families
- Bucket
- drivers/s390
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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
fsm.hlinux/export.hlinux/module.hlinux/slab.hlinux/timer.h
Detected Declarations
function init_fsmfunction kfree_fsmfunction fsm_print_historyfunction fsm_record_historyfunction fsm_getstate_strfunction fsm_expire_timerfunction fsm_settimerfunction fsm_deltimerfunction fsm_addtimerfunction fsm_modtimerexport init_fsmexport kfree_fsmexport fsm_settimerexport fsm_deltimerexport fsm_addtimerexport fsm_modtimerexport fsm_getstate_strexport fsm_print_historyexport fsm_record_history
Annotated Snippet
if (this->f) {
kfree(this->f->jumpmatrix);
kfree(this->f);
}
kfree(this);
} else
printk(KERN_WARNING
"fsm: kfree_fsm called with NULL argument\n");
}
#if FSM_DEBUG_HISTORY
void
fsm_print_history(fsm_instance *fi)
{
int idx = 0;
int i;
if (fi->history_size >= FSM_HISTORY_SIZE)
idx = fi->history_index;
printk(KERN_DEBUG "fsm(%s): History:\n", fi->name);
for (i = 0; i < fi->history_size; i++) {
int e = fi->history[idx].event;
int s = fi->history[idx++].state;
idx %= FSM_HISTORY_SIZE;
if (e == -1)
printk(KERN_DEBUG " S=%s\n",
fi->f->state_names[s]);
else
printk(KERN_DEBUG " S=%s E=%s\n",
fi->f->state_names[s],
fi->f->event_names[e]);
}
fi->history_size = fi->history_index = 0;
}
void
fsm_record_history(fsm_instance *fi, int state, int event)
{
fi->history[fi->history_index].state = state;
fi->history[fi->history_index++].event = event;
fi->history_index %= FSM_HISTORY_SIZE;
if (fi->history_size < FSM_HISTORY_SIZE)
fi->history_size++;
}
#endif
const char *
fsm_getstate_str(fsm_instance *fi)
{
int st = atomic_read(&fi->state);
if (st >= fi->f->nr_states)
return "Invalid";
return fi->f->state_names[st];
}
static void
fsm_expire_timer(struct timer_list *t)
{
fsm_timer *this = timer_container_of(this, t, tl);
#if FSM_TIMER_DEBUG
printk(KERN_DEBUG "fsm(%s): Timer %p expired\n",
this->fi->name, this);
#endif
fsm_event(this->fi, this->expire_event, this->event_arg);
}
void
fsm_settimer(fsm_instance *fi, fsm_timer *this)
{
this->fi = fi;
#if FSM_TIMER_DEBUG
printk(KERN_DEBUG "fsm(%s): Create timer %p\n", fi->name,
this);
#endif
timer_setup(&this->tl, fsm_expire_timer, 0);
}
void
fsm_deltimer(fsm_timer *this)
{
#if FSM_TIMER_DEBUG
printk(KERN_DEBUG "fsm(%s): Delete timer %p\n", this->fi->name,
this);
#endif
timer_delete(&this->tl);
}
int
fsm_addtimer(fsm_timer *this, int millisec, int event, void *arg)
Annotation
- Immediate include surface: `fsm.h`, `linux/export.h`, `linux/module.h`, `linux/slab.h`, `linux/timer.h`.
- Detected declarations: `function init_fsm`, `function kfree_fsm`, `function fsm_print_history`, `function fsm_record_history`, `function fsm_getstate_str`, `function fsm_expire_timer`, `function fsm_settimer`, `function fsm_deltimer`, `function fsm_addtimer`, `function fsm_modtimer`.
- Atlas domain: Driver Families / drivers/s390.
- Implementation status: integration 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.