drivers/net/can/softing/softing_cs.c

Source file repositories/reference/linux-study-clean/drivers/net/can/softing/softing_cs.c

File Facts

System
Linux kernel
Corpus path
drivers/net/can/softing/softing_cs.c
Extension
.c
Size
8976 bytes
Lines
336
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 dev {
		struct platform_device pdev;
		struct resource res[2];
	} *dev;

	/* find matching platform_data */
	pdat = softingcs_find_platform_data(pcmcia->manf_id, pcmcia->card_id);
	if (!pdat)
		return -ENOTTY;

	/* setup pcmcia device */
	pcmcia->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IOMEM |
		CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC;
	ret = pcmcia_loop_config(pcmcia, softingcs_probe_config, (void *)pdat);
	if (ret)
		goto pcmcia_failed;

	ret = pcmcia_enable_device(pcmcia);
	if (ret < 0)
		goto pcmcia_failed;

	pres = pcmcia->resource[PCMCIA_IOMEM_0];
	if (!pres) {
		ret = -EBADF;
		goto pcmcia_bad;
	}

	/* create softing platform device */
	dev = kzalloc_obj(*dev);
	if (!dev) {
		ret = -ENOMEM;
		goto mem_failed;
	}
	dev->pdev.resource = dev->res;
	dev->pdev.num_resources = ARRAY_SIZE(dev->res);
	dev->pdev.dev.release = softingcs_pdev_release;

	pdev = &dev->pdev;
	pdev->dev.platform_data = (void *)pdat;
	pdev->dev.parent = &pcmcia->dev;
	pcmcia->priv = pdev;

	/* platform device resources */
	pdev->resource[0].flags = IORESOURCE_MEM;
	pdev->resource[0].start = pres->start;
	pdev->resource[0].end = pres->end;

	pdev->resource[1].flags = IORESOURCE_IRQ;
	pdev->resource[1].start = pcmcia->irq;
	pdev->resource[1].end = pdev->resource[1].start;

	/* platform device setup */
	spin_lock(&softingcs_index_lock);
	pdev->id = softingcs_index++;
	spin_unlock(&softingcs_index_lock);
	pdev->name = "softing";
	dev_set_name(&pdev->dev, "softingcs.%i", pdev->id);
	ret = platform_device_register(pdev);
	if (ret < 0)
		goto platform_failed;

	dev_info(&pcmcia->dev, "created %s\n", dev_name(&pdev->dev));
	return 0;

platform_failed:
	platform_device_put(pdev);
mem_failed:
pcmcia_bad:
pcmcia_failed:
	pcmcia_disable_device(pcmcia);
	pcmcia->priv = NULL;
	return ret;
}

static const struct pcmcia_device_id softingcs_ids[] = {
	/* softing */
	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0001),
	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0002),
	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0004),
	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0005),
	/* vector, manufacturer? */
	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0081),
	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0084),
	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0085),
	/* EDIC */
	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0102),
	PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0105),
	PCMCIA_DEVICE_NULL,
};

Annotation

Implementation Notes