drivers/net/ethernet/xircom/xirc2ps_cs.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/xircom/xirc2ps_cs.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/xircom/xirc2ps_cs.c
Extension
.c
Size
53298 bytes
Lines
1795
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern 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

static const struct net_device_ops netdev_ops = {
	.ndo_open		= do_open,
	.ndo_stop		= do_stop,
	.ndo_start_xmit		= do_start_xmit,
	.ndo_tx_timeout 	= xirc_tx_timeout,
	.ndo_set_config		= do_config,
	.ndo_eth_ioctl		= do_ioctl,
	.ndo_set_rx_mode	= set_multicast_list,
	.ndo_set_mac_address 	= eth_mac_addr,
	.ndo_validate_addr	= eth_validate_addr,
};

static int
xirc2ps_probe(struct pcmcia_device *link)
{
    struct net_device *dev;
    struct local_info *local;

    dev_dbg(&link->dev, "attach()\n");

    /* Allocate the device structure */
    dev = alloc_etherdev(sizeof(struct local_info));
    if (!dev)
	    return -ENOMEM;
    local = netdev_priv(dev);
    local->dev = dev;
    local->p_dev = link;
    link->priv = dev;

    /* General socket configuration */
    link->config_index = 1;

    /* Fill in card specific entries */
    dev->netdev_ops = &netdev_ops;
    dev->ethtool_ops = &netdev_ethtool_ops;
    dev->watchdog_timeo = TX_TIMEOUT;
    INIT_WORK(&local->tx_timeout_task, xirc2ps_tx_timeout_task);

    return xirc2ps_config(link);
} /* xirc2ps_attach */

static void
xirc2ps_detach(struct pcmcia_device *link)
{
    struct net_device *dev = link->priv;
    struct local_info *local = netdev_priv(dev);

    netif_carrier_off(dev);
    netif_tx_disable(dev);
    cancel_work_sync(&local->tx_timeout_task);

    dev_dbg(&link->dev, "detach\n");

    unregister_netdev(dev);

    xirc2ps_release(link);

    free_netdev(dev);
} /* xirc2ps_detach */

/****************
 * Detect the type of the card. s is the buffer with the data of tuple 0x20
 * Returns: 0 := not supported
 *		       mediaid=11 and prodid=47
 * Media-Id bits:
 *  Ethernet	    0x01
 *  Tokenring	    0x02
 *  Arcnet	    0x04
 *  Wireless	    0x08
 *  Modem	    0x10
 *  GSM only	    0x20
 * Prod-Id bits:
 *  Pocket	    0x10
 *  External	    0x20
 *  Creditcard	    0x40
 *  Cardbus	    0x80
 *
 */
static int
set_card_type(struct pcmcia_device *link)
{
    struct net_device *dev = link->priv;
    struct local_info *local = netdev_priv(dev);
    u8 *buf;
    unsigned int cisrev, mediaid, prodid;
    size_t len;

    len = pcmcia_get_tuple(link, CISTPL_MANFID, &buf);
    if (len < 5) {
	    dev_err(&link->dev, "invalid CIS -- sorry\n");

Annotation

Implementation Notes