Linux Sdio bus Driver (iii) __linux

Source: Internet
Author: User

Registering a SDIO driver will call the following function:

/**
* Sdio_register_driver-register a function driver
* @drv: SDIO function Driver
*/
int sdio_register_driver (struct sdio_driver *drv)
{
Drv->drv.name = drv->name;
Drv->drv.bus = &sdio_bus_type;
Return Driver_register (&DRV->DRV);
}

In fact, very good understanding sdio_driver is actually driver encapsulation, and the driver bus for Sdio_bus_type. The drive of this device is very simple. Look at the sdio_driver structure.

/*
* SDIO function Device driver
*/
struct Sdio_driver {
Char *name;
const struct SDIO_DEVICE_ID *id_table;


Int (*probe) (struct Sdio_func *, const struct sdio_device_id *);
void (*remove) (struct sdio_func *);


struct Device_driver DRV;
};

D_table very familiar with it, hehe. How to match device and driver in USB drive is based on this thing. The Sdio is also based on the id_table for device and driver matching.

After introducing device registration and driver registration, let's look at how these two match. Remember that there are two buses on top of the Sdio Drive one MMC bus one is sdio.

First look at the Match of MMC bus

static int Mmc_bus_match (struct device *dev,struct device_driver *drv)

{

RETURN1;

}

This is very convenient, direct is 1.

It's looking at match Sdio bus.

static int Sdio_bus_match (struct device *dev,struct device_driver *drv)

{

Structsdio_func *func = Dev_to_sdio_func (dev);

Structsdio_driver *sdrv = To_sdio_driver (DRV);

if (Sdio_match_device (func, Sdrv))

RETURN1;

Return0;

}

By looking at the implementation of the specific code above, you will find that the device and the driver match are based on id_table.

The corresponding driver is invoked if a corresponding device and driver is found when the device is registered or driven. But remember that all will first call MMC bus probe followed by the Sdio bus probe, specific to see Mmc_attach_sdio (). The process of its implementation is similar to that of Platfrom and does not repeat itself.

Six. Summary

Sdio plainly or a bus, its essence is inseparable from the driver and equipment, if the experience of USB drive will be very good understanding of the Sdio bus driver. Can be analogy in the Linux kernel

-Sdio_register_driver (): Registers the Sdio interface drive to the system, after the call, the system triggers the SDIO device ID detection, if the device ID and the ID defined in the interface driver are identical, then the system calls the probe function. 1. Can be called in the Dibbridgetargetmoduleinit (), so that after Insmod, the driver interface is registered (device ID is registered), and the corresponding device insertion is probe will be called (this practice reference LinuxKernelSdioMx28) 2 . It can also be invoked when the Sdio is initialized, so that the probe is not invoked when the device is plugged in, and the device ID is not instrumented until the Sdio is initialized and Sdio_register_driver () is invoked, and the probe is invoked. (The advantage of this approach is that module initialization does not involve any kind of device and is more versatile.) Reference LinuxKernelSdioMx53)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.