diff options
author | Michael Ernst <mernst@de.ibm.com> | 2008-07-14 03:57:24 -0400 |
---|---|---|
committer | Heiko Carstens <heiko.carstens@de.ibm.com> | 2008-07-14 04:01:59 -0400 |
commit | b1c02d9110e72ec510ec9b038f9564e3c0d87384 (patch) | |
tree | 7c7e75d9230ffbbc29e7424736973f79cbdf50ba /drivers/s390/char | |
parent | 9689b336e193680fc0fcaa33829dc670637e9c98 (diff) |
[S390] cio: Use locks when accessing /sys/firmware/cpi data.
Mutex locks are used to avoid problems when /sys/firmware/cpi data
are accessed to in parallel.
Signed-off-by: Michael Ernst <mernst@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Diffstat (limited to 'drivers/s390/char')
-rw-r--r-- | drivers/s390/char/sclp_cpi_sys.c | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/drivers/s390/char/sclp_cpi_sys.c b/drivers/s390/char/sclp_cpi_sys.c index 9f37456222e9..005f330ed926 100644 --- a/drivers/s390/char/sclp_cpi_sys.c +++ b/drivers/s390/char/sclp_cpi_sys.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #define CPI_LENGTH_NAME 8 | 27 | #define CPI_LENGTH_NAME 8 |
28 | #define CPI_LENGTH_LEVEL 16 | 28 | #define CPI_LENGTH_LEVEL 16 |
29 | 29 | ||
30 | static DEFINE_MUTEX(sclp_cpi_mutex); | ||
31 | |||
30 | struct cpi_evbuf { | 32 | struct cpi_evbuf { |
31 | struct evbuf_header header; | 33 | struct evbuf_header header; |
32 | u8 id_format; | 34 | u8 id_format; |
@@ -223,7 +225,12 @@ static void set_string(char *attr, const char *value) | |||
223 | static ssize_t system_name_show(struct kobject *kobj, | 225 | static ssize_t system_name_show(struct kobject *kobj, |
224 | struct kobj_attribute *attr, char *page) | 226 | struct kobj_attribute *attr, char *page) |
225 | { | 227 | { |
226 | return snprintf(page, PAGE_SIZE, "%s\n", system_name); | 228 | int rc; |
229 | |||
230 | mutex_lock(&sclp_cpi_mutex); | ||
231 | rc = snprintf(page, PAGE_SIZE, "%s\n", system_name); | ||
232 | mutex_unlock(&sclp_cpi_mutex); | ||
233 | return rc; | ||
227 | } | 234 | } |
228 | 235 | ||
229 | static ssize_t system_name_store(struct kobject *kobj, | 236 | static ssize_t system_name_store(struct kobject *kobj, |
@@ -237,7 +244,9 @@ static ssize_t system_name_store(struct kobject *kobj, | |||
237 | if (rc) | 244 | if (rc) |
238 | return rc; | 245 | return rc; |
239 | 246 | ||
247 | mutex_lock(&sclp_cpi_mutex); | ||
240 | set_string(system_name, buf); | 248 | set_string(system_name, buf); |
249 | mutex_unlock(&sclp_cpi_mutex); | ||
241 | 250 | ||
242 | return len; | 251 | return len; |
243 | } | 252 | } |
@@ -248,7 +257,12 @@ static struct kobj_attribute system_name_attr = | |||
248 | static ssize_t sysplex_name_show(struct kobject *kobj, | 257 | static ssize_t sysplex_name_show(struct kobject *kobj, |
249 | struct kobj_attribute *attr, char *page) | 258 | struct kobj_attribute *attr, char *page) |
250 | { | 259 | { |
251 | return snprintf(page, PAGE_SIZE, "%s\n", sysplex_name); | 260 | int rc; |
261 | |||
262 | mutex_lock(&sclp_cpi_mutex); | ||
263 | rc = snprintf(page, PAGE_SIZE, "%s\n", sysplex_name); | ||
264 | mutex_unlock(&sclp_cpi_mutex); | ||
265 | return rc; | ||
252 | } | 266 | } |
253 | 267 | ||
254 | static ssize_t sysplex_name_store(struct kobject *kobj, | 268 | static ssize_t sysplex_name_store(struct kobject *kobj, |
@@ -262,7 +276,9 @@ static ssize_t sysplex_name_store(struct kobject *kobj, | |||
262 | if (rc) | 276 | if (rc) |
263 | return rc; | 277 | return rc; |
264 | 278 | ||
279 | mutex_lock(&sclp_cpi_mutex); | ||
265 | set_string(sysplex_name, buf); | 280 | set_string(sysplex_name, buf); |
281 | mutex_unlock(&sclp_cpi_mutex); | ||
266 | 282 | ||
267 | return len; | 283 | return len; |
268 | } | 284 | } |
@@ -273,7 +289,12 @@ static struct kobj_attribute sysplex_name_attr = | |||
273 | static ssize_t system_type_show(struct kobject *kobj, | 289 | static ssize_t system_type_show(struct kobject *kobj, |
274 | struct kobj_attribute *attr, char *page) | 290 | struct kobj_attribute *attr, char *page) |
275 | { | 291 | { |
276 | return snprintf(page, PAGE_SIZE, "%s\n", system_type); | 292 | int rc; |
293 | |||
294 | mutex_lock(&sclp_cpi_mutex); | ||
295 | rc = snprintf(page, PAGE_SIZE, "%s\n", system_type); | ||
296 | mutex_unlock(&sclp_cpi_mutex); | ||
297 | return rc; | ||
277 | } | 298 | } |
278 | 299 | ||
279 | static ssize_t system_type_store(struct kobject *kobj, | 300 | static ssize_t system_type_store(struct kobject *kobj, |
@@ -287,7 +308,9 @@ static ssize_t system_type_store(struct kobject *kobj, | |||
287 | if (rc) | 308 | if (rc) |
288 | return rc; | 309 | return rc; |
289 | 310 | ||
311 | mutex_lock(&sclp_cpi_mutex); | ||
290 | set_string(system_type, buf); | 312 | set_string(system_type, buf); |
313 | mutex_unlock(&sclp_cpi_mutex); | ||
291 | 314 | ||
292 | return len; | 315 | return len; |
293 | } | 316 | } |
@@ -298,8 +321,11 @@ static struct kobj_attribute system_type_attr = | |||
298 | static ssize_t system_level_show(struct kobject *kobj, | 321 | static ssize_t system_level_show(struct kobject *kobj, |
299 | struct kobj_attribute *attr, char *page) | 322 | struct kobj_attribute *attr, char *page) |
300 | { | 323 | { |
301 | unsigned long long level = system_level; | 324 | unsigned long long level; |
302 | 325 | ||
326 | mutex_lock(&sclp_cpi_mutex); | ||
327 | level = system_level; | ||
328 | mutex_unlock(&sclp_cpi_mutex); | ||
303 | return snprintf(page, PAGE_SIZE, "%#018llx\n", level); | 329 | return snprintf(page, PAGE_SIZE, "%#018llx\n", level); |
304 | } | 330 | } |
305 | 331 | ||
@@ -320,8 +346,9 @@ static ssize_t system_level_store(struct kobject *kobj, | |||
320 | if (*endp) | 346 | if (*endp) |
321 | return -EINVAL; | 347 | return -EINVAL; |
322 | 348 | ||
349 | mutex_lock(&sclp_cpi_mutex); | ||
323 | system_level = level; | 350 | system_level = level; |
324 | 351 | mutex_unlock(&sclp_cpi_mutex); | |
325 | return len; | 352 | return len; |
326 | } | 353 | } |
327 | 354 | ||
@@ -334,7 +361,9 @@ static ssize_t set_store(struct kobject *kobj, | |||
334 | { | 361 | { |
335 | int rc; | 362 | int rc; |
336 | 363 | ||
364 | mutex_lock(&sclp_cpi_mutex); | ||
337 | rc = cpi_req(); | 365 | rc = cpi_req(); |
366 | mutex_unlock(&sclp_cpi_mutex); | ||
338 | if (rc) | 367 | if (rc) |
339 | return rc; | 368 | return rc; |
340 | 369 | ||
@@ -373,12 +402,16 @@ int sclp_cpi_set_data(const char *system, const char *sysplex, const char *type, | |||
373 | if (rc) | 402 | if (rc) |
374 | return rc; | 403 | return rc; |
375 | 404 | ||
405 | mutex_lock(&sclp_cpi_mutex); | ||
376 | set_string(system_name, system); | 406 | set_string(system_name, system); |
377 | set_string(sysplex_name, sysplex); | 407 | set_string(sysplex_name, sysplex); |
378 | set_string(system_type, type); | 408 | set_string(system_type, type); |
379 | system_level = level; | 409 | system_level = level; |
380 | 410 | ||
381 | return cpi_req(); | 411 | rc = cpi_req(); |
412 | mutex_unlock(&sclp_cpi_mutex); | ||
413 | |||
414 | return rc; | ||
382 | } | 415 | } |
383 | EXPORT_SYMBOL(sclp_cpi_set_data); | 416 | EXPORT_SYMBOL(sclp_cpi_set_data); |
384 | 417 | ||