1 /* /linux/drivers/misc/modem_if/modem_io_device.c
3 * Copyright (C) 2010 Google, Inc.
4 * Copyright (C) 2010 Samsung Electronics.
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 #include <linux/init.h>
18 #include <linux/sched.h>
20 #include <linux/poll.h>
21 #include <linux/irq.h>
22 #include <linux/gpio.h>
23 #include <linux/if_arp.h>
25 #include <linux/if_ether.h>
26 #include <linux/etherdevice.h>
27 #include <linux/ratelimit.h>
29 #include <linux/platform_data/modem_na.h>
30 #include "modem_prj.h"
33 #define HDLC_START 0x7F
35 #define SIZE_OF_HDLC_START 1
36 #define SIZE_OF_HDLC_END 1
37 #define MAX_RXDATA_SIZE (4096 - 512)
39 static const char hdlc_start[1] = { HDLC_START };
40 static const char hdlc_end[1] = { HDLC_END };
59 static const char const *modem_state_name[] = {
60 [STATE_OFFLINE] = "OFFLINE",
61 [STATE_CRASH_EXIT] = "CRASH_EXIT",
62 [STATE_BOOTING] = "BOOTING",
63 [STATE_ONLINE] = "ONLINE",
64 [STATE_LOADER_DONE] = "LOADER_DONE",
65 [STATE_NV_REBUILDING] = "NV_REBUILDING",
68 static int rx_iodev_skb(struct io_device *iod);
70 static int get_header_size(struct io_device *iod)
72 switch (iod->format) {
74 return sizeof(struct fmt_hdr);
78 return sizeof(struct raw_hdr);
81 return sizeof(struct rfs_hdr);
84 /* minimum size for transaction align */
93 static int get_hdlc_size(struct io_device *iod, char *buf)
95 struct fmt_hdr *fmt_header;
96 struct raw_hdr *raw_header;
97 struct rfs_hdr *rfs_header;
99 pr_debug("[MODEM_IF] buf : %02x %02x %02x (%d)\n", *buf, *(buf + 1),
100 *(buf + 2), __LINE__);
102 switch (iod->format) {
104 fmt_header = (struct fmt_hdr *)buf;
105 return fmt_header->len;
108 raw_header = (struct raw_hdr *)buf;
109 return raw_header->len;
111 rfs_header = (struct rfs_hdr *)buf;
112 return rfs_header->len;
119 static void *get_header(struct io_device *iod, size_t count,
120 char *frame_header_buf)
122 struct fmt_hdr *fmt_h;
123 struct raw_hdr *raw_h;
124 struct rfs_hdr *rfs_h;
126 switch (iod->format) {
128 fmt_h = (struct fmt_hdr *)frame_header_buf;
130 fmt_h->len = count + sizeof(struct fmt_hdr);
133 return (void *)frame_header_buf;
137 raw_h = (struct raw_hdr *)frame_header_buf;
139 raw_h->len = count + sizeof(struct raw_hdr);
140 raw_h->channel = iod->id & 0x1F;
143 return (void *)frame_header_buf;
146 rfs_h = (struct rfs_hdr *)frame_header_buf;
148 rfs_h->len = count + sizeof(struct raw_hdr);
151 return (void *)frame_header_buf;
158 static inline int rx_hdlc_head_start_check(char *buf)
160 /* check hdlc head and return size of start byte */
161 return (buf[0] == HDLC_START) ? SIZE_OF_HDLC_START : -EBADMSG;
164 static inline int rx_hdlc_tail_check(char *buf)
166 /* check hdlc tail and return size of tail byte */
167 return (buf[0] == HDLC_END) ? SIZE_OF_HDLC_END : -EBADMSG;
170 /* remove hdlc header and store IPC header */
171 static int rx_hdlc_head_check(struct io_device *iod, char *buf, unsigned rest)
173 struct header_data *hdr = &iod->h_data;
174 int head_size = get_header_size(iod);
177 struct modem_data *md = (struct modem_data *)\
178 iod->mc->dev->platform_data;
180 /* first frame, remove start header 7F */
182 len = rx_hdlc_head_start_check(buf);
184 pr_err("[MODEM_IF] Wrong HDLC start: 0x%x(%s)\n",
186 return len; /*Wrong hdlc start*/
189 pr_debug("[MODEM_IF] check len : %d, rest : %d (%d)\n", len,
192 /* set the start flag of current packet */
193 hdr->start = HDLC_START;
198 rest -= len; /* rest, call by value */
201 pr_debug("[MODEM_IF] check len : %d, rest : %d (%d)\n", len, rest,
204 /* store the IPC header to iod priv */
205 if (hdr->len < head_size) {
206 len = min(rest, head_size - hdr->len);
207 memcpy(hdr->hdr + hdr->len, buf, len);
209 /* Skip the dummy byte inserted for 2-byte alignment in header.
210 RAW format header size is 6 bytes. Start + 6 + 1 (skip byte) */
211 if (md->align == 1) {
212 if ((iod->format == IPC_RAW
213 || iod->format == IPC_MULTI_RAW)
214 && (iod->net_typ == CDMA_NETWORK)
222 pr_debug("[MODEM_IF] check done_len : %d, rest : %d (%d)\n", done_len,
227 /* alloc skb and copy dat to skb */
228 static int rx_hdlc_data_check(struct io_device *iod, char *buf, unsigned rest)
230 struct header_data *hdr = &iod->h_data;
231 struct sk_buff *skb = iod->skb_recv;
232 int head_size = get_header_size(iod);
233 int data_size = get_hdlc_size(iod, hdr->hdr) - head_size;
234 int alloc_size = min(data_size, MAX_RXDATA_SIZE);
237 int rest_len = data_size - hdr->flag_len;
239 /* first payload data - alloc skb */
241 switch (iod->format) {
243 alloc_size = min(data_size + head_size, \
245 skb = alloc_skb(alloc_size, GFP_ATOMIC);
248 /* copy the RFS haeder to skb->data */
249 memcpy(skb_put(skb, head_size), hdr->hdr, head_size);
253 if (data_size > MAX_RXDATA_SIZE) { \
254 pr_err("%s: %s: packet size too large (%d)\n",\
255 __func__, iod->name, data_size);
259 if (iod->net_typ == UMTS_NETWORK)
260 skb = alloc_skb(alloc_size, GFP_ATOMIC);
262 skb = alloc_skb(alloc_size +
263 sizeof(struct ethhdr), GFP_ATOMIC);
267 if (iod->net_typ != UMTS_NETWORK)
268 skb_reserve(skb, sizeof(struct ethhdr));
272 skb = alloc_skb(alloc_size, GFP_ATOMIC);
281 len = min(rest, alloc_size - skb->len);
282 len = min(len, rest_len);
283 memcpy(skb_put(skb, len), buf, len);
286 hdr->flag_len += len;
290 if (!rest_len || !rest)
294 iod->skb_recv = NULL;
296 alloc_size = min(rest_len, MAX_RXDATA_SIZE);
297 skb = alloc_skb(alloc_size, GFP_ATOMIC);
306 static int rx_iodev_skb_raw(struct io_device *iod)
309 struct sk_buff *skb = iod->skb_recv;
310 struct net_device *ndev;
311 struct iphdr *ip_header;
313 const char source[ETH_ALEN] = SOURCE_MAC_ADDR;
315 switch (iod->io_typ) {
317 skb_queue_tail(&iod->sk_rx_q, iod->skb_recv);
327 ndev->stats.rx_packets++;
328 ndev->stats.rx_bytes += skb->len;
330 /* check the version of IP */
331 ip_header = (struct iphdr *)skb->data;
332 if (ip_header->version == IP6VERSION)
333 skb->protocol = htons(ETH_P_IPV6);
335 skb->protocol = htons(ETH_P_IP);
337 if (iod->net_typ == UMTS_NETWORK) {
338 skb_reset_mac_header(skb);
340 ehdr = (void *)skb_push(skb, sizeof(struct ethhdr));
341 memcpy(ehdr->h_dest, ndev->dev_addr, ETH_ALEN);
342 memcpy(ehdr->h_source, source, ETH_ALEN);
343 ehdr->h_proto = skb->protocol;
344 skb->ip_summed = CHECKSUM_NONE;
345 skb_reset_mac_header(skb);
347 skb_pull(skb, sizeof(struct ethhdr));
350 err = netif_rx_ni(skb);
351 if (err != NET_RX_SUCCESS)
352 dev_err(&ndev->dev, "rx error: %d\n", err);
356 pr_err("[MODEM_IF] wrong io_type : %d\n", iod->io_typ);
361 static void rx_iodev_work(struct work_struct *work)
365 struct io_device *real_iod;
366 struct io_device *iod = container_of(work, struct io_device,
369 skb = skb_dequeue(&iod->sk_rx_q);
371 real_iod = *((struct io_device **)skb->cb);
372 real_iod->skb_recv = skb;
374 ret = rx_iodev_skb_raw(real_iod);
375 if (ret == NET_RX_DROP) {
376 pr_err("[MODEM_IF] %s: queue delayed work!\n",
378 skb_queue_head(&iod->sk_rx_q, skb);
379 schedule_delayed_work(&iod->rx_work,
380 msecs_to_jiffies(20));
383 dev_kfree_skb_any(skb);
385 skb = skb_dequeue(&iod->sk_rx_q);
390 static int rx_multipdp(struct io_device *iod)
393 struct raw_hdr *raw_header = (struct raw_hdr *)&iod->h_data.hdr;
394 struct io_raw_devices *io_raw_devs =
395 (struct io_raw_devices *)iod->private_data;
396 struct io_device *real_iod;
398 ch = raw_header->channel;
399 real_iod = io_raw_devs->raw_devices[ch];
401 pr_err("[MODEM_IF] %s: wrong channel %d\n", __func__, ch);
405 *((struct io_device **)iod->skb_recv->cb) = real_iod;
406 skb_queue_tail(&iod->sk_rx_q, iod->skb_recv);
407 pr_debug("sk_rx_qlen:%d\n", iod->sk_rx_q.qlen);
409 schedule_delayed_work(&iod->rx_work, 0);
413 /* de-mux function draft */
414 static int rx_iodev_skb(struct io_device *iod)
416 switch (iod->format) {
418 return rx_multipdp(iod);
423 skb_queue_tail(&iod->sk_rx_q, iod->skb_recv);
425 pr_debug("[MODEM_IF] wake up fmt,rfs skb\n");
431 static int rx_hdlc_packet(struct io_device *iod, const char *data,
434 unsigned rest = recv_size;
435 char *buf = (char *)data;
438 struct modem_data *md = (struct modem_data *)\
439 iod->mc->dev->platform_data;
445 pr_debug("[MODEM_IF] RX_SIZE=%d\n", rest);
447 if (iod->h_data.flag_len)
451 err = len = rx_hdlc_head_check(iod, buf, rest);
453 goto exit; /* buf++; rest--; goto next_frame; */
454 pr_debug("[MODEM_IF] check len : %d, rest : %d (%d)\n", len, rest,
463 err = len = rx_hdlc_data_check(iod, buf, rest);
466 pr_debug("[MODEM_IF] check len : %d, rest : %d (%d)\n", len, rest,
469 /* If the lenght of actual data is odd. Skip the dummy bit*/
470 if (md->align == 1) {
471 if ((iod->format == IPC_RAW || iod->format == IPC_MULTI_RAW)
472 && (iod->net_typ == CDMA_NETWORK) && (len & 0x01))
478 if (!rest && iod->h_data.flag_len)
483 err = len = rx_hdlc_tail_check(buf);
485 pr_err("[MODEM_IF] Wrong HDLC end: 0x%x(%s)\n",
489 pr_debug("[MODEM_IF] check len : %d, rest : %d (%d)\n", len, rest,
492 /* Skip the dummy byte inserted for 2-byte alignment in header.
494 if (md->align == 1) {
495 if ((iod->format == IPC_RAW || iod->format == IPC_MULTI_RAW)
496 && (iod->net_typ == CDMA_NETWORK))
504 err = rx_iodev_skb(iod);
508 /* initialize header & skb */
509 iod->skb_recv = NULL;
510 memset(&iod->h_data, 0x00, sizeof(struct header_data));
516 /* free buffers. mipi-hsi re-use recv buf */
522 memset(&iod->h_data, 0x00, sizeof(struct header_data));
525 dev_kfree_skb_any(iod->skb_recv);
526 iod->skb_recv = NULL;
533 /* called from link device when a packet arrives for this io device */
534 static int io_dev_recv_data_from_link_dev(struct io_device *iod,
535 const char *data, unsigned int len)
540 switch (iod->format) {
545 err = rx_hdlc_packet(iod, data, len);
547 pr_err("[MODEM_IF] fail process hdlc fram\n");
551 /* TODO- handle flow control command from CP */
556 /* save packet to sk_buff */
557 skb = alloc_skb(len, GFP_ATOMIC);
559 pr_err("[MODEM_IF] fail alloc skb (%d)\n", __LINE__);
563 pr_debug("[MODEM_IF] boot len : %d\n", len);
565 memcpy(skb_put(skb, len), data, len);
566 skb_queue_tail(&iod->sk_rx_q, skb);
567 pr_debug("[MODEM_IF] skb len : %d\n", skb->len);
577 /* inform the IO device that the modem is now online or offline or
578 * crashing or whatever...
580 static void io_dev_modem_state_changed(struct io_device *iod,
581 enum modem_state state)
583 iod->mc->phone_state = state;
584 pr_info("[MODEM_IF] %s state changed: %s\n", \
585 iod->name, modem_state_name[state]);
587 if ((state == STATE_CRASH_EXIT) || (state == STATE_NV_REBUILDING))
591 static int misc_open(struct inode *inode, struct file *filp)
593 struct io_device *iod = to_io_device(filp->private_data);
594 filp->private_data = (void *)iod;
596 if (iod->format != IPC_BOOT && iod->format != IPC_RAMDUMP)
597 pr_info("[MODEM_IF] misc_open : %s\n", iod->name);
599 if (iod->link->init_comm)
600 return iod->link->init_comm(iod->link, iod);
604 static int misc_release(struct inode *inode, struct file *filp)
606 struct io_device *iod = (struct io_device *)filp->private_data;
608 if (iod->format != IPC_BOOT && iod->format != IPC_RAMDUMP)
609 pr_info("[MODEM_IF] misc_release : %s\n", iod->name);
611 if (iod->link->terminate_comm)
612 iod->link->terminate_comm(iod->link, iod);
614 skb_queue_purge(&iod->sk_rx_q);
618 static unsigned int misc_poll(struct file *filp,
619 struct poll_table_struct *wait)
621 struct io_device *iod = (struct io_device *)filp->private_data;
623 poll_wait(filp, &iod->wq, wait);
625 if ((!skb_queue_empty(&iod->sk_rx_q))
626 && (iod->mc->phone_state != STATE_OFFLINE))
627 return POLLIN | POLLRDNORM;
628 else if ((iod->mc->phone_state == STATE_CRASH_EXIT) ||
629 (iod->mc->phone_state == STATE_NV_REBUILDING))
635 static long misc_ioctl(struct file *filp, unsigned int cmd, unsigned long _arg)
638 struct io_device *iod = (struct io_device *)filp->private_data;
640 pr_debug("[MODEM_IF] misc_ioctl : 0x%x\n", cmd);
644 pr_debug("[MODEM_IF] misc_ioctl : IOCTL_MODEM_ON\n");
645 return iod->mc->ops.modem_on(iod->mc);
647 case IOCTL_MODEM_OFF:
648 pr_debug("[MODEM_IF] misc_ioctl : IOCTL_MODEM_OFF\n");
649 return iod->mc->ops.modem_off(iod->mc);
651 case IOCTL_MODEM_RESET:
652 pr_debug("[MODEM_IF] misc_ioctl : IOCTL_MODEM_RESET\n");
653 return iod->mc->ops.modem_reset(iod->mc);
655 case IOCTL_MODEM_FORCE_CRASH_EXIT:
656 pr_debug("[MODEM_IF] misc_ioctl : IOCTL_MODEM_FORCE_CRASH_EXIT\n");
657 return iod->mc->ops.modem_force_crash_exit(iod->mc);
659 case IOCTL_MODEM_DUMP_RESET:
660 pr_debug("[MODEM_IF] misc_ioctl : IOCTL_MODEM_FORCE_CRASH_EXIT\n");
661 return iod->mc->ops.modem_dump_reset(iod->mc);
663 case IOCTL_MODEM_BOOT_ON:
664 pr_debug("[MODEM_IF] misc_ioctl : IOCTL_MODEM_BOOT_ON\n");
665 return iod->mc->ops.modem_boot_on(iod->mc);
667 case IOCTL_MODEM_BOOT_OFF:
668 pr_debug("[MODEM_IF] misc_ioctl : IOCTL_MODEM_BOOT_OFF\n");
669 return iod->mc->ops.modem_boot_off(iod->mc);
671 /* TODO - will remove this command after ril updated */
672 case IOCTL_MODEM_START:
673 pr_debug("[MODEM_IF] misc_ioctl : IOCTL_MODEM_START\n");
676 case IOCTL_MODEM_STATUS:
677 pr_debug("[MODEM_IF] misc_ioctl : IOCTL_MODEM_STATUS\n");
678 p_state = iod->mc->phone_state;
679 if (p_state == STATE_NV_REBUILDING) {
680 pr_info("[MODEM_IF] nv rebuild state : %d\n", p_state);
681 iod->mc->phone_state = STATE_ONLINE;
685 case IOCTL_MODEM_DUMP_START:
686 pr_debug("[MODEM_IF] misc_ioctl : IOCTL_MODEM_DUMP_START\n");
687 return iod->link->dump_start(iod->link, iod);
689 case IOCTL_MODEM_DUMP_UPDATE:
690 pr_debug("[MODEM_IF] misc_ioctl : IOCTL_MODEM_DUMP_UPDATE\n");
691 return iod->link->dump_update(iod->link, iod, _arg);
693 case IOCTL_MODEM_GOTA_START:
694 pr_debug("[GOTA] misc_ioctl : IOCTL_MODEM_GOTA_START\n");
695 return iod->link->gota_start(iod->link, iod);
697 case IOCTL_MODEM_FW_UPDATE:
698 pr_debug("[GOTA] misc_ioctl : IOCTL_MODEM_FW_UPDATE\n");
699 return iod->link->modem_update(iod->link, iod, _arg);
706 static ssize_t misc_write(struct file *filp, const char __user * buf,
707 size_t count, loff_t *ppos)
709 struct io_device *iod = (struct io_device *)filp->private_data;
711 char frame_header_buf[sizeof(struct raw_hdr)];
714 /* TODO - check here flow control for only raw data */
716 if (iod->format == IPC_BOOT || iod->format == IPC_RAMDUMP)
717 frame_len = count + get_header_size(iod);
719 frame_len = count + SIZE_OF_HDLC_START + get_header_size(iod)
722 skb = alloc_skb(frame_len, GFP_KERNEL);
724 pr_err("[MODEM_IF] fail alloc skb (%d)\n", __LINE__);
728 switch (iod->format) {
731 if (copy_from_user(skb_put(skb, count), buf, count) != 0) {
732 dev_kfree_skb_any(skb);
738 memcpy(skb_put(skb, SIZE_OF_HDLC_START), hdlc_start,
740 if (copy_from_user(skb_put(skb, count), buf, count) != 0) {
741 dev_kfree_skb_any(skb);
744 memcpy(skb_put(skb, SIZE_OF_HDLC_END), hdlc_end,
749 memcpy(skb_put(skb, SIZE_OF_HDLC_START), hdlc_start,
751 memcpy(skb_put(skb, get_header_size(iod)),
752 get_header(iod, count, frame_header_buf),
753 get_header_size(iod));
754 if (copy_from_user(skb_put(skb, count), buf, count) != 0) {
755 dev_kfree_skb_any(skb);
758 memcpy(skb_put(skb, SIZE_OF_HDLC_END), hdlc_end,
763 /* send data with sk_buff, link device will put sk_buff
764 * into the specific sk_buff_q and run work-q to send data
766 return iod->link->send(iod->link, iod, skb);
769 static ssize_t misc_read(struct file *filp, char *buf, size_t count,
772 struct io_device *iod = (struct io_device *)filp->private_data;
776 skb = skb_dequeue(&iod->sk_rx_q);
778 printk_ratelimited(KERN_ERR "[MODEM_IF] no data from sk_rx_q, "
779 "modem_state : %s(%s)\n",
780 modem_state_name[iod->mc->phone_state], iod->name);
784 if (skb->len > count) {
785 pr_err("[MODEM_IF] skb len is too big = %d,%d!(%d)\n",
786 count, skb->len, __LINE__);
787 dev_kfree_skb_any(skb);
790 pr_debug("[MODEM_IF] skb len : %d\n", skb->len);
793 if (copy_to_user(buf, skb->data, pktsize) != 0)
795 dev_kfree_skb_any(skb);
797 pr_debug("[MODEM_IF] copy to user : %d\n", pktsize);
802 static const struct file_operations misc_io_fops = {
803 .owner = THIS_MODULE,
805 .release = misc_release,
807 .unlocked_ioctl = misc_ioctl,
812 static int vnet_open(struct net_device *ndev)
814 netif_start_queue(ndev);
818 static int vnet_stop(struct net_device *ndev)
820 netif_stop_queue(ndev);
824 static int vnet_xmit(struct sk_buff *skb, struct net_device *ndev)
828 struct sk_buff *skb_new;
829 struct vnet *vnet = netdev_priv(ndev);
830 struct io_device *iod = vnet->iod;
832 /* umts doesn't need to discard ethernet header */
833 if (iod->net_typ != UMTS_NETWORK) {
834 if (iod->id >= PSD_DATA_CHID_BEGIN &&
835 iod->id <= PSD_DATA_CHID_END)
836 skb_pull(skb, sizeof(struct ethhdr));
839 hd.len = skb->len + sizeof(hd);
841 hd.channel = iod->id & 0x1F;
843 skb_new = skb_copy_expand(skb, sizeof(hd) + sizeof(hdlc_start),
844 sizeof(hdlc_end), GFP_ATOMIC);
846 dev_kfree_skb_any(skb);
850 memcpy(skb_push(skb_new, sizeof(hd)), &hd, sizeof(hd));
851 memcpy(skb_push(skb_new, sizeof(hdlc_start)), hdlc_start,
853 memcpy(skb_put(skb_new, sizeof(hdlc_end)), hdlc_end, sizeof(hdlc_end));
855 ret = iod->link->send(iod->link, iod, skb_new);
857 dev_kfree_skb_any(skb);
858 return NETDEV_TX_BUSY;
861 ndev->stats.tx_packets++;
862 ndev->stats.tx_bytes += skb->len;
863 dev_kfree_skb_any(skb);
868 static struct net_device_ops vnet_ops = {
869 .ndo_open = vnet_open,
870 .ndo_stop = vnet_stop,
871 .ndo_start_xmit = vnet_xmit,
874 static void vnet_setup(struct net_device *ndev)
876 ndev->netdev_ops = &vnet_ops;
877 ndev->type = ARPHRD_PPP;
878 ndev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
880 ndev->hard_header_len = 0;
881 ndev->tx_queue_len = 1000;
882 ndev->mtu = ETH_DATA_LEN;
883 ndev->watchdog_timeo = 5 * HZ;
886 static void vnet_setup_ether(struct net_device *ndev)
888 ndev->netdev_ops = &vnet_ops;
889 ndev->type = ARPHRD_ETHER;
890 ndev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST | IFF_SLAVE;
891 ndev->addr_len = ETH_ALEN;
892 random_ether_addr(ndev->dev_addr);
893 ndev->hard_header_len = 0;
894 ndev->tx_queue_len = 1000;
895 ndev->mtu = ETH_DATA_LEN;
896 ndev->watchdog_timeo = 5 * HZ;
899 int init_io_device(struct io_device *iod)
904 /* get modem state from modem control device */
905 iod->modem_state_changed = io_dev_modem_state_changed;
906 /* get data from link device */
907 iod->recv = io_dev_recv_data_from_link_dev;
909 INIT_LIST_HEAD(&iod->list);
911 /* register misc or net drv */
912 switch (iod->io_typ) {
914 init_waitqueue_head(&iod->wq);
915 skb_queue_head_init(&iod->sk_rx_q);
916 INIT_DELAYED_WORK(&iod->rx_work, rx_iodev_work);
918 iod->miscdev.minor = MISC_DYNAMIC_MINOR;
919 iod->miscdev.name = iod->name;
920 iod->miscdev.fops = &misc_io_fops;
922 ret = misc_register(&iod->miscdev);
924 pr_err("failed to register misc io device : %s\n",
930 if (iod->net_typ == UMTS_NETWORK)
931 iod->ndev = alloc_netdev(0, iod->name, vnet_setup);
933 iod->ndev = alloc_netdev(0, iod->name,
936 pr_err("failed to alloc netdev\n");
940 ret = register_netdev(iod->ndev);
942 free_netdev(iod->ndev);
944 pr_debug("%s: %d(iod:0x%p)\n", __func__, __LINE__, iod);
945 vnet = netdev_priv(iod->ndev);
946 pr_debug("%s: %d(vnet:0x%p)\n", __func__, __LINE__, vnet);
952 skb_queue_head_init(&iod->sk_rx_q);
953 INIT_DELAYED_WORK(&iod->rx_work, rx_iodev_work);
958 pr_err("wrong io_type : %d\n", iod->io_typ);
962 pr_debug("[MODEM_IF] %s(%d) : init_io_device() done : %d\n",
963 iod->name, iod->io_typ, ret);