Skip to content

Commit b4691ba

Browse files
oberparAlexander Gordeev
authored andcommitted
s390/cio: simplify measurement attribute registration
Use attribute groups to simplify registration, removal and extension of measurement related sysfs attributes. Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com> Acked-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
1 parent a817d98 commit b4691ba

File tree

1 file changed

+15
-34
lines changed

1 file changed

+15
-34
lines changed

drivers/s390/cio/chp.c

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,9 @@ static int s390_vary_chpid(struct chp_id chpid, int on)
127127
/*
128128
* Channel measurement related functions
129129
*/
130-
static ssize_t chp_measurement_chars_read(struct file *filp,
131-
struct kobject *kobj,
132-
struct bin_attribute *bin_attr,
133-
char *buf, loff_t off, size_t count)
130+
static ssize_t measurement_chars_read(struct file *filp, struct kobject *kobj,
131+
struct bin_attribute *bin_attr,
132+
char *buf, loff_t off, size_t count)
134133
{
135134
struct channel_path *chp;
136135
struct device *device;
@@ -143,15 +142,7 @@ static ssize_t chp_measurement_chars_read(struct file *filp,
143142
return memory_read_from_buffer(buf, count, &off, &chp->cmg_chars,
144143
sizeof(chp->cmg_chars));
145144
}
146-
147-
static const struct bin_attribute chp_measurement_chars_attr = {
148-
.attr = {
149-
.name = "measurement_chars",
150-
.mode = S_IRUSR,
151-
},
152-
.size = sizeof(struct cmg_chars),
153-
.read = chp_measurement_chars_read,
154-
};
145+
static BIN_ATTR_ADMIN_RO(measurement_chars, sizeof(struct cmg_chars));
155146

156147
static void chp_measurement_copy_block(struct cmg_entry *buf,
157148
struct channel_subsystem *css,
@@ -175,9 +166,9 @@ static void chp_measurement_copy_block(struct cmg_entry *buf,
175166
} while (reference_buf.values[0] != buf->values[0]);
176167
}
177168

178-
static ssize_t chp_measurement_read(struct file *filp, struct kobject *kobj,
179-
struct bin_attribute *bin_attr,
180-
char *buf, loff_t off, size_t count)
169+
static ssize_t measurement_read(struct file *filp, struct kobject *kobj,
170+
struct bin_attribute *bin_attr,
171+
char *buf, loff_t off, size_t count)
181172
{
182173
struct channel_path *chp;
183174
struct channel_subsystem *css;
@@ -197,33 +188,23 @@ static ssize_t chp_measurement_read(struct file *filp, struct kobject *kobj,
197188
count = size;
198189
return count;
199190
}
191+
static BIN_ATTR_ADMIN_RO(measurement, sizeof(struct cmg_entry));
200192

201-
static const struct bin_attribute chp_measurement_attr = {
202-
.attr = {
203-
.name = "measurement",
204-
.mode = S_IRUSR,
205-
},
206-
.size = sizeof(struct cmg_entry),
207-
.read = chp_measurement_read,
193+
static struct bin_attribute *measurement_attrs[] = {
194+
&bin_attr_measurement_chars,
195+
&bin_attr_measurement,
196+
NULL,
208197
};
198+
BIN_ATTRIBUTE_GROUPS(measurement);
209199

210200
void chp_remove_cmg_attr(struct channel_path *chp)
211201
{
212-
device_remove_bin_file(&chp->dev, &chp_measurement_chars_attr);
213-
device_remove_bin_file(&chp->dev, &chp_measurement_attr);
202+
device_remove_groups(&chp->dev, measurement_groups);
214203
}
215204

216205
int chp_add_cmg_attr(struct channel_path *chp)
217206
{
218-
int ret;
219-
220-
ret = device_create_bin_file(&chp->dev, &chp_measurement_chars_attr);
221-
if (ret)
222-
return ret;
223-
ret = device_create_bin_file(&chp->dev, &chp_measurement_attr);
224-
if (ret)
225-
device_remove_bin_file(&chp->dev, &chp_measurement_chars_attr);
226-
return ret;
207+
return device_add_groups(&chp->dev, measurement_groups);
227208
}
228209

229210
/*

0 commit comments

Comments
 (0)