blob: 5eb02aeabc25edb64e6d8149fb008a83b6c4df4d [file] [log] [blame]
---
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c | 74 +++++++++++-----------
1 file changed, 40 insertions(+), 34 deletions(-)
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
@@ -31,9 +31,9 @@ int qlcnicvf_config_led(struct qlcnic_ad
return -EOPNOTSUPP;
}
-static ssize_t qlcnic_store_bridged_mode(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
+static ssize_t bridged_mode_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
{
struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
unsigned long new;
@@ -55,9 +55,8 @@ err_out:
return ret;
}
-static ssize_t qlcnic_show_bridged_mode(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t bridged_mode_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
{
struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
int bridged_mode = 0;
@@ -67,10 +66,11 @@ static ssize_t qlcnic_show_bridged_mode(
return sprintf(buf, "%d\n", bridged_mode);
}
+static DEVICE_ATTR_RW(bridged_mode);
-static ssize_t qlcnic_store_diag_mode(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
+static ssize_t diag_mode_store(struct device *dev,
+ struct device_attribute *attr, const char *buf,
+ size_t len)
{
struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
unsigned long new;
@@ -84,12 +84,13 @@ static ssize_t qlcnic_store_diag_mode(st
return len;
}
-static ssize_t qlcnic_show_diag_mode(struct device *dev,
- struct device_attribute *attr, char *buf)
+static ssize_t diag_mode_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
{
struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
return sprintf(buf, "%d\n", !!(adapter->flags & QLCNIC_DIAG_ENABLED));
}
+static DEVICE_ATTR_RW(diag_mode);
static int qlcnic_validate_beacon(struct qlcnic_adapter *adapter, u16 beacon,
u8 *state, u8 *rate)
@@ -210,9 +211,8 @@ out:
return err;
}
-static ssize_t qlcnic_store_beacon(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
+static ssize_t beacon_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t len)
{
struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
int err = 0;
@@ -233,8 +233,8 @@ static ssize_t qlcnic_store_beacon(struc
return err;
}
-static ssize_t qlcnic_show_beacon(struct device *dev,
- struct device_attribute *attr, char *buf)
+static ssize_t beacon_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
{
struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
@@ -262,6 +262,7 @@ static int qlcnic_sysfs_validate_crb(str
return 0;
}
+static DEVICE_ATTR_RW(beacon);
static ssize_t qlcnic_sysfs_read_crb(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr, char *buf,
@@ -1174,24 +1175,6 @@ static ssize_t qlcnic_83xx_sysfs_flash_w
return size;
}
-static const struct device_attribute dev_attr_bridged_mode = {
- .attr = { .name = "bridged_mode", .mode = 0644 },
- .show = qlcnic_show_bridged_mode,
- .store = qlcnic_store_bridged_mode,
-};
-
-static const struct device_attribute dev_attr_diag_mode = {
- .attr = { .name = "diag_mode", .mode = 0644 },
- .show = qlcnic_show_diag_mode,
- .store = qlcnic_store_diag_mode,
-};
-
-static const struct device_attribute dev_attr_beacon = {
- .attr = { .name = "beacon", .mode = 0644 },
- .show = qlcnic_show_beacon,
- .store = qlcnic_store_beacon,
-};
-
static const struct bin_attribute bin_attr_crb = {
.attr = { .name = "crb", .mode = 0644 },
.size = 0,
@@ -1317,6 +1300,24 @@ void qlcnic_unregister_hwmon_dev(struct
}
#endif
+static struct attribute *qlcnic_attrs[] = {
+ &dev_attr_diag_mode.attr,
+ NULL,
+};
+
+static struct bin_attribute *qlcnic_bin_attrs[] = {
+ &bin_attr_esw_config,
+ &bin_attr_pm_config,
+ &bin_attr_flash,
+ NULL,
+};
+
+static const struct attribute_group qlcnic_attr = {
+ .attrs = qlcnic_attrs,
+ .bin_attrs = qlcnic_bin_attrs,
+};
+
+
void qlcnic_create_sysfs_entries(struct qlcnic_adapter *adapter)
{
struct device *dev = &adapter->pdev->dev;
@@ -1330,6 +1331,11 @@ void qlcnic_create_sysfs_entries(struct
void qlcnic_remove_sysfs_entries(struct qlcnic_adapter *adapter)
{
struct device *dev = &adapter->pdev->dev;
+ int err;
+
+ err = sysfs_create_group(&dev->kobj, &qlcnic_attr);
+ if (err)
+ dev_err(dev, "error creating sysfs files\n");
if (adapter->ahw->capabilities & QLCNIC_FW_CAPABILITY_BDG)
device_remove_file(dev, &dev_attr_bridged_mode);