From: Andrew Morton <akpm@linux-foundation.org>
To: Simon Arlott <6bb2a87f9b7b4e2eab1hkmdb0005e80d@thunder.lp0.eu>
Cc: simon@arlott.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cxacru: Export detailed device info through sysfs. (updated, card_info array one element too large)
Date: Tue, 27 Feb 2007 12:26:21 -0800 [thread overview]
Message-ID: <20070227122621.fde461ae.akpm@linux-foundation.org> (raw)
In-Reply-To: <45DF9C3F.1040309@simon.arlott.org.uk>
> On Sat, 24 Feb 2007 02:00:31 +0000 Simon Arlott <simon@arlott.org> wrote:
> When the device is polled for status there is a lot of useful status
> information available that is ignored. This patch stores the device
> info array when the status is polled and adds sysfs files to the usb
> device to allow userspace to query it. Since the device updates its
> status internally once a second the poll time is changed to this, and
> round_jiffies_relative is used to avoid waking the cpu unnecessarily.
>
> ..
>
> +static ssize_t cxacru_sysfs_showattr_bool(u32 value, char *buf)
> +{
> + switch (value) {
> + case 0: return snprintf(buf, PAGE_SIZE, "no\n");
> + case 1: return snprintf(buf, PAGE_SIZE, "yes\n");
> + default: return 0;
> + }
> +}
> +
> +static ssize_t cxacru_sysfs_showattr_LINK(u32 value, char *buf)
> +{
> + switch (value) {
> + case 1: return snprintf(buf, PAGE_SIZE, "not connected\n");
> + case 2: return snprintf(buf, PAGE_SIZE, "connected\n");
> + case 3: return snprintf(buf, PAGE_SIZE, "lost\n");
> + default: return snprintf(buf, PAGE_SIZE, "unknown (%u)\n", value);
> + }
> +}
> +
> +static ssize_t cxacru_sysfs_showattr_LINE(u32 value, char *buf)
> +{
> + switch (value) {
> + case 0: return snprintf(buf, PAGE_SIZE, "down\n");
> + case 1: return snprintf(buf, PAGE_SIZE, "attempting to activate\n");
> + case 2: return snprintf(buf, PAGE_SIZE, "training\n");
> + case 3: return snprintf(buf, PAGE_SIZE, "channel analysis\n");
> + case 4: return snprintf(buf, PAGE_SIZE, "exchange\n");
> + case 5: return snprintf(buf, PAGE_SIZE, "up\n");
> + case 6: return snprintf(buf, PAGE_SIZE, "waiting\n");
> + case 7: return snprintf(buf, PAGE_SIZE, "initialising\n");
> + default: return snprintf(buf, PAGE_SIZE, "unknown (%u)\n", value);
> + }
> +}
> +
> +static ssize_t cxacru_sysfs_showattr_MODU(u32 value, char *buf)
> +{
> + switch (value) {
> + case 0: return 0;
> + case 1: return snprintf(buf, PAGE_SIZE, "ANSI T1.413\n");
> + case 2: return snprintf(buf, PAGE_SIZE, "ITU-T G.992.1 (G.DMT)\n");
> + case 3: return snprintf(buf, PAGE_SIZE, "ITU-T G.992.2 (G.LITE)\n");
> + default: return snprintf(buf, PAGE_SIZE, "unknown (%u)\n", value);
> + }
> +}
It is conventional to do
switch (a) {
case 0:
stuff();
break;
case 1:
stuff();
}
But all the above could be array-driven anyway.
prev parent reply other threads:[~2007-02-27 20:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-23 22:29 [PATCH] cxacru: Export detailed device info through sysfs Simon Arlott
2007-02-23 22:41 ` Simon Arlott
2007-02-24 2:00 ` [PATCH] cxacru: Export detailed device info through sysfs. (updated, card_info array one element too large) Simon Arlott
2007-02-27 20:26 ` Andrew Morton [this message]
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=20070227122621.fde461ae.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=6bb2a87f9b7b4e2eab1hkmdb0005e80d@thunder.lp0.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=simon@arlott.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.