drivers/net/can/sja1000/peak_pcmcia.c

Source file repositories/reference/linux-study-clean/drivers/net/can/sja1000/peak_pcmcia.c

File Facts

System
Linux kernel
Corpus path
drivers/net/can/sja1000/peak_pcmcia.c
Extension
.c
Size
17921 bytes
Lines
734
Domain
Driver Families
Bucket
drivers/net
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 pcan_channel {
	struct net_device *netdev;
	unsigned long prev_rx_bytes;
	unsigned long prev_tx_bytes;
};

/* PCAN-PC Card private structure */
struct pcan_pccard {
	struct pcmcia_device *pdev;
	int chan_count;
	struct pcan_channel channel[PCC_CHAN_MAX];
	u8 ccr;
	u8 fw_major;
	u8 fw_minor;
	void __iomem *ioport_addr;
	struct timer_list led_timer;
};

static struct pcmcia_device_id pcan_table[] = {
	PCMCIA_DEVICE_MANF_CARD(PCC_MANF_ID, PCC_CARD_ID),
	PCMCIA_DEVICE_NULL,
};

MODULE_DEVICE_TABLE(pcmcia, pcan_table);

static void pcan_set_leds(struct pcan_pccard *card, u8 mask, u8 state);

/*
 * start timer which controls leds state
 */
static void pcan_start_led_timer(struct pcan_pccard *card)
{
	if (!timer_pending(&card->led_timer))
		mod_timer(&card->led_timer, jiffies + HZ);
}

/*
 * stop the timer which controls leds state
 */
static void pcan_stop_led_timer(struct pcan_pccard *card)
{
	timer_delete_sync(&card->led_timer);
}

/*
 * read a sja1000 register
 */
static u8 pcan_read_canreg(const struct sja1000_priv *priv, int port)
{
	return ioread8(priv->reg_base + port);
}

/*
 * write a sja1000 register
 */
static void pcan_write_canreg(const struct sja1000_priv *priv, int port, u8 v)
{
	struct pcan_pccard *card = priv->priv;
	int c = (priv->reg_base - card->ioport_addr) / PCC_CHAN_SIZE;

	/* sja1000 register changes control the leds state */
	if (port == SJA1000_MOD)
		switch (v) {
		case MOD_RM:
			/* Reset Mode: set led on */
			pcan_set_leds(card, PCC_LED(c), PCC_LED_ON);
			break;
		case 0x00:
			/* Normal Mode: led slow blinking and start led timer */
			pcan_set_leds(card, PCC_LED(c), PCC_LED_SLOW);
			pcan_start_led_timer(card);
			break;
		default:
			break;
		}

	iowrite8(v, priv->reg_base + port);
}

/*
 * read a register from the common area
 */
static u8 pcan_read_reg(struct pcan_pccard *card, int port)
{
	return ioread8(card->ioport_addr + PCC_COMN_OFF + port);
}

/*
 * write a register into the common area
 */

Annotation

Implementation Notes