UPSTREAM: staging: gdm72xx: cancel work when driver unloads
[cascardo/linux.git] / drivers / staging / gdm72xx / gdm_sdio.c
1 /*
2  * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
3  *
4  * This software is licensed under the terms of the GNU General Public
5  * License version 2, as published by the Free Software Foundation, and
6  * may be copied, distributed, and modified under those terms.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  */
13
14 #include <linux/module.h>
15 #include <linux/init.h>
16 #include <linux/kernel.h>
17
18 #include <linux/mmc/core.h>
19 #include <linux/mmc/card.h>
20 #include <linux/mmc/sdio_func.h>
21 #include <linux/mmc/sdio_ids.h>
22
23 #include "gdm_sdio.h"
24 #include "gdm_wimax.h"
25 #include "sdio_boot.h"
26 #include "hci.h"
27
28 #define TYPE_A_HEADER_SIZE      4
29 #define TYPE_A_LOOKAHEAD_SIZE   16
30
31 #define MAX_NR_RX_BUF   4
32
33 #define SDU_TX_BUF_SIZE 2048
34 #define TX_BUF_SIZE             2048
35 #define TX_CHUNK_SIZE   (2048 - TYPE_A_HEADER_SIZE)
36 #define RX_BUF_SIZE             (25*1024)
37
38 #define TX_HZ   2000
39 #define TX_INTERVAL     (1000000/TX_HZ)
40
41 /*#define DEBUG*/
42
43 static int init_sdio(struct sdiowm_dev *sdev);
44 static void release_sdio(struct sdiowm_dev *sdev);
45
46 #ifdef DEBUG
47 static void hexdump(char *title, u8 *data, int len)
48 {
49         int i;
50
51         printk(KERN_DEBUG "%s: length = %d\n", title, len);
52         for (i = 0; i < len; i++) {
53                 printk(KERN_DEBUG "%02x ", data[i]);
54                 if ((i & 0xf) == 0xf)
55                         printk(KERN_DEBUG "\n");
56         }
57         printk(KERN_DEBUG "\n");
58 }
59 #endif
60
61 static struct sdio_tx *alloc_tx_struct(struct tx_cxt *tx)
62 {
63         struct sdio_tx *t = kzalloc(sizeof(*t), GFP_ATOMIC);
64
65         if (!t)
66                 return NULL;
67
68         t->buf = kmalloc(TX_BUF_SIZE, GFP_ATOMIC);
69         if (!t->buf) {
70                 kfree(t);
71                 return NULL;
72         }
73
74         t->tx_cxt = tx;
75
76         return t;
77 }
78
79 static void free_tx_struct(struct sdio_tx *t)
80 {
81         if (t) {
82                 kfree(t->buf);
83                 kfree(t);
84         }
85 }
86
87 static struct sdio_rx *alloc_rx_struct(struct rx_cxt *rx)
88 {
89         struct sdio_rx *r = kzalloc(sizeof(*r), GFP_ATOMIC);
90
91         if (r)
92                 r->rx_cxt = rx;
93
94         return r;
95 }
96
97 static void free_rx_struct(struct sdio_rx *r)
98 {
99         kfree(r);
100 }
101
102 /* Before this function is called, spin lock should be locked. */
103 static struct sdio_tx *get_tx_struct(struct tx_cxt *tx, int *no_spc)
104 {
105         struct sdio_tx *t;
106
107         if (list_empty(&tx->free_list))
108                 return NULL;
109
110         t = list_entry(tx->free_list.prev, struct sdio_tx, list);
111         list_del(&t->list);
112
113         *no_spc = list_empty(&tx->free_list) ? 1 : 0;
114
115         return t;
116 }
117
118 /* Before this function is called, spin lock should be locked. */
119 static void put_tx_struct(struct tx_cxt *tx, struct sdio_tx *t)
120 {
121         list_add_tail(&t->list, &tx->free_list);
122 }
123
124 /* Before this function is called, spin lock should be locked. */
125 static struct sdio_rx *get_rx_struct(struct rx_cxt *rx)
126 {
127         struct sdio_rx *r;
128
129         if (list_empty(&rx->free_list))
130                 return NULL;
131
132         r = list_entry(rx->free_list.prev, struct sdio_rx, list);
133         list_del(&r->list);
134
135         return r;
136 }
137
138 /* Before this function is called, spin lock should be locked. */
139 static void put_rx_struct(struct rx_cxt *rx, struct sdio_rx *r)
140 {
141         list_add_tail(&r->list, &rx->free_list);
142 }
143
144 static int init_sdio(struct sdiowm_dev *sdev)
145 {
146         int ret = 0, i;
147         struct tx_cxt   *tx = &sdev->tx;
148         struct rx_cxt   *rx = &sdev->rx;
149         struct sdio_tx  *t;
150         struct sdio_rx  *r;
151
152         INIT_LIST_HEAD(&tx->free_list);
153         INIT_LIST_HEAD(&tx->sdu_list);
154         INIT_LIST_HEAD(&tx->hci_list);
155
156         spin_lock_init(&tx->lock);
157
158         tx->sdu_buf = kmalloc(SDU_TX_BUF_SIZE, GFP_KERNEL);
159         if (tx->sdu_buf == NULL) {
160                 dev_err(&sdev->func->dev, "Failed to allocate SDU tx buffer.\n");
161                 goto fail;
162         }
163
164         for (i = 0; i < MAX_NR_SDU_BUF; i++) {
165                 t = alloc_tx_struct(tx);
166                 if (t == NULL) {
167                         ret = -ENOMEM;
168                         goto fail;
169                 }
170                 list_add(&t->list, &tx->free_list);
171         }
172
173         INIT_LIST_HEAD(&rx->free_list);
174         INIT_LIST_HEAD(&rx->req_list);
175
176         spin_lock_init(&rx->lock);
177
178         for (i = 0; i < MAX_NR_RX_BUF; i++) {
179                 r = alloc_rx_struct(rx);
180                 if (r == NULL) {
181                         ret = -ENOMEM;
182                         goto fail;
183                 }
184                 list_add(&r->list, &rx->free_list);
185         }
186
187         rx->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL);
188         if (rx->rx_buf == NULL) {
189                 dev_err(&sdev->func->dev, "Failed to allocate rx buffer.\n");
190                 goto fail;
191         }
192
193         return 0;
194
195 fail:
196         release_sdio(sdev);
197         return ret;
198 }
199
200 static void release_sdio(struct sdiowm_dev *sdev)
201 {
202         struct tx_cxt   *tx = &sdev->tx;
203         struct rx_cxt   *rx = &sdev->rx;
204         struct sdio_tx  *t, *t_next;
205         struct sdio_rx  *r, *r_next;
206
207         kfree(tx->sdu_buf);
208
209         list_for_each_entry_safe(t, t_next, &tx->free_list, list) {
210                 list_del(&t->list);
211                 free_tx_struct(t);
212         }
213
214         list_for_each_entry_safe(t, t_next, &tx->sdu_list, list) {
215                 list_del(&t->list);
216                 free_tx_struct(t);
217         }
218
219         list_for_each_entry_safe(t, t_next, &tx->hci_list, list) {
220                 list_del(&t->list);
221                 free_tx_struct(t);
222         }
223
224         kfree(rx->rx_buf);
225
226         list_for_each_entry_safe(r, r_next, &rx->free_list, list) {
227                 list_del(&r->list);
228                 free_rx_struct(r);
229         }
230
231         list_for_each_entry_safe(r, r_next, &rx->req_list, list) {
232                 list_del(&r->list);
233                 free_rx_struct(r);
234         }
235 }
236
237 static void send_sdio_pkt(struct sdio_func *func, u8 *data, int len)
238 {
239         int n, blocks, ret, remain;
240
241         sdio_claim_host(func);
242
243         blocks = len / func->cur_blksize;
244         n = blocks * func->cur_blksize;
245         if (blocks) {
246                 ret = sdio_memcpy_toio(func, 0, data, n);
247                 if (ret < 0) {
248                         if (ret != -ENOMEDIUM)
249                                 dev_err(&func->dev,
250                                         "gdmwms: %s error: ret = %d\n",
251                                         __func__, ret);
252                         goto end_io;
253                 }
254         }
255
256         remain = len - n;
257         remain = (remain + 3) & ~3;
258
259         if (remain) {
260                 ret = sdio_memcpy_toio(func, 0, data + n, remain);
261                 if (ret < 0) {
262                         if (ret != -ENOMEDIUM)
263                                 dev_err(&func->dev,
264                                         "gdmwms: %s error: ret = %d\n",
265                                         __func__, ret);
266                         goto end_io;
267                 }
268         }
269
270 end_io:
271         sdio_release_host(func);
272 }
273
274 static void send_sdu(struct sdio_func *func, struct tx_cxt *tx)
275 {
276         struct list_head *l, *next;
277         struct hci_s *hci;
278         struct sdio_tx *t;
279         int pos, len, i, estlen, aggr_num = 0, aggr_len;
280         u8 *buf;
281         unsigned long flags;
282
283         spin_lock_irqsave(&tx->lock, flags);
284
285         pos = TYPE_A_HEADER_SIZE + HCI_HEADER_SIZE;
286         list_for_each_entry(t, &tx->sdu_list, list) {
287                 estlen = ((t->len + 3) & ~3) + 4;
288                 if ((pos + estlen) > SDU_TX_BUF_SIZE)
289                         break;
290
291                 aggr_num++;
292                 memcpy(tx->sdu_buf + pos, t->buf, t->len);
293                 memset(tx->sdu_buf + pos + t->len, 0, estlen - t->len);
294                 pos += estlen;
295         }
296         aggr_len = pos;
297
298         hci = (struct hci_s *)(tx->sdu_buf + TYPE_A_HEADER_SIZE);
299         hci->cmd_evt = H2B(WIMAX_TX_SDU_AGGR);
300         hci->length = H2B(aggr_len - TYPE_A_HEADER_SIZE - HCI_HEADER_SIZE);
301
302         spin_unlock_irqrestore(&tx->lock, flags);
303
304 #ifdef DEBUG
305         hexdump("sdio_send", tx->sdu_buf + TYPE_A_HEADER_SIZE,
306                 aggr_len - TYPE_A_HEADER_SIZE);
307 #endif
308
309         for (pos = TYPE_A_HEADER_SIZE; pos < aggr_len; pos += TX_CHUNK_SIZE) {
310                 len = aggr_len - pos;
311                 len = len > TX_CHUNK_SIZE ? TX_CHUNK_SIZE : len;
312                 buf = tx->sdu_buf + pos - TYPE_A_HEADER_SIZE;
313
314                 buf[0] = len & 0xff;
315                 buf[1] = (len >> 8) & 0xff;
316                 buf[2] = (len >> 16) & 0xff;
317                 buf[3] = (pos + len) >= aggr_len ? 0 : 1;
318                 send_sdio_pkt(func, buf, len + TYPE_A_HEADER_SIZE);
319         }
320
321         spin_lock_irqsave(&tx->lock, flags);
322
323         for (l = tx->sdu_list.next, i = 0; i < aggr_num; i++, l = next) {
324                 next = l->next;
325                 t = list_entry(l, struct sdio_tx, list);
326                 if (t->callback)
327                         t->callback(t->cb_data);
328
329                 list_del(l);
330                 put_tx_struct(t->tx_cxt, t);
331         }
332
333         do_gettimeofday(&tx->sdu_stamp);
334         spin_unlock_irqrestore(&tx->lock, flags);
335 }
336
337 static void send_hci(struct sdio_func *func, struct tx_cxt *tx,
338                         struct sdio_tx *t)
339 {
340         unsigned long flags;
341
342 #ifdef DEBUG
343         hexdump("sdio_send", t->buf + TYPE_A_HEADER_SIZE,
344                 t->len - TYPE_A_HEADER_SIZE);
345 #endif
346         send_sdio_pkt(func, t->buf, t->len);
347
348         spin_lock_irqsave(&tx->lock, flags);
349         if (t->callback)
350                 t->callback(t->cb_data);
351         free_tx_struct(t);
352         spin_unlock_irqrestore(&tx->lock, flags);
353 }
354
355 static void do_tx(struct work_struct *work)
356 {
357         struct sdiowm_dev *sdev = container_of(work, struct sdiowm_dev, ws);
358         struct sdio_func *func = sdev->func;
359         struct tx_cxt *tx = &sdev->tx;
360         struct sdio_tx *t = NULL;
361         struct timeval now, *before;
362         int is_sdu = 0;
363         long diff;
364         unsigned long flags;
365
366         spin_lock_irqsave(&tx->lock, flags);
367         if (!tx->can_send) {
368                 spin_unlock_irqrestore(&tx->lock, flags);
369                 return;
370         }
371
372         if (!list_empty(&tx->hci_list)) {
373                 t = list_entry(tx->hci_list.next, struct sdio_tx, list);
374                 list_del(&t->list);
375                 is_sdu = 0;
376         } else if (!tx->stop_sdu_tx && !list_empty(&tx->sdu_list)) {
377                 do_gettimeofday(&now);
378                 before = &tx->sdu_stamp;
379
380                 diff = (now.tv_sec - before->tv_sec) * 1000000 +
381                         (now.tv_usec - before->tv_usec);
382                 if (diff >= 0 && diff < TX_INTERVAL) {
383                         schedule_work(&sdev->ws);
384                         spin_unlock_irqrestore(&tx->lock, flags);
385                         return;
386                 }
387                 is_sdu = 1;
388         }
389
390         if (!is_sdu && t == NULL) {
391                 spin_unlock_irqrestore(&tx->lock, flags);
392                 return;
393         }
394
395         tx->can_send = 0;
396
397         spin_unlock_irqrestore(&tx->lock, flags);
398
399         if (is_sdu)
400                 send_sdu(func, tx);
401         else
402                 send_hci(func, tx, t);
403 }
404
405 static int gdm_sdio_send(void *priv_dev, void *data, int len,
406                         void (*cb)(void *data), void *cb_data)
407 {
408         struct sdiowm_dev *sdev = priv_dev;
409         struct tx_cxt *tx = &sdev->tx;
410         struct sdio_tx *t;
411         u8 *pkt = data;
412         int no_spc = 0;
413         u16 cmd_evt;
414         unsigned long flags;
415
416         BUG_ON(len > TX_BUF_SIZE - TYPE_A_HEADER_SIZE);
417
418         spin_lock_irqsave(&tx->lock, flags);
419
420         cmd_evt = (pkt[0] << 8) | pkt[1];
421         if (cmd_evt == WIMAX_TX_SDU) {
422                 t = get_tx_struct(tx, &no_spc);
423                 if (t == NULL) {
424                         /* This case must not happen. */
425                         spin_unlock_irqrestore(&tx->lock, flags);
426                         return -ENOSPC;
427                 }
428                 list_add_tail(&t->list, &tx->sdu_list);
429
430                 memcpy(t->buf, data, len);
431
432                 t->len = len;
433                 t->callback = cb;
434                 t->cb_data = cb_data;
435         } else {
436                 t = alloc_tx_struct(tx);
437                 if (t == NULL) {
438                         spin_unlock_irqrestore(&tx->lock, flags);
439                         return -ENOMEM;
440                 }
441                 list_add_tail(&t->list, &tx->hci_list);
442
443                 t->buf[0] = len & 0xff;
444                 t->buf[1] = (len >> 8) & 0xff;
445                 t->buf[2] = (len >> 16) & 0xff;
446                 t->buf[3] = 2;
447                 memcpy(t->buf + TYPE_A_HEADER_SIZE, data, len);
448
449                 t->len = len + TYPE_A_HEADER_SIZE;
450                 t->callback = cb;
451                 t->cb_data = cb_data;
452         }
453
454         if (tx->can_send)
455                 schedule_work(&sdev->ws);
456
457         spin_unlock_irqrestore(&tx->lock, flags);
458
459         if (no_spc)
460                 return -ENOSPC;
461
462         return 0;
463 }
464
465 /*
466  * Handle the HCI, WIMAX_SDU_TX_FLOW.
467  */
468 static int control_sdu_tx_flow(struct sdiowm_dev *sdev, u8 *hci_data, int len)
469 {
470         struct tx_cxt *tx = &sdev->tx;
471         u16 cmd_evt;
472         unsigned long flags;
473
474         spin_lock_irqsave(&tx->lock, flags);
475
476         cmd_evt = (hci_data[0] << 8) | (hci_data[1]);
477         if (cmd_evt != WIMAX_SDU_TX_FLOW)
478                 goto out;
479
480         if (hci_data[4] == 0) {
481 #ifdef DEBUG
482                 printk(KERN_DEBUG "WIMAX ==> STOP SDU TX\n");
483 #endif
484                 tx->stop_sdu_tx = 1;
485         } else if (hci_data[4] == 1) {
486 #ifdef DEBUG
487                 printk(KERN_DEBUG "WIMAX ==> START SDU TX\n");
488 #endif
489                 tx->stop_sdu_tx = 0;
490                 if (tx->can_send)
491                         schedule_work(&sdev->ws);
492                 /*
493                  * If free buffer for sdu tx doesn't exist, then tx queue
494                  * should not be woken. For this reason, don't pass the command,
495                  * START_SDU_TX.
496                  */
497                 if (list_empty(&tx->free_list))
498                         len = 0;
499         }
500
501 out:
502         spin_unlock_irqrestore(&tx->lock, flags);
503         return len;
504 }
505
506 static void gdm_sdio_irq(struct sdio_func *func)
507 {
508         struct phy_dev *phy_dev = sdio_get_drvdata(func);
509         struct sdiowm_dev *sdev = phy_dev->priv_dev;
510         struct tx_cxt *tx = &sdev->tx;
511         struct rx_cxt *rx = &sdev->rx;
512         struct sdio_rx *r;
513         unsigned long flags;
514         u8 val, hdr[TYPE_A_LOOKAHEAD_SIZE], *buf;
515         u32 len, blocks, n;
516         int ret, remain;
517
518         /* Check interrupt */
519         val = sdio_readb(func, 0x13, &ret);
520         if (val & 0x01)
521                 sdio_writeb(func, 0x01, 0x13, &ret);    /* clear interrupt */
522         else
523                 return;
524
525         ret = sdio_memcpy_fromio(func, hdr, 0x0, TYPE_A_LOOKAHEAD_SIZE);
526         if (ret) {
527                 dev_err(&func->dev,
528                         "Cannot read from function %d\n", func->num);
529                 goto done;
530         }
531
532         len = (hdr[2] << 16) | (hdr[1] << 8) | hdr[0];
533         if (len > (RX_BUF_SIZE - TYPE_A_HEADER_SIZE)) {
534                 dev_err(&func->dev, "Too big Type-A size: %d\n", len);
535                 goto done;
536         }
537
538         if (hdr[3] == 1) {      /* Ack */
539 #ifdef DEBUG
540                 u32 *ack_seq = (u32 *)&hdr[4];
541 #endif
542                 spin_lock_irqsave(&tx->lock, flags);
543                 tx->can_send = 1;
544
545                 if (!list_empty(&tx->sdu_list) || !list_empty(&tx->hci_list))
546                         schedule_work(&sdev->ws);
547                 spin_unlock_irqrestore(&tx->lock, flags);
548 #ifdef DEBUG
549                 printk(KERN_DEBUG "Ack... %0x\n", ntohl(*ack_seq));
550 #endif
551                 goto done;
552         }
553
554         memcpy(rx->rx_buf, hdr + TYPE_A_HEADER_SIZE,
555                         TYPE_A_LOOKAHEAD_SIZE - TYPE_A_HEADER_SIZE);
556
557         buf = rx->rx_buf + TYPE_A_LOOKAHEAD_SIZE - TYPE_A_HEADER_SIZE;
558         remain = len - TYPE_A_LOOKAHEAD_SIZE + TYPE_A_HEADER_SIZE;
559         if (remain <= 0)
560                 goto end_io;
561
562         blocks = remain / func->cur_blksize;
563
564         if (blocks) {
565                 n = blocks * func->cur_blksize;
566                 ret = sdio_memcpy_fromio(func, buf, 0x0, n);
567                 if (ret) {
568                         dev_err(&func->dev,
569                                 "Cannot read from function %d\n", func->num);
570                         goto done;
571                 }
572                 buf += n;
573                 remain -= n;
574         }
575
576         if (remain) {
577                 ret = sdio_memcpy_fromio(func, buf, 0x0, remain);
578                 if (ret) {
579                         dev_err(&func->dev,
580                                 "Cannot read from function %d\n", func->num);
581                         goto done;
582                 }
583         }
584
585 end_io:
586 #ifdef DEBUG
587         hexdump("sdio_receive", rx->rx_buf, len);
588 #endif
589         len = control_sdu_tx_flow(sdev, rx->rx_buf, len);
590
591         spin_lock_irqsave(&rx->lock, flags);
592
593         if (!list_empty(&rx->req_list)) {
594                 r = list_entry(rx->req_list.next, struct sdio_rx, list);
595                 spin_unlock_irqrestore(&rx->lock, flags);
596                 if (r->callback)
597                         r->callback(r->cb_data, rx->rx_buf, len);
598                 spin_lock_irqsave(&rx->lock, flags);
599                 list_del(&r->list);
600                 put_rx_struct(rx, r);
601         }
602
603         spin_unlock_irqrestore(&rx->lock, flags);
604
605 done:
606         sdio_writeb(func, 0x00, 0x10, &ret);    /* PCRRT */
607         if (!phy_dev->netdev)
608                 register_wimax_device(phy_dev, &func->dev);
609 }
610
611 static int gdm_sdio_receive(void *priv_dev,
612                                 void (*cb)(void *cb_data, void *data, int len),
613                                 void *cb_data)
614 {
615         struct sdiowm_dev *sdev = priv_dev;
616         struct rx_cxt *rx = &sdev->rx;
617         struct sdio_rx *r;
618         unsigned long flags;
619
620         spin_lock_irqsave(&rx->lock, flags);
621         r = get_rx_struct(rx);
622         if (r == NULL) {
623                 spin_unlock_irqrestore(&rx->lock, flags);
624                 return -ENOMEM;
625         }
626
627         r->callback = cb;
628         r->cb_data = cb_data;
629
630         list_add_tail(&r->list, &rx->req_list);
631         spin_unlock_irqrestore(&rx->lock, flags);
632
633         return 0;
634 }
635
636 static int sdio_wimax_probe(struct sdio_func *func,
637                                 const struct sdio_device_id *id)
638 {
639         int ret;
640         struct phy_dev *phy_dev = NULL;
641         struct sdiowm_dev *sdev = NULL;
642
643         dev_info(&func->dev, "Found GDM SDIO VID = 0x%04x PID = 0x%04x...\n",
644                  func->vendor, func->device);
645         dev_info(&func->dev, "GCT WiMax driver version %s\n", DRIVER_VERSION);
646
647         sdio_claim_host(func);
648         sdio_enable_func(func);
649         sdio_claim_irq(func, gdm_sdio_irq);
650
651         ret = sdio_boot(func);
652         if (ret)
653                 return ret;
654
655         phy_dev = kzalloc(sizeof(*phy_dev), GFP_KERNEL);
656         if (phy_dev == NULL) {
657                 ret = -ENOMEM;
658                 goto out;
659         }
660         sdev = kzalloc(sizeof(*sdev), GFP_KERNEL);
661         if (sdev == NULL) {
662                 ret = -ENOMEM;
663                 goto out;
664         }
665
666         phy_dev->priv_dev = (void *)sdev;
667         phy_dev->send_func = gdm_sdio_send;
668         phy_dev->rcv_func = gdm_sdio_receive;
669
670         ret = init_sdio(sdev);
671         if (ret < 0)
672                 goto out;
673
674         sdev->func = func;
675
676         sdio_writeb(func, 1, 0x14, &ret);       /* Enable interrupt */
677         sdio_release_host(func);
678
679         INIT_WORK(&sdev->ws, do_tx);
680
681         sdio_set_drvdata(func, phy_dev);
682 out:
683         if (ret) {
684                 kfree(phy_dev);
685                 kfree(sdev);
686         }
687
688         return ret;
689 }
690
691 static void sdio_wimax_remove(struct sdio_func *func)
692 {
693         struct phy_dev *phy_dev = sdio_get_drvdata(func);
694         struct sdiowm_dev *sdev = phy_dev->priv_dev;
695
696         cancel_work_sync(&sdev->ws);
697         if (phy_dev->netdev)
698                 unregister_wimax_device(phy_dev);
699         sdio_claim_host(func);
700         sdio_release_irq(func);
701         sdio_disable_func(func);
702         sdio_release_host(func);
703         release_sdio(sdev);
704
705         kfree(sdev);
706         kfree(phy_dev);
707 }
708
709 static const struct sdio_device_id sdio_wimax_ids[] = {
710         { SDIO_DEVICE(0x0296, 0x5347) },
711         {0}
712 };
713
714 MODULE_DEVICE_TABLE(sdio, sdio_wimax_ids);
715
716 static struct sdio_driver sdio_wimax_driver = {
717         .probe          = sdio_wimax_probe,
718         .remove         = sdio_wimax_remove,
719         .name           = "sdio_wimax",
720         .id_table       = sdio_wimax_ids,
721 };
722
723 static int __init sdio_gdm_wimax_init(void)
724 {
725         return sdio_register_driver(&sdio_wimax_driver);
726 }
727
728 static void __exit sdio_gdm_wimax_exit(void)
729 {
730         sdio_unregister_driver(&sdio_wimax_driver);
731 }
732
733 module_init(sdio_gdm_wimax_init);
734 module_exit(sdio_gdm_wimax_exit);
735
736 MODULE_VERSION(DRIVER_VERSION);
737 MODULE_DESCRIPTION("GCT WiMax SDIO Device Driver");
738 MODULE_AUTHOR("Ethan Park");
739 MODULE_LICENSE("GPL");