From: Linus Torvalds Date: Fri, 14 Oct 2016 22:17:12 +0000 (-0700) Subject: Merge tag 'linux-kselftest-4.9-rc1-update' of git://git.kernel.org/pub/scm/linux... X-Git-Tag: v4.9-rc1~9 X-Git-Url: http://git.cascardo.info/?p=cascardo%2Flinux.git;a=commitdiff_plain;h=5d89d9f502f9c33ed0270d716f238429861e1942;hp=50cff89837a43a7c62ac080de9742a298d6418b3 Merge tag 'linux-kselftest-4.9-rc1-update' of git://git./linux/kernel/git/shuah/linux-kselftest Pull kselftest updates from Shuah Khan: "This update consists of: - Fixes and improvements to existing tests - Moving code from Documentation to selftests, samples, and tools: * Moves dnotify_test, prctl, ptp, vDSO, ia64, watchdog, and networking tests from Documentation to selftests. * Moves mic/mpssd, misc-devices/mei, timers, watchdog, auxdisplay, and blackfin examples from Documentation to samples. * Moves accounting, laptops/dslm, and pcmcia/crc32hash tools from Documentation to tools. * Deletes BUILD_DOCSRC and its dependencies" * tag 'linux-kselftest-4.9-rc1-update' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (21 commits) selftests/futex: Check ANSI terminal color support Doc: update 00-INDEX files to reflect the runnable code move samples: move blackfin gptimers-example from Documentation tools: move pcmcia crc32hash tool from Documentation tools: move laptops dslm tool from Documentation tools: move accounting tool from Documentation samples: move auxdisplay example code from Documentation samples: move watchdog example code from Documentation samples: move timers example code from Documentation samples: move misc-devices/mei example code from Documentation samples: move mic/mpssd example code from Documentation selftests: Move networking/timestamping from Documentation selftests: move watchdog tests from Documentation/watchdog selftests: move ia64 tests from Documentation/ia64 selftests: move vDSO tests from Documentation/vDSO selftests: move ptp tests from Documentation/ptp selftests: move prctl tests from Documentation/prctl selftests: move dnotify_test from Documentation/filesystems selftests/timers: Add missing error code assignment before test selftests/zram: replace ZRAM_LZ4_COMPRESS ... --- diff --git a/Documentation/00-INDEX b/Documentation/00-INDEX index cb9a6c6fa83b..3acc4f1a6f84 100644 --- a/Documentation/00-INDEX +++ b/Documentation/00-INDEX @@ -46,7 +46,8 @@ IRQ.txt Intel-IOMMU.txt - basic info on the Intel IOMMU virtualization support. Makefile - - some files in Documentation dir are actually sample code to build + - This file does nothing. Removing it breaks make htmldocs and + make distclean. ManagementStyle - how to (attempt to) manage kernel hackers. RCU/ diff --git a/Documentation/Makefile b/Documentation/Makefile index de955e151af8..c2a469112c37 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -1,3 +1 @@ -subdir-y := accounting auxdisplay blackfin \ - filesystems filesystems ia64 laptops mic misc-devices \ - networking pcmcia prctl ptp timers vDSO watchdog +subdir-y := diff --git a/Documentation/accounting/.gitignore b/Documentation/accounting/.gitignore deleted file mode 100644 index 86485203c4ae..000000000000 --- a/Documentation/accounting/.gitignore +++ /dev/null @@ -1 +0,0 @@ -getdelays diff --git a/Documentation/accounting/Makefile b/Documentation/accounting/Makefile deleted file mode 100644 index 7e232cb6fd7d..000000000000 --- a/Documentation/accounting/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# List of programs to build -hostprogs-y := getdelays - -# Tell kbuild to always build the programs -always := $(hostprogs-y) - -HOSTCFLAGS_getdelays.o += -I$(objtree)/usr/include diff --git a/Documentation/accounting/delay-accounting.txt b/Documentation/accounting/delay-accounting.txt index 8a12f0730c94..042ea59b5853 100644 --- a/Documentation/accounting/delay-accounting.txt +++ b/Documentation/accounting/delay-accounting.txt @@ -54,9 +54,9 @@ are sent to userspace without requiring a command. If it is the last exiting task of a thread group, the per-tgid statistics are also sent. More details are given in the taskstats interface description. -The getdelays.c userspace utility in this directory allows simple commands to -be run and the corresponding delay statistics to be displayed. It also serves -as an example of using the taskstats interface. +The getdelays.c userspace utility in tools/accounting directory allows simple +commands to be run and the corresponding delay statistics to be displayed. It +also serves as an example of using the taskstats interface. Usage ----- diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c deleted file mode 100644 index b5ca536e56a8..000000000000 --- a/Documentation/accounting/getdelays.c +++ /dev/null @@ -1,550 +0,0 @@ -/* getdelays.c - * - * Utility to get per-pid and per-tgid delay accounting statistics - * Also illustrates usage of the taskstats interface - * - * Copyright (C) Shailabh Nagar, IBM Corp. 2005 - * Copyright (C) Balbir Singh, IBM Corp. 2006 - * Copyright (c) Jay Lan, SGI. 2006 - * - * Compile with - * gcc -I/usr/src/linux/include getdelays.c -o getdelays - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -/* - * Generic macros for dealing with netlink sockets. Might be duplicated - * elsewhere. It is recommended that commercial grade applications use - * libnl or libnetlink and use the interfaces provided by the library - */ -#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN)) -#define GENLMSG_PAYLOAD(glh) (NLMSG_PAYLOAD(glh, 0) - GENL_HDRLEN) -#define NLA_DATA(na) ((void *)((char*)(na) + NLA_HDRLEN)) -#define NLA_PAYLOAD(len) (len - NLA_HDRLEN) - -#define err(code, fmt, arg...) \ - do { \ - fprintf(stderr, fmt, ##arg); \ - exit(code); \ - } while (0) - -int done; -int rcvbufsz; -char name[100]; -int dbg; -int print_delays; -int print_io_accounting; -int print_task_context_switch_counts; - -#define PRINTF(fmt, arg...) { \ - if (dbg) { \ - printf(fmt, ##arg); \ - } \ - } - -/* Maximum size of response requested or message sent */ -#define MAX_MSG_SIZE 1024 -/* Maximum number of cpus expected to be specified in a cpumask */ -#define MAX_CPUS 32 - -struct msgtemplate { - struct nlmsghdr n; - struct genlmsghdr g; - char buf[MAX_MSG_SIZE]; -}; - -char cpumask[100+6*MAX_CPUS]; - -static void usage(void) -{ - fprintf(stderr, "getdelays [-dilv] [-w logfile] [-r bufsize] " - "[-m cpumask] [-t tgid] [-p pid]\n"); - fprintf(stderr, " -d: print delayacct stats\n"); - fprintf(stderr, " -i: print IO accounting (works only with -p)\n"); - fprintf(stderr, " -l: listen forever\n"); - fprintf(stderr, " -v: debug on\n"); - fprintf(stderr, " -C: container path\n"); -} - -/* - * Create a raw netlink socket and bind - */ -static int create_nl_socket(int protocol) -{ - int fd; - struct sockaddr_nl local; - - fd = socket(AF_NETLINK, SOCK_RAW, protocol); - if (fd < 0) - return -1; - - if (rcvbufsz) - if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, - &rcvbufsz, sizeof(rcvbufsz)) < 0) { - fprintf(stderr, "Unable to set socket rcv buf size to %d\n", - rcvbufsz); - goto error; - } - - memset(&local, 0, sizeof(local)); - local.nl_family = AF_NETLINK; - - if (bind(fd, (struct sockaddr *) &local, sizeof(local)) < 0) - goto error; - - return fd; -error: - close(fd); - return -1; -} - - -static int send_cmd(int sd, __u16 nlmsg_type, __u32 nlmsg_pid, - __u8 genl_cmd, __u16 nla_type, - void *nla_data, int nla_len) -{ - struct nlattr *na; - struct sockaddr_nl nladdr; - int r, buflen; - char *buf; - - struct msgtemplate msg; - - msg.n.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN); - msg.n.nlmsg_type = nlmsg_type; - msg.n.nlmsg_flags = NLM_F_REQUEST; - msg.n.nlmsg_seq = 0; - msg.n.nlmsg_pid = nlmsg_pid; - msg.g.cmd = genl_cmd; - msg.g.version = 0x1; - na = (struct nlattr *) GENLMSG_DATA(&msg); - na->nla_type = nla_type; - na->nla_len = nla_len + 1 + NLA_HDRLEN; - memcpy(NLA_DATA(na), nla_data, nla_len); - msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len); - - buf = (char *) &msg; - buflen = msg.n.nlmsg_len ; - memset(&nladdr, 0, sizeof(nladdr)); - nladdr.nl_family = AF_NETLINK; - while ((r = sendto(sd, buf, buflen, 0, (struct sockaddr *) &nladdr, - sizeof(nladdr))) < buflen) { - if (r > 0) { - buf += r; - buflen -= r; - } else if (errno != EAGAIN) - return -1; - } - return 0; -} - - -/* - * Probe the controller in genetlink to find the family id - * for the TASKSTATS family - */ -static int get_family_id(int sd) -{ - struct { - struct nlmsghdr n; - struct genlmsghdr g; - char buf[256]; - } ans; - - int id = 0, rc; - struct nlattr *na; - int rep_len; - - strcpy(name, TASKSTATS_GENL_NAME); - rc = send_cmd(sd, GENL_ID_CTRL, getpid(), CTRL_CMD_GETFAMILY, - CTRL_ATTR_FAMILY_NAME, (void *)name, - strlen(TASKSTATS_GENL_NAME)+1); - if (rc < 0) - return 0; /* sendto() failure? */ - - rep_len = recv(sd, &ans, sizeof(ans), 0); - if (ans.n.nlmsg_type == NLMSG_ERROR || - (rep_len < 0) || !NLMSG_OK((&ans.n), rep_len)) - return 0; - - na = (struct nlattr *) GENLMSG_DATA(&ans); - na = (struct nlattr *) ((char *) na + NLA_ALIGN(na->nla_len)); - if (na->nla_type == CTRL_ATTR_FAMILY_ID) { - id = *(__u16 *) NLA_DATA(na); - } - return id; -} - -#define average_ms(t, c) (t / 1000000ULL / (c ? c : 1)) - -static void print_delayacct(struct taskstats *t) -{ - printf("\n\nCPU %15s%15s%15s%15s%15s\n" - " %15llu%15llu%15llu%15llu%15.3fms\n" - "IO %15s%15s%15s\n" - " %15llu%15llu%15llums\n" - "SWAP %15s%15s%15s\n" - " %15llu%15llu%15llums\n" - "RECLAIM %12s%15s%15s\n" - " %15llu%15llu%15llums\n", - "count", "real total", "virtual total", - "delay total", "delay average", - (unsigned long long)t->cpu_count, - (unsigned long long)t->cpu_run_real_total, - (unsigned long long)t->cpu_run_virtual_total, - (unsigned long long)t->cpu_delay_total, - average_ms((double)t->cpu_delay_total, t->cpu_count), - "count", "delay total", "delay average", - (unsigned long long)t->blkio_count, - (unsigned long long)t->blkio_delay_total, - average_ms(t->blkio_delay_total, t->blkio_count), - "count", "delay total", "delay average", - (unsigned long long)t->swapin_count, - (unsigned long long)t->swapin_delay_total, - average_ms(t->swapin_delay_total, t->swapin_count), - "count", "delay total", "delay average", - (unsigned long long)t->freepages_count, - (unsigned long long)t->freepages_delay_total, - average_ms(t->freepages_delay_total, t->freepages_count)); -} - -static void task_context_switch_counts(struct taskstats *t) -{ - printf("\n\nTask %15s%15s\n" - " %15llu%15llu\n", - "voluntary", "nonvoluntary", - (unsigned long long)t->nvcsw, (unsigned long long)t->nivcsw); -} - -static void print_cgroupstats(struct cgroupstats *c) -{ - printf("sleeping %llu, blocked %llu, running %llu, stopped %llu, " - "uninterruptible %llu\n", (unsigned long long)c->nr_sleeping, - (unsigned long long)c->nr_io_wait, - (unsigned long long)c->nr_running, - (unsigned long long)c->nr_stopped, - (unsigned long long)c->nr_uninterruptible); -} - - -static void print_ioacct(struct taskstats *t) -{ - printf("%s: read=%llu, write=%llu, cancelled_write=%llu\n", - t->ac_comm, - (unsigned long long)t->read_bytes, - (unsigned long long)t->write_bytes, - (unsigned long long)t->cancelled_write_bytes); -} - -int main(int argc, char *argv[]) -{ - int c, rc, rep_len, aggr_len, len2; - int cmd_type = TASKSTATS_CMD_ATTR_UNSPEC; - __u16 id; - __u32 mypid; - - struct nlattr *na; - int nl_sd = -1; - int len = 0; - pid_t tid = 0; - pid_t rtid = 0; - - int fd = 0; - int count = 0; - int write_file = 0; - int maskset = 0; - char *logfile = NULL; - int loop = 0; - int containerset = 0; - char *containerpath = NULL; - int cfd = 0; - int forking = 0; - sigset_t sigset; - - struct msgtemplate msg; - - while (!forking) { - c = getopt(argc, argv, "qdiw:r:m:t:p:vlC:c:"); - if (c < 0) - break; - - switch (c) { - case 'd': - printf("print delayacct stats ON\n"); - print_delays = 1; - break; - case 'i': - printf("printing IO accounting\n"); - print_io_accounting = 1; - break; - case 'q': - printf("printing task/process context switch rates\n"); - print_task_context_switch_counts = 1; - break; - case 'C': - containerset = 1; - containerpath = optarg; - break; - case 'w': - logfile = strdup(optarg); - printf("write to file %s\n", logfile); - write_file = 1; - break; - case 'r': - rcvbufsz = atoi(optarg); - printf("receive buf size %d\n", rcvbufsz); - if (rcvbufsz < 0) - err(1, "Invalid rcv buf size\n"); - break; - case 'm': - strncpy(cpumask, optarg, sizeof(cpumask)); - cpumask[sizeof(cpumask) - 1] = '\0'; - maskset = 1; - printf("cpumask %s maskset %d\n", cpumask, maskset); - break; - case 't': - tid = atoi(optarg); - if (!tid) - err(1, "Invalid tgid\n"); - cmd_type = TASKSTATS_CMD_ATTR_TGID; - break; - case 'p': - tid = atoi(optarg); - if (!tid) - err(1, "Invalid pid\n"); - cmd_type = TASKSTATS_CMD_ATTR_PID; - break; - case 'c': - - /* Block SIGCHLD for sigwait() later */ - if (sigemptyset(&sigset) == -1) - err(1, "Failed to empty sigset"); - if (sigaddset(&sigset, SIGCHLD)) - err(1, "Failed to set sigchld in sigset"); - sigprocmask(SIG_BLOCK, &sigset, NULL); - - /* fork/exec a child */ - tid = fork(); - if (tid < 0) - err(1, "Fork failed\n"); - if (tid == 0) - if (execvp(argv[optind - 1], - &argv[optind - 1]) < 0) - exit(-1); - - /* Set the command type and avoid further processing */ - cmd_type = TASKSTATS_CMD_ATTR_PID; - forking = 1; - break; - case 'v': - printf("debug on\n"); - dbg = 1; - break; - case 'l': - printf("listen forever\n"); - loop = 1; - break; - default: - usage(); - exit(-1); - } - } - - if (write_file) { - fd = open(logfile, O_WRONLY | O_CREAT | O_TRUNC, - S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - if (fd == -1) { - perror("Cannot open output file\n"); - exit(1); - } - } - - nl_sd = create_nl_socket(NETLINK_GENERIC); - if (nl_sd < 0) - err(1, "error creating Netlink socket\n"); - - - mypid = getpid(); - id = get_family_id(nl_sd); - if (!id) { - fprintf(stderr, "Error getting family id, errno %d\n", errno); - goto err; - } - PRINTF("family id %d\n", id); - - if (maskset) { - rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET, - TASKSTATS_CMD_ATTR_REGISTER_CPUMASK, - &cpumask, strlen(cpumask) + 1); - PRINTF("Sent register cpumask, retval %d\n", rc); - if (rc < 0) { - fprintf(stderr, "error sending register cpumask\n"); - goto err; - } - } - - if (tid && containerset) { - fprintf(stderr, "Select either -t or -C, not both\n"); - goto err; - } - - /* - * If we forked a child, wait for it to exit. Cannot use waitpid() - * as all the delicious data would be reaped as part of the wait - */ - if (tid && forking) { - int sig_received; - sigwait(&sigset, &sig_received); - } - - if (tid) { - rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET, - cmd_type, &tid, sizeof(__u32)); - PRINTF("Sent pid/tgid, retval %d\n", rc); - if (rc < 0) { - fprintf(stderr, "error sending tid/tgid cmd\n"); - goto done; - } - } - - if (containerset) { - cfd = open(containerpath, O_RDONLY); - if (cfd < 0) { - perror("error opening container file"); - goto err; - } - rc = send_cmd(nl_sd, id, mypid, CGROUPSTATS_CMD_GET, - CGROUPSTATS_CMD_ATTR_FD, &cfd, sizeof(__u32)); - if (rc < 0) { - perror("error sending cgroupstats command"); - goto err; - } - } - if (!maskset && !tid && !containerset) { - usage(); - goto err; - } - - do { - rep_len = recv(nl_sd, &msg, sizeof(msg), 0); - PRINTF("received %d bytes\n", rep_len); - - if (rep_len < 0) { - fprintf(stderr, "nonfatal reply error: errno %d\n", - errno); - continue; - } - if (msg.n.nlmsg_type == NLMSG_ERROR || - !NLMSG_OK((&msg.n), rep_len)) { - struct nlmsgerr *err = NLMSG_DATA(&msg); - fprintf(stderr, "fatal reply error, errno %d\n", - err->error); - goto done; - } - - PRINTF("nlmsghdr size=%zu, nlmsg_len=%d, rep_len=%d\n", - sizeof(struct nlmsghdr), msg.n.nlmsg_len, rep_len); - - - rep_len = GENLMSG_PAYLOAD(&msg.n); - - na = (struct nlattr *) GENLMSG_DATA(&msg); - len = 0; - while (len < rep_len) { - len += NLA_ALIGN(na->nla_len); - switch (na->nla_type) { - case TASKSTATS_TYPE_AGGR_TGID: - /* Fall through */ - case TASKSTATS_TYPE_AGGR_PID: - aggr_len = NLA_PAYLOAD(na->nla_len); - len2 = 0; - /* For nested attributes, na follows */ - na = (struct nlattr *) NLA_DATA(na); - done = 0; - while (len2 < aggr_len) { - switch (na->nla_type) { - case TASKSTATS_TYPE_PID: - rtid = *(int *) NLA_DATA(na); - if (print_delays) - printf("PID\t%d\n", rtid); - break; - case TASKSTATS_TYPE_TGID: - rtid = *(int *) NLA_DATA(na); - if (print_delays) - printf("TGID\t%d\n", rtid); - break; - case TASKSTATS_TYPE_STATS: - count++; - if (print_delays) - print_delayacct((struct taskstats *) NLA_DATA(na)); - if (print_io_accounting) - print_ioacct((struct taskstats *) NLA_DATA(na)); - if (print_task_context_switch_counts) - task_context_switch_counts((struct taskstats *) NLA_DATA(na)); - if (fd) { - if (write(fd, NLA_DATA(na), na->nla_len) < 0) { - err(1,"write error\n"); - } - } - if (!loop) - goto done; - break; - case TASKSTATS_TYPE_NULL: - break; - default: - fprintf(stderr, "Unknown nested" - " nla_type %d\n", - na->nla_type); - break; - } - len2 += NLA_ALIGN(na->nla_len); - na = (struct nlattr *)((char *)na + - NLA_ALIGN(na->nla_len)); - } - break; - - case CGROUPSTATS_TYPE_CGROUP_STATS: - print_cgroupstats(NLA_DATA(na)); - break; - default: - fprintf(stderr, "Unknown nla_type %d\n", - na->nla_type); - case TASKSTATS_TYPE_NULL: - break; - } - na = (struct nlattr *) (GENLMSG_DATA(&msg) + len); - } - } while (loop); -done: - if (maskset) { - rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET, - TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK, - &cpumask, strlen(cpumask) + 1); - printf("Sent deregister mask, retval %d\n", rc); - if (rc < 0) - err(rc, "error sending deregister cpumask\n"); - } -err: - close(nl_sd); - if (fd) - close(fd); - if (cfd) - close(cfd); - return 0; -} diff --git a/Documentation/arm/00-INDEX b/Documentation/arm/00-INDEX index dea011c8d7c7..b6e69fd371c4 100644 --- a/Documentation/arm/00-INDEX +++ b/Documentation/arm/00-INDEX @@ -8,8 +8,6 @@ Interrupts - ARM Interrupt subsystem documentation IXP4xx - Intel IXP4xx Network processor. -Makefile - - Build sourcefiles as part of the Documentation-build for arm Netwinder - Netwinder specific documentation Porting diff --git a/Documentation/auxdisplay/.gitignore b/Documentation/auxdisplay/.gitignore deleted file mode 100644 index 7af222860a96..000000000000 --- a/Documentation/auxdisplay/.gitignore +++ /dev/null @@ -1 +0,0 @@ -cfag12864b-example diff --git a/Documentation/auxdisplay/Makefile b/Documentation/auxdisplay/Makefile deleted file mode 100644 index ada4dac99ef4..000000000000 --- a/Documentation/auxdisplay/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# List of programs to build -hostprogs-y := cfag12864b-example - -# Tell kbuild to always build the programs -always := $(hostprogs-y) - -HOSTCFLAGS_cfag12864b-example.o += -I$(objtree)/usr/include diff --git a/Documentation/auxdisplay/cfag12864b b/Documentation/auxdisplay/cfag12864b index eb7be393a510..12fd51b8de75 100644 --- a/Documentation/auxdisplay/cfag12864b +++ b/Documentation/auxdisplay/cfag12864b @@ -101,5 +101,5 @@ Although the LCD won't get updated until the next refresh time arrives. Also, you can mmap the framebuffer: open & mmap, munmap & close... which is the best option for most uses. -Check Documentation/auxdisplay/cfag12864b-example.c +Check samples/auxdisplay/cfag12864b-example.c for a real working userspace complete program with usage examples. diff --git a/Documentation/auxdisplay/cfag12864b-example.c b/Documentation/auxdisplay/cfag12864b-example.c deleted file mode 100644 index e7823ffb1ca0..000000000000 --- a/Documentation/auxdisplay/cfag12864b-example.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Filename: cfag12864b-example.c - * Version: 0.1.0 - * Description: cfag12864b LCD userspace example program - * License: GPLv2 - * - * Author: Copyright (C) Miguel Ojeda Sandonis - * Date: 2006-10-31 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/* - * ------------------------ - * start of cfag12864b code - * ------------------------ - */ - -#include -#include -#include -#include -#include -#include - -#define CFAG12864B_WIDTH (128) -#define CFAG12864B_HEIGHT (64) -#define CFAG12864B_SIZE (128 * 64 / 8) -#define CFAG12864B_BPB (8) -#define CFAG12864B_ADDRESS(x, y) ((y) * CFAG12864B_WIDTH / \ - CFAG12864B_BPB + (x) / CFAG12864B_BPB) -#define CFAG12864B_BIT(n) (((unsigned char) 1) << (n)) - -#undef CFAG12864B_DOCHECK -#ifdef CFAG12864B_DOCHECK - #define CFAG12864B_CHECK(x, y) ((x) < CFAG12864B_WIDTH && \ - (y) < CFAG12864B_HEIGHT) -#else - #define CFAG12864B_CHECK(x, y) (1) -#endif - -int cfag12864b_fd; -unsigned char * cfag12864b_mem; -unsigned char cfag12864b_buffer[CFAG12864B_SIZE]; - -/* - * init a cfag12864b framebuffer device - * - * No error: return = 0 - * Unable to open: return = -1 - * Unable to mmap: return = -2 - */ -static int cfag12864b_init(char *path) -{ - cfag12864b_fd = open(path, O_RDWR); - if (cfag12864b_fd == -1) - return -1; - - cfag12864b_mem = mmap(0, CFAG12864B_SIZE, PROT_READ | PROT_WRITE, - MAP_SHARED, cfag12864b_fd, 0); - if (cfag12864b_mem == MAP_FAILED) { - close(cfag12864b_fd); - return -2; - } - - return 0; -} - -/* - * exit a cfag12864b framebuffer device - */ -static void cfag12864b_exit(void) -{ - munmap(cfag12864b_mem, CFAG12864B_SIZE); - close(cfag12864b_fd); -} - -/* - * set (x, y) pixel - */ -static void cfag12864b_set(unsigned char x, unsigned char y) -{ - if (CFAG12864B_CHECK(x, y)) - cfag12864b_buffer[CFAG12864B_ADDRESS(x, y)] |= - CFAG12864B_BIT(x % CFAG12864B_BPB); -} - -/* - * unset (x, y) pixel - */ -static void cfag12864b_unset(unsigned char x, unsigned char y) -{ - if (CFAG12864B_CHECK(x, y)) - cfag12864b_buffer[CFAG12864B_ADDRESS(x, y)] &= - ~CFAG12864B_BIT(x % CFAG12864B_BPB); -} - -/* - * is set (x, y) pixel? - * - * Pixel off: return = 0 - * Pixel on: return = 1 - */ -static unsigned char cfag12864b_isset(unsigned char x, unsigned char y) -{ - if (CFAG12864B_CHECK(x, y)) - if (cfag12864b_buffer[CFAG12864B_ADDRESS(x, y)] & - CFAG12864B_BIT(x % CFAG12864B_BPB)) - return 1; - - return 0; -} - -/* - * not (x, y) pixel - */ -static void cfag12864b_not(unsigned char x, unsigned char y) -{ - if (cfag12864b_isset(x, y)) - cfag12864b_unset(x, y); - else - cfag12864b_set(x, y); -} - -/* - * fill (set all pixels) - */ -static void cfag12864b_fill(void) -{ - unsigned short i; - - for (i = 0; i < CFAG12864B_SIZE; i++) - cfag12864b_buffer[i] = 0xFF; -} - -/* - * clear (unset all pixels) - */ -static void cfag12864b_clear(void) -{ - unsigned short i; - - for (i = 0; i < CFAG12864B_SIZE; i++) - cfag12864b_buffer[i] = 0; -} - -/* - * format a [128*64] matrix - * - * Pixel off: src[i] = 0 - * Pixel on: src[i] > 0 - */ -static void cfag12864b_format(unsigned char * matrix) -{ - unsigned char i, j, n; - - for (i = 0; i < CFAG12864B_HEIGHT; i++) - for (j = 0; j < CFAG12864B_WIDTH / CFAG12864B_BPB; j++) { - cfag12864b_buffer[i * CFAG12864B_WIDTH / CFAG12864B_BPB + - j] = 0; - for (n = 0; n < CFAG12864B_BPB; n++) - if (matrix[i * CFAG12864B_WIDTH + - j * CFAG12864B_BPB + n]) - cfag12864b_buffer[i * CFAG12864B_WIDTH / - CFAG12864B_BPB + j] |= - CFAG12864B_BIT(n); - } -} - -/* - * blit buffer to lcd - */ -static void cfag12864b_blit(void) -{ - memcpy(cfag12864b_mem, cfag12864b_buffer, CFAG12864B_SIZE); -} - -/* - * ---------------------- - * end of cfag12864b code - * ---------------------- - */ - -#include - -#define EXAMPLES 6 - -static void example(unsigned char n) -{ - unsigned short i, j; - unsigned char matrix[CFAG12864B_WIDTH * CFAG12864B_HEIGHT]; - - if (n > EXAMPLES) - return; - - printf("Example %i/%i - ", n, EXAMPLES); - - switch (n) { - case 1: - printf("Draw points setting bits"); - cfag12864b_clear(); - for (i = 0; i < CFAG12864B_WIDTH; i += 2) - for (j = 0; j < CFAG12864B_HEIGHT; j += 2) - cfag12864b_set(i, j); - break; - - case 2: - printf("Clear the LCD"); - cfag12864b_clear(); - break; - - case 3: - printf("Draw rows formatting a [128*64] matrix"); - memset(matrix, 0, CFAG12864B_WIDTH * CFAG12864B_HEIGHT); - for (i = 0; i < CFAG12864B_WIDTH; i++) - for (j = 0; j < CFAG12864B_HEIGHT; j += 2) - matrix[j * CFAG12864B_WIDTH + i] = 1; - cfag12864b_format(matrix); - break; - - case 4: - printf("Fill the lcd"); - cfag12864b_fill(); - break; - - case 5: - printf("Draw columns unsetting bits"); - for (i = 0; i < CFAG12864B_WIDTH; i += 2) - for (j = 0; j < CFAG12864B_HEIGHT; j++) - cfag12864b_unset(i, j); - break; - - case 6: - printf("Do negative not-ing all bits"); - for (i = 0; i < CFAG12864B_WIDTH; i++) - for (j = 0; j < CFAG12864B_HEIGHT; j ++) - cfag12864b_not(i, j); - break; - } - - puts(" - [Press Enter]"); -} - -int main(int argc, char *argv[]) -{ - unsigned char n; - - if (argc != 2) { - printf( - "Sintax: %s fbdev\n" - "Usually: /dev/fb0, /dev/fb1...\n", argv[0]); - return -1; - } - - if (cfag12864b_init(argv[1])) { - printf("Can't init %s fbdev\n", argv[1]); - return -2; - } - - for (n = 1; n <= EXAMPLES; n++) { - example(n); - cfag12864b_blit(); - while (getchar() != '\n'); - } - - cfag12864b_exit(); - - return 0; -} diff --git a/Documentation/blackfin/00-INDEX b/Documentation/blackfin/00-INDEX index c54fcdd4ae9f..265a1effebde 100644 --- a/Documentation/blackfin/00-INDEX +++ b/Documentation/blackfin/00-INDEX @@ -1,10 +1,6 @@ 00-INDEX - This file -Makefile - - Makefile for gptimers example file. bfin-gpio-notes.txt - Notes in developing/using bfin-gpio driver. bfin-spi-notes.txt - Notes for using bfin spi bus driver. -gptimers-example.c - - gptimers example diff --git a/Documentation/blackfin/Makefile b/Documentation/blackfin/Makefile deleted file mode 100644 index 6782c58fbc29..000000000000 --- a/Documentation/blackfin/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -ifneq ($(CONFIG_BLACKFIN),) -ifneq ($(CONFIG_BFIN_GPTIMERS),) -obj-m := gptimers-example.o -endif -endif diff --git a/Documentation/blackfin/gptimers-example.c b/Documentation/blackfin/gptimers-example.c deleted file mode 100644 index 283eba993d9d..000000000000 --- a/Documentation/blackfin/gptimers-example.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Simple gptimers example - * http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:gptimers - * - * Copyright 2007-2009 Analog Devices Inc. - * - * Licensed under the GPL-2 or later. - */ - -#include -#include - -#include -#include - -/* ... random driver includes ... */ - -#define DRIVER_NAME "gptimer_example" - -#ifdef IRQ_TIMER5 -#define SAMPLE_IRQ_TIMER IRQ_TIMER5 -#else -#define SAMPLE_IRQ_TIMER IRQ_TIMER2 -#endif - -struct gptimer_data { - uint32_t period, width; -}; -static struct gptimer_data data; - -/* ... random driver state ... */ - -static irqreturn_t gptimer_example_irq(int irq, void *dev_id) -{ - struct gptimer_data *data = dev_id; - - /* make sure it was our timer which caused the interrupt */ - if (!get_gptimer_intr(TIMER5_id)) - return IRQ_NONE; - - /* read the width/period values that were captured for the waveform */ - data->width = get_gptimer_pwidth(TIMER5_id); - data->period = get_gptimer_period(TIMER5_id); - - /* acknowledge the interrupt */ - clear_gptimer_intr(TIMER5_id); - - /* tell the upper layers we took care of things */ - return IRQ_HANDLED; -} - -/* ... random driver code ... */ - -static int __init gptimer_example_init(void) -{ - int ret; - - /* grab the peripheral pins */ - ret = peripheral_request(P_TMR5, DRIVER_NAME); - if (ret) { - printk(KERN_NOTICE DRIVER_NAME ": peripheral request failed\n"); - return ret; - } - - /* grab the IRQ for the timer */ - ret = request_irq(SAMPLE_IRQ_TIMER, gptimer_example_irq, - IRQF_SHARED, DRIVER_NAME, &data); - if (ret) { - printk(KERN_NOTICE DRIVER_NAME ": IRQ request failed\n"); - peripheral_free(P_TMR5); - return ret; - } - - /* setup the timer and enable it */ - set_gptimer_config(TIMER5_id, - WDTH_CAP | PULSE_HI | PERIOD_CNT | IRQ_ENA); - enable_gptimers(TIMER5bit); - - return 0; -} -module_init(gptimer_example_init); - -static void __exit gptimer_example_exit(void) -{ - disable_gptimers(TIMER5bit); - free_irq(SAMPLE_IRQ_TIMER, &data); - peripheral_free(P_TMR5); -} -module_exit(gptimer_example_exit); - -MODULE_LICENSE("BSD"); diff --git a/Documentation/filesystems/.gitignore b/Documentation/filesystems/.gitignore deleted file mode 100644 index 31d6e426b6d4..000000000000 --- a/Documentation/filesystems/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dnotify_test diff --git a/Documentation/filesystems/00-INDEX b/Documentation/filesystems/00-INDEX index 9922939e7d99..f66e748fc5e4 100644 --- a/Documentation/filesystems/00-INDEX +++ b/Documentation/filesystems/00-INDEX @@ -2,8 +2,6 @@ - this file (info on some of the filesystems supported by linux). Locking - info on locking rules as they pertain to Linux VFS. -Makefile - - Makefile for building the filsystems-part of DocBook. 9p.txt - 9p (v9fs) is an implementation of the Plan 9 remote fs protocol. adfs.txt diff --git a/Documentation/filesystems/Makefile b/Documentation/filesystems/Makefile deleted file mode 100644 index 883010ce5e35..000000000000 --- a/Documentation/filesystems/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# List of programs to build -hostprogs-y := dnotify_test - -# Tell kbuild to always build the programs -always := $(hostprogs-y) diff --git a/Documentation/filesystems/dnotify_test.c b/Documentation/filesystems/dnotify_test.c deleted file mode 100644 index 8b37b4a1e18d..000000000000 --- a/Documentation/filesystems/dnotify_test.c +++ /dev/null @@ -1,34 +0,0 @@ -#define _GNU_SOURCE /* needed to get the defines */ -#include /* in glibc 2.2 this has the needed - values defined */ -#include -#include -#include - -static volatile int event_fd; - -static void handler(int sig, siginfo_t *si, void *data) -{ - event_fd = si->si_fd; -} - -int main(void) -{ - struct sigaction act; - int fd; - - act.sa_sigaction = handler; - sigemptyset(&act.sa_mask); - act.sa_flags = SA_SIGINFO; - sigaction(SIGRTMIN + 1, &act, NULL); - - fd = open(".", O_RDONLY); - fcntl(fd, F_SETSIG, SIGRTMIN + 1); - fcntl(fd, F_NOTIFY, DN_MODIFY|DN_CREATE|DN_MULTISHOT); - /* we will now be notified if any of the files - in "." is modified or new files are created */ - while (1) { - pause(); - printf("Got event on fd=%d\n", event_fd); - } -} diff --git a/Documentation/ia64/.gitignore b/Documentation/ia64/.gitignore deleted file mode 100644 index ab806edc8732..000000000000 --- a/Documentation/ia64/.gitignore +++ /dev/null @@ -1 +0,0 @@ -aliasing-test diff --git a/Documentation/ia64/Makefile b/Documentation/ia64/Makefile deleted file mode 100644 index d493163affe7..000000000000 --- a/Documentation/ia64/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# List of programs to build -hostprogs-y := aliasing-test - -# Tell kbuild to always build the programs -always := $(hostprogs-y) diff --git a/Documentation/ia64/aliasing-test.c b/Documentation/ia64/aliasing-test.c deleted file mode 100644 index 62a190d45f38..000000000000 --- a/Documentation/ia64/aliasing-test.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Exercise /dev/mem mmap cases that have been troublesome in the past - * - * (c) Copyright 2007 Hewlett-Packard Development Company, L.P. - * Bjorn Helgaas - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -int sum; - -static int map_mem(char *path, off_t offset, size_t length, int touch) -{ - int fd, rc; - void *addr; - int *c; - - fd = open(path, O_RDWR); - if (fd == -1) { - perror(path); - return -1; - } - - if (fnmatch("/proc/bus/pci/*", path, 0) == 0) { - rc = ioctl(fd, PCIIOC_MMAP_IS_MEM); - if (rc == -1) - perror("PCIIOC_MMAP_IS_MEM ioctl"); - } - - addr = mmap(NULL, length, PROT_READ|PROT_WRITE, MAP_SHARED, fd, offset); - if (addr == MAP_FAILED) - return 1; - - if (touch) { - c = (int *) addr; - while (c < (int *) (addr + length)) - sum += *c++; - } - - rc = munmap(addr, length); - if (rc == -1) { - perror("munmap"); - return -1; - } - - close(fd); - return 0; -} - -static int scan_tree(char *path, char *file, off_t offset, size_t length, int touch) -{ - struct dirent **namelist; - char *name, *path2; - int i, n, r, rc = 0, result = 0; - struct stat buf; - - n = scandir(path, &namelist, 0, alphasort); - if (n < 0) { - perror("scandir"); - return -1; - } - - for (i = 0; i < n; i++) { - name = namelist[i]->d_name; - - if (fnmatch(".", name, 0) == 0) - goto skip; - if (fnmatch("..", name, 0) == 0) - goto skip; - - path2 = malloc(strlen(path) + strlen(name) + 3); - strcpy(path2, path); - strcat(path2, "/"); - strcat(path2, name); - - if (fnmatch(file, name, 0) == 0) { - rc = map_mem(path2, offset, length, touch); - if (rc == 0) - fprintf(stderr, "PASS: %s 0x%lx-0x%lx is %s\n", path2, offset, offset + length, touch ? "readable" : "mappable"); - else if (rc > 0) - fprintf(stderr, "PASS: %s 0x%lx-0x%lx not mappable\n", path2, offset, offset + length); - else { - fprintf(stderr, "FAIL: %s 0x%lx-0x%lx not accessible\n", path2, offset, offset + length); - return rc; - } - } else { - r = lstat(path2, &buf); - if (r == 0 && S_ISDIR(buf.st_mode)) { - rc = scan_tree(path2, file, offset, length, touch); - if (rc < 0) - return rc; - } - } - - result |= rc; - free(path2); - -skip: - free(namelist[i]); - } - free(namelist); - return result; -} - -char buf[1024]; - -static int read_rom(char *path) -{ - int fd, rc; - size_t size = 0; - - fd = open(path, O_RDWR); - if (fd == -1) { - perror(path); - return -1; - } - - rc = write(fd, "1", 2); - if (rc <= 0) { - close(fd); - perror("write"); - return -1; - } - - do { - rc = read(fd, buf, sizeof(buf)); - if (rc > 0) - size += rc; - } while (rc > 0); - - close(fd); - return size; -} - -static int scan_rom(char *path, char *file) -{ - struct dirent **namelist; - char *name, *path2; - int i, n, r, rc = 0, result = 0; - struct stat buf; - - n = scandir(path, &namelist, 0, alphasort); - if (n < 0) { - perror("scandir"); - return -1; - } - - for (i = 0; i < n; i++) { - name = namelist[i]->d_name; - - if (fnmatch(".", name, 0) == 0) - goto skip; - if (fnmatch("..", name, 0) == 0) - goto skip; - - path2 = malloc(strlen(path) + strlen(name) + 3); - strcpy(path2, path); - strcat(path2, "/"); - strcat(path2, name); - - if (fnmatch(file, name, 0) == 0) { - rc = read_rom(path2); - - /* - * It's OK if the ROM is unreadable. Maybe there - * is no ROM, or some other error occurred. The - * important thing is that no MCA happened. - */ - if (rc > 0) - fprintf(stderr, "PASS: %s read %d bytes\n", path2, rc); - else { - fprintf(stderr, "PASS: %s not readable\n", path2); - return rc; - } - } else { - r = lstat(path2, &buf); - if (r == 0 && S_ISDIR(buf.st_mode)) { - rc = scan_rom(path2, file); - if (rc < 0) - return rc; - } - } - - result |= rc; - free(path2); - -skip: - free(namelist[i]); - } - free(namelist); - return result; -} - -int main(void) -{ - int rc; - - if (map_mem("/dev/mem", 0, 0xA0000, 1) == 0) - fprintf(stderr, "PASS: /dev/mem 0x0-0xa0000 is readable\n"); - else - fprintf(stderr, "FAIL: /dev/mem 0x0-0xa0000 not accessible\n"); - - /* - * It's not safe to blindly read the VGA frame buffer. If you know - * how to poke the card the right way, it should respond, but it's - * not safe in general. Many machines, e.g., Intel chipsets, cover - * up a non-responding card by just returning -1, but others will - * report the failure as a machine check. - */ - if (map_mem("/dev/mem", 0xA0000, 0x20000, 0) == 0) - fprintf(stderr, "PASS: /dev/mem 0xa0000-0xc0000 is mappable\n"); - else - fprintf(stderr, "FAIL: /dev/mem 0xa0000-0xc0000 not accessible\n"); - - if (map_mem("/dev/mem", 0xC0000, 0x40000, 1) == 0) - fprintf(stderr, "PASS: /dev/mem 0xc0000-0x100000 is readable\n"); - else - fprintf(stderr, "FAIL: /dev/mem 0xc0000-0x100000 not accessible\n"); - - /* - * Often you can map all the individual pieces above (0-0xA0000, - * 0xA0000-0xC0000, and 0xC0000-0x100000), but can't map the whole - * thing at once. This is because the individual pieces use different - * attributes, and there's no single attribute supported over the - * whole region. - */ - rc = map_mem("/dev/mem", 0, 1024*1024, 0); - if (rc == 0) - fprintf(stderr, "PASS: /dev/mem 0x0-0x100000 is mappable\n"); - else if (rc > 0) - fprintf(stderr, "PASS: /dev/mem 0x0-0x100000 not mappable\n"); - else - fprintf(stderr, "FAIL: /dev/mem 0x0-0x100000 not accessible\n"); - - scan_tree("/sys/class/pci_bus", "legacy_mem", 0, 0xA0000, 1); - scan_tree("/sys/class/pci_bus", "legacy_mem", 0xA0000, 0x20000, 0); - scan_tree("/sys/class/pci_bus", "legacy_mem", 0xC0000, 0x40000, 1); - scan_tree("/sys/class/pci_bus", "legacy_mem", 0, 1024*1024, 0); - - scan_rom("/sys/devices", "rom"); - - scan_tree("/proc/bus/pci", "??.?", 0, 0xA0000, 1); - scan_tree("/proc/bus/pci", "??.?", 0xA0000, 0x20000, 0); - scan_tree("/proc/bus/pci", "??.?", 0xC0000, 0x40000, 1); - scan_tree("/proc/bus/pci", "??.?", 0, 1024*1024, 0); - - return rc; -} diff --git a/Documentation/kselftest.txt b/Documentation/kselftest.txt index 979eacae243d..54bee77fa728 100644 --- a/Documentation/kselftest.txt +++ b/Documentation/kselftest.txt @@ -1,8 +1,9 @@ Linux Kernel Selftests The kernel contains a set of "self tests" under the tools/testing/selftests/ -directory. These are intended to be small unit tests to exercise individual -code paths in the kernel. +directory. These are intended to be small tests to exercise individual code +paths in the kernel. Tests are intended to be run after building, installing +and booting a kernel. On some systems, hot-plug tests could hang forever waiting for cpu and memory to be ready to be offlined. A special hot-plug target is created diff --git a/Documentation/laptops/.gitignore b/Documentation/laptops/.gitignore deleted file mode 100644 index 9fc984e64386..000000000000 --- a/Documentation/laptops/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dslm diff --git a/Documentation/laptops/00-INDEX b/Documentation/laptops/00-INDEX index 7c0ac2a26b9e..86169dc766f7 100644 --- a/Documentation/laptops/00-INDEX +++ b/Documentation/laptops/00-INDEX @@ -1,13 +1,9 @@ 00-INDEX - This file -Makefile - - Makefile for building dslm example program. asus-laptop.txt - information on the Asus Laptop Extras driver. disk-shock-protection.txt - information on hard disk shock protection. -dslm.c - - Simple Disk Sleep Monitor program laptop-mode.txt - how to conserve battery power using laptop-mode. sony-laptop.txt diff --git a/Documentation/laptops/Makefile b/Documentation/laptops/Makefile deleted file mode 100644 index 0abe44f68965..000000000000 --- a/Documentation/laptops/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# List of programs to build -hostprogs-y := dslm - -# Tell kbuild to always build the programs -always := $(hostprogs-y) diff --git a/Documentation/laptops/dslm.c b/Documentation/laptops/dslm.c deleted file mode 100644 index d5dd2d4b04d8..000000000000 --- a/Documentation/laptops/dslm.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * dslm.c - * Simple Disk Sleep Monitor - * by Bartek Kania - * Licensed under the GPL - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef DEBUG -#define D(x) x -#else -#define D(x) -#endif - -int endit = 0; - -/* Check if the disk is in powersave-mode - * Most of the code is stolen from hdparm. - * 1 = active, 0 = standby/sleep, -1 = unknown */ -static int check_powermode(int fd) -{ - unsigned char args[4] = {WIN_CHECKPOWERMODE1,0,0,0}; - int state; - - if (ioctl(fd, HDIO_DRIVE_CMD, &args) - && (args[0] = WIN_CHECKPOWERMODE2) /* try again with 0x98 */ - && ioctl(fd, HDIO_DRIVE_CMD, &args)) { - if (errno != EIO || args[0] != 0 || args[1] != 0) { - state = -1; /* "unknown"; */ - } else - state = 0; /* "sleeping"; */ - } else { - state = (args[2] == 255) ? 1 : 0; - } - D(printf(" drive state is: %d\n", state)); - - return state; -} - -static char *state_name(int i) -{ - if (i == -1) return "unknown"; - if (i == 0) return "sleeping"; - if (i == 1) return "active"; - - return "internal error"; -} - -static char *myctime(time_t time) -{ - char *ts = ctime(&time); - ts[strlen(ts) - 1] = 0; - - return ts; -} - -static void measure(int fd) -{ - time_t start_time; - int last_state; - time_t last_time; - int curr_state; - time_t curr_time = 0; - time_t time_diff; - time_t active_time = 0; - time_t sleep_time = 0; - time_t unknown_time = 0; - time_t total_time = 0; - int changes = 0; - float tmp; - - printf("Starting measurements\n"); - - last_state = check_powermode(fd); - start_time = last_time = time(0); - printf(" System is in state %s\n\n", state_name(last_state)); - - while(!endit) { - sleep(1); - curr_state = check_powermode(fd); - - if (curr_state != last_state || endit) { - changes++; - curr_time = time(0); - time_diff = curr_time - last_time; - - if (last_state == 1) active_time += time_diff; - else if (last_state == 0) sleep_time += time_diff; - else unknown_time += time_diff; - - last_state = curr_state; - last_time = curr_time; - - printf("%s: State-change to %s\n", myctime(curr_time), - state_name(curr_state)); - } - } - changes--; /* Compensate for SIGINT */ - - total_time = time(0) - start_time; - printf("\nTotal running time: %lus\n", curr_time - start_time); - printf(" State changed %d times\n", changes); - - tmp = (float)sleep_time / (float)total_time * 100; - printf(" Time in sleep state: %lus (%.2f%%)\n", sleep_time, tmp); - tmp = (float)active_time / (float)total_time * 100; - printf(" Time in active state: %lus (%.2f%%)\n", active_time, tmp); - tmp = (float)unknown_time / (float)total_time * 100; - printf(" Time in unknown state: %lus (%.2f%%)\n", unknown_time, tmp); -} - -static void ender(int s) -{ - endit = 1; -} - -static void usage(void) -{ - puts("usage: dslm [-w