Skip to content

Commit

Permalink
net: atm: use DEVICE_ATTR_RO macro
Browse files Browse the repository at this point in the history
Use DEVICE_ATTR_RO helper instead of plain DEVICE_ATTR,
which makes the code a bit shorter and easier to read.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
YueHaibing authored and David S. Miller committed May 20, 2021
1 parent 25173dd commit 48afdae
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions net/atm/atm_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@

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

static ssize_t show_type(struct device *cdev,
static ssize_t type_show(struct device *cdev,
struct device_attribute *attr, char *buf)
{
struct atm_dev *adev = to_atm_dev(cdev);

return scnprintf(buf, PAGE_SIZE, "%s\n", adev->type);
}

static ssize_t show_address(struct device *cdev,
static ssize_t address_show(struct device *cdev,
struct device_attribute *attr, char *buf)
{
struct atm_dev *adev = to_atm_dev(cdev);

return scnprintf(buf, PAGE_SIZE, "%pM\n", adev->esi);
}

static ssize_t show_atmaddress(struct device *cdev,
static ssize_t atmaddress_show(struct device *cdev,
struct device_attribute *attr, char *buf)
{
unsigned long flags;
Expand All @@ -50,15 +50,15 @@ static ssize_t show_atmaddress(struct device *cdev,
return count;
}

static ssize_t show_atmindex(struct device *cdev,
static ssize_t atmindex_show(struct device *cdev,
struct device_attribute *attr, char *buf)
{
struct atm_dev *adev = to_atm_dev(cdev);

return scnprintf(buf, PAGE_SIZE, "%d\n", adev->number);
}

static ssize_t show_carrier(struct device *cdev,
static ssize_t carrier_show(struct device *cdev,
struct device_attribute *attr, char *buf)
{
struct atm_dev *adev = to_atm_dev(cdev);
Expand All @@ -67,7 +67,7 @@ static ssize_t show_carrier(struct device *cdev,
adev->signal == ATM_PHY_SIG_LOST ? 0 : 1);
}

static ssize_t show_link_rate(struct device *cdev,
static ssize_t link_rate_show(struct device *cdev,
struct device_attribute *attr, char *buf)
{
struct atm_dev *adev = to_atm_dev(cdev);
Expand All @@ -90,12 +90,12 @@ static ssize_t show_link_rate(struct device *cdev,
return scnprintf(buf, PAGE_SIZE, "%d\n", link_rate);
}

static DEVICE_ATTR(address, 0444, show_address, NULL);
static DEVICE_ATTR(atmaddress, 0444, show_atmaddress, NULL);
static DEVICE_ATTR(atmindex, 0444, show_atmindex, NULL);
static DEVICE_ATTR(carrier, 0444, show_carrier, NULL);
static DEVICE_ATTR(type, 0444, show_type, NULL);
static DEVICE_ATTR(link_rate, 0444, show_link_rate, NULL);
static DEVICE_ATTR_RO(address);
static DEVICE_ATTR_RO(atmaddress);
static DEVICE_ATTR_RO(atmindex);
static DEVICE_ATTR_RO(carrier);
static DEVICE_ATTR_RO(type);
static DEVICE_ATTR_RO(link_rate);

static struct device_attribute *atm_attrs[] = {
&dev_attr_atmaddress,
Expand Down

0 comments on commit 48afdae

Please sign in to comment.