diff options
-rw-r--r-- | drivers/misc/tifm_7xx1.c | 14 | ||||
-rw-r--r-- | drivers/misc/tifm_core.c | 57 | ||||
-rw-r--r-- | drivers/mmc/tifm_sd.c | 6 | ||||
-rw-r--r-- | include/linux/tifm.h | 16 |
4 files changed, 53 insertions, 40 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 | ||
76 | static tifm_media_id tifm_7xx1_toggle_sock_power(char __iomem *sock_addr, | 76 | static 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 @@ | |||
19 | static DEFINE_IDR(tifm_adapter_idr); | 19 | static DEFINE_IDR(tifm_adapter_idr); |
20 | static DEFINE_SPINLOCK(tifm_adapter_lock); | 20 | static DEFINE_SPINLOCK(tifm_adapter_lock); |
21 | 21 | ||
22 | static tifm_media_id *tifm_device_match(tifm_media_id *ids, | 22 | static 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 | ||
33 | static int tifm_match(struct device *dev, struct device_driver *drv) | 35 | static 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 | |||
42 | static 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 | ||
46 | static int tifm_uevent(struct device *dev, char **envp, int num_envp, | 59 | static 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 | ||
133 | static struct bus_type tifm_bus_type = { | 144 | static 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, |
diff --git a/drivers/mmc/tifm_sd.c b/drivers/mmc/tifm_sd.c index 8905b129e4e1..4388ee9062a0 100644 --- a/drivers/mmc/tifm_sd.c +++ b/drivers/mmc/tifm_sd.c | |||
@@ -948,7 +948,7 @@ static int tifm_sd_resume(struct tifm_dev *sock) | |||
948 | struct mmc_host *mmc = tifm_get_drvdata(sock); | 948 | struct mmc_host *mmc = tifm_get_drvdata(sock); |
949 | struct tifm_sd *host = mmc_priv(mmc); | 949 | struct tifm_sd *host = mmc_priv(mmc); |
950 | 950 | ||
951 | if (sock->media_id != FM_SD | 951 | if (sock->type != TIFM_TYPE_SD |
952 | || tifm_sd_initialize_host(host)) { | 952 | || tifm_sd_initialize_host(host)) { |
953 | tifm_eject(sock); | 953 | tifm_eject(sock); |
954 | return 0; | 954 | return 0; |
@@ -964,8 +964,8 @@ static int tifm_sd_resume(struct tifm_dev *sock) | |||
964 | 964 | ||
965 | #endif /* CONFIG_PM */ | 965 | #endif /* CONFIG_PM */ |
966 | 966 | ||
967 | static tifm_media_id tifm_sd_id_tbl[] = { | 967 | static struct tifm_device_id tifm_sd_id_tbl[] = { |
968 | FM_SD, 0 | 968 | { TIFM_TYPE_SD }, { } |
969 | }; | 969 | }; |
970 | 970 | ||
971 | static struct tifm_driver tifm_sd_driver = { | 971 | static struct tifm_driver tifm_sd_driver = { |
diff --git a/include/linux/tifm.h b/include/linux/tifm.h index ee1056396b95..57b2653494cf 100644 --- a/include/linux/tifm.h +++ b/include/linux/tifm.h | |||
@@ -74,13 +74,19 @@ enum { | |||
74 | #define TIFM_DMA_TX 0x00008000 /* Meaning of this constant is unverified */ | 74 | #define TIFM_DMA_TX 0x00008000 /* Meaning of this constant is unverified */ |
75 | #define TIFM_DMA_EN 0x00000001 /* Meaning of this constant is unverified */ | 75 | #define TIFM_DMA_EN 0x00000001 /* Meaning of this constant is unverified */ |
76 | 76 | ||
77 | typedef enum {FM_NULL = 0, FM_XD = 0x01, FM_MS = 0x02, FM_SD = 0x03} tifm_media_id; | 77 | #define TIFM_TYPE_XD 1 |
78 | #define TIFM_TYPE_MS 2 | ||
79 | #define TIFM_TYPE_SD 3 | ||
80 | |||
81 | struct tifm_device_id { | ||
82 | unsigned char type; | ||
83 | }; | ||
78 | 84 | ||
79 | struct tifm_driver; | 85 | struct tifm_driver; |
80 | struct tifm_dev { | 86 | struct tifm_dev { |
81 | char __iomem *addr; | 87 | char __iomem *addr; |
82 | spinlock_t lock; | 88 | spinlock_t lock; |
83 | tifm_media_id media_id; | 89 | unsigned char type; |
84 | unsigned int socket_id; | 90 | unsigned int socket_id; |
85 | 91 | ||
86 | void (*card_event)(struct tifm_dev *sock); | 92 | void (*card_event)(struct tifm_dev *sock); |
@@ -90,7 +96,7 @@ struct tifm_dev { | |||
90 | }; | 96 | }; |
91 | 97 | ||
92 | struct tifm_driver { | 98 | struct tifm_driver { |
93 | tifm_media_id *id_table; | 99 | struct tifm_device_id *id_table; |
94 | int (*probe)(struct tifm_dev *dev); | 100 | int (*probe)(struct tifm_dev *dev); |
95 | void (*remove)(struct tifm_dev *dev); | 101 | void (*remove)(struct tifm_dev *dev); |
96 | int (*suspend)(struct tifm_dev *dev, | 102 | int (*suspend)(struct tifm_dev *dev, |
@@ -141,8 +147,4 @@ static inline void tifm_set_drvdata(struct tifm_dev *dev, void *data) | |||
141 | dev_set_drvdata(&dev->dev, data); | 147 | dev_set_drvdata(&dev->dev, data); |
142 | } | 148 | } |
143 | 149 | ||
144 | struct tifm_device_id { | ||
145 | tifm_media_id media_id; | ||
146 | }; | ||
147 | |||
148 | #endif | 150 | #endif |