Commit b4691baa authored by Peter Oberparleiter's avatar Peter Oberparleiter Committed by Alexander Gordeev

s390/cio: simplify measurement attribute registration

Use attribute groups to simplify registration, removal and extension of
measurement related sysfs attributes.
Reviewed-by: default avatarVineeth Vijayan <vneethv@linux.ibm.com>
Acked-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarPeter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
parent a817d98d
...@@ -127,10 +127,9 @@ static int s390_vary_chpid(struct chp_id chpid, int on) ...@@ -127,10 +127,9 @@ static int s390_vary_chpid(struct chp_id chpid, int on)
/* /*
* Channel measurement related functions * Channel measurement related functions
*/ */
static ssize_t chp_measurement_chars_read(struct file *filp, static ssize_t measurement_chars_read(struct file *filp, struct kobject *kobj,
struct kobject *kobj, struct bin_attribute *bin_attr,
struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
char *buf, loff_t off, size_t count)
{ {
struct channel_path *chp; struct channel_path *chp;
struct device *device; struct device *device;
...@@ -143,15 +142,7 @@ static ssize_t chp_measurement_chars_read(struct file *filp, ...@@ -143,15 +142,7 @@ static ssize_t chp_measurement_chars_read(struct file *filp,
return memory_read_from_buffer(buf, count, &off, &chp->cmg_chars, return memory_read_from_buffer(buf, count, &off, &chp->cmg_chars,
sizeof(chp->cmg_chars)); sizeof(chp->cmg_chars));
} }
static BIN_ATTR_ADMIN_RO(measurement_chars, sizeof(struct cmg_chars));
static const struct bin_attribute chp_measurement_chars_attr = {
.attr = {
.name = "measurement_chars",
.mode = S_IRUSR,
},
.size = sizeof(struct cmg_chars),
.read = chp_measurement_chars_read,
};
static void chp_measurement_copy_block(struct cmg_entry *buf, static void chp_measurement_copy_block(struct cmg_entry *buf,
struct channel_subsystem *css, struct channel_subsystem *css,
...@@ -175,9 +166,9 @@ static void chp_measurement_copy_block(struct cmg_entry *buf, ...@@ -175,9 +166,9 @@ static void chp_measurement_copy_block(struct cmg_entry *buf,
} while (reference_buf.values[0] != buf->values[0]); } while (reference_buf.values[0] != buf->values[0]);
} }
static ssize_t chp_measurement_read(struct file *filp, struct kobject *kobj, static ssize_t measurement_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr, struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count) char *buf, loff_t off, size_t count)
{ {
struct channel_path *chp; struct channel_path *chp;
struct channel_subsystem *css; struct channel_subsystem *css;
...@@ -197,33 +188,23 @@ static ssize_t chp_measurement_read(struct file *filp, struct kobject *kobj, ...@@ -197,33 +188,23 @@ static ssize_t chp_measurement_read(struct file *filp, struct kobject *kobj,
count = size; count = size;
return count; return count;
} }
static BIN_ATTR_ADMIN_RO(measurement, sizeof(struct cmg_entry));
static const struct bin_attribute chp_measurement_attr = { static struct bin_attribute *measurement_attrs[] = {
.attr = { &bin_attr_measurement_chars,
.name = "measurement", &bin_attr_measurement,
.mode = S_IRUSR, NULL,
},
.size = sizeof(struct cmg_entry),
.read = chp_measurement_read,
}; };
BIN_ATTRIBUTE_GROUPS(measurement);
void chp_remove_cmg_attr(struct channel_path *chp) void chp_remove_cmg_attr(struct channel_path *chp)
{ {
device_remove_bin_file(&chp->dev, &chp_measurement_chars_attr); device_remove_groups(&chp->dev, measurement_groups);
device_remove_bin_file(&chp->dev, &chp_measurement_attr);
} }
int chp_add_cmg_attr(struct channel_path *chp) int chp_add_cmg_attr(struct channel_path *chp)
{ {
int ret; return device_add_groups(&chp->dev, measurement_groups);
ret = device_create_bin_file(&chp->dev, &chp_measurement_chars_attr);
if (ret)
return ret;
ret = device_create_bin_file(&chp->dev, &chp_measurement_attr);
if (ret)
device_remove_bin_file(&chp->dev, &chp_measurement_chars_attr);
return ret;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment