drivers/usb/chipidea/otg_fsm.c
Source file repositories/reference/linux-study-clean/drivers/usb/chipidea/otg_fsm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/chipidea/otg_fsm.c- Extension
.c- Size
- 19786 bytes
- Lines
- 852
- Domain
- Driver Families
- Bucket
- drivers/usb
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/usb/otg.hlinux/usb/gadget.hlinux/usb/hcd.hlinux/usb/chipidea.hlinux/regulator/consumer.hci.hbits.hotg.hotg_fsm.h
Detected Declarations
function Copyrightfunction a_bus_req_storefunction a_bus_drop_showfunction a_bus_drop_storefunction b_bus_req_showfunction b_bus_req_storefunction a_clr_err_storefunction ci_otg_add_timerfunction ktime_afterfunction ci_otg_del_timerfunction for_each_set_bitfunction a_wait_vrise_tmoutfunction a_wait_vfall_tmoutfunction a_wait_bcon_tmoutfunction a_aidl_bdis_tmoutfunction b_ase0_brst_tmoutfunction a_bidl_adis_tmoutfunction b_aidl_bdis_tmoutfunction b_se0_srp_tmoutfunction b_srp_fail_tmoutfunction b_data_pls_tmoutfunction b_ssend_srp_tmoutfunction ci_otg_hrtimer_funcfunction ci_otg_init_timersfunction ci_otg_fsm_add_timerfunction ci_otg_fsm_del_timerfunction ci_otg_drv_vbusfunction ci_otg_loc_connfunction ci_otg_loc_soffunction ci_otg_start_pulsefunction ci_otg_start_hostfunction ci_otg_start_gadgetfunction ci_otg_fsm_workfunction ci_otg_fsm_eventfunction ci_otg_fsm_irqfunction ci_hdrc_otg_fsm_startfunction ci_hdrc_otg_fsm_initfunction ci_hdrc_otg_fsm_remove
Annotated Snippet
if (ci->fsm.a_bus_drop) {
mutex_unlock(&ci->fsm.lock);
return count;
}
ci->fsm.a_bus_req = 1;
if (ci->fsm.otg->state == OTG_STATE_A_PERIPHERAL) {
ci->gadget.host_request_flag = 1;
mutex_unlock(&ci->fsm.lock);
return count;
}
}
ci_otg_queue_work(ci);
mutex_unlock(&ci->fsm.lock);
return count;
}
static DEVICE_ATTR_RW(a_bus_req);
static ssize_t
a_bus_drop_show(struct device *dev, struct device_attribute *attr, char *buf)
{
char *next;
unsigned size, t;
struct ci_hdrc *ci = dev_get_drvdata(dev);
next = buf;
size = PAGE_SIZE;
t = scnprintf(next, size, "%d\n", ci->fsm.a_bus_drop);
size -= t;
next += t;
return PAGE_SIZE - size;
}
static ssize_t
a_bus_drop_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct ci_hdrc *ci = dev_get_drvdata(dev);
if (count > 2)
return -1;
mutex_lock(&ci->fsm.lock);
if (buf[0] == '0') {
ci->fsm.a_bus_drop = 0;
} else if (buf[0] == '1') {
ci->fsm.a_bus_drop = 1;
ci->fsm.a_bus_req = 0;
}
ci_otg_queue_work(ci);
mutex_unlock(&ci->fsm.lock);
return count;
}
static DEVICE_ATTR_RW(a_bus_drop);
static ssize_t
b_bus_req_show(struct device *dev, struct device_attribute *attr, char *buf)
{
char *next;
unsigned size, t;
struct ci_hdrc *ci = dev_get_drvdata(dev);
next = buf;
size = PAGE_SIZE;
t = scnprintf(next, size, "%d\n", ci->fsm.b_bus_req);
size -= t;
next += t;
return PAGE_SIZE - size;
}
static ssize_t
b_bus_req_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct ci_hdrc *ci = dev_get_drvdata(dev);
if (count > 2)
return -1;
mutex_lock(&ci->fsm.lock);
if (buf[0] == '0')
ci->fsm.b_bus_req = 0;
else if (buf[0] == '1') {
ci->fsm.b_bus_req = 1;
if (ci->fsm.otg->state == OTG_STATE_B_PERIPHERAL) {
Annotation
- Immediate include surface: `linux/usb/otg.h`, `linux/usb/gadget.h`, `linux/usb/hcd.h`, `linux/usb/chipidea.h`, `linux/regulator/consumer.h`, `ci.h`, `bits.h`, `otg.h`.
- Detected declarations: `function Copyright`, `function a_bus_req_store`, `function a_bus_drop_show`, `function a_bus_drop_store`, `function b_bus_req_show`, `function b_bus_req_store`, `function a_clr_err_store`, `function ci_otg_add_timer`, `function ktime_after`, `function ci_otg_del_timer`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.