public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Ira Weiny <weiny2-i2BcT+NCU+M@public.gmane.org>
To: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>,
	"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Roland Dreier <rdreier-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>,
	Ralph Campbell
	<ralph.campbell-h88ZbnxC6KDQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH V2] ib_qib: Allow writes to the diag_counters to be able to clear them
Date: Thu, 8 Jul 2010 13:11:05 -0700	[thread overview]
Message-ID: <20100708131105.4103a6e3.weiny2@llnl.gov> (raw)
In-Reply-To: <20100708110446.97317098.weiny2-i2BcT+NCU+M@public.gmane.org>


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 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 |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_sysfs.c b/drivers/infiniband/hw/qib/qib_sysfs.c
index dab4d9f..e4ec50e 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,26 @@ 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;
+	long val = simple_strtol(buf, NULL, 0);
+
+	if (val < 0)
+		return -EINVAL;
+
+	*(u32 *)((char *)qibp + dattr->counter) = (u32)val;
+	return strnlen(buf, PAGE_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

  parent reply	other threads:[~2010-07-08 20:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-08  0:33 ib_qib: Allow writes to the diag_counters to be able to clear them Ira Weiny
     [not found] ` <20100707173313.675cd665.weiny2-i2BcT+NCU+M@public.gmane.org>
2010-07-08 17:37   ` Bart Van Assche
     [not found]     ` <AANLkTin_OHC8r__FDXPY6QhCaXDYgNFDY9SeE8ffdc35-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-07-08 18:04       ` Ira Weiny
     [not found]         ` <20100708110446.97317098.weiny2-i2BcT+NCU+M@public.gmane.org>
2010-07-08 20:11           ` Ira Weiny [this message]
     [not found]             ` <20100708131105.4103a6e3.weiny2-i2BcT+NCU+M@public.gmane.org>
2010-07-21 18:40               ` [PATCH V2] " Roland Dreier
2010-07-09 19:33           ` Bart Van Assche
     [not found]             ` <AANLkTik07Zp9uONyzBTAH4UnviviS-lopUJ42rZ5iQ_m-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-07-10  0:56               ` Ira Weiny
     [not found]                 ` <20100709175615.2e093989.weiny2-i2BcT+NCU+M@public.gmane.org>
2010-07-10 15:25                   ` Bart Van Assche
     [not found]                     ` <AANLkTik7MnJGL3Hlz1vqkmyruK7pRwyBWgKfTd0Lknpe-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-07-13 10:31                       ` Bart Van Assche
     [not found]                         ` <AANLkTil_p-lJmUGMzzPPj6Dx52jh_xbhN2Zt5uLZM53E-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-07-14  1:50                           ` Ira Weiny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100708131105.4103a6e3.weiny2@llnl.gov \
    --to=weiny2-i2bct+ncu+m@public.gmane.org \
    --cc=bvanassche-HInyCGIudOg@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ralph.campbell-h88ZbnxC6KDQT0dZR+AlfA@public.gmane.org \
    --cc=rdreier-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox