Skip to content

Commit

Permalink
Network: convert network devices to use struct device instead of clas…
Browse files Browse the repository at this point in the history
…s_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: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Greg Kroah-Hartman committed Feb 7, 2007
1 parent 2943ecf commit 43cb76d
Show file tree
Hide file tree
Showing 20 changed files with 451 additions and 362 deletions.
33 changes: 15 additions & 18 deletions drivers/infiniband/ulp/ipoib/ipoib_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
11 changes: 5 additions & 6 deletions drivers/infiniband/ulp/ipoib/ipoib_vlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/arm/at91_ether.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/arm/etherh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
Loading

0 comments on commit 43cb76d

Please sign in to comment.