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.

Dependency Surface

Detected Declarations

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

Implementation Notes