+static ssize_t
+remove_write (struct device_driver *drv, const char *buf, size_t count)
+{
+ struct iucv_connection **clist = &connections;
+ struct net_device *ndev;
+ struct netiucv_priv *priv;
+ struct device *dev;
+ char name[IFNAMSIZ];
+ char *p;
+ int i;
+
+ pr_debug("%s() called\n", __FUNCTION__);
+
+ if (count >= IFNAMSIZ)
+ count = IFNAMSIZ-1;
+
+ for (i=0, p=(char *)buf; i<count && *p; i++, p++) {
+ if ((*p == '\n') | (*p == ' ')) {
+ /* trailing lf, grr */
+ break;
+ } else {
+ name[i]=*p;
+ }
+ }
+ name[i] = '\0';
+
+ while (*clist) {
+ ndev = (*clist)->netdev;
+ priv = (struct netiucv_priv*)ndev->priv;
+ dev = priv->dev;
+
+ if (strncmp(name, ndev->name, count)) {
+ clist = &((*clist)->next);
+ continue;
+ }
+ if (ndev->flags & (IFF_UP | IFF_RUNNING)) {
+ printk(KERN_WARNING
+ "netiucv: net device %s active with peer %s\n",
+ ndev->name, priv->conn->userid);
+ printk(KERN_WARNING
+ "netiucv: %s cannot be removed\n",
+ ndev->name);
+ return -EBUSY;
+ }
+ unregister_netdev(ndev);
+ netiucv_unregister_device(dev);
+ return count;
+ }
+ printk(KERN_WARNING
+ "netiucv: net device %s unknown\n", name);
+ return -EINVAL;
+}
+
+DRIVER_ATTR(remove, 0200, NULL, remove_write);
+