drivers/memstick/host/rtsx_usb_ms.c
Source file repositories/reference/linux-study-clean/drivers/memstick/host/rtsx_usb_ms.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/memstick/host/rtsx_usb_ms.c- Extension
.c- Size
- 22103 bytes
- Lines
- 873
- Domain
- Driver Families
- Bucket
- drivers/memstick
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/highmem.hlinux/delay.hlinux/platform_device.hlinux/workqueue.hlinux/memstick.hlinux/kthread.hlinux/rtsx_usb.hlinux/pm_runtime.hlinux/mutex.hlinux/sched.hlinux/completion.hlinux/unaligned.h
Detected Declarations
struct rtsx_usb_msfunction ms_clear_errorfunction ms_print_debug_regsfunction ms_print_debug_regsfunction ms_pull_ctl_disable_qfn24function ms_pull_ctl_enable_lqfp48function ms_pull_ctl_enable_qfn24function ms_power_onfunction ms_power_offfunction ms_transfer_datafunction ms_write_bytesfunction ms_read_bytesfunction rtsx_usb_ms_issue_cmdfunction rtsx_usb_ms_handle_reqfunction rtsx_usb_ms_requestfunction rtsx_usb_ms_set_paramfunction rtsx_usb_ms_suspendfunction rtsx_usb_ms_resumefunction rtsx_usb_ms_runtime_suspendfunction rtsx_usb_ms_runtime_resumefunction rtsx_usb_ms_poll_cardfunction rtsx_usb_ms_drv_probefunction rtsx_usb_ms_drv_remove
Annotated Snippet
struct rtsx_usb_ms {
struct platform_device *pdev;
struct rtsx_ucr *ucr;
struct memstick_host *msh;
struct memstick_request *req;
struct mutex host_mutex;
struct work_struct handle_req;
struct delayed_work poll_card;
u8 ssc_depth;
unsigned int clock;
int power_mode;
unsigned char ifmode;
bool eject;
bool system_suspending;
};
static inline struct device *ms_dev(struct rtsx_usb_ms *host)
{
return &(host->pdev->dev);
}
static inline void ms_clear_error(struct rtsx_usb_ms *host)
{
struct rtsx_ucr *ucr = host->ucr;
rtsx_usb_ep0_write_register(ucr, CARD_STOP,
MS_STOP | MS_CLR_ERR,
MS_STOP | MS_CLR_ERR);
rtsx_usb_clear_dma_err(ucr);
rtsx_usb_clear_fsm_err(ucr);
}
#ifdef DEBUG
static void ms_print_debug_regs(struct rtsx_usb_ms *host)
{
struct rtsx_ucr *ucr = host->ucr;
u16 i;
u8 *ptr;
/* Print MS host internal registers */
rtsx_usb_init_cmd(ucr);
/* MS_CFG to MS_INT_REG */
for (i = 0xFD40; i <= 0xFD44; i++)
rtsx_usb_add_cmd(ucr, READ_REG_CMD, i, 0, 0);
/* CARD_SHARE_MODE to CARD_GPIO */
for (i = 0xFD51; i <= 0xFD56; i++)
rtsx_usb_add_cmd(ucr, READ_REG_CMD, i, 0, 0);
/* CARD_PULL_CTLx */
for (i = 0xFD60; i <= 0xFD65; i++)
rtsx_usb_add_cmd(ucr, READ_REG_CMD, i, 0, 0);
/* CARD_DATA_SOURCE, CARD_SELECT, CARD_CLK_EN, CARD_PWR_CTL */
rtsx_usb_add_cmd(ucr, READ_REG_CMD, CARD_DATA_SOURCE, 0, 0);
rtsx_usb_add_cmd(ucr, READ_REG_CMD, CARD_SELECT, 0, 0);
rtsx_usb_add_cmd(ucr, READ_REG_CMD, CARD_CLK_EN, 0, 0);
rtsx_usb_add_cmd(ucr, READ_REG_CMD, CARD_PWR_CTL, 0, 0);
rtsx_usb_send_cmd(ucr, MODE_CR, 100);
rtsx_usb_get_rsp(ucr, 21, 100);
ptr = ucr->rsp_buf;
for (i = 0xFD40; i <= 0xFD44; i++)
dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));
for (i = 0xFD51; i <= 0xFD56; i++)
dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));
for (i = 0xFD60; i <= 0xFD65; i++)
dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", i, *(ptr++));
dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", CARD_DATA_SOURCE, *(ptr++));
dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", CARD_SELECT, *(ptr++));
dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", CARD_CLK_EN, *(ptr++));
dev_dbg(ms_dev(host), "0x%04X: 0x%02x\n", CARD_PWR_CTL, *(ptr++));
}
#else
static void ms_print_debug_regs(struct rtsx_usb_ms *host)
{
}
#endif
static int ms_pull_ctl_disable_lqfp48(struct rtsx_ucr *ucr)
{
Annotation
- Immediate include surface: `linux/module.h`, `linux/highmem.h`, `linux/delay.h`, `linux/platform_device.h`, `linux/workqueue.h`, `linux/memstick.h`, `linux/kthread.h`, `linux/rtsx_usb.h`.
- Detected declarations: `struct rtsx_usb_ms`, `function ms_clear_error`, `function ms_print_debug_regs`, `function ms_print_debug_regs`, `function ms_pull_ctl_disable_qfn24`, `function ms_pull_ctl_enable_lqfp48`, `function ms_pull_ctl_enable_qfn24`, `function ms_power_on`, `function ms_power_off`, `function ms_transfer_data`.
- Atlas domain: Driver Families / drivers/memstick.
- 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.