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.
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/kernel.hlinux/module.hlinux/interrupt.hlinux/netdevice.hlinux/delay.hlinux/timer.hlinux/io.hpcmcia/cistpl.hpcmcia/ds.hlinux/can.hlinux/can/dev.hsja1000.h
Detected Declarations
struct pcan_channelstruct pcan_pccardfunction pcan_start_led_timerfunction pcan_stop_led_timerfunction pcan_read_canregfunction pcan_write_canregfunction pcan_read_regfunction pcan_write_regfunction pcan_pccard_presentfunction pcan_wait_spi_busyfunction pcan_write_eepromfunction pcan_set_ledsfunction pcan_set_can_powerfunction pcan_led_timerfunction pcan_isrfunction sja1000_interruptfunction pcan_free_channelsfunction pcan_channel_presentfunction pcan_add_channelsfunction pcan_conf_checkfunction pcan_freefunction pcan_probefunction pcan_remove
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
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/interrupt.h`, `linux/netdevice.h`, `linux/delay.h`, `linux/timer.h`, `linux/io.h`, `pcmcia/cistpl.h`.
- Detected declarations: `struct pcan_channel`, `struct pcan_pccard`, `function pcan_start_led_timer`, `function pcan_stop_led_timer`, `function pcan_read_canreg`, `function pcan_write_canreg`, `function pcan_read_reg`, `function pcan_write_reg`, `function pcan_pccard_present`, `function pcan_wait_spi_busy`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.