Lines Matching refs:stir
194 static int write_reg(struct stir_cb *stir, __u16 reg, __u8 value)
196 struct usb_device *dev = stir->usbdev;
199 stir->netdev->name, reg, value);
208 static inline int read_reg(struct stir_cb *stir, __u16 reg,
211 struct usb_device *dev = stir->usbdev;
315 static void fir_eof(struct stir_cb *stir)
317 iobuff_t *rx_buff = &stir->rx_buff;
324 stir->netdev->name, len);
326 ++stir->netdev->stats.rx_errors;
327 ++stir->netdev->stats.rx_length_errors;
334 stir->netdev->stats.rx_errors++;
335 stir->netdev->stats.rx_crc_errors++;
343 ++stir->netdev->stats.rx_dropped;
352 ++stir->netdev->stats.rx_dropped;
365 skb->dev = stir->netdev;
369 stir->netdev->stats.rx_packets++;
370 stir->netdev->stats.rx_bytes += len;
377 static void stir_fir_chars(struct stir_cb *stir,
380 iobuff_t *rx_buff = &stir->rx_buff;
402 stir->netdev->name);
425 stir->netdev->name);
430 fir_eof(stir);
439 stir->netdev->name, rx_buff->truesize);
440 ++stir->netdev->stats.rx_over_errors;
448 ++stir->netdev->stats.rx_frame_errors;
451 ++stir->netdev->stats.rx_errors;
458 static void stir_sir_chars(struct stir_cb *stir,
464 async_unwrap_char(stir->netdev, &stir->netdev->stats,
465 &stir->rx_buff, bytes[i]);
468 static inline void unwrap_chars(struct stir_cb *stir,
471 if (isfir(stir->speed))
472 stir_fir_chars(stir, bytes, length);
474 stir_sir_chars(stir, bytes, length);
499 static int change_speed(struct stir_cb *stir, unsigned speed)
509 dev_warn(&stir->netdev->dev, "invalid speed %d\n", speed);
513 pr_debug("speed change from %d to %d\n", stir->speed, speed);
516 err = write_reg(stir, REG_CTRL1, CTRL1_SRESET);
521 err = write_reg(stir, REG_DPLL, 0x15);
526 err = write_reg(stir, REG_PDCLK, stir_modes[i].pdclk);
539 err = write_reg(stir, REG_MODE, mode);
544 err = write_reg(stir, REG_CTRL1,
549 err = write_reg(stir, REG_CTRL1, (tx_power & 3) << 1);
554 err = write_reg(stir, REG_CTRL2, (rx_sensitivity & 7) << 5);
556 stir->speed = speed;
566 struct stir_cb *stir = netdev_priv(netdev);
573 skb = xchg(&stir->tx_pending, skb);
574 wake_up_process(stir->thread);
591 static int fifo_txwait(struct stir_cb *stir, int space)
599 err = read_reg(stir, REG_FIFOCTL, stir->fifo_status,
602 dev_warn(&stir->netdev->dev,
608 status = stir->fifo_status[0];
609 count = (unsigned)(stir->fifo_status[2] & 0x1f) << 8
610 | stir->fifo_status[1];
623 if (!netif_running(stir->netdev) ||
624 !netif_device_present(stir->netdev))
636 msleep((count * 8000) / stir->speed);
639 err = write_reg(stir, REG_FIFOCTL, FIFOCTL_CLR);
642 err = write_reg(stir, REG_FIFOCTL, 0);
651 static void turnaround_delay(const struct stir_cb *stir, long us)
660 if (now.tv_sec - stir->rx_time.tv_sec > 0)
662 us -= now.tv_usec - stir->rx_time.tv_usec;
677 static int receive_start(struct stir_cb *stir)
680 stir->receiving = 1;
682 stir->rx_buff.in_frame = FALSE;
683 stir->rx_buff.state = OUTSIDE_FRAME;
685 stir->rx_urb->status = 0;
686 return usb_submit_urb(stir->rx_urb, GFP_KERNEL);
690 static void receive_stop(struct stir_cb *stir)
692 stir->receiving = 0;
693 usb_kill_urb(stir->rx_urb);
695 if (stir->rx_buff.in_frame)
696 stir->netdev->stats.collisions++;
701 static void stir_send(struct stir_cb *stir, struct sk_buff *skb)
707 if (stir->receiving) {
708 receive_stop(stir);
709 turnaround_delay(stir, irda_get_mtt(skb));
713 if (isfir(stir->speed))
714 wraplen = wrap_fir_skb(skb, stir->io_buf);
716 wraplen = wrap_sir_skb(skb, stir->io_buf);
720 fifo_txwait(stir, wraplen);
722 stir->netdev->stats.tx_packets++;
723 stir->netdev->stats.tx_bytes += skb->len;
724 stir->netdev->trans_start = jiffies;
727 if (usb_bulk_msg(stir->usbdev, usb_sndbulkpipe(stir->usbdev, 1),
728 stir->io_buf, wraplen,
730 stir->netdev->stats.tx_errors++;
738 struct stir_cb *stir = arg;
739 struct net_device *dev = stir->netdev;
746 if (stir->receiving)
747 receive_stop(stir);
749 fifo_txwait(stir, -1);
751 write_reg(stir, REG_CTRL1, CTRL1_TXPWD|CTRL1_RXPWD);
755 if (change_speed(stir, stir->speed))
761 skb = xchg(&stir->tx_pending, NULL);
767 stir_send(stir, skb);
770 if ((new_speed != -1) && (stir->speed != new_speed)) {
771 if (fifo_txwait(stir, -1) ||
772 change_speed(stir, new_speed))
779 if (!stir->receiving &&
782 if (fifo_txwait(stir, -1))
785 if (unlikely(receive_start(stir))) {
789 stir->netdev->name);
790 stir->receiving = 0;
812 struct stir_cb *stir = urb->context;
816 if (!netif_running(stir->netdev))
825 unwrap_chars(stir, urb->transfer_buffer,
828 do_gettimeofday(&stir->rx_time);
832 if (!stir->receiving)
840 dev_warn(&stir->netdev->dev, "usb receive submit error: %d\n",
842 stir->receiving = 0;
843 wake_up_process(stir->thread);
854 struct stir_cb *stir = netdev_priv(netdev);
858 err = usb_clear_halt(stir->usbdev, usb_sndbulkpipe(stir->usbdev, 1));
861 err = usb_clear_halt(stir->usbdev, usb_rcvbulkpipe(stir->usbdev, 2));
865 err = change_speed(stir, 9600);
872 stir->receiving = 0;
873 stir->rx_buff.truesize = IRDA_SKB_MAX_MTU;
874 stir->rx_buff.skb = dev_alloc_skb(IRDA_SKB_MAX_MTU);
875 if (!stir->rx_buff.skb)
878 skb_reserve(stir->rx_buff.skb, 1);
879 stir->rx_buff.head = stir->rx_buff.skb->data;
880 do_gettimeofday(&stir->rx_time);
882 stir->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
883 if (!stir->rx_urb)
886 stir->io_buf = kmalloc(STIR_FIFO_SIZE, GFP_KERNEL);
887 if (!stir->io_buf)
890 usb_fill_bulk_urb(stir->rx_urb, stir->usbdev,
891 usb_rcvbulkpipe(stir->usbdev, 2),
892 stir->io_buf, STIR_FIFO_SIZE,
893 stir_rcv_irq, stir);
895 stir->fifo_status = kmalloc(FIFO_REGS_SIZE, GFP_KERNEL);
896 if (!stir->fifo_status)
904 sprintf(hwname, "usb#%d", stir->usbdev->devnum);
905 stir->irlap = irlap_open(netdev, &stir->qos, hwname);
906 if (!stir->irlap) {
912 stir->thread = kthread_run(stir_transmit_thread, stir,
913 "%s", stir->netdev->name);
914 if (IS_ERR(stir->thread)) {
915 err = PTR_ERR(stir->thread);
925 irlap_close(stir->irlap);
927 kfree(stir->fifo_status);
929 kfree(stir->io_buf);
931 usb_free_urb(stir->rx_urb);
933 kfree_skb(stir->rx_buff.skb);
939 * Function stir_net_close (stir)
946 struct stir_cb *stir = netdev_priv(netdev);
952 kthread_stop(stir->thread);
953 kfree(stir->fifo_status);
956 usb_kill_urb(stir->rx_urb);
958 kfree(stir->io_buf);
959 usb_free_urb(stir->rx_urb);
960 kfree_skb(stir->rx_buff.skb);
963 if (stir->irlap)
964 irlap_close(stir->irlap);
966 stir->irlap = NULL;
977 struct stir_cb *stir = netdev_priv(netdev);
986 if (netif_device_present(stir->netdev))
987 ret = change_speed(stir, irq->ifr_baudrate);
995 if (netif_running(stir->netdev))
996 irda_device_set_media_busy(stir->netdev, TRUE);
1001 irq->ifr_receiving = stir->receiving;
1029 struct stir_cb *stir = NULL;
1034 net = alloc_irdadev(sizeof(*stir));
1039 stir = netdev_priv(net);
1040 stir->netdev = net;
1041 stir->usbdev = dev;
1055 irda_init_max_qos_capabilies(&stir->qos);
1058 stir->qos.baud_rate.bits &= IR_2400 | IR_9600 | IR_19200 |
1061 stir->qos.min_turn_time.bits &= qos_mtt_bits;
1062 irda_qos_bits_to_value(&stir->qos);
1074 usb_set_intfdata(intf, stir);
1089 struct stir_cb *stir = usb_get_intfdata(intf);
1091 if (!stir)
1094 unregister_netdev(stir->netdev);
1095 free_netdev(stir->netdev);
1104 struct stir_cb *stir = usb_get_intfdata(intf);
1106 netif_device_detach(stir->netdev);
1113 struct stir_cb *stir = usb_get_intfdata(intf);
1115 netif_device_attach(stir->netdev);