Commit 43cb76d9 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Network: convert network devices to use struct device instead of class_device

This lets the network core have the ability to handle suspend/resume
issues, if it wants to.

Thanks to Frederik Deweerdt <frederik.deweerdt@gmail.com> for the arm
driver fixes.
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 2943ecf2
...@@ -958,16 +958,17 @@ struct ipoib_dev_priv *ipoib_intf_alloc(const char *name) ...@@ -958,16 +958,17 @@ struct ipoib_dev_priv *ipoib_intf_alloc(const char *name)
return netdev_priv(dev); return netdev_priv(dev);
} }
static ssize_t show_pkey(struct class_device *cdev, char *buf) static ssize_t show_pkey(struct device *dev,
struct device_attribute *attr, char *buf)
{ {
struct ipoib_dev_priv *priv = struct ipoib_dev_priv *priv = netdev_priv(to_net_dev(dev));
netdev_priv(container_of(cdev, struct net_device, class_dev));
return sprintf(buf, "0x%04x\n", priv->pkey); return sprintf(buf, "0x%04x\n", priv->pkey);
} }
static CLASS_DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL); static DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL);
static ssize_t create_child(struct class_device *cdev, static ssize_t create_child(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
int pkey; int pkey;
...@@ -985,14 +986,14 @@ static ssize_t create_child(struct class_device *cdev, ...@@ -985,14 +986,14 @@ static ssize_t create_child(struct class_device *cdev,
*/ */
pkey |= 0x8000; pkey |= 0x8000;
ret = ipoib_vlan_add(container_of(cdev, struct net_device, class_dev), ret = ipoib_vlan_add(to_net_dev(dev), pkey);
pkey);
return ret ? ret : count; return ret ? ret : count;
} }
static CLASS_DEVICE_ATTR(create_child, S_IWUGO, NULL, create_child); static DEVICE_ATTR(create_child, S_IWUGO, NULL, create_child);
static ssize_t delete_child(struct class_device *cdev, static ssize_t delete_child(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
int pkey; int pkey;
...@@ -1004,18 +1005,16 @@ static ssize_t delete_child(struct class_device *cdev, ...@@ -1004,18 +1005,16 @@ static ssize_t delete_child(struct class_device *cdev,
if (pkey < 0 || pkey > 0xffff) if (pkey < 0 || pkey > 0xffff)
return -EINVAL; return -EINVAL;
ret = ipoib_vlan_delete(container_of(cdev, struct net_device, class_dev), ret = ipoib_vlan_delete(to_net_dev(dev), pkey);
pkey);
return ret ? ret : count; return ret ? ret : count;
} }
static CLASS_DEVICE_ATTR(delete_child, S_IWUGO, NULL, delete_child); static DEVICE_ATTR(delete_child, S_IWUGO, NULL, delete_child);
int ipoib_add_pkey_attr(struct net_device *dev) int ipoib_add_pkey_attr(struct net_device *dev)
{ {
return class_device_create_file(&dev->class_dev, return device_create_file(&dev->dev, &dev_attr_pkey);
&class_device_attr_pkey);
} }
static struct net_device *ipoib_add_port(const char *format, static struct net_device *ipoib_add_port(const char *format,
...@@ -1083,11 +1082,9 @@ static struct net_device *ipoib_add_port(const char *format, ...@@ -1083,11 +1082,9 @@ static struct net_device *ipoib_add_port(const char *format,
if (ipoib_add_pkey_attr(priv->dev)) if (ipoib_add_pkey_attr(priv->dev))
goto sysfs_failed; goto sysfs_failed;
if (class_device_create_file(&priv->dev->class_dev, if (device_create_file(&priv->dev->dev, &dev_attr_create_child))
&class_device_attr_create_child))
goto sysfs_failed; goto sysfs_failed;
if (class_device_create_file(&priv->dev->class_dev, if (device_create_file(&priv->dev->dev, &dev_attr_delete_child))
&class_device_attr_delete_child))
goto sysfs_failed; goto sysfs_failed;
return priv->dev; return priv->dev;
......
...@@ -42,15 +42,15 @@ ...@@ -42,15 +42,15 @@
#include "ipoib.h" #include "ipoib.h"
static ssize_t show_parent(struct class_device *class_dev, char *buf) static ssize_t show_parent(struct device *d, struct device_attribute *attr,
char *buf)
{ {
struct net_device *dev = struct net_device *dev = to_net_dev(d);
container_of(class_dev, struct net_device, class_dev);
struct ipoib_dev_priv *priv = netdev_priv(dev); struct ipoib_dev_priv *priv = netdev_priv(dev);
return sprintf(buf, "%s\n", priv->parent->name); return sprintf(buf, "%s\n", priv->parent->name);
} }
static CLASS_DEVICE_ATTR(parent, S_IRUGO, show_parent, NULL); static DEVICE_ATTR(parent, S_IRUGO, show_parent, NULL);
int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey) int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
{ {
...@@ -118,8 +118,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey) ...@@ -118,8 +118,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
if (ipoib_add_pkey_attr(priv->dev)) if (ipoib_add_pkey_attr(priv->dev))
goto sysfs_failed; goto sysfs_failed;
if (class_device_create_file(&priv->dev->class_dev, if (device_create_file(&priv->dev->dev, &dev_attr_parent))
&class_device_attr_parent))
goto sysfs_failed; goto sysfs_failed;
list_add_tail(&priv->list, &ppriv->child_intfs); list_add_tail(&priv->list, &ppriv->child_intfs);
......
...@@ -641,7 +641,7 @@ static void at91ether_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo ...@@ -641,7 +641,7 @@ static void at91ether_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo
{ {
strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
strlcpy(info->version, DRV_VERSION, sizeof(info->version)); strlcpy(info->version, DRV_VERSION, sizeof(info->version));
strlcpy(info->bus_info, dev->class_dev.dev->bus_id, sizeof(info->bus_info)); strlcpy(info->bus_info, dev->dev.parent->bus_id, sizeof(info->bus_info));
} }
static const struct ethtool_ops at91ether_ethtool_ops = { static const struct ethtool_ops at91ether_ethtool_ops = {
......
...@@ -587,7 +587,7 @@ static void etherh_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *i ...@@ -587,7 +587,7 @@ static void etherh_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *i
{ {
strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
strlcpy(info->version, DRV_VERSION, sizeof(info->version)); strlcpy(info->version, DRV_VERSION, sizeof(info->version));
strlcpy(info->bus_info, dev->class_dev.dev->bus_id, strlcpy(info->bus_info, dev->dev.parent->bus_id,
sizeof(info->bus_info)); sizeof(info->bus_info));
} }
......
This diff is collapsed.
...@@ -1102,7 +1102,7 @@ static struct net_device * __init veth_probe_one(int vlan, ...@@ -1102,7 +1102,7 @@ static struct net_device * __init veth_probe_one(int vlan,
} }
kobject_init(&port->kobject); kobject_init(&port->kobject);
port->kobject.parent = &dev->class_dev.kobj; port->kobject.parent = &dev->dev.kobj;
port->kobject.ktype = &veth_port_ktype; port->kobject.ktype = &veth_port_ktype;
kobject_set_name(&port->kobject, "veth_port"); kobject_set_name(&port->kobject, "veth_port");
if (0 != kobject_add(&port->kobject)) if (0 != kobject_add(&port->kobject))
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include "macb.h" #include "macb.h"
#define to_net_dev(class) container_of(class, struct net_device, class_dev)
#define RX_BUFFER_SIZE 128 #define RX_BUFFER_SIZE 128
#define RX_RING_SIZE 512 #define RX_RING_SIZE 512
#define RX_RING_BYTES (sizeof(struct dma_desc) * RX_RING_SIZE) #define RX_RING_BYTES (sizeof(struct dma_desc) * RX_RING_SIZE)
...@@ -945,10 +943,10 @@ static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -945,10 +943,10 @@ static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
return ret; return ret;
} }
static ssize_t macb_mii_show(const struct class_device *cd, char *buf, static ssize_t macb_mii_show(const struct device *_dev, char *buf,
unsigned long addr) unsigned long addr)
{ {
struct net_device *dev = to_net_dev(cd); struct net_device *dev = to_net_dev(_dev);
struct macb *bp = netdev_priv(dev); struct macb *bp = netdev_priv(dev);
ssize_t ret = -EINVAL; ssize_t ret = -EINVAL;
...@@ -962,11 +960,13 @@ static ssize_t macb_mii_show(const struct class_device *cd, char *buf, ...@@ -962,11 +960,13 @@ static ssize_t macb_mii_show(const struct class_device *cd, char *buf,
} }
#define MII_ENTRY(name, addr) \ #define MII_ENTRY(name, addr) \
static ssize_t show_##name(struct class_device *cd, char *buf) \ static ssize_t show_##name(struct device *_dev, \
struct device_attribute *attr, \
char *buf) \
{ \ { \
return macb_mii_show(cd, buf, addr); \ return macb_mii_show(_dev, buf, addr); \
} \ } \
static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
MII_ENTRY(bmcr, MII_BMCR); MII_ENTRY(bmcr, MII_BMCR);
MII_ENTRY(bmsr, MII_BMSR); MII_ENTRY(bmsr, MII_BMSR);
...@@ -977,13 +977,13 @@ MII_ENTRY(lpa, MII_LPA); ...@@ -977,13 +977,13 @@ MII_ENTRY(lpa, MII_LPA);
MII_ENTRY(expansion, MII_EXPANSION); MII_ENTRY(expansion, MII_EXPANSION);
static struct attribute *macb_mii_attrs[] = { static struct attribute *macb_mii_attrs[] = {
&class_device_attr_bmcr.attr, &dev_attr_bmcr.attr,
&class_device_attr_bmsr.attr, &dev_attr_bmsr.attr,
&class_device_attr_physid1.attr, &dev_attr_physid1.attr,
&class_device_attr_physid2.attr, &dev_attr_physid2.attr,
&class_device_attr_advertise.attr, &dev_attr_advertise.attr,
&class_device_attr_lpa.attr, &dev_attr_lpa.attr,
&class_device_attr_expansion.attr, &dev_attr_expansion.attr,
NULL, NULL,
}; };
...@@ -994,17 +994,17 @@ static struct attribute_group macb_mii_group = { ...@@ -994,17 +994,17 @@ static struct attribute_group macb_mii_group = {
static void macb_unregister_sysfs(struct net_device *net) static void macb_unregister_sysfs(struct net_device *net)
{ {
struct class_device *class_dev = &net->class_dev; struct device *_dev = &net->dev;
sysfs_remove_group(&class_dev->kobj, &macb_mii_group); sysfs_remove_group(&_dev->kobj, &macb_mii_group);
} }
static int macb_register_sysfs(struct net_device *net) static int macb_register_sysfs(struct net_device *net)
{ {
struct class_device *class_dev = &net->class_dev; struct device *_dev = &net->dev;
int ret; int ret;
ret = sysfs_create_group(&class_dev->kobj, &macb_mii_group); ret = sysfs_create_group(&_dev->kobj, &macb_mii_group);
if (ret) if (ret)
printk(KERN_WARNING printk(KERN_WARNING
"%s: sysfs mii attribute registration failed: %d\n", "%s: sysfs mii attribute registration failed: %d\n",
......
...@@ -1659,7 +1659,7 @@ smc911x_ethtool_getdrvinfo(struct net_device *dev, struct ethtool_drvinfo *info) ...@@ -1659,7 +1659,7 @@ smc911x_ethtool_getdrvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
{ {
strncpy(info->driver, CARDNAME, sizeof(info->driver)); strncpy(info->driver, CARDNAME, sizeof(info->driver));
strncpy(info->version, version, sizeof(info->version)); strncpy(info->version, version, sizeof(info->version));
strncpy(info->bus_info, dev->class_dev.dev->bus_id, sizeof(info->bus_info)); strncpy(info->bus_info, dev->dev.parent->bus_id, sizeof(info->bus_info));
} }
static int smc911x_ethtool_nwayreset(struct net_device *dev) static int smc911x_ethtool_nwayreset(struct net_device *dev)
......
...@@ -1712,7 +1712,7 @@ smc_ethtool_getdrvinfo(struct net_device *dev, struct ethtool_drvinfo *info) ...@@ -1712,7 +1712,7 @@ smc_ethtool_getdrvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
{ {
strncpy(info->driver, CARDNAME, sizeof(info->driver)); strncpy(info->driver, CARDNAME, sizeof(info->driver));
strncpy(info->version, version, sizeof(info->version)); strncpy(info->version, version, sizeof(info->version));
strncpy(info->bus_info, dev->class_dev.dev->bus_id, sizeof(info->bus_info)); strncpy(info->bus_info, dev->dev.parent->bus_id, sizeof(info->bus_info));
} }
static int smc_ethtool_nwayreset(struct net_device *dev) static int smc_ethtool_nwayreset(struct net_device *dev)
......
...@@ -84,7 +84,7 @@ struct net_device * hostap_add_interface(struct local_info *local, ...@@ -84,7 +84,7 @@ struct net_device * hostap_add_interface(struct local_info *local,
if (strchr(dev->name, '%')) if (strchr(dev->name, '%'))
ret = dev_alloc_name(dev, dev->name); ret = dev_alloc_name(dev, dev->name);
SET_NETDEV_DEV(dev, mdev->class_dev.dev); SET_NETDEV_DEV(dev, mdev->dev.parent);
if (ret >= 0) if (ret >= 0)
ret = register_netdevice(dev); ret = register_netdevice(dev);
......
...@@ -4293,8 +4293,8 @@ static void orinoco_get_drvinfo(struct net_device *dev, ...@@ -4293,8 +4293,8 @@ static void orinoco_get_drvinfo(struct net_device *dev,
strncpy(info->driver, DRIVER_NAME, sizeof(info->driver) - 1); strncpy(info->driver, DRIVER_NAME, sizeof(info->driver) - 1);
strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1); strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1);
strncpy(info->fw_version, priv->fw_name, sizeof(info->fw_version) - 1); strncpy(info->fw_version, priv->fw_name, sizeof(info->fw_version) - 1);
if (dev->class_dev.dev) if (dev->dev.parent)
strncpy(info->bus_info, dev->class_dev.dev->bus_id, strncpy(info->bus_info, dev->dev.parent->bus_id,
sizeof(info->bus_info) - 1); sizeof(info->bus_info) - 1);
else else
snprintf(info->bus_info, sizeof(info->bus_info) - 1, snprintf(info->bus_info, sizeof(info->bus_info) - 1,
......
...@@ -332,7 +332,7 @@ orinoco_cs_config(struct pcmcia_device *link) ...@@ -332,7 +332,7 @@ orinoco_cs_config(struct pcmcia_device *link)
/* Finally, report what we've done */ /* Finally, report what we've done */
printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io " printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io "
"0x%04x-0x%04x\n", dev->name, dev->class_dev.dev->bus_id, "0x%04x-0x%04x\n", dev->name, dev->dev.parent->bus_id,
link->irq.AssignedIRQ, link->io.BasePort1, link->irq.AssignedIRQ, link->io.BasePort1,
link->io.BasePort1 + link->io.NumPorts1 - 1); link->io.BasePort1 + link->io.NumPorts1 - 1);
......
...@@ -806,7 +806,7 @@ spectrum_cs_config(struct pcmcia_device *link) ...@@ -806,7 +806,7 @@ spectrum_cs_config(struct pcmcia_device *link)
/* Finally, report what we've done */ /* Finally, report what we've done */
printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io " printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io "
"0x%04x-0x%04x\n", dev->name, dev->class_dev.dev->bus_id, "0x%04x-0x%04x\n", dev->name, dev->dev.parent->bus_id,
link->irq.AssignedIRQ, link->io.BasePort1, link->irq.AssignedIRQ, link->io.BasePort1,
link->io.BasePort1 + link->io.NumPorts1 - 1); link->io.BasePort1 + link->io.NumPorts1 - 1);
......
...@@ -529,10 +529,11 @@ struct net_device ...@@ -529,10 +529,11 @@ struct net_device
struct net_bridge_port *br_port; struct net_bridge_port *br_port;
/* class/net/name entry */ /* class/net/name entry */
struct class_device class_dev; struct device dev;
/* space for optional statistics and wireless sysfs groups */ /* space for optional statistics and wireless sysfs groups */
struct attribute_group *sysfs_groups[3]; struct attribute_group *sysfs_groups[3];
}; };
#define to_net_dev(d) container_of(d, struct net_device, dev)
#define NETDEV_ALIGN 32 #define NETDEV_ALIGN 32
#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1) #define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1)
...@@ -548,7 +549,7 @@ static inline void *netdev_priv(struct net_device *dev) ...@@ -548,7 +549,7 @@ static inline void *netdev_priv(struct net_device *dev)
/* Set the sysfs physical device reference for the network logical device /* Set the sysfs physical device reference for the network logical device
* if set prior to registration will cause a symlink during initialization. * if set prior to registration will cause a symlink during initialization.
*/ */
#define SET_NETDEV_DEV(net, pdev) ((net)->class_dev.dev = (pdev)) #define SET_NETDEV_DEV(net, pdev) ((net)->dev.parent = (pdev))
struct packet_type { struct packet_type {
__be16 type; /* This is really htons(ether_type). */ __be16 type; /* This is really htons(ether_type). */
......
...@@ -286,7 +286,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br, ...@@ -286,7 +286,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br,
kobject_init(&p->kobj); kobject_init(&p->kobj);
kobject_set_name(&p->kobj, SYSFS_BRIDGE_PORT_ATTR); kobject_set_name(&p->kobj, SYSFS_BRIDGE_PORT_ATTR);
p->kobj.ktype = &brport_ktype; p->kobj.ktype = &brport_ktype;
p->kobj.parent = &(dev->class_dev.kobj); p->kobj.parent = &(dev->dev.kobj);
p->kobj.kset = NULL; p->kobj.kset = NULL;
return p; return p;
......
This diff is collapsed.
...@@ -211,7 +211,7 @@ int br_sysfs_addif(struct net_bridge_port *p) ...@@ -211,7 +211,7 @@ int br_sysfs_addif(struct net_bridge_port *p)
struct brport_attribute **a; struct brport_attribute **a;
int err; int err;
err = sysfs_create_link(&p->kobj, &br->dev->class_dev.kobj, err = sysfs_create_link(&p->kobj, &br->dev->dev.kobj,
SYSFS_BRIDGE_PORT_LINK); SYSFS_BRIDGE_PORT_LINK);
if (err) if (err)
goto out2; goto out2;
......
...@@ -751,7 +751,7 @@ int dev_change_name(struct net_device *dev, char *newname) ...@@ -751,7 +751,7 @@ int dev_change_name(struct net_device *dev, char *newname)
else else
strlcpy(dev->name, newname, IFNAMSIZ); strlcpy(dev->name, newname, IFNAMSIZ);
err = class_device_rename(&dev->class_dev, dev->name); err = device_rename(&dev->dev, dev->name);
if (!err) { if (!err) {
hlist_del(&dev->name_hlist); hlist_del(&dev->name_hlist);
hlist_add_head(&dev->name_hlist, dev_name_hash(dev->name)); hlist_add_head(&dev->name_hlist, dev_name_hash(dev->name));
...@@ -3221,8 +3221,8 @@ void free_netdev(struct net_device *dev) ...@@ -3221,8 +3221,8 @@ void free_netdev(struct net_device *dev)
BUG_ON(dev->reg_state != NETREG_UNREGISTERED); BUG_ON(dev->reg_state != NETREG_UNREGISTERED);
dev->reg_state = NETREG_RELEASED; dev->reg_state = NETREG_RELEASED;
/* will free via class release */ /* will free via device release */
class_device_put(&dev->class_dev); put_device(&dev->dev);
#else #else
kfree((char *)dev - dev->padded); kfree((char *)dev - dev->padded);
#endif #endif
......
This diff is collapsed.
...@@ -268,7 +268,7 @@ nodata: ...@@ -268,7 +268,7 @@ nodata:
struct sk_buff *__netdev_alloc_skb(struct net_device *dev, struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
unsigned int length, gfp_t gfp_mask) unsigned int length, gfp_t gfp_mask)
{ {
int node = dev->class_dev.dev ? dev_to_node(dev->class_dev.dev) : -1; int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1;
struct sk_buff *skb; struct sk_buff *skb;
skb = __alloc_skb(length + NET_SKB_PAD, gfp_mask, 0, node); skb = __alloc_skb(length + NET_SKB_PAD, gfp_mask, 0, node);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment