Skip to content

Commit

Permalink
Bluetooth: RFCOMM: 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 <[email protected]>
Signed-off-by: Marcel Holtmann <[email protected]>
  • Loading branch information
YueHaibing authored and holtmann committed Jun 26, 2021
1 parent e848dbd commit c615943
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions net/bluetooth/rfcomm/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,22 @@ static void rfcomm_reparent_device(struct rfcomm_dev *dev)
hci_dev_put(hdev);
}

static ssize_t show_address(struct device *tty_dev, struct device_attribute *attr, char *buf)
static ssize_t address_show(struct device *tty_dev,
struct device_attribute *attr, char *buf)
{
struct rfcomm_dev *dev = dev_get_drvdata(tty_dev);
return sprintf(buf, "%pMR\n", &dev->dst);
}

static ssize_t show_channel(struct device *tty_dev, struct device_attribute *attr, char *buf)
static ssize_t channel_show(struct device *tty_dev,
struct device_attribute *attr, char *buf)
{
struct rfcomm_dev *dev = dev_get_drvdata(tty_dev);
return sprintf(buf, "%d\n", dev->channel);
}

static DEVICE_ATTR(address, 0444, show_address, NULL);
static DEVICE_ATTR(channel, 0444, show_channel, NULL);
static DEVICE_ATTR_RO(address);
static DEVICE_ATTR_RO(channel);

static struct rfcomm_dev *__rfcomm_dev_add(struct rfcomm_dev_req *req,
struct rfcomm_dlc *dlc)
Expand Down

0 comments on commit c615943

Please sign in to comment.