mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-04 16:15:11 +00:00
libertas: use DEVICE_ATTR_RW macro
Use DEVICE_ATTR_RW 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: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20210523040339.2724-1-yuehaibing@huawei.com
This commit is contained in:
parent
3f60f46856
commit
8667ab49a6
1 changed files with 78 additions and 71 deletions
|
@ -151,13 +151,13 @@ static uint16_t lbs_mesh_get_channel(struct lbs_private *priv)
|
|||
*/
|
||||
|
||||
/**
|
||||
* lbs_anycast_get - Get function for sysfs attribute anycast_mask
|
||||
* anycast_mask_show - Get function for sysfs attribute anycast_mask
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer where data will be returned
|
||||
*/
|
||||
static ssize_t lbs_anycast_get(struct device *dev,
|
||||
struct device_attribute *attr, char * buf)
|
||||
static ssize_t anycast_mask_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
||||
struct cmd_ds_mesh_access mesh_access;
|
||||
|
@ -173,14 +173,15 @@ static ssize_t lbs_anycast_get(struct device *dev,
|
|||
}
|
||||
|
||||
/**
|
||||
* lbs_anycast_set - Set function for sysfs attribute anycast_mask
|
||||
* anycast_mask_store - Set function for sysfs attribute anycast_mask
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer that contains new attribute value
|
||||
* @count: size of buffer
|
||||
*/
|
||||
static ssize_t lbs_anycast_set(struct device *dev,
|
||||
struct device_attribute *attr, const char * buf, size_t count)
|
||||
static ssize_t anycast_mask_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
||||
struct cmd_ds_mesh_access mesh_access;
|
||||
|
@ -199,13 +200,13 @@ static ssize_t lbs_anycast_set(struct device *dev,
|
|||
}
|
||||
|
||||
/**
|
||||
* lbs_prb_rsp_limit_get - Get function for sysfs attribute prb_rsp_limit
|
||||
* prb_rsp_limit_show - Get function for sysfs attribute prb_rsp_limit
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer where data will be returned
|
||||
*/
|
||||
static ssize_t lbs_prb_rsp_limit_get(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
static ssize_t prb_rsp_limit_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
||||
struct cmd_ds_mesh_access mesh_access;
|
||||
|
@ -225,14 +226,15 @@ static ssize_t lbs_prb_rsp_limit_get(struct device *dev,
|
|||
}
|
||||
|
||||
/**
|
||||
* lbs_prb_rsp_limit_set - Set function for sysfs attribute prb_rsp_limit
|
||||
* prb_rsp_limit_store - Set function for sysfs attribute prb_rsp_limit
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer that contains new attribute value
|
||||
* @count: size of buffer
|
||||
*/
|
||||
static ssize_t lbs_prb_rsp_limit_set(struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
static ssize_t prb_rsp_limit_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
||||
struct cmd_ds_mesh_access mesh_access;
|
||||
|
@ -259,27 +261,28 @@ static ssize_t lbs_prb_rsp_limit_set(struct device *dev,
|
|||
}
|
||||
|
||||
/**
|
||||
* lbs_mesh_get - Get function for sysfs attribute mesh
|
||||
* lbs_mesh_show - Get function for sysfs attribute mesh
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer where data will be returned
|
||||
*/
|
||||
static ssize_t lbs_mesh_get(struct device *dev,
|
||||
struct device_attribute *attr, char * buf)
|
||||
static ssize_t lbs_mesh_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
||||
return snprintf(buf, 5, "0x%X\n", !!priv->mesh_dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* lbs_mesh_set - Set function for sysfs attribute mesh
|
||||
* lbs_mesh_store - Set function for sysfs attribute mesh
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer that contains new attribute value
|
||||
* @count: size of buffer
|
||||
*/
|
||||
static ssize_t lbs_mesh_set(struct device *dev,
|
||||
struct device_attribute *attr, const char * buf, size_t count)
|
||||
static ssize_t lbs_mesh_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
||||
int enable;
|
||||
|
@ -301,20 +304,19 @@ static ssize_t lbs_mesh_set(struct device *dev,
|
|||
* lbs_mesh attribute to be exported per ethX interface
|
||||
* through sysfs (/sys/class/net/ethX/lbs_mesh)
|
||||
*/
|
||||
static DEVICE_ATTR(lbs_mesh, 0644, lbs_mesh_get, lbs_mesh_set);
|
||||
static DEVICE_ATTR_RW(lbs_mesh);
|
||||
|
||||
/*
|
||||
* anycast_mask attribute to be exported per mshX interface
|
||||
* through sysfs (/sys/class/net/mshX/anycast_mask)
|
||||
*/
|
||||
static DEVICE_ATTR(anycast_mask, 0644, lbs_anycast_get, lbs_anycast_set);
|
||||
static DEVICE_ATTR_RW(anycast_mask);
|
||||
|
||||
/*
|
||||
* prb_rsp_limit attribute to be exported per mshX interface
|
||||
* through sysfs (/sys/class/net/mshX/prb_rsp_limit)
|
||||
*/
|
||||
static DEVICE_ATTR(prb_rsp_limit, 0644, lbs_prb_rsp_limit_get,
|
||||
lbs_prb_rsp_limit_set);
|
||||
static DEVICE_ATTR_RW(prb_rsp_limit);
|
||||
|
||||
static struct attribute *lbs_mesh_sysfs_entries[] = {
|
||||
&dev_attr_anycast_mask.attr,
|
||||
|
@ -351,13 +353,13 @@ static int mesh_get_default_parameters(struct device *dev,
|
|||
}
|
||||
|
||||
/**
|
||||
* bootflag_get - Get function for sysfs attribute bootflag
|
||||
* bootflag_show - Get function for sysfs attribute bootflag
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer where data will be returned
|
||||
*/
|
||||
static ssize_t bootflag_get(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
static ssize_t bootflag_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mrvl_mesh_defaults defs;
|
||||
int ret;
|
||||
|
@ -371,14 +373,14 @@ static ssize_t bootflag_get(struct device *dev,
|
|||
}
|
||||
|
||||
/**
|
||||
* bootflag_set - Set function for sysfs attribute bootflag
|
||||
* bootflag_store - Set function for sysfs attribute bootflag
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer that contains new attribute value
|
||||
* @count: size of buffer
|
||||
*/
|
||||
static ssize_t bootflag_set(struct device *dev, struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
static ssize_t bootflag_store(struct device *dev, struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
||||
struct cmd_ds_mesh_config cmd;
|
||||
|
@ -401,13 +403,13 @@ static ssize_t bootflag_set(struct device *dev, struct device_attribute *attr,
|
|||
}
|
||||
|
||||
/**
|
||||
* boottime_get - Get function for sysfs attribute boottime
|
||||
* boottime_show - Get function for sysfs attribute boottime
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer where data will be returned
|
||||
*/
|
||||
static ssize_t boottime_get(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
static ssize_t boottime_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mrvl_mesh_defaults defs;
|
||||
int ret;
|
||||
|
@ -421,14 +423,15 @@ static ssize_t boottime_get(struct device *dev,
|
|||
}
|
||||
|
||||
/**
|
||||
* boottime_set - Set function for sysfs attribute boottime
|
||||
* boottime_store - Set function for sysfs attribute boottime
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer that contains new attribute value
|
||||
* @count: size of buffer
|
||||
*/
|
||||
static ssize_t boottime_set(struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
static ssize_t boottime_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
||||
struct cmd_ds_mesh_config cmd;
|
||||
|
@ -460,13 +463,13 @@ static ssize_t boottime_set(struct device *dev,
|
|||
}
|
||||
|
||||
/**
|
||||
* channel_get - Get function for sysfs attribute channel
|
||||
* channel_show - Get function for sysfs attribute channel
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer where data will be returned
|
||||
*/
|
||||
static ssize_t channel_get(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
static ssize_t channel_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mrvl_mesh_defaults defs;
|
||||
int ret;
|
||||
|
@ -480,14 +483,14 @@ static ssize_t channel_get(struct device *dev,
|
|||
}
|
||||
|
||||
/**
|
||||
* channel_set - Set function for sysfs attribute channel
|
||||
* channel_store - Set function for sysfs attribute channel
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer that contains new attribute value
|
||||
* @count: size of buffer
|
||||
*/
|
||||
static ssize_t channel_set(struct device *dev, struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
static ssize_t channel_store(struct device *dev, struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct lbs_private *priv = to_net_dev(dev)->ml_priv;
|
||||
struct cmd_ds_mesh_config cmd;
|
||||
|
@ -510,13 +513,13 @@ static ssize_t channel_set(struct device *dev, struct device_attribute *attr,
|
|||
}
|
||||
|
||||
/**
|
||||
* mesh_id_get - Get function for sysfs attribute mesh_id
|
||||
* mesh_id_show - Get function for sysfs attribute mesh_id
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer where data will be returned
|
||||
*/
|
||||
static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
static ssize_t mesh_id_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct mrvl_mesh_defaults defs;
|
||||
int ret;
|
||||
|
@ -539,14 +542,14 @@ static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr,
|
|||
}
|
||||
|
||||
/**
|
||||
* mesh_id_set - Set function for sysfs attribute mesh_id
|
||||
* mesh_id_store - Set function for sysfs attribute mesh_id
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer that contains new attribute value
|
||||
* @count: size of buffer
|
||||
*/
|
||||
static ssize_t mesh_id_set(struct device *dev, struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
static ssize_t mesh_id_store(struct device *dev, struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct cmd_ds_mesh_config cmd;
|
||||
struct mrvl_mesh_defaults defs;
|
||||
|
@ -585,13 +588,14 @@ static ssize_t mesh_id_set(struct device *dev, struct device_attribute *attr,
|
|||
}
|
||||
|
||||
/**
|
||||
* protocol_id_get - Get function for sysfs attribute protocol_id
|
||||
* protocol_id_show - Get function for sysfs attribute protocol_id
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer where data will be returned
|
||||
*/
|
||||
static ssize_t protocol_id_get(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
static ssize_t protocol_id_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct mrvl_mesh_defaults defs;
|
||||
int ret;
|
||||
|
@ -605,14 +609,15 @@ static ssize_t protocol_id_get(struct device *dev,
|
|||
}
|
||||
|
||||
/**
|
||||
* protocol_id_set - Set function for sysfs attribute protocol_id
|
||||
* protocol_id_store - Set function for sysfs attribute protocol_id
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer that contains new attribute value
|
||||
* @count: size of buffer
|
||||
*/
|
||||
static ssize_t protocol_id_set(struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
static ssize_t protocol_id_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct cmd_ds_mesh_config cmd;
|
||||
struct mrvl_mesh_defaults defs;
|
||||
|
@ -646,13 +651,13 @@ static ssize_t protocol_id_set(struct device *dev,
|
|||
}
|
||||
|
||||
/**
|
||||
* metric_id_get - Get function for sysfs attribute metric_id
|
||||
* metric_id_show - Get function for sysfs attribute metric_id
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer where data will be returned
|
||||
*/
|
||||
static ssize_t metric_id_get(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
static ssize_t metric_id_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mrvl_mesh_defaults defs;
|
||||
int ret;
|
||||
|
@ -666,14 +671,15 @@ static ssize_t metric_id_get(struct device *dev,
|
|||
}
|
||||
|
||||
/**
|
||||
* metric_id_set - Set function for sysfs attribute metric_id
|
||||
* metric_id_store - Set function for sysfs attribute metric_id
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer that contains new attribute value
|
||||
* @count: size of buffer
|
||||
*/
|
||||
static ssize_t metric_id_set(struct device *dev, struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
static ssize_t metric_id_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct cmd_ds_mesh_config cmd;
|
||||
struct mrvl_mesh_defaults defs;
|
||||
|
@ -707,13 +713,13 @@ static ssize_t metric_id_set(struct device *dev, struct device_attribute *attr,
|
|||
}
|
||||
|
||||
/**
|
||||
* capability_get - Get function for sysfs attribute capability
|
||||
* capability_show - Get function for sysfs attribute capability
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer where data will be returned
|
||||
*/
|
||||
static ssize_t capability_get(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
static ssize_t capability_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mrvl_mesh_defaults defs;
|
||||
int ret;
|
||||
|
@ -727,14 +733,15 @@ static ssize_t capability_get(struct device *dev,
|
|||
}
|
||||
|
||||
/**
|
||||
* capability_set - Set function for sysfs attribute capability
|
||||
* capability_store - Set function for sysfs attribute capability
|
||||
* @dev: the &struct device
|
||||
* @attr: device attributes
|
||||
* @buf: buffer that contains new attribute value
|
||||
* @count: size of buffer
|
||||
*/
|
||||
static ssize_t capability_set(struct device *dev, struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
static ssize_t capability_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct cmd_ds_mesh_config cmd;
|
||||
struct mrvl_mesh_defaults defs;
|
||||
|
@ -768,13 +775,13 @@ static ssize_t capability_set(struct device *dev, struct device_attribute *attr,
|
|||
}
|
||||
|
||||
|
||||
static DEVICE_ATTR(bootflag, 0644, bootflag_get, bootflag_set);
|
||||
static DEVICE_ATTR(boottime, 0644, boottime_get, boottime_set);
|
||||
static DEVICE_ATTR(channel, 0644, channel_get, channel_set);
|
||||
static DEVICE_ATTR(mesh_id, 0644, mesh_id_get, mesh_id_set);
|
||||
static DEVICE_ATTR(protocol_id, 0644, protocol_id_get, protocol_id_set);
|
||||
static DEVICE_ATTR(metric_id, 0644, metric_id_get, metric_id_set);
|
||||
static DEVICE_ATTR(capability, 0644, capability_get, capability_set);
|
||||
static DEVICE_ATTR_RW(bootflag);
|
||||
static DEVICE_ATTR_RW(boottime);
|
||||
static DEVICE_ATTR_RW(channel);
|
||||
static DEVICE_ATTR_RW(mesh_id);
|
||||
static DEVICE_ATTR_RW(protocol_id);
|
||||
static DEVICE_ATTR_RW(metric_id);
|
||||
static DEVICE_ATTR_RW(capability);
|
||||
|
||||
static struct attribute *boot_opts_attrs[] = {
|
||||
&dev_attr_bootflag.attr,
|
||||
|
|
Loading…
Reference in a new issue