Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 78639
b: refs/heads/master
c: ef39592
h: refs/heads/master
i:
  78637: 17c0c20
  78635: fbfd037
  78631: 3ef38b3
  78623: 21a6a50
v: v3
  • Loading branch information
Kay Sievers authored and David S. Miller committed Jan 28, 2008
1 parent 667c0ee commit 930ad0a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 33 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6fe5452b3bb53e5bf5f37590b280ee73dc1e61b6
refs/heads/master: ef39592f786b6d56d9faf988a3f18786eeb050b3
4 changes: 2 additions & 2 deletions trunk/include/linux/atmdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ struct atm_dev {
struct proc_dir_entry *proc_entry; /* proc entry */
char *proc_name; /* proc entry name */
#endif
struct class_device class_dev; /* sysfs class device */
struct device class_dev; /* sysfs device */
struct list_head dev_list; /* linkage */
};

Expand Down Expand Up @@ -461,7 +461,7 @@ static inline void atm_dev_put(struct atm_dev *dev)
BUG_ON(!test_bit(ATM_DF_REMOVED, &dev->flags));
if (dev->ops->dev_close)
dev->ops->dev_close(dev);
class_device_put(&dev->class_dev);
put_device(&dev->class_dev);
}
}

Expand Down
66 changes: 36 additions & 30 deletions trunk/net/atm/atm_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

#define to_atm_dev(cldev) container_of(cldev, struct atm_dev, class_dev)

static ssize_t show_type(struct class_device *cdev, char *buf)
static ssize_t show_type(struct device *cdev,
struct device_attribute *attr, char *buf)
{
struct atm_dev *adev = to_atm_dev(cdev);
return sprintf(buf, "%s\n", adev->type);
}

static ssize_t show_address(struct class_device *cdev, char *buf)
static ssize_t show_address(struct device *cdev,
struct device_attribute *attr, char *buf)
{
char *pos = buf;
struct atm_dev *adev = to_atm_dev(cdev);
Expand All @@ -28,7 +30,8 @@ static ssize_t show_address(struct class_device *cdev, char *buf)
return pos - buf;
}

static ssize_t show_atmaddress(struct class_device *cdev, char *buf)
static ssize_t show_atmaddress(struct device *cdev,
struct device_attribute *attr, char *buf)
{
unsigned long flags;
char *pos = buf;
Expand All @@ -54,7 +57,8 @@ static ssize_t show_atmaddress(struct class_device *cdev, char *buf)
return pos - buf;
}

static ssize_t show_carrier(struct class_device *cdev, char *buf)
static ssize_t show_carrier(struct device *cdev,
struct device_attribute *attr, char *buf)
{
char *pos = buf;
struct atm_dev *adev = to_atm_dev(cdev);
Expand All @@ -65,7 +69,8 @@ static ssize_t show_carrier(struct class_device *cdev, char *buf)
return pos - buf;
}

static ssize_t show_link_rate(struct class_device *cdev, char *buf)
static ssize_t show_link_rate(struct device *cdev,
struct device_attribute *attr, char *buf)
{
char *pos = buf;
struct atm_dev *adev = to_atm_dev(cdev);
Expand All @@ -90,22 +95,23 @@ static ssize_t show_link_rate(struct class_device *cdev, char *buf)
return pos - buf;
}

static CLASS_DEVICE_ATTR(address, S_IRUGO, show_address, NULL);
static CLASS_DEVICE_ATTR(atmaddress, S_IRUGO, show_atmaddress, NULL);
static CLASS_DEVICE_ATTR(carrier, S_IRUGO, show_carrier, NULL);
static CLASS_DEVICE_ATTR(type, S_IRUGO, show_type, NULL);
static CLASS_DEVICE_ATTR(link_rate, S_IRUGO, show_link_rate, NULL);

static struct class_device_attribute *atm_attrs[] = {
&class_device_attr_atmaddress,
&class_device_attr_address,
&class_device_attr_carrier,
&class_device_attr_type,
&class_device_attr_link_rate,
static DEVICE_ATTR(address, S_IRUGO, show_address, NULL);
static DEVICE_ATTR(atmaddress, S_IRUGO, show_atmaddress, NULL);
static DEVICE_ATTR(carrier, S_IRUGO, show_carrier, NULL);
static DEVICE_ATTR(type, S_IRUGO, show_type, NULL);
static DEVICE_ATTR(link_rate, S_IRUGO, show_link_rate, NULL);

static struct device_attribute *atm_attrs[] = {
&dev_attr_atmaddress,
&dev_attr_address,
&dev_attr_carrier,
&dev_attr_type,
&dev_attr_link_rate,
NULL
};

static int atm_uevent(struct class_device *cdev, struct kobj_uevent_env *env)

static int atm_uevent(struct device *cdev, struct kobj_uevent_env *env)
{
struct atm_dev *adev;

Expand All @@ -122,7 +128,7 @@ static int atm_uevent(struct class_device *cdev, struct kobj_uevent_env *env)
return 0;
}

static void atm_release(struct class_device *cdev)
static void atm_release(struct device *cdev)
{
struct atm_dev *adev = to_atm_dev(cdev);

Expand All @@ -131,25 +137,25 @@ static void atm_release(struct class_device *cdev)

static struct class atm_class = {
.name = "atm",
.release = atm_release,
.uevent = atm_uevent,
.dev_release = atm_release,
.dev_uevent = atm_uevent,
};

int atm_register_sysfs(struct atm_dev *adev)
{
struct class_device *cdev = &adev->class_dev;
struct device *cdev = &adev->class_dev;
int i, j, err;

cdev->class = &atm_class;
class_set_devdata(cdev, adev);
dev_set_drvdata(cdev, adev);

snprintf(cdev->class_id, BUS_ID_SIZE, "%s%d", adev->type, adev->number);
err = class_device_register(cdev);
snprintf(cdev->bus_id, BUS_ID_SIZE, "%s%d", adev->type, adev->number);
err = device_register(cdev);
if (err < 0)
return err;

for (i = 0; atm_attrs[i]; i++) {
err = class_device_create_file(cdev, atm_attrs[i]);
err = device_create_file(cdev, atm_attrs[i]);
if (err)
goto err_out;
}
Expand All @@ -158,16 +164,16 @@ int atm_register_sysfs(struct atm_dev *adev)

err_out:
for (j = 0; j < i; j++)
class_device_remove_file(cdev, atm_attrs[j]);
class_device_del(cdev);
device_remove_file(cdev, atm_attrs[j]);
device_del(cdev);
return err;
}

void atm_unregister_sysfs(struct atm_dev *adev)
{
struct class_device *cdev = &adev->class_dev;
struct device *cdev = &adev->class_dev;

class_device_del(cdev);
device_del(cdev);
}

int __init atm_sysfs_init(void)
Expand Down

0 comments on commit 930ad0a

Please sign in to comment.