> On Sat, 24 Feb 2007 02:00:31 +0000 Simon Arlott <[EMAIL PROTECTED]> 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.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to