diff options
author | Ira Weiny <weiny2@llnl.gov> | 2010-07-13 21:53:18 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2010-08-03 16:59:19 -0400 |
commit | 4c6931f5d4f423238ae6e93423081c6ff9753d26 (patch) | |
tree | 7bad11aa4fd0ebe68bd7567e52862942e140fa75 | |
parent | 0502f94c62be79d1f4ae6f53ceaefde67ef3cea2 (diff) |
IB/qib: Allow writes to the diag_counters to be able to clear them
Signed-off-by: Ira Weiny <weiny2@llnl.gov>
Acked-by: Ralph Campbell <ralph.campbell@qlogic.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r-- | drivers/infiniband/hw/qib/qib_sysfs.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/qib/qib_sysfs.c b/drivers/infiniband/hw/qib/qib_sysfs.c index dab4d9f4a2cc..d50a33fe8bbc 100644 --- a/drivers/infiniband/hw/qib/qib_sysfs.c +++ b/drivers/infiniband/hw/qib/qib_sysfs.c | |||
@@ -347,7 +347,7 @@ static struct kobj_type qib_sl2vl_ktype = { | |||
347 | 347 | ||
348 | #define QIB_DIAGC_ATTR(N) \ | 348 | #define QIB_DIAGC_ATTR(N) \ |
349 | static struct qib_diagc_attr qib_diagc_attr_##N = { \ | 349 | static struct qib_diagc_attr qib_diagc_attr_##N = { \ |
350 | .attr = { .name = __stringify(N), .mode = 0444 }, \ | 350 | .attr = { .name = __stringify(N), .mode = 0664 }, \ |
351 | .counter = offsetof(struct qib_ibport, n_##N) \ | 351 | .counter = offsetof(struct qib_ibport, n_##N) \ |
352 | } | 352 | } |
353 | 353 | ||
@@ -403,8 +403,27 @@ static ssize_t diagc_attr_show(struct kobject *kobj, struct attribute *attr, | |||
403 | return sprintf(buf, "%u\n", *(u32 *)((char *)qibp + dattr->counter)); | 403 | return sprintf(buf, "%u\n", *(u32 *)((char *)qibp + dattr->counter)); |
404 | } | 404 | } |
405 | 405 | ||
406 | static ssize_t diagc_attr_store(struct kobject *kobj, struct attribute *attr, | ||
407 | const char *buf, size_t size) | ||
408 | { | ||
409 | struct qib_diagc_attr *dattr = | ||
410 | container_of(attr, struct qib_diagc_attr, attr); | ||
411 | struct qib_pportdata *ppd = | ||
412 | container_of(kobj, struct qib_pportdata, diagc_kobj); | ||
413 | struct qib_ibport *qibp = &ppd->ibport_data; | ||
414 | char *endp; | ||
415 | long val = simple_strtol(buf, &endp, 0); | ||
416 | |||
417 | if (val < 0 || endp == buf) | ||
418 | return -EINVAL; | ||
419 | |||
420 | *(u32 *)((char *) qibp + dattr->counter) = val; | ||
421 | return size; | ||
422 | } | ||
423 | |||
406 | static const struct sysfs_ops qib_diagc_ops = { | 424 | static const struct sysfs_ops qib_diagc_ops = { |
407 | .show = diagc_attr_show, | 425 | .show = diagc_attr_show, |
426 | .store = diagc_attr_store, | ||
408 | }; | 427 | }; |
409 | 428 | ||
410 | static struct kobj_type qib_diagc_ktype = { | 429 | static struct kobj_type qib_diagc_ktype = { |