lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20070227122621.fde461ae.akpm@linux-foundation.org>
Date:	Tue, 27 Feb 2007 12:26:21 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Simon Arlott <6bb2a87f9b7b4e2eab1hkmdb0005e80d@...nder.lp0.eu>
Cc:	simon@...ott.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] cxacru: Export detailed device info through sysfs.
 (updated, card_info array one element too large)

> On Sat, 24 Feb 2007 02:00:31 +0000 Simon Arlott <simon@...ott.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.


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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ