drivers/usb/atm/cxacru.c

Source file repositories/reference/linux-study-clean/drivers/usb/atm/cxacru.c

File Facts

System
Linux kernel
Corpus path
drivers/usb/atm/cxacru.c
Extension
.c
Size
39459 bytes
Lines
1386
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 cxacru_modem_type {
	u32 pll_f_clk;
	u32 pll_b_clk;
	int boot_rom_patch;
};

struct cxacru_data {
	struct usbatm_data *usbatm;

	const struct cxacru_modem_type *modem_type;

	int line_status;
	struct mutex adsl_state_serialize;
	int adsl_status;
	struct delayed_work poll_work;
	u32 card_info[CXINF_MAX];
	struct mutex poll_state_serialize;
	enum cxacru_poll_state poll_state;

	/* control handles */
	struct mutex cm_serialize;
	u8 *rcv_buf;
	u8 *snd_buf;
	struct urb *rcv_urb;
	struct urb *snd_urb;
	struct completion rcv_done;
	struct completion snd_done;
};

static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
	u8 *wdata, int wsize, u8 *rdata, int rsize);
static void cxacru_poll_status(struct work_struct *work);

/* Card info exported through sysfs */
#define CXACRU__ATTR_INIT(_name) \
static DEVICE_ATTR_RO(_name)

#define CXACRU_CMD_INIT(_name) \
static DEVICE_ATTR_RW(_name)

#define CXACRU_SET_INIT(_name) \
static DEVICE_ATTR_WO(_name)

#define CXACRU_ATTR_INIT(_value, _type, _name) \
static ssize_t _name##_show(struct device *dev, \
	struct device_attribute *attr, char *buf) \
{ \
	struct cxacru_data *instance = to_usbatm_driver_data(\
		to_usb_interface(dev)); \
\
	if (instance == NULL) \
		return -ENODEV; \
\
	return cxacru_sysfs_showattr_##_type(instance->card_info[_value], buf); \
} \
CXACRU__ATTR_INIT(_name)

#define CXACRU_ATTR_CREATE(_v, _t, _name) CXACRU_DEVICE_CREATE_FILE(_name)
#define CXACRU_CMD_CREATE(_name)          CXACRU_DEVICE_CREATE_FILE(_name)
#define CXACRU_SET_CREATE(_name)          CXACRU_DEVICE_CREATE_FILE(_name)
#define CXACRU__ATTR_CREATE(_name)        CXACRU_DEVICE_CREATE_FILE(_name)

#define CXACRU_ATTR_REMOVE(_v, _t, _name) CXACRU_DEVICE_REMOVE_FILE(_name)
#define CXACRU_CMD_REMOVE(_name)          CXACRU_DEVICE_REMOVE_FILE(_name)
#define CXACRU_SET_REMOVE(_name)          CXACRU_DEVICE_REMOVE_FILE(_name)
#define CXACRU__ATTR_REMOVE(_name)        CXACRU_DEVICE_REMOVE_FILE(_name)

static ssize_t cxacru_sysfs_showattr_u32(u32 value, char *buf)
{
	return sprintf(buf, "%u\n", value);
}

static ssize_t cxacru_sysfs_showattr_s8(s8 value, char *buf)
{
	return sprintf(buf, "%d\n", value);
}

static ssize_t cxacru_sysfs_showattr_dB(s16 value, char *buf)
{
	if (likely(value >= 0)) {
		return snprintf(buf, PAGE_SIZE, "%u.%02u\n",
					value / 100, value % 100);
	} else {
		value = -value;
		return snprintf(buf, PAGE_SIZE, "-%u.%02u\n",
					value / 100, value % 100);
	}
}

static ssize_t cxacru_sysfs_showattr_bool(u32 value, char *buf)

Annotation

Implementation Notes