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)
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 =
netdev_priv(container_of(cdev, struct net_device, class_dev));
struct ipoib_dev_priv *priv = netdev_priv(to_net_dev(dev));
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)
{
int pkey;
......@@ -985,14 +986,14 @@ static ssize_t create_child(struct class_device *cdev,
*/
pkey |= 0x8000;
ret = ipoib_vlan_add(container_of(cdev, struct net_device, class_dev),
pkey);
ret = ipoib_vlan_add(to_net_dev(dev), pkey);
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)
{
int pkey;
......@@ -1004,18 +1005,16 @@ static ssize_t delete_child(struct class_device *cdev,
if (pkey < 0 || pkey > 0xffff)
return -EINVAL;
ret = ipoib_vlan_delete(container_of(cdev, struct net_device, class_dev),
pkey);
ret = ipoib_vlan_delete(to_net_dev(dev), pkey);
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)
{
return class_device_create_file(&dev->class_dev,
&class_device_attr_pkey);
return device_create_file(&dev->dev, &dev_attr_pkey);
}
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))
goto sysfs_failed;
if (class_device_create_file(&priv->dev->class_dev,
&class_device_attr_create_child))
if (device_create_file(&priv->dev->dev, &dev_attr_create_child))
goto sysfs_failed;
if (class_device_create_file(&priv->dev->class_dev,
&class_device_attr_delete_child))
if (device_create_file(&priv->dev->dev, &dev_attr_delete_child))
goto sysfs_failed;
return priv->dev;
......
......@@ -42,15 +42,15 @@
#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 =
container_of(class_dev, struct net_device, class_dev);
struct net_device *dev = to_net_dev(d);
struct ipoib_dev_priv *priv = netdev_priv(dev);
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)
{
......@@ -118,8 +118,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
if (ipoib_add_pkey_attr(priv->dev))
goto sysfs_failed;
if (class_device_create_file(&priv->dev->class_dev,
&class_device_attr_parent))
if (device_create_file(&priv->dev->dev, &dev_attr_parent))
goto sysfs_failed;
list_add_tail(&priv->list, &ppriv->child_intfs);
......
......@@ -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->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 = {
......
......@@ -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->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));
}
......
This diff is collapsed.
......@@ -1102,7 +1102,7 @@ static struct net_device * __init veth_probe_one(int vlan,
}
kobject_init(&port->kobject);
port->kobject.parent = &dev->class_dev.kobj;
port->kobject.parent = &dev->dev.kobj;
port->kobject.ktype = &veth_port_ktype;
kobject_set_name(&port->kobject, "veth_port");
if (0 != kobject_add(&port->kobject))
......
......@@ -27,8 +27,6 @@
#include "macb.h"
#define to_net_dev(class) container_of(class, struct net_device, class_dev)
#define RX_BUFFER_SIZE 128
#define RX_RING_SIZE 512
#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)
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)
{
struct net_device *dev = to_net_dev(cd);
struct net_device *dev = to_net_dev(_dev);
struct macb *bp = netdev_priv(dev);
ssize_t ret = -EINVAL;
......@@ -962,11 +960,13 @@ static ssize_t macb_mii_show(const struct class_device *cd, char *buf,
}
#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(bmsr, MII_BMSR);
......@@ -977,13 +977,13 @@ MII_ENTRY(lpa, MII_LPA);
MII_ENTRY(expansion, MII_EXPANSION);
static struct attribute *macb_mii_attrs[] = {
&class_device_attr_bmcr.attr,
&class_device_attr_bmsr.attr,
&class_device_attr_physid1.attr,
&class_device_attr_physid2.attr,
&class_device_attr_advertise.attr,
&class_device_attr_lpa.attr,
&class_device_attr_expansion.attr,
&dev_attr_bmcr.attr,
&dev_attr_bmsr.attr,
&dev_attr_physid1.attr,
&dev_attr_physid2.attr,
&dev_attr_advertise.attr,
&dev_attr_lpa.attr,
&dev_attr_expansion.attr,
NULL,
};
......@@ -994,17 +994,17 @@ static struct attribute_group macb_mii_group = {
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)
{
struct class_device *class_dev = &net->class_dev;
struct device *_dev = &net->dev;
int ret;
ret = sysfs_create_group(&class_dev->kobj, &macb_mii_group);
ret = sysfs_create_group(&_dev->kobj, &macb_mii_group);
if (ret)
printk(KERN_WARNING
"%s: sysfs mii attribute registration failed: %d\n",
......
......@@ -1659,7 +1659,7 @@ smc911x_ethtool_getdrvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
{
strncpy(info->driver, CARDNAME, sizeof(info->driver));
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)
......
......@@ -1712,7 +1712,7 @@ smc_ethtool_getdrvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
{
strncpy(info->driver, CARDNAME, sizeof(info->driver));
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)
......
......@@ -84,7 +84,7 @@ struct net_device * hostap_add_interface(struct local_info *local,
if (strchr(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)
ret = register_netdevice(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->version, DRIVER_VERSION, sizeof(info->version) - 1);
strncpy(info->fw_version, priv->fw_name, sizeof(info->fw_version) - 1);
if (dev->class_dev.dev)
strncpy(info->bus_info, dev->class_dev.dev->bus_id,
if (dev->dev.parent)
strncpy(info->bus_info, dev->dev.parent->bus_id,
sizeof(info->bus_info) - 1);
else
snprintf(info->bus_info, sizeof(info->bus_info) - 1,
......
......@@ -332,7 +332,7 @@ orinoco_cs_config(struct pcmcia_device *link)
/* Finally, report what we've done */
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->io.BasePort1 + link->io.NumPorts1 - 1);
......
......@@ -806,7 +806,7 @@ spectrum_cs_config(struct pcmcia_device *link)
/* Finally, report what we've done */
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->io.BasePort1 + link->io.NumPorts1 - 1);
......
......@@ -529,10 +529,11 @@ struct net_device
struct net_bridge_port *br_port;
/* class/net/name entry */
struct class_device class_dev;
struct device dev;
/* space for optional statistics and wireless sysfs groups */
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_CONST (NETDEV_ALIGN - 1)
......@@ -548,7 +549,7 @@ static inline void *netdev_priv(struct net_device *dev)
/* Set the sysfs physical device reference for the network logical device
* 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 {
__be16 type; /* This is really htons(ether_type). */
......
......@@ -286,7 +286,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br,
kobject_init(&p->kobj);
kobject_set_name(&p->kobj, SYSFS_BRIDGE_PORT_ATTR);
p->kobj.ktype = &brport_ktype;
p->kobj.parent = &(dev->class_dev.kobj);
p->kobj.parent = &(dev->dev.kobj);
p->kobj.kset = NULL;
return p;
......
This diff is collapsed.
......@@ -211,7 +211,7 @@ int br_sysfs_addif(struct net_bridge_port *p)
struct brport_attribute **a;
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);
if (err)
goto out2;
......
......@@ -751,7 +751,7 @@ int dev_change_name(struct net_device *dev, char *newname)
else
strlcpy(dev->name, newname, IFNAMSIZ);
err = class_device_rename(&dev->class_dev, dev->name);
err = device_rename(&dev->dev, dev->name);
if (!err) {
hlist_del(&dev->name_hlist);
hlist_add_head(&dev->name_hlist, dev_name_hash(dev->name));
......@@ -3221,8 +3221,8 @@ void free_netdev(struct net_device *dev)
BUG_ON(dev->reg_state != NETREG_UNREGISTERED);
dev->reg_state = NETREG_RELEASED;
/* will free via class release */
class_device_put(&dev->class_dev);
/* will free via device release */
put_device(&dev->dev);
#else
kfree((char *)dev - dev->padded);
#endif
......
This diff is collapsed.
......@@ -268,7 +268,7 @@ struct sk_buff *alloc_skb_from_cache(struct kmem_cache *cp,
struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
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;
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