aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/tifm_7xx1.c14
-rw-r--r--drivers/misc/tifm_core.c57
2 files changed, 41 insertions, 30 deletions
diff --git a/drivers/misc/tifm_7xx1.c b/drivers/misc/tifm_7xx1.c
index d6652b3301dc..fd7b8dadc821 100644
--- a/drivers/misc/tifm_7xx1.c
+++ b/drivers/misc/tifm_7xx1.c
@@ -73,7 +73,7 @@ static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id)
73 return IRQ_HANDLED; 73 return IRQ_HANDLED;
74} 74}
75 75
76static tifm_media_id tifm_7xx1_toggle_sock_power(char __iomem *sock_addr, 76static unsigned char tifm_7xx1_toggle_sock_power(char __iomem *sock_addr,
77 int is_x2) 77 int is_x2)
78{ 78{
79 unsigned int s_state; 79 unsigned int s_state;
@@ -90,7 +90,7 @@ static tifm_media_id tifm_7xx1_toggle_sock_power(char __iomem *sock_addr,
90 90
91 s_state = readl(sock_addr + SOCK_PRESENT_STATE); 91 s_state = readl(sock_addr + SOCK_PRESENT_STATE);
92 if (!(TIFM_SOCK_STATE_OCCUPIED & s_state)) 92 if (!(TIFM_SOCK_STATE_OCCUPIED & s_state))
93 return FM_NULL; 93 return 0;
94 94
95 if (is_x2) { 95 if (is_x2) {
96 writel((s_state & 7) | 0x0c00, sock_addr + SOCK_CONTROL); 96 writel((s_state & 7) | 0x0c00, sock_addr + SOCK_CONTROL);
@@ -129,7 +129,7 @@ static int tifm_7xx1_switch_media(void *data)
129{ 129{
130 struct tifm_adapter *fm = data; 130 struct tifm_adapter *fm = data;
131 unsigned long flags; 131 unsigned long flags;
132 tifm_media_id media_id; 132 unsigned char media_id;
133 char *card_name = "xx"; 133 char *card_name = "xx";
134 int cnt, rc; 134 int cnt, rc;
135 struct tifm_dev *sock; 135 struct tifm_dev *sock;
@@ -184,7 +184,7 @@ static int tifm_7xx1_switch_media(void *data)
184 if (sock) { 184 if (sock) {
185 sock->addr = tifm_7xx1_sock_addr(fm->addr, 185 sock->addr = tifm_7xx1_sock_addr(fm->addr,
186 cnt); 186 cnt);
187 sock->media_id = media_id; 187 sock->type = media_id;
188 sock->socket_id = cnt; 188 sock->socket_id = cnt;
189 switch (media_id) { 189 switch (media_id) {
190 case 1: 190 case 1:
@@ -266,7 +266,7 @@ static int tifm_7xx1_resume(struct pci_dev *dev)
266 struct tifm_adapter *fm = pci_get_drvdata(dev); 266 struct tifm_adapter *fm = pci_get_drvdata(dev);
267 int cnt, rc; 267 int cnt, rc;
268 unsigned long flags; 268 unsigned long flags;
269 tifm_media_id new_ids[fm->num_sockets]; 269 unsigned char new_ids[fm->num_sockets];
270 270
271 pci_set_power_state(dev, PCI_D0); 271 pci_set_power_state(dev, PCI_D0);
272 pci_restore_state(dev); 272 pci_restore_state(dev);
@@ -285,10 +285,10 @@ static int tifm_7xx1_resume(struct pci_dev *dev)
285 fm->socket_change_set = 0; 285 fm->socket_change_set = 0;
286 for (cnt = 0; cnt < fm->num_sockets; cnt++) { 286 for (cnt = 0; cnt < fm->num_sockets; cnt++) {
287 if (fm->sockets[cnt]) { 287 if (fm->sockets[cnt]) {
288 if (fm->sockets[cnt]->media_id == new_ids[cnt]) 288 if (fm->sockets[cnt]->type == new_ids[cnt])
289 fm->socket_change_set |= 1 << cnt; 289 fm->socket_change_set |= 1 << cnt;
290 290
291 fm->sockets[cnt]->media_id = new_ids[cnt]; 291 fm->sockets[cnt]->type = new_ids[cnt];
292 } 292 }
293 } 293 }
294 294
diff --git a/drivers/misc/tifm_core.c b/drivers/misc/tifm_core.c
index dcff45a19bcb..6b2c447dc8ee 100644
--- a/drivers/misc/tifm_core.c
+++ b/drivers/misc/tifm_core.c
@@ -19,42 +19,53 @@
19static DEFINE_IDR(tifm_adapter_idr); 19static DEFINE_IDR(tifm_adapter_idr);
20static DEFINE_SPINLOCK(tifm_adapter_lock); 20static DEFINE_SPINLOCK(tifm_adapter_lock);
21 21
22static tifm_media_id *tifm_device_match(tifm_media_id *ids, 22static const char *tifm_media_type_name(unsigned char type, unsigned char nt)
23 struct tifm_dev *dev)
24{ 23{
25 while (*ids) { 24 const char *card_type_name[3][3] = {
26 if (dev->media_id == *ids) 25 { "SmartMedia/xD", "MemoryStick", "MMC/SD" },
27 return ids; 26 { "XD", "MS", "SD"},
28 ids++; 27 { "xd", "ms", "sd"}
29 } 28 };
30 return NULL; 29
30 if (nt > 2 || type < 1 || type > 3)
31 return NULL;
32 return card_type_name[nt][type - 1];
31} 33}
32 34
33static int tifm_match(struct device *dev, struct device_driver *drv) 35static int tifm_dev_match(struct tifm_dev *sock, struct tifm_device_id *id)
34{ 36{
35 struct tifm_dev *fm_dev = container_of(dev, struct tifm_dev, dev); 37 if (sock->type == id->type)
36 struct tifm_driver *fm_drv;
37
38 fm_drv = container_of(drv, struct tifm_driver, driver);
39 if (!fm_drv->id_table)
40 return -EINVAL;
41 if (tifm_device_match(fm_drv->id_table, fm_dev))
42 return 1; 38 return 1;
43 return -ENODEV; 39 return 0;
40}
41
42static int tifm_bus_match(struct device *dev, struct device_driver *drv)
43{
44 struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
45 struct tifm_driver *fm_drv = container_of(drv, struct tifm_driver,
46 driver);
47 struct tifm_device_id *ids = fm_drv->id_table;
48
49 if (ids) {
50 while (ids->type) {
51 if (tifm_dev_match(sock, ids))
52 return 1;
53 ++ids;
54 }
55 }
56 return 0;
44} 57}
45 58
46static int tifm_uevent(struct device *dev, char **envp, int num_envp, 59static int tifm_uevent(struct device *dev, char **envp, int num_envp,
47 char *buffer, int buffer_size) 60 char *buffer, int buffer_size)
48{ 61{
49 struct tifm_dev *fm_dev; 62 struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
50 int i = 0; 63 int i = 0;
51 int length = 0; 64 int length = 0;
52 const char *card_type_name[] = {"INV", "SM", "MS", "SD"};
53 65
54 if (!dev || !(fm_dev = container_of(dev, struct tifm_dev, dev)))
55 return -ENODEV;
56 if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, 66 if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
57 "TIFM_CARD_TYPE=%s", card_type_name[fm_dev->media_id])) 67 "TIFM_CARD_TYPE=%s",
68 tifm_media_type_name(sock->type, 1)))
58 return -ENOMEM; 69 return -ENOMEM;
59 70
60 return 0; 71 return 0;
@@ -132,7 +143,7 @@ static int tifm_device_resume(struct device *dev)
132 143
133static struct bus_type tifm_bus_type = { 144static struct bus_type tifm_bus_type = {
134 .name = "tifm", 145 .name = "tifm",
135 .match = tifm_match, 146 .match = tifm_bus_match,
136 .uevent = tifm_uevent, 147 .uevent = tifm_uevent,
137 .probe = tifm_device_probe, 148 .probe = tifm_device_probe,
138 .remove = tifm_device_remove, 149 .remove = tifm_device_remove,