* [PATCH V3] ib_qib: Allow writes to the diag_counters to be able to clear them
@ 2010-07-14 1:53 Ira Weiny
[not found] ` <20100713185318.faf1c5b8.weiny2-i2BcT+NCU+M@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Ira Weiny @ 2010-07-14 1:53 UTC (permalink / raw)
To: Roland Dreier
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Bart Van Assche, Ralph Campbell
From: Ira Weiny <weiny2-i2BcT+NCU+M@public.gmane.org>
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
Signed-off-by: Ira Weiny <weiny2-i2BcT+NCU+M@public.gmane.org>
---
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 dab4d9f..b214eff 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 = {
#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 = {
--
1.5.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V3] ib_qib: Allow writes to the diag_counters to be able to clear them
[not found] ` <20100713185318.faf1c5b8.weiny2-i2BcT+NCU+M@public.gmane.org>
@ 2010-07-21 21:01 ` Ralph Campbell
[not found] ` <1279746081.31421.155.camel-/vjeY7uYZjrPXfVEPVhPGq6RkeBMCJyt@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Ralph Campbell @ 2010-07-21 21:01 UTC (permalink / raw)
To: Ira Weiny
Cc: Roland Dreier, linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Bart Van Assche
Acked-by: Ralph Campbell <ralph.campbell-h88ZbnxC6KDQT0dZR+AlfA@public.gmane.org>
On Tue, 2010-07-13 at 18:53 -0700, Ira Weiny wrote:
> From: Ira Weiny <weiny2-i2BcT+NCU+M@public.gmane.org>
> 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
>
> Signed-off-by: Ira Weiny <weiny2-i2BcT+NCU+M@public.gmane.org>
> ---
> 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 dab4d9f..b214eff 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 = {
>
> #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 = {
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH V3] ib_qib: Allow writes to the diag_counters to be able to clear them
[not found] ` <1279746081.31421.155.camel-/vjeY7uYZjrPXfVEPVhPGq6RkeBMCJyt@public.gmane.org>
@ 2010-08-04 17:16 ` Roland Dreier
0 siblings, 0 replies; 3+ messages in thread
From: Roland Dreier @ 2010-08-04 17:16 UTC (permalink / raw)
To: Ralph Campbell; +Cc: Ira Weiny, linux-rdma@vger.kernel.org, Bart Van Assche
thanks guys, applied
--
Roland Dreier <rolandd-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org> || 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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-04 17:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-14 1:53 [PATCH V3] ib_qib: Allow writes to the diag_counters to be able to clear them Ira Weiny
[not found] ` <20100713185318.faf1c5b8.weiny2-i2BcT+NCU+M@public.gmane.org>
2010-07-21 21:01 ` Ralph Campbell
[not found] ` <1279746081.31421.155.camel-/vjeY7uYZjrPXfVEPVhPGq6RkeBMCJyt@public.gmane.org>
2010-08-04 17:16 ` Roland Dreier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).