drivers/usb/storage/realtek_cr.c
Source file repositories/reference/linux-study-clean/drivers/usb/storage/realtek_cr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/storage/realtek_cr.c- Extension
.c- Size
- 26860 bytes
- Lines
- 1072
- 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.
- 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/module.hlinux/blkdev.hlinux/kthread.hlinux/sched.hlinux/kernel.hscsi/scsi.hscsi/scsi_cmnd.hscsi/scsi_device.hlinux/cdrom.hlinux/usb.hlinux/slab.hlinux/usb_usual.husb.htransport.hprotocol.hdebug.hscsiglue.hunusual_realtek.h
Detected Declarations
struct rts51x_statusstruct rts51x_chipenum RTS51X_STATfunction rts51x_bulk_transportfunction rts51x_bulk_transport_specialfunction rts51x_get_max_lunfunction rts51x_read_memfunction rts51x_write_memfunction rts51x_read_statusfunction rts51x_check_statusfunction enable_oscillatorfunction __do_config_autodelinkfunction do_config_autodelinkfunction config_autodelink_after_power_onfunction config_autodelink_before_power_downfunction fw5895_initfunction fw5895_set_mmc_wpfunction rts51x_modi_suspend_timerfunction rts51x_suspend_timer_fnfunction working_scsifunction rts51x_invoke_transportfunction realtek_cr_autosuspend_setupfunction realtek_cr_destructorfunction realtek_cr_suspendfunction realtek_cr_resumefunction init_realtek_crfunction realtek_cr_probe
Annotated Snippet
struct rts51x_status {
u16 vid;
u16 pid;
u8 cur_lun;
u8 card_type;
u8 total_lun;
u16 fw_ver;
u8 phy_exist;
u8 multi_flag;
u8 multi_card;
u8 log_exist;
union {
u8 detailed_type1;
u8 detailed_type2;
} detailed_type;
u8 function[2];
};
struct rts51x_chip {
u16 vendor_id;
u16 product_id;
char max_lun;
struct rts51x_status *status;
int status_len;
u32 flag;
struct us_data *us;
#ifdef CONFIG_REALTEK_AUTOPM
struct timer_list rts51x_suspend_timer;
unsigned long timer_expires;
int pwr_state;
u8 lun_ready;
enum RTS51X_STAT state;
int support_auto_delink;
#endif
/* used to back up the protocol chosen in probe1 phase */
proto_cmnd proto_handler_backup;
};
/* flag definition */
#define FLIDX_AUTO_DELINK 0x01
#define SCSI_LUN(srb) ((srb)->device->lun)
/* Bit Operation */
#define SET_BIT(data, idx) ((data) |= 1 << (idx))
#define CLR_BIT(data, idx) ((data) &= ~(1 << (idx)))
#define CHK_BIT(data, idx) ((data) & (1 << (idx)))
#define SET_AUTO_DELINK(chip) ((chip)->flag |= FLIDX_AUTO_DELINK)
#define CLR_AUTO_DELINK(chip) ((chip)->flag &= ~FLIDX_AUTO_DELINK)
#define CHK_AUTO_DELINK(chip) ((chip)->flag & FLIDX_AUTO_DELINK)
#define RTS51X_GET_VID(chip) ((chip)->vendor_id)
#define RTS51X_GET_PID(chip) ((chip)->product_id)
#define VENDOR_ID(chip) ((chip)->status[0].vid)
#define PRODUCT_ID(chip) ((chip)->status[0].pid)
#define FW_VERSION(chip) ((chip)->status[0].fw_ver)
#define STATUS_LEN(chip) ((chip)->status_len)
#define STATUS_SUCCESS 0
#define STATUS_FAIL 1
/* Check card reader function */
#define SUPPORT_DETAILED_TYPE1(chip) \
CHK_BIT((chip)->status[0].function[0], 1)
#define SUPPORT_OT(chip) \
CHK_BIT((chip)->status[0].function[0], 2)
#define SUPPORT_OC(chip) \
CHK_BIT((chip)->status[0].function[0], 3)
#define SUPPORT_AUTO_DELINK(chip) \
CHK_BIT((chip)->status[0].function[0], 4)
#define SUPPORT_SDIO(chip) \
CHK_BIT((chip)->status[0].function[1], 0)
#define SUPPORT_DETAILED_TYPE2(chip) \
CHK_BIT((chip)->status[0].function[1], 1)
#define CHECK_PID(chip, pid) (RTS51X_GET_PID(chip) == (pid))
#define CHECK_FW_VER(chip, fw_ver) (FW_VERSION(chip) == (fw_ver))
#define CHECK_ID(chip, pid, fw_ver) \
(CHECK_PID((chip), (pid)) && CHECK_FW_VER((chip), (fw_ver)))
static int init_realtek_cr(struct us_data *us);
/*
* The table of devices
*/
Annotation
- Immediate include surface: `linux/module.h`, `linux/blkdev.h`, `linux/kthread.h`, `linux/sched.h`, `linux/kernel.h`, `scsi/scsi.h`, `scsi/scsi_cmnd.h`, `scsi/scsi_device.h`.
- Detected declarations: `struct rts51x_status`, `struct rts51x_chip`, `enum RTS51X_STAT`, `function rts51x_bulk_transport`, `function rts51x_bulk_transport_special`, `function rts51x_get_max_lun`, `function rts51x_read_mem`, `function rts51x_write_mem`, `function rts51x_read_status`, `function rts51x_check_status`.
- 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.
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.