ib_qib: Allow writes to the diag_counters to be able to clear them
PATCH v3 1/1 ib_qib: Allow writes to the diag_counters to be able to clear them
From: Ira Weiny <[email protected]>
Date: Wed, 7 Jul 2010 17:35:34 -0700
Subject: [PATCH] ib_qib: Allow writes to the diag_counters to be able to clear them
Changes in V3:
Add non-number error check
Return "proper" proper length
Changes in V2:
Add check for negative values
Return proper length
--- drivers/infiniband/hw/qib/qib_sysfs.c | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-)
drivers/infiniband/hw/qib/qib_sysfs.c +20 -1
@@ -347,7 +347,7 @@ static struct kobj_type qib_sl2vl_ktype = {#define QIB_DIAGC_ATTR (N ) \ static struct qib_diagc_attr qib_diagc_attr_##N = { \ - .attr = { .name = __stringify(N), .mode = 0444 }, \ + .attr = { .name = __stringify(N), .mode = 0664 }, \ .counter = offsetof(struct qib_ibport, n_##N) \ }
@@ -403,8 +403,27 @@ static ssize_t diagc_attr_show(struct kobject *kobj, struct attribute *attr,return sprintf (buf,"%u\n" , *(u32 *)((char *)qibp + dattr->counter)); } +static ssize_t diagc_attr_store (struct kobject *kobj,struct attribute *attr, +const char *buf,size_t size) +{ +struct qib_diagc_attr *dattr = + container_of(attr, struct qib_diagc_attr, attr); +struct qib_pportdata *ppd = + container_of(kobj, struct qib_pportdata, diagc_kobj); +struct qib_ibport *qibp = &ppd->ibport_data; +char *endp; +long val =simple_strtol (buf, &endp,0 ); + +if (val <0 || endp == buf) +return -EINVAL ; + + *(u32 *)((char *)qibp + dattr->counter) = (u32 )val; +return size; +} +static const struct sysfs_ops qib_diagc_ops = { .show = diagc_attr_show, + .store = diagc_attr_store, };static struct kobj_type qib_diagc_ktype = {
Signature · 6 lines
1.5.4.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Ralph Campbell
Acked-byQuoted 48 lines · Ira Weiny
From: Ira Weiny <[email protected]>
Date: Wed, 7 Jul 2010 17:35:34 -0700
Subject: [PATCH]ib_qib: Allow writes to thediag_countersto be able to clear themChanges in V3:
Add non-number error check
Return "proper" proper lengthChanges in V2:
Add check for negative values
Return proper lengthSigned-off-by Ira Weiny <[email protected]>--- drivers/infiniband/hw/qib/qib_sysfs.c | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-)drivers/infiniband/hw/qib/qib_sysfs.c +15
-1@@ -347,7 +347,7 @@ static struct kobj_type qib_sl2vl_ktype = {#define QIB_DIAGC_ATTR (N ) \ static struct qib_diagc_attr qib_diagc_attr_##N = { \ - .attr = { .name = __stringify(N), .mode = 0444 }, \ + .attr = { .name = __stringify(N), .mode = 0664 }, \ .counter = offsetof(struct qib_ibport, n_##N) \ }@@ -403,8 +403,27 @@ static ssize_t diagc_attr_show(struct kobject *kobj, struct attribute *attr,return sprintf (buf,"%u\n" , *(u32 *)((char *)qibp + dattr->counter)); } +static ssize_t diagc_attr_store (struct kobject *kobj,struct attribute *attr, +const char *buf,size_t size) +{ +struct qib_diagc_attr *dattr = + container_of(attr, struct qib_diagc_attr, attr); +struct qib_pportdata *ppd = + container_of(kobj, struct qib_pportdata, diagc_kobj); +struct qib_ibport *qibp = &ppd->ibport_data; +char *endp; +long val =simple_strtol (buf, &endp,0 ); + +if (val <0 || endp == buf) +return -EINVAL ; +
drivers/infiniband/hw/qib/qib_sysfs.c static ssize_t diagc_attr_show(struct kobject *kobj, struct attribute *attr, · line 429
Quoted 10 lines
drivers/infiniband/hw/qib/qib_sysfs.c +5
-0+ *(u32 *)((char *)qibp + dattr->counter) = (u32 )val; +return size; +} +static const struct sysfs_ops qib_diagc_ops = { .show = diagc_attr_show, + .store = diagc_attr_store, };static struct kobj_type qib_diagc_ktype = {
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1279746081.31421.155.camel-/[email protected]
thanks guys, applied
Signature · 6 lines
Roland Dreier <[email protected]> || For corporate legal information go to: http://www.cisco.com/web/about/doing_business/legal/cri/index.html -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html