diff options
Diffstat (limited to 'drivers/misc/tifm_7xx1.c')
-rw-r--r-- | drivers/misc/tifm_7xx1.c | 94 |
1 files changed, 35 insertions, 59 deletions
diff --git a/drivers/misc/tifm_7xx1.c b/drivers/misc/tifm_7xx1.c index e051f9da9c5c..356386904a5d 100644 --- a/drivers/misc/tifm_7xx1.c +++ b/drivers/misc/tifm_7xx1.c | |||
@@ -136,7 +136,6 @@ static void tifm_7xx1_switch_media(struct work_struct *work) | |||
136 | media_switcher); | 136 | media_switcher); |
137 | unsigned long flags; | 137 | unsigned long flags; |
138 | unsigned char media_id; | 138 | unsigned char media_id; |
139 | char *card_name = "xx"; | ||
140 | int cnt; | 139 | int cnt; |
141 | struct tifm_dev *sock; | 140 | struct tifm_dev *sock; |
142 | unsigned int socket_change_set; | 141 | unsigned int socket_change_set; |
@@ -153,68 +152,45 @@ static void tifm_7xx1_switch_media(struct work_struct *work) | |||
153 | return; | 152 | return; |
154 | } | 153 | } |
155 | 154 | ||
156 | for (cnt = 0; cnt < fm->num_sockets; cnt++) { | 155 | for (cnt = 0; cnt < fm->num_sockets; cnt++) { |
157 | if (!(socket_change_set & (1 << cnt))) | 156 | if (!(socket_change_set & (1 << cnt))) |
158 | continue; | 157 | continue; |
159 | sock = fm->sockets[cnt]; | 158 | sock = fm->sockets[cnt]; |
160 | if (sock) { | 159 | if (sock) { |
161 | printk(KERN_INFO DRIVER_NAME | 160 | printk(KERN_INFO |
162 | ": demand removing card from socket %d\n", | 161 | "%s : demand removing card from socket %u:%u\n", |
163 | cnt); | 162 | fm->cdev.class_id, fm->id, cnt); |
164 | fm->sockets[cnt] = NULL; | 163 | fm->sockets[cnt] = NULL; |
165 | spin_unlock_irqrestore(&fm->lock, flags); | ||
166 | device_unregister(&sock->dev); | ||
167 | spin_lock_irqsave(&fm->lock, flags); | ||
168 | writel(0x0e00, | ||
169 | tifm_7xx1_sock_addr(fm->addr, cnt) | ||
170 | + SOCK_CONTROL); | ||
171 | } | ||
172 | |||
173 | spin_unlock_irqrestore(&fm->lock, flags); | 164 | spin_unlock_irqrestore(&fm->lock, flags); |
174 | media_id = tifm_7xx1_toggle_sock_power( | 165 | device_unregister(&sock->dev); |
175 | tifm_7xx1_sock_addr(fm->addr, cnt)); | 166 | spin_lock_irqsave(&fm->lock, flags); |
176 | if (media_id) { | 167 | writel(0x0e00, tifm_7xx1_sock_addr(fm->addr, cnt) |
177 | sock = tifm_alloc_device(fm); | 168 | + SOCK_CONTROL); |
178 | if (sock) { | 169 | } |
179 | sock->addr = tifm_7xx1_sock_addr(fm->addr, | 170 | |
180 | cnt); | 171 | spin_unlock_irqrestore(&fm->lock, flags); |
181 | sock->type = media_id; | 172 | |
182 | sock->socket_id = cnt; | 173 | media_id = tifm_7xx1_toggle_sock_power( |
183 | switch (media_id) { | 174 | tifm_7xx1_sock_addr(fm->addr, cnt)); |
184 | case 1: | 175 | |
185 | card_name = "xd"; | 176 | // tifm_alloc_device will check if media_id is valid |
186 | break; | 177 | sock = tifm_alloc_device(fm, cnt, media_id); |
187 | case 2: | 178 | if (sock) { |
188 | card_name = "ms"; | 179 | sock->addr = tifm_7xx1_sock_addr(fm->addr, cnt); |
189 | break; | 180 | |
190 | case 3: | 181 | if (!device_register(&sock->dev)) { |
191 | card_name = "sd"; | ||
192 | break; | ||
193 | default: | ||
194 | tifm_free_device(&sock->dev); | ||
195 | spin_lock_irqsave(&fm->lock, flags); | ||
196 | continue; | ||
197 | } | ||
198 | snprintf(sock->dev.bus_id, BUS_ID_SIZE, | ||
199 | "tifm_%s%u:%u", card_name, | ||
200 | fm->id, cnt); | ||
201 | printk(KERN_INFO DRIVER_NAME | ||
202 | ": %s card detected in socket %d\n", | ||
203 | card_name, cnt); | ||
204 | if (!device_register(&sock->dev)) { | ||
205 | spin_lock_irqsave(&fm->lock, flags); | ||
206 | if (!fm->sockets[cnt]) { | ||
207 | fm->sockets[cnt] = sock; | ||
208 | sock = NULL; | ||
209 | } | ||
210 | spin_unlock_irqrestore(&fm->lock, flags); | ||
211 | } | ||
212 | if (sock) | ||
213 | tifm_free_device(&sock->dev); | ||
214 | } | ||
215 | spin_lock_irqsave(&fm->lock, flags); | 182 | spin_lock_irqsave(&fm->lock, flags); |
183 | if (!fm->sockets[cnt]) { | ||
184 | fm->sockets[cnt] = sock; | ||
185 | sock = NULL; | ||
186 | } | ||
187 | spin_unlock_irqrestore(&fm->lock, flags); | ||
216 | } | 188 | } |
189 | if (sock) | ||
190 | tifm_free_device(&sock->dev); | ||
217 | } | 191 | } |
192 | spin_lock_irqsave(&fm->lock, flags); | ||
193 | } | ||
218 | 194 | ||
219 | writel(TIFM_IRQ_FIFOMASK(socket_change_set) | 195 | writel(TIFM_IRQ_FIFOMASK(socket_change_set) |
220 | | TIFM_IRQ_CARDMASK(socket_change_set), | 196 | | TIFM_IRQ_CARDMASK(socket_change_set), |