aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorPierre Ossman <drzeus@drzeus.cx>2007-06-16 09:54:55 -0400
committerPierre Ossman <drzeus@drzeus.cx>2007-09-23 14:51:27 -0400
commit3b38bea0d976513970f947806b08b9faca418e7a (patch)
treef542a7e3dfe206be4de9f7ca6ebc23d25a196731 /drivers/mmc
parent26074962e8f547b96614dbe248748ba2a1996ca3 (diff)
sdio: add device id table and matching
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/core/sdio_bus.c58
1 files changed, 52 insertions, 6 deletions
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index 461fe4837a9f..a3a89e973d94 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -21,14 +21,47 @@
21#include "sdio_bus.h" 21#include "sdio_bus.h"
22 22
23#define dev_to_sdio_func(d) container_of(d, struct sdio_func, dev) 23#define dev_to_sdio_func(d) container_of(d, struct sdio_func, dev)
24#define to_sdio_driver(d) container_of(d, struct sdio_driver, drv)
25
26static const struct sdio_device_id *sdio_match_one(struct sdio_func *func,
27 const struct sdio_device_id *id)
28{
29 if (id->class != (__u8)SDIO_ANY_ID && id->class != func->class)
30 return NULL;
31 if (id->vendor != (__u16)SDIO_ANY_ID && id->vendor != func->vendor)
32 return NULL;
33 if (id->device != (__u16)SDIO_ANY_ID && id->device != func->device)
34 return NULL;
35 return id;
36}
37
38static const struct sdio_device_id *sdio_match_device(struct sdio_func *func,
39 struct sdio_driver *sdrv)
40{
41 const struct sdio_device_id *ids;
42
43 ids = sdrv->id_table;
44
45 if (ids) {
46 while (ids->class || ids->vendor || ids->device) {
47 if (sdio_match_one(func, ids))
48 return ids;
49 ids++;
50 }
51 }
52
53 return NULL;
54}
24 55
25/*
26 * This currently matches any SDIO function to any driver in order
27 * to help initial development and testing.
28 */
29static int sdio_bus_match(struct device *dev, struct device_driver *drv) 56static int sdio_bus_match(struct device *dev, struct device_driver *drv)
30{ 57{
31 return 1; 58 struct sdio_func *func = dev_to_sdio_func(dev);
59 struct sdio_driver *sdrv = to_sdio_driver(drv);
60
61 if (sdio_match_device(func, sdrv))
62 return 1;
63
64 return 0;
32} 65}
33 66
34static int 67static int
@@ -42,11 +75,24 @@ sdio_bus_uevent(struct device *dev, char **envp, int num_envp, char *buf,
42 75
43static int sdio_bus_probe(struct device *dev) 76static int sdio_bus_probe(struct device *dev)
44{ 77{
45 return -ENODEV; 78 struct sdio_driver *drv = to_sdio_driver(dev->driver);
79 struct sdio_func *func = dev_to_sdio_func(dev);
80 const struct sdio_device_id *id;
81
82 id = sdio_match_device(func, drv);
83 if (!id)
84 return -ENODEV;
85
86 return drv->probe(func, id);
46} 87}
47 88
48static int sdio_bus_remove(struct device *dev) 89static int sdio_bus_remove(struct device *dev)
49{ 90{
91 struct sdio_driver *drv = to_sdio_driver(dev->driver);
92 struct sdio_func *func = dev_to_sdio_func(dev);
93
94 drv->remove(func);
95
50 return 0; 96 return 0;
51} 97}
52 98