diff -Nru ipheth-1.0/debian/changelog ipheth-1.0+git20101013/debian/changelog --- ipheth-1.0/debian/changelog 2010-09-23 23:44:01.000000000 +0000 +++ ipheth-1.0+git20101013/debian/changelog 2010-10-13 10:24:49.000000000 +0000 @@ -1,8 +1,15 @@ -ipheth (1.0-2ubuntu1~ppa1) maverick; urgency=low +ipheth (1.0+git20101013-3ubuntu1~maverick1) maverick; urgency=low * Backport latest Debian package + * New upstream snapshot - -- Paul McEnery Fri, 24 Sep 2010 00:42:46 +0100 + -- Paul McEnery Wed, 13 Oct 2010 11:23:27 +0100 + +ipheth (1.0-3) unstable; urgency=low + + * Add statement regarding Debian kernel version in NEWS.Debian + + -- Paul McEnery Tue, 28 Sep 2010 23:02:47 +0100 ipheth (1.0-2) unstable; urgency=low diff -Nru ipheth-1.0/debian/NEWS ipheth-1.0+git20101013/debian/NEWS --- ipheth-1.0/debian/NEWS 2010-09-23 23:44:01.000000000 +0000 +++ ipheth-1.0+git20101013/debian/NEWS 2010-10-13 10:24:49.000000000 +0000 @@ -1,9 +1,11 @@ -ipheth (1.0-2) unstable; urgency=low +ipheth (1.0-3) unstable; urgency=low As of 21 April 2010, the ipheth kernel module has been accepted in - the mainstream Linux kernel (2.6.34). There is therefore no longer - any need to supply the source code for the driver. For this reason, - the ipheth-dkms package been removed. + the mainstream Linux kernel (2.6.34). The Debian kernel team have + backported the driver which has been available since Debian kernel + 2.6.32-12. There is therefore no longer any need to supply the source + code for the driver. For this reason, the ipheth-dkms package been + removed. If you run a desktop system, it may not be necessary to install ipheth-utils. Desktop packages such as GVFS and libgpod automatically @@ -12,6 +14,6 @@ use of the iPhone's Internet connection. Users upgrading from version 1.0-1 are advised to remove the - ipheth-dkms package in order to use the Kernel maintained driver. + ipheth-dkms package in order to use the kernel maintained driver. - -- Paul McEnery Thu, 23 Sep 2010 15:01:13 +0100 + -- Paul McEnery Tue, 28 Sep 2010 23:02:47 +0100 diff -Nru ipheth-1.0/ipheth-driver/ipheth.c ipheth-1.0+git20101013/ipheth-driver/ipheth.c --- ipheth-1.0/ipheth-driver/ipheth.c 2010-02-12 21:56:11.000000000 +0000 +++ ipheth-1.0+git20101013/ipheth-driver/ipheth.c 2010-10-13 10:23:18.000000000 +0000 @@ -51,17 +51,18 @@ #include #include #include -#include #include #include #define USB_VENDOR_APPLE 0x05ac -#define USB_PRODUCT_IPHETH 0x1290 -#define USB_PRODUCT_IPHETH_3G 0x1292 -#define USB_PRODUCT_IPHETH_3GS 0x1294 +#define USB_PRODUCT_IPHONE 0x1290 +#define USB_PRODUCT_IPHONE_3G 0x1292 +#define USB_PRODUCT_IPHONE_3GS 0x1294 +#define USB_PRODUCT_IPHONE_4 0x1297 #define IPHETH_USBINTF_CLASS 255 #define IPHETH_USBINTF_SUBCLASS 253 +#define IPHETH_USBINTF_PROTO 1 #define IPHETH_BUF_SIZE 1516 #define IPHETH_TX_TIMEOUT (5 * HZ) @@ -70,19 +71,32 @@ #define IPHETH_ALT_INTFNUM 1 #define IPHETH_CTRL_ENDP 0x00 -#define IPHETH_CTRL_BUF_SIZE 0x40 +#define IPHETH_CTRL_BUF_SIZE 0x40 #define IPHETH_CTRL_TIMEOUT (5 * HZ) #define IPHETH_CMD_GET_MACADDR 0x00 #define IPHETH_CMD_CARRIER_CHECK 0x45 -#define IPHETH_CARRIER_CHECK_TIMEOUT (1 * HZ) +#define IPHETH_CARRIER_CHECK_TIMEOUT round_jiffies_relative(1 * HZ) #define IPHETH_CARRIER_ON 0x04 -static struct usb_device_id ipheth_table [] = { - { USB_DEVICE(USB_VENDOR_APPLE, USB_PRODUCT_IPHETH) }, - { USB_DEVICE(USB_VENDOR_APPLE, USB_PRODUCT_IPHETH_3G) }, - { USB_DEVICE(USB_VENDOR_APPLE, USB_PRODUCT_IPHETH_3GS) }, +static struct usb_device_id ipheth_table[] = { + { USB_DEVICE_AND_INTERFACE_INFO( + USB_VENDOR_APPLE, USB_PRODUCT_IPHONE, + IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, + IPHETH_USBINTF_PROTO) }, + { USB_DEVICE_AND_INTERFACE_INFO( + USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3G, + IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, + IPHETH_USBINTF_PROTO) }, + { USB_DEVICE_AND_INTERFACE_INFO( + USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3GS, + IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, + IPHETH_USBINTF_PROTO) }, + { USB_DEVICE_AND_INTERFACE_INFO( + USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4, + IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, + IPHETH_USBINTF_PROTO) }, { } }; MODULE_DEVICE_TABLE(usb, ipheth_table); @@ -98,8 +112,8 @@ unsigned char *tx_buf; unsigned char *rx_buf; unsigned char *ctrl_buf; - __u8 bulk_in; - __u8 bulk_out; + u8 bulk_in; + u8 bulk_out; struct delayed_work carrier_work; }; @@ -114,25 +128,25 @@ tx_urb = usb_alloc_urb(0, GFP_KERNEL); if (tx_urb == NULL) - goto error; + goto error_nomem; rx_urb = usb_alloc_urb(0, GFP_KERNEL); if (rx_urb == NULL) - goto error; + goto free_tx_urb; tx_buf = usb_buffer_alloc(iphone->udev, IPHETH_BUF_SIZE, GFP_KERNEL, &tx_urb->transfer_dma); if (tx_buf == NULL) - goto error; + goto free_rx_urb; rx_buf = usb_buffer_alloc(iphone->udev, IPHETH_BUF_SIZE, GFP_KERNEL, &rx_urb->transfer_dma); if (rx_buf == NULL) - goto error; + goto free_tx_buf; iphone->tx_urb = tx_urb; @@ -141,17 +155,18 @@ iphone->rx_buf = rx_buf; return 0; -error: - usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, rx_buf, - rx_urb->transfer_dma); +free_tx_buf: usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, tx_buf, tx_urb->transfer_dma); +free_rx_urb: usb_free_urb(rx_urb); +free_tx_urb: usb_free_urb(tx_urb); +error_nomem: return -ENOMEM; } -static void ipheth_free_urbs (struct ipheth_device *iphone) +static void ipheth_free_urbs(struct ipheth_device *iphone) { usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, iphone->rx_buf, iphone->rx_urb->transfer_dma); @@ -161,13 +176,13 @@ usb_free_urb(iphone->tx_urb); } -static void ipheth_unlink_urbs (struct ipheth_device *dev) +static void ipheth_kill_urbs(struct ipheth_device *dev) { usb_kill_urb(dev->tx_urb); usb_kill_urb(dev->rx_urb); } -static void ipheth_rcvbulk_callback (struct urb *urb) +static void ipheth_rcvbulk_callback(struct urb *urb) { struct ipheth_device *dev; struct sk_buff *skb; @@ -188,14 +203,15 @@ case 0: break; default: - err("%s: urb status: %d", __func__, urb->status); + err("%s: urb status: %d", __func__, status); return; } len = urb->actual_length; buf = urb->transfer_buffer; - if (!(skb = dev_alloc_skb(NET_IP_ALIGN + len))) { + skb = dev_alloc_skb(NET_IP_ALIGN + len); + if (!skb) { err("%s: dev_alloc_skb: -ENOMEM", __func__); dev->stats.rx_dropped++; return; @@ -213,22 +229,23 @@ ipheth_rx_submit(dev, GFP_ATOMIC); } -static void ipheth_sndbulk_callback (struct urb *urb) +static void ipheth_sndbulk_callback(struct urb *urb) { struct ipheth_device *dev; + int status = urb->status; dev = urb->context; if (dev == NULL) return; - if (urb->status != 0 && - urb->status != -ENOENT && - urb->status != -ECONNRESET && - urb->status != -ESHUTDOWN) - err("%s: urb status: %d", __func__, urb->status); + if (status != 0 && + status != -ENOENT && + status != -ECONNRESET && + status != -ESHUTDOWN) + err("%s: urb status: %d", __func__, status); - netif_wake_queue(dev->net); dev_kfree_skb_irq(dev->tx_skb); + netif_wake_queue(dev->net); } static int ipheth_carrier_set(struct ipheth_device *dev) @@ -236,14 +253,15 @@ struct usb_device *udev = dev->udev; int retval; - if ((retval = usb_control_msg(udev, - usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP), - IPHETH_CMD_CARRIER_CHECK, /* request */ - 0xc0, /* request type */ - 0x00, /* value */ - 0x02, /* index */ - dev->ctrl_buf, IPHETH_CTRL_BUF_SIZE, - IPHETH_CTRL_TIMEOUT)) < 0) { + retval = usb_control_msg(udev, + usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP), + IPHETH_CMD_CARRIER_CHECK, /* request */ + 0xc0, /* request type */ + 0x00, /* value */ + 0x02, /* index */ + dev->ctrl_buf, IPHETH_CTRL_BUF_SIZE, + IPHETH_CTRL_TIMEOUT); + if (retval < 0) { err("%s: usb_control_msg: %d", __func__, retval); return retval; } @@ -271,7 +289,7 @@ struct net_device *net = dev->net; int retval; - retval = usb_control_msg(udev, + retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP), IPHETH_CMD_GET_MACADDR, /* request */ 0xc0, /* request type */ @@ -283,7 +301,8 @@ if (retval < 0) { err("%s: usb_control_msg: %d", __func__, retval); } else if (retval < ETH_ALEN) { - err("%s: usb_control_msg: short packet: %d bytes", __func__, retval); + err("%s: usb_control_msg: short packet: %d bytes", + __func__, retval); retval = -EINVAL; } else { memcpy(net->dev_addr, dev->ctrl_buf, ETH_ALEN); @@ -305,12 +324,13 @@ dev); dev->rx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; - if ((retval = usb_submit_urb(dev->rx_urb, mem_flags))) + retval = usb_submit_urb(dev->rx_urb, mem_flags); + if (retval) err("%s: usb_submit_urb: %d", __func__, retval); return retval; } -static int ipheth_open (struct net_device *net) +static int ipheth_open(struct net_device *net) { struct ipheth_device *dev = netdev_priv(net); struct usb_device *udev = dev->udev; @@ -320,19 +340,20 @@ usb_clear_halt(udev, usb_rcvbulkpipe(udev, dev->bulk_in)); usb_clear_halt(udev, usb_sndbulkpipe(udev, dev->bulk_out)); - if ((retval = ipheth_carrier_set(dev))) - goto error; + retval = ipheth_carrier_set(dev); + if (retval) + return retval; - if ((retval = ipheth_rx_submit(dev, GFP_KERNEL))) - goto error; + retval = ipheth_rx_submit(dev, GFP_KERNEL); + if (retval) + return retval; schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT); netif_start_queue(net); -error: return retval; } -static int ipheth_close (struct net_device *net) +static int ipheth_close(struct net_device *net) { struct ipheth_device *dev = netdev_priv(net); @@ -341,7 +362,7 @@ return 0; } -static int ipheth_tx (struct sk_buff *skb, struct net_device *net) +static int ipheth_tx(struct sk_buff *skb, struct net_device *net) { struct ipheth_device *dev = netdev_priv(net); struct usb_device *udev = dev->udev; @@ -352,12 +373,13 @@ err("%s: skb too large: %d bytes", __func__, skb->len); dev->stats.tx_dropped++; dev_kfree_skb_irq(skb); - goto exit; + return NETDEV_TX_OK; } - memset(dev->tx_buf, 0, IPHETH_BUF_SIZE); memcpy(dev->tx_buf, skb->data, skb->len); - + if (skb->len < IPHETH_BUF_SIZE) + memset(dev->tx_buf + skb->len, 0, IPHETH_BUF_SIZE - skb->len); + usb_fill_bulk_urb(dev->tx_urb, udev, usb_sndbulkpipe(udev, dev->bulk_out), dev->tx_buf, IPHETH_BUF_SIZE, @@ -365,7 +387,8 @@ dev); dev->tx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; - if ((retval = usb_submit_urb (dev->tx_urb, GFP_ATOMIC))) { + retval = usb_submit_urb(dev->tx_urb, GFP_ATOMIC); + if (retval) { err("%s: usb_submit_urb: %d", __func__, retval); dev->stats.tx_errors++; dev_kfree_skb_irq(skb); @@ -377,11 +400,11 @@ dev->stats.tx_bytes += skb->len; netif_stop_queue(net); } -exit: + return NETDEV_TX_OK; } -static void ipheth_tx_timeout (struct net_device *net) +static void ipheth_tx_timeout(struct net_device *net) { struct ipheth_device *dev = netdev_priv(net); @@ -390,7 +413,7 @@ usb_unlink_urb(dev->tx_urb); } -static struct net_device_stats *ipheth_stats (struct net_device *net) +static struct net_device_stats *ipheth_stats(struct net_device *net) { struct ipheth_device *dev = netdev_priv(net); return &dev->stats; @@ -408,16 +431,16 @@ #ifdef HAVE_NET_DEVICE_OPS static const struct net_device_ops ipheth_netdev_ops = { - .ndo_open = &ipheth_open, - .ndo_stop = &ipheth_close, - .ndo_start_xmit = &ipheth_tx, - .ndo_tx_timeout = &ipheth_tx_timeout, - .ndo_get_stats = &ipheth_stats, + .ndo_open = &ipheth_open, + .ndo_stop = &ipheth_close, + .ndo_start_xmit = &ipheth_tx, + .ndo_tx_timeout = &ipheth_tx_timeout, + .ndo_get_stats = &ipheth_stats, }; #endif -static int ipheth_probe (struct usb_interface *intf, - const struct usb_device_id *id) +static int ipheth_probe(struct usb_interface *intf, + const struct usb_device_id *id) { struct usb_device *udev = interface_to_usbdev(intf); struct usb_host_interface *hintf; @@ -427,11 +450,6 @@ int i; int retval; - /* Ensure we are probing the right interface */ - if (intf->cur_altsetting->desc.bInterfaceClass != IPHETH_USBINTF_CLASS || - intf->cur_altsetting->desc.bInterfaceSubClass != IPHETH_USBINTF_SUBCLASS) - return -ENODEV; - netdev = alloc_etherdev(sizeof(struct ipheth_device)); if (!netdev) return -ENOMEM; @@ -446,6 +464,7 @@ netdev->get_stats = &ipheth_stats; #endif netdev->watchdog_timeo = IPHETH_TX_TIMEOUT; + strcpy(netdev->name, "eth%d"); dev = netdev_priv(netdev); dev->udev = udev; @@ -453,7 +472,7 @@ dev->intf = intf; /* Set up endpoints */ - hintf = usb_altnum_to_altsetting (intf, IPHETH_ALT_INTFNUM); + hintf = usb_altnum_to_altsetting(intf, IPHETH_ALT_INTFNUM); if (hintf == NULL) { retval = -ENODEV; err("Unable to find alternate settings interface"); @@ -479,12 +498,14 @@ goto err_alloc_ctrl_buf; } - if ((retval = ipheth_get_macaddr(dev))) + retval = ipheth_get_macaddr(dev); + if (retval) goto err_get_macaddr; INIT_DELAYED_WORK(&dev->carrier_work, ipheth_carrier_check_work); - if ((retval = ipheth_alloc_urbs(dev))) { + retval = ipheth_alloc_urbs(dev); + if (retval) { err("error allocating urbs: %d", retval); goto err_alloc_urbs; } @@ -494,7 +515,8 @@ SET_NETDEV_DEV(netdev, &intf->dev); SET_ETHTOOL_OPS(netdev, &ops); - if ((retval = register_netdev(netdev))) { + retval = register_netdev(netdev); + if (retval) { err("error registering netdev: %d", retval); retval = -EIO; goto err_register_netdev; @@ -521,7 +543,7 @@ dev = usb_get_intfdata(intf); if (dev != NULL) { unregister_netdev(dev->net); - ipheth_unlink_urbs(dev); + ipheth_kill_urbs(dev); ipheth_free_urbs(dev); kfree(dev->ctrl_buf); free_netdev(dev->net); @@ -535,7 +557,6 @@ .probe = ipheth_probe, .disconnect = ipheth_disconnect, .id_table = ipheth_table, - .supports_autosuspend = 0, }; static int __init ipheth_init(void) diff -Nru ipheth-1.0/ipheth-driver/Makefile ipheth-1.0+git20101013/ipheth-driver/Makefile --- ipheth-1.0/ipheth-driver/Makefile 2010-02-12 21:56:11.000000000 +0000 +++ ipheth-1.0+git20101013/ipheth-driver/Makefile 2010-10-13 10:23:18.000000000 +0000 @@ -1,12 +1,13 @@ obj-m += ipheth.o +KERNELDIR ?= /lib/modules/$(shell uname -r)/build +PWD := $(shell pwd) + all: - make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules + make -C $(KERNELDIR) M=$(PWD) modules clean: - make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean + make -C $(KERNELDIR) M=$(PWD) clean install: - make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules_install - - + make -C $(KERNELDIR) M=$(PWD) modules_install