Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+15 −18
Original line number Diff line number Diff line
@@ -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;
+5 −6
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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 = {
+1 −1
Original line number Diff line number Diff line
@@ -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));
}

+174 −113

File changed.

Preview size limit exceeded, changes collapsed.

Loading