Merge branch 'upstream'
[pandora-kernel.git] / arch / um / drivers / net_kern.c
index fe865d9..fb1f9fb 100644 (file)
@@ -34,7 +34,7 @@
 #define DRIVER_NAME "uml-netdev"
 
 static DEFINE_SPINLOCK(opened_lock);
-LIST_HEAD(opened);
+static LIST_HEAD(opened);
 
 static int uml_net_rx(struct net_device *dev)
 {
@@ -150,6 +150,7 @@ static int uml_net_close(struct net_device *dev)
        if(lp->close != NULL)
                (*lp->close)(lp->fd, &lp->user);
        lp->fd = -1;
+       list_del(&lp->list);
 
        spin_unlock(&lp->lock);
        return 0;
@@ -243,34 +244,18 @@ static int uml_net_change_mtu(struct net_device *dev, int new_mtu)
        return err;
 }
 
-static int uml_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
-{
-       static const struct ethtool_drvinfo info = {
-               .cmd     = ETHTOOL_GDRVINFO,
-               .driver  = DRIVER_NAME,
-               .version = "42",
-       };
-       void *useraddr;
-       u32 ethcmd;
-
-       switch (cmd) {
-       case SIOCETHTOOL:
-               useraddr = ifr->ifr_data;
-               if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
-                       return -EFAULT;
-               switch (ethcmd) {
-               case ETHTOOL_GDRVINFO:
-                       if (copy_to_user(useraddr, &info, sizeof(info)))
-                               return -EFAULT;
-                       return 0;
-               default:
-                       return -EOPNOTSUPP;
-               }
-       default:
-               return -EINVAL;
-       }
+static void uml_net_get_drvinfo(struct net_device *dev,
+                               struct ethtool_drvinfo *info)
+{
+       strcpy(info->driver, DRIVER_NAME);
+       strcpy(info->version, "42");
 }
 
+static struct ethtool_ops uml_net_ethtool_ops = {
+       .get_drvinfo    = uml_net_get_drvinfo,
+       .get_link       = ethtool_op_get_link,
+};
+
 void uml_net_user_timer_expire(unsigned long _conn)
 {
 #ifdef undef
@@ -282,11 +267,12 @@ void uml_net_user_timer_expire(unsigned long _conn)
 }
 
 static DEFINE_SPINLOCK(devices_lock);
-static struct list_head devices = LIST_HEAD_INIT(devices);
+static LIST_HEAD(devices);
 
-static struct device_driver uml_net_driver = {
-       .name  = DRIVER_NAME,
-       .bus   = &platform_bus_type,
+static struct platform_driver uml_net_driver = {
+       .driver = {
+               .name  = DRIVER_NAME,
+       },
 };
 static int driver_registered;
 
@@ -333,7 +319,7 @@ static int eth_configure(int n, void *init, char *mac,
 
        /* sysfs register */
        if (!driver_registered) {
-               driver_register(&uml_net_driver);
+               platform_driver_register(&uml_net_driver);
                driver_registered = 1;
        }
        device->pdev.id = n;
@@ -359,7 +345,7 @@ static int eth_configure(int n, void *init, char *mac,
        dev->tx_timeout = uml_net_tx_timeout;
        dev->set_mac_address = uml_net_set_mac;
        dev->change_mtu = uml_net_change_mtu;
-       dev->do_ioctl = uml_net_ioctl;
+       dev->ethtool_ops = &uml_net_ethtool_ops;
        dev->watchdog_timeo = (HZ >> 1);
        dev->irq = UM_ETH_IRQ;
 
@@ -601,7 +587,7 @@ static int net_config(char *str)
        err = eth_parse(str, &n, &str);
        if(err) return(err);
 
-       str = uml_strdup(str);
+       str = kstrdup(str, GFP_KERNEL);
        if(str == NULL){
                printk(KERN_ERR "net_config failed to strdup string\n");
                return(-1);
@@ -730,6 +716,7 @@ static void close_devices(void)
 
        list_for_each(ele, &opened){
                lp = list_entry(ele, struct uml_net_private, list);
+               free_irq(lp->dev->irq, lp->dev);
                if((lp->close != NULL) && (lp->fd >= 0))
                        (*lp->close)(lp->fd, &lp->user);
                if(lp->remove != NULL) (*lp->remove)(&lp->user);