static struct sdio_driver if_sdio_driver = {
.name = "libertas_sdio",
.id_table = if_sdio_ids,
.probe = if_sdio_probe,
.remove = if_sdio_remove,
};
static int __init if_sdio_init_module(void)
{
int ret = 0;
ret = sdio_register_driver(&if_sdio_driver);
return ret;
}
static void __exit if_sdio_exit_module(void)
{
sdio_unregister_driver(&if_sdio_driver);
}
SDIO采用的与MMC兼容的命令接口,因此对于mmc的操作,LINUX又封装一层,使用数据结构 mmc_host
struct mmc_host { /* private data */ struct mmc_ios ios; /* current io bus settings */ /* group bitfields together to minimize padding */ struct mmc_card *card; /* device attached to this host */ wait_queue_head_t wq; struct delayed_work detect; const struct mmc_bus_ops *bus_ops; /* current bus driver */ unsigned int sdio_irqs; #ifdef CONFIG_LEDS_TRIGGERS struct dentry *debugfs_root; unsigned long private[0] ____cacheline_aligned;
struct device *parent;
struct device class_dev;
int index;
const struct mmc_host_ops *ops;
unsigned int f_min;
unsigned int f_max;
u32 ocr_avail;
unsigned long caps; /* Host capabilities */
/* host specific block data */
unsigned int max_seg_size; /* see blk_queue_max_segment_size */
unsigned short max_hw_segs; /* see blk_queue_max_hw_segments */
unsigned short max_phys_segs; /* see blk_queue_max_phys_segments */
unsigned short unused;
unsigned int max_req_size; /* maximum number of bytes in one req */
unsigned int max_blk_size; /* maximum size of one mmc block */
unsigned int max_blk_count; /* maximum number of blocks in one req */
spinlock_t lock; /* lock for claim and bus ops */
u32 ocr; /* the current OCR setting */
unsigned int use_spi_crc:1;
unsigned int claimed:1; /* host exclusively claimed */
unsigned int bus_dead:1; /* bus has been released */
#ifdef CONFIG_MMC_DEBUG
unsigned int removed:1; /* host is being removed */
#endif
unsigned int bus_refs; /* reference counter */
struct task_struct *sdio_irq_thread;
atomic_t sdio_irq_thread_abort;
struct led_trigger *led; /* activity led */
#endif
};
而mmc_host是一个特殊内核类 mmc_host,它会在 /sys/class/ 建立一个mmc_host类.
//drivers/mmc/core/host.c static struct class mmc_host_class = { int mmc_register_host_class(void) void mmc_unregister_host_class(void)
.name = "mmc_host",
.dev_release = mmc_host_classdev_release,
};
{
return class_register(&mmc_host_class);
}
{
class_unregister(&mmc_host_class);
}