* [PATCH 1/8] samples: move accounting example code from Documentation
2016-09-19 14:47 [PATCH 0/8] Move runnable examples code from Documentation to samples Shuah Khan
@ 2016-09-19 14:47 ` Shuah Khan
2016-09-19 16:02 ` Jonathan Corbet
2016-09-19 14:47 ` [PATCH 2/8] samples: move auxdisplay " Shuah Khan
` (7 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Shuah Khan @ 2016-09-19 14:47 UTC (permalink / raw)
To: corbet, sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim,
linux, elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann
Cc: Shuah Khan, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
Move accounting examples to samples and remove it from Documentation
Makefile. Create a new Makefile to build accounting. It can be built
from top level directory or from accounting directory:
Run make -C samples/accounting or cd samples/accounting; make
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
Documentation/Makefile | 2 +-
Documentation/accounting/.gitignore | 1 -
Documentation/accounting/Makefile | 7 -
Documentation/accounting/getdelays.c | 550 -----------------------------------
samples/accounting/.gitignore | 1 +
samples/accounting/Makefile | 9 +
samples/accounting/getdelays.c | 550 +++++++++++++++++++++++++++++++++++
7 files changed, 561 insertions(+), 559 deletions(-)
delete mode 100644 Documentation/accounting/.gitignore
delete mode 100644 Documentation/accounting/Makefile
delete mode 100644 Documentation/accounting/getdelays.c
create mode 100644 samples/accounting/.gitignore
create mode 100644 samples/accounting/Makefile
create mode 100644 samples/accounting/getdelays.c
diff --git a/Documentation/Makefile b/Documentation/Makefile
index f530c29..58c6629 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -1,2 +1,2 @@
-subdir-y := accounting auxdisplay blackfin \
+subdir-y := auxdisplay blackfin \
laptops mic misc-devices pcmcia timers watchdog
diff --git a/Documentation/accounting/.gitignore b/Documentation/accounting/.gitignore
deleted file mode 100644
index 8648520..0000000
--- 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 7e232cb..0000000
--- 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/getdelays.c b/Documentation/accounting/getdelays.c
deleted file mode 100644
index b5ca536..0000000
--- 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 <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <poll.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/wait.h>
-#include <signal.h>
-
-#include <linux/genetlink.h>
-#include <linux/taskstats.h>
-#include <linux/cgroupstats.h>
-
-/*
- * 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/samples/accounting/.gitignore b/samples/accounting/.gitignore
new file mode 100644
index 0000000..8648520
--- /dev/null
+++ b/samples/accounting/.gitignore
@@ -0,0 +1 @@
+getdelays
diff --git a/samples/accounting/Makefile b/samples/accounting/Makefile
new file mode 100644
index 0000000..647c94a
--- /dev/null
+++ b/samples/accounting/Makefile
@@ -0,0 +1,9 @@
+CC := $(CROSS_COMPILE)gcc
+CFLAGS := -I../../usr/include
+
+PROGS := getdelays
+
+all: $(PROGS)
+
+clean:
+ rm -fr $(PROGS)
diff --git a/samples/accounting/getdelays.c b/samples/accounting/getdelays.c
new file mode 100644
index 0000000..b5ca536
--- /dev/null
+++ b/samples/accounting/getdelays.c
@@ -0,0 +1,550 @@
+/* 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 <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <poll.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <signal.h>
+
+#include <linux/genetlink.h>
+#include <linux/taskstats.h>
+#include <linux/cgroupstats.h>
+
+/*
+ * 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;
+}
--
2.7.4
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 1/8] samples: move accounting example code from Documentation
2016-09-19 14:47 ` [PATCH 1/8] samples: move accounting example code from Documentation Shuah Khan
@ 2016-09-19 16:02 ` Jonathan Corbet
2016-09-20 16:05 ` Shuah Khan
0 siblings, 1 reply; 23+ messages in thread
From: Jonathan Corbet @ 2016-09-19 16:02 UTC (permalink / raw)
To: Shuah Khan
Cc: sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim, linux,
elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
On Mon, 19 Sep 2016 08:47:32 -0600
Shuah Khan <shuahkh@osg.samsung.com> wrote:
> Move accounting examples to samples and remove it from Documentation
> Makefile. Create a new Makefile to build accounting. It can be built
> from top level directory or from accounting directory:
So I like the basic idea of these patches; it's the direction we've been
trying to push things for a little bit. I have a couple of specific
comments for this one that may well apply to the others as well.
1) Is samples the right destination for these utilities? Some of them
might well be better placed under tools/ instead. I'm not sure we've
ever formally stated the purpose of those two subtrees; I see samples/
as demonstrations of how to use something, while tools/ are utilities
you might actually want to use for some purpose. Something like
getdelays might well fall into the latter group. But maybe others
disagree?
2) Tools like getdelays are referenced in the documents that have been
left behind; see accounting/delay-accounting.txt, for example. Those
documents should be updated so that readers know where to find the
referenced programs, wherever they end up. Converting them to Sphinx
while you're at it is an extra-credit exercise :)
Thanks,
jon
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/8] samples: move accounting example code from Documentation
2016-09-19 16:02 ` Jonathan Corbet
@ 2016-09-20 16:05 ` Shuah Khan
0 siblings, 0 replies; 23+ messages in thread
From: Shuah Khan @ 2016-09-20 16:05 UTC (permalink / raw)
To: Jonathan Corbet
Cc: sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim, linux,
elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog,
shuah Khan
On 09/19/2016 10:02 AM, Jonathan Corbet wrote:
> On Mon, 19 Sep 2016 08:47:32 -0600
> Shuah Khan <shuahkh@osg.samsung.com> wrote:
>
>> Move accounting examples to samples and remove it from Documentation
>> Makefile. Create a new Makefile to build accounting. It can be built
>> from top level directory or from accounting directory:
>
> So I like the basic idea of these patches; it's the direction we've been
> trying to push things for a little bit. I have a couple of specific
> comments for this one that may well apply to the others as well.
>
> 1) Is samples the right destination for these utilities? Some of them
> might well be better placed under tools/ instead. I'm not sure we've
> ever formally stated the purpose of those two subtrees; I see samples/
> as demonstrations of how to use something, while tools/ are utilities
> you might actually want to use for some purpose. Something like
> getdelays might well fall into the latter group. But maybe others
> disagree?
getdelays stumped me a bit. My first choice was tools and then I noticed
that the documentation says it is a tool and an example usage of taskstruct.
I am not set on tools or samples as location for this. I can move it to
tools instead.
>
> 2) Tools like getdelays are referenced in the documents that have been
> left behind; see accounting/delay-accounting.txt, for example. Those
> documents should be updated so that readers know where to find the
> referenced programs, wherever they end up. Converting them to Sphinx
> while you're at it is an extra-credit exercise :)
Right. Documents need updates and also the 00-Index files. I agree with
you that converting to Sphinx makes sense. There will be some learning
curve on my part. I can take this one once the move happens and do the
Documentation and 00-Index file updates.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 2/8] samples: move auxdisplay example code from Documentation
2016-09-19 14:47 [PATCH 0/8] Move runnable examples code from Documentation to samples Shuah Khan
2016-09-19 14:47 ` [PATCH 1/8] samples: move accounting example code from Documentation Shuah Khan
@ 2016-09-19 14:47 ` Shuah Khan
2016-09-19 16:05 ` Jonathan Corbet
2016-09-19 14:47 ` [PATCH 3/8] samples: move laptops " Shuah Khan
` (6 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Shuah Khan @ 2016-09-19 14:47 UTC (permalink / raw)
To: corbet, sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim,
linux, elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann
Cc: Shuah Khan, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
Move auxdisplay examples to samples and remove it from Documentation
Makefile. Create a new Makefile to build auxdisplay. It can be built
from top level directory or from auxdisplay directory:
Run make -C samples/auxdisplay or cd samples/auxdisplay; make
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
Documentation/Makefile | 3 +-
Documentation/auxdisplay/.gitignore | 1 -
Documentation/auxdisplay/Makefile | 7 -
Documentation/auxdisplay/cfag12864b-example.c | 281 --------------------------
samples/auxdisplay/.gitignore | 1 +
samples/auxdisplay/Makefile | 9 +
samples/auxdisplay/cfag12864b-example.c | 281 ++++++++++++++++++++++++++
7 files changed, 292 insertions(+), 291 deletions(-)
delete mode 100644 Documentation/auxdisplay/.gitignore
delete mode 100644 Documentation/auxdisplay/Makefile
delete mode 100644 Documentation/auxdisplay/cfag12864b-example.c
create mode 100644 samples/auxdisplay/.gitignore
create mode 100644 samples/auxdisplay/Makefile
create mode 100644 samples/auxdisplay/cfag12864b-example.c
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 58c6629..60ec0dc 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -1,2 +1 @@
-subdir-y := auxdisplay blackfin \
- laptops mic misc-devices pcmcia timers watchdog
+subdir-y := blackfin laptops mic misc-devices pcmcia timers watchdog
diff --git a/Documentation/auxdisplay/.gitignore b/Documentation/auxdisplay/.gitignore
deleted file mode 100644
index 7af2228..0000000
--- 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 ada4dac..0000000
--- 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-example.c b/Documentation/auxdisplay/cfag12864b-example.c
deleted file mode 100644
index e7823ff..0000000
--- 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 <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-
-#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 <stdio.h>
-
-#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/samples/auxdisplay/.gitignore b/samples/auxdisplay/.gitignore
new file mode 100644
index 0000000..7af2228
--- /dev/null
+++ b/samples/auxdisplay/.gitignore
@@ -0,0 +1 @@
+cfag12864b-example
diff --git a/samples/auxdisplay/Makefile b/samples/auxdisplay/Makefile
new file mode 100644
index 0000000..05e471f
--- /dev/null
+++ b/samples/auxdisplay/Makefile
@@ -0,0 +1,9 @@
+CC := $(CROSS_COMPILE)gcc
+CFLAGS := -I../../usr/include
+
+PROGS := cfag12864b-example
+
+all: $(PROGS)
+
+clean:
+ rm -fr $(PROGS)
diff --git a/samples/auxdisplay/cfag12864b-example.c b/samples/auxdisplay/cfag12864b-example.c
new file mode 100644
index 0000000..e7823ff
--- /dev/null
+++ b/samples/auxdisplay/cfag12864b-example.c
@@ -0,0 +1,281 @@
+/*
+ * 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 <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+
+#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 <stdio.h>
+
+#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;
+}
--
2.7.4
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 2/8] samples: move auxdisplay example code from Documentation
2016-09-19 14:47 ` [PATCH 2/8] samples: move auxdisplay " Shuah Khan
@ 2016-09-19 16:05 ` Jonathan Corbet
2016-09-19 19:50 ` SF Markus Elfring
2016-09-20 16:09 ` [PATCH 2/8] " Shuah Khan
0 siblings, 2 replies; 23+ messages in thread
From: Jonathan Corbet @ 2016-09-19 16:05 UTC (permalink / raw)
To: Shuah Khan
Cc: sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim, linux,
elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
On Mon, 19 Sep 2016 08:47:33 -0600
Shuah Khan <shuahkh@osg.samsung.com> wrote:
> Move auxdisplay examples to samples and remove it from Documentation
> Makefile. Create a new Makefile to build auxdisplay. It can be built
> from top level directory or from auxdisplay directory:
Documentation/auxdisplay/cfag12864b needs to be updated to reflect the new
home for the program (which probably does belong in samples/).
I wonder if these programs need MAINTAINERS entries too?
jon
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: samples: move auxdisplay example code from Documentation
2016-09-19 16:05 ` Jonathan Corbet
@ 2016-09-19 19:50 ` SF Markus Elfring
2016-09-20 16:09 ` [PATCH 2/8] " Shuah Khan
1 sibling, 0 replies; 23+ messages in thread
From: SF Markus Elfring @ 2016-09-19 19:50 UTC (permalink / raw)
To: Jonathan Corbet, Shuah Khan
Cc: Sudeep Dutt, Ashutosh Dixit, Tomas Winkler, Thomas Gleixner,
Wim Van Sebroeck, Günter Röck, Nicolas Dichtel,
David S. Miller, Greg Kroah-Hartman, Dasaratharaman Chandramouli,
Mahesh Khanwalkar, Mike Danese, Ben Hutchings, Greg Hackmann,
linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
> Documentation/auxdisplay/cfag12864b needs to be updated to reflect the new
> home for the program (which probably does belong in samples/).
>
> I wonder if these programs need MAINTAINERS entries too?
Do you find any more update suggestions interesting around this software module?
https://patchwork.kernel.org/project/LKML/list/?q=cfag12864b
Regards,
Markus
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/8] samples: move auxdisplay example code from Documentation
2016-09-19 16:05 ` Jonathan Corbet
2016-09-19 19:50 ` SF Markus Elfring
@ 2016-09-20 16:09 ` Shuah Khan
1 sibling, 0 replies; 23+ messages in thread
From: Shuah Khan @ 2016-09-20 16:09 UTC (permalink / raw)
To: Jonathan Corbet
Cc: sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim, linux,
elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog,
Shuah Khan
On 09/19/2016 10:05 AM, Jonathan Corbet wrote:
> On Mon, 19 Sep 2016 08:47:33 -0600
> Shuah Khan <shuahkh@osg.samsung.com> wrote:
>
>> Move auxdisplay examples to samples and remove it from Documentation
>> Makefile. Create a new Makefile to build auxdisplay. It can be built
>> from top level directory or from auxdisplay directory:
>
> Documentation/auxdisplay/cfag12864b needs to be updated to reflect the new
> home for the program (which probably does belong in samples/).
>
> I wonder if these programs need MAINTAINERS entries too?
>
> jon
>
I will make sure Documentation and MAINTAINERS update happens in v2 patch
for this change.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 3/8] samples: move laptops example code from Documentation
2016-09-19 14:47 [PATCH 0/8] Move runnable examples code from Documentation to samples Shuah Khan
2016-09-19 14:47 ` [PATCH 1/8] samples: move accounting example code from Documentation Shuah Khan
2016-09-19 14:47 ` [PATCH 2/8] samples: move auxdisplay " Shuah Khan
@ 2016-09-19 14:47 ` Shuah Khan
2016-09-19 16:10 ` Jonathan Corbet
2016-09-19 14:47 ` [PATCH 5/8] samples: move misc-devices/mei " Shuah Khan
` (5 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Shuah Khan @ 2016-09-19 14:47 UTC (permalink / raw)
To: corbet, sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim,
linux, elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann
Cc: Shuah Khan, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
Move laptops examples to samples and remove it from Documentation
Makefile. Create a new Makefile to build laptops. It can be built
from top level directory or from laptops directory:
Run make -C samples/laptops or cd samples/laptops; make
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
Documentation/Makefile | 2 +-
Documentation/laptops/.gitignore | 1 -
Documentation/laptops/Makefile | 5 --
Documentation/laptops/dslm.c | 166 ---------------------------------------
samples/laptops/.gitignore | 1 +
samples/laptops/Makefile | 9 +++
samples/laptops/dslm.c | 166 +++++++++++++++++++++++++++++++++++++++
7 files changed, 177 insertions(+), 173 deletions(-)
delete mode 100644 Documentation/laptops/.gitignore
delete mode 100644 Documentation/laptops/Makefile
delete mode 100644 Documentation/laptops/dslm.c
create mode 100644 samples/laptops/.gitignore
create mode 100644 samples/laptops/Makefile
create mode 100644 samples/laptops/dslm.c
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 60ec0dc..539120b 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -1 +1 @@
-subdir-y := blackfin laptops mic misc-devices pcmcia timers watchdog
+subdir-y := blackfin mic misc-devices pcmcia timers watchdog
diff --git a/Documentation/laptops/.gitignore b/Documentation/laptops/.gitignore
deleted file mode 100644
index 9fc984e..0000000
--- a/Documentation/laptops/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-dslm
diff --git a/Documentation/laptops/Makefile b/Documentation/laptops/Makefile
deleted file mode 100644
index 0abe44f..0000000
--- 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 d5dd2d4..0000000
--- 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 <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <time.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <linux/hdreg.h>
-
-#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 <time>] <disk>");
- exit(0);
-}
-
-int main(int argc, char **argv)
-{
- int fd;
- char *disk = 0;
- int settle_time = 60;
-
- /* Parse the simple command-line */
- if (argc == 2)
- disk = argv[1];
- else if (argc == 4) {
- settle_time = atoi(argv[2]);
- disk = argv[3];
- } else
- usage();
-
- if (!(fd = open(disk, O_RDONLY|O_NONBLOCK))) {
- printf("Can't open %s, because: %s\n", disk, strerror(errno));
- exit(-1);
- }
-
- if (settle_time) {
- printf("Waiting %d seconds for the system to settle down to "
- "'normal'\n", settle_time);
- sleep(settle_time);
- } else
- puts("Not waiting for system to settle down");
-
- signal(SIGINT, ender);
-
- measure(fd);
-
- close(fd);
-
- return 0;
-}
diff --git a/samples/laptops/.gitignore b/samples/laptops/.gitignore
new file mode 100644
index 0000000..9fc984e
--- /dev/null
+++ b/samples/laptops/.gitignore
@@ -0,0 +1 @@
+dslm
diff --git a/samples/laptops/Makefile b/samples/laptops/Makefile
new file mode 100644
index 0000000..ff613b3
--- /dev/null
+++ b/samples/laptops/Makefile
@@ -0,0 +1,9 @@
+CC := $(CROSS_COMPILE)gcc
+CFLAGS := -I../../usr/include
+
+PROGS := dslm
+
+all: $(PROGS)
+
+clean:
+ rm -fr $(PROGS)
diff --git a/samples/laptops/dslm.c b/samples/laptops/dslm.c
new file mode 100644
index 0000000..d5dd2d4
--- /dev/null
+++ b/samples/laptops/dslm.c
@@ -0,0 +1,166 @@
+/*
+ * dslm.c
+ * Simple Disk Sleep Monitor
+ * by Bartek Kania
+ * Licensed under the GPL
+ */
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <time.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/ioctl.h>
+#include <linux/hdreg.h>
+
+#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 <time>] <disk>");
+ exit(0);
+}
+
+int main(int argc, char **argv)
+{
+ int fd;
+ char *disk = 0;
+ int settle_time = 60;
+
+ /* Parse the simple command-line */
+ if (argc == 2)
+ disk = argv[1];
+ else if (argc == 4) {
+ settle_time = atoi(argv[2]);
+ disk = argv[3];
+ } else
+ usage();
+
+ if (!(fd = open(disk, O_RDONLY|O_NONBLOCK))) {
+ printf("Can't open %s, because: %s\n", disk, strerror(errno));
+ exit(-1);
+ }
+
+ if (settle_time) {
+ printf("Waiting %d seconds for the system to settle down to "
+ "'normal'\n", settle_time);
+ sleep(settle_time);
+ } else
+ puts("Not waiting for system to settle down");
+
+ signal(SIGINT, ender);
+
+ measure(fd);
+
+ close(fd);
+
+ return 0;
+}
--
2.7.4
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 3/8] samples: move laptops example code from Documentation
2016-09-19 14:47 ` [PATCH 3/8] samples: move laptops " Shuah Khan
@ 2016-09-19 16:10 ` Jonathan Corbet
2016-09-20 16:11 ` Shuah Khan
0 siblings, 1 reply; 23+ messages in thread
From: Jonathan Corbet @ 2016-09-19 16:10 UTC (permalink / raw)
To: Shuah Khan
Cc: sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim, linux,
elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
On Mon, 19 Sep 2016 08:47:34 -0600
Shuah Khan <shuahkh@osg.samsung.com> wrote:
> Move laptops examples to samples and remove it from Documentation
> Makefile. Create a new Makefile to build laptops. It can be built
> from top level directory or from laptops directory:
This one might be better called a "tool" rather than a "sample" - assuming
it actually still works, of course. It hasn't seen a real update in the
Git era, which is a bit disconcerting. Is it possible that this is dead
code that we might want to just get rid of?
If it stays, Documentation/laptops/laptop-mode.txt needs an update.
jon
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 3/8] samples: move laptops example code from Documentation
2016-09-19 16:10 ` Jonathan Corbet
@ 2016-09-20 16:11 ` Shuah Khan
0 siblings, 0 replies; 23+ messages in thread
From: Shuah Khan @ 2016-09-20 16:11 UTC (permalink / raw)
To: Jonathan Corbet
Cc: sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim, linux,
elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog,
Shuah Khan
On 09/19/2016 10:10 AM, Jonathan Corbet wrote:
> On Mon, 19 Sep 2016 08:47:34 -0600
> Shuah Khan <shuahkh@osg.samsung.com> wrote:
>
>> Move laptops examples to samples and remove it from Documentation
>> Makefile. Create a new Makefile to build laptops. It can be built
>> from top level directory or from laptops directory:
>
> This one might be better called a "tool" rather than a "sample" - assuming
> it actually still works, of course. It hasn't seen a real update in the
> Git era, which is a bit disconcerting. Is it possible that this is dead
> code that we might want to just get rid of?
I can send a removal patch and see if anybody objects. :)
>
> If it stays, Documentation/laptops/laptop-mode.txt needs an update.
Right. Looks like I missed Documentation updates for these moves. I get
that done in v2.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 5/8] samples: move misc-devices/mei example code from Documentation
2016-09-19 14:47 [PATCH 0/8] Move runnable examples code from Documentation to samples Shuah Khan
` (2 preceding siblings ...)
2016-09-19 14:47 ` [PATCH 3/8] samples: move laptops " Shuah Khan
@ 2016-09-19 14:47 ` Shuah Khan
2016-09-19 16:13 ` Jonathan Corbet
2016-09-19 14:47 ` [PATCH 6/8] samples: move pcmcia " Shuah Khan
` (4 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Shuah Khan @ 2016-09-19 14:47 UTC (permalink / raw)
To: corbet, sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim,
linux, elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann
Cc: Shuah Khan, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
Move misc-devices/mei examples to samples/mei and remove it from
Documentation Makefile. Delete misc-devices/Makefile.
Create a new Makefile to build samples/mei. It can be built from top
level directory or from mei directory:
Run make -C samples/mei or cd samples/mei; make
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
Documentation/Makefile | 2 +-
Documentation/misc-devices/Makefile | 1 -
Documentation/misc-devices/mei/.gitignore | 1 -
Documentation/misc-devices/mei/Makefile | 5 -
Documentation/misc-devices/mei/TODO | 2 -
Documentation/misc-devices/mei/mei-amt-version.c | 479 -----------------------
samples/mei/.gitignore | 1 +
samples/mei/Makefile | 9 +
samples/mei/TODO | 2 +
samples/mei/mei-amt-version.c | 479 +++++++++++++++++++++++
10 files changed, 492 insertions(+), 489 deletions(-)
delete mode 100644 Documentation/misc-devices/Makefile
delete mode 100644 Documentation/misc-devices/mei/.gitignore
delete mode 100644 Documentation/misc-devices/mei/Makefile
delete mode 100644 Documentation/misc-devices/mei/TODO
delete mode 100644 Documentation/misc-devices/mei/mei-amt-version.c
create mode 100644 samples/mei/.gitignore
create mode 100644 samples/mei/Makefile
create mode 100644 samples/mei/TODO
create mode 100644 samples/mei/mei-amt-version.c
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 90271bc..ac7d68f 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -1 +1 @@
-subdir-y := blackfin misc-devices pcmcia timers watchdog
+subdir-y := blackfin pcmcia timers watchdog
diff --git a/Documentation/misc-devices/Makefile b/Documentation/misc-devices/Makefile
deleted file mode 100644
index e2b7aa4..0000000
--- a/Documentation/misc-devices/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-subdir-y := mei
diff --git a/Documentation/misc-devices/mei/.gitignore b/Documentation/misc-devices/mei/.gitignore
deleted file mode 100644
index f356b81..0000000
--- a/Documentation/misc-devices/mei/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-mei-amt-version
diff --git a/Documentation/misc-devices/mei/Makefile b/Documentation/misc-devices/mei/Makefile
deleted file mode 100644
index d758047..0000000
--- a/Documentation/misc-devices/mei/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# List of programs to build
-hostprogs-y := mei-amt-version
-HOSTCFLAGS_mei-amt-version.o += -I$(objtree)/usr/include
-# Tell kbuild to always build the programs
-always := $(hostprogs-y)
diff --git a/Documentation/misc-devices/mei/TODO b/Documentation/misc-devices/mei/TODO
deleted file mode 100644
index 6b3625d..0000000
--- a/Documentation/misc-devices/mei/TODO
+++ /dev/null
@@ -1,2 +0,0 @@
-TODO:
- - Cleanup and split the timer function
diff --git a/Documentation/misc-devices/mei/mei-amt-version.c b/Documentation/misc-devices/mei/mei-amt-version.c
deleted file mode 100644
index 57d0d87..0000000
--- a/Documentation/misc-devices/mei/mei-amt-version.c
+++ /dev/null
@@ -1,479 +0,0 @@
-/******************************************************************************
- * Intel Management Engine Interface (Intel MEI) Linux driver
- * Intel MEI Interface Header
- *
- * This file is provided under a dual BSD/GPLv2 license. When using or
- * redistributing this file, you may do so under either license.
- *
- * GPL LICENSE SUMMARY
- *
- * Copyright(c) 2012 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
- * USA
- *
- * The full GNU General Public License is included in this distribution
- * in the file called LICENSE.GPL.
- *
- * Contact Information:
- * Intel Corporation.
- * linux-mei@linux.intel.com
- * http://www.intel.com
- *
- * BSD LICENSE
- *
- * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *****************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <bits/wordsize.h>
-#include <linux/mei.h>
-
-/*****************************************************************************
- * Intel Management Engine Interface
- *****************************************************************************/
-
-#define mei_msg(_me, fmt, ARGS...) do { \
- if (_me->verbose) \
- fprintf(stderr, fmt, ##ARGS); \
-} while (0)
-
-#define mei_err(_me, fmt, ARGS...) do { \
- fprintf(stderr, "Error: " fmt, ##ARGS); \
-} while (0)
-
-struct mei {
- uuid_le guid;
- bool initialized;
- bool verbose;
- unsigned int buf_size;
- unsigned char prot_ver;
- int fd;
-};
-
-static void mei_deinit(struct mei *cl)
-{
- if (cl->fd != -1)
- close(cl->fd);
- cl->fd = -1;
- cl->buf_size = 0;
- cl->prot_ver = 0;
- cl->initialized = false;
-}
-
-static bool mei_init(struct mei *me, const uuid_le *guid,
- unsigned char req_protocol_version, bool verbose)
-{
- int result;
- struct mei_client *cl;
- struct mei_connect_client_data data;
-
- me->verbose = verbose;
-
- me->fd = open("/dev/mei", O_RDWR);
- if (me->fd == -1) {
- mei_err(me, "Cannot establish a handle to the Intel MEI driver\n");
- goto err;
- }
- memcpy(&me->guid, guid, sizeof(*guid));
- memset(&data, 0, sizeof(data));
- me->initialized = true;
-
- memcpy(&data.in_client_uuid, &me->guid, sizeof(me->guid));
- result = ioctl(me->fd, IOCTL_MEI_CONNECT_CLIENT, &data);
- if (result) {
- mei_err(me, "IOCTL_MEI_CONNECT_CLIENT receive message. err=%d\n", result);
- goto err;
- }
- cl = &data.out_client_properties;
- mei_msg(me, "max_message_length %d\n", cl->max_msg_length);
- mei_msg(me, "protocol_version %d\n", cl->protocol_version);
-
- if ((req_protocol_version > 0) &&
- (cl->protocol_version != req_protocol_version)) {
- mei_err(me, "Intel MEI protocol version not supported\n");
- goto err;
- }
-
- me->buf_size = cl->max_msg_length;
- me->prot_ver = cl->protocol_version;
-
- return true;
-err:
- mei_deinit(me);
- return false;
-}
-
-static ssize_t mei_recv_msg(struct mei *me, unsigned char *buffer,
- ssize_t len, unsigned long timeout)
-{
- ssize_t rc;
-
- mei_msg(me, "call read length = %zd\n", len);
-
- rc = read(me->fd, buffer, len);
- if (rc < 0) {
- mei_err(me, "read failed with status %zd %s\n",
- rc, strerror(errno));
- mei_deinit(me);
- } else {
- mei_msg(me, "read succeeded with result %zd\n", rc);
- }
- return rc;
-}
-
-static ssize_t mei_send_msg(struct mei *me, const unsigned char *buffer,
- ssize_t len, unsigned long timeout)
-{
- struct timeval tv;
- ssize_t written;
- ssize_t rc;
- fd_set set;
-
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout % 1000) * 1000000;
-
- mei_msg(me, "call write length = %zd\n", len);
-
- written = write(me->fd, buffer, len);
- if (written < 0) {
- rc = -errno;
- mei_err(me, "write failed with status %zd %s\n",
- written, strerror(errno));
- goto out;
- }
-
- FD_ZERO(&set);
- FD_SET(me->fd, &set);
- rc = select(me->fd + 1 , &set, NULL, NULL, &tv);
- if (rc > 0 && FD_ISSET(me->fd, &set)) {
- mei_msg(me, "write success\n");
- } else if (rc == 0) {
- mei_err(me, "write failed on timeout with status\n");
- goto out;
- } else { /* rc < 0 */
- mei_err(me, "write failed on select with status %zd\n", rc);
- goto out;
- }
-
- rc = written;
-out:
- if (rc < 0)
- mei_deinit(me);
-
- return rc;
-}
-
-/***************************************************************************
- * Intel Advanced Management Technology ME Client
- ***************************************************************************/
-
-#define AMT_MAJOR_VERSION 1
-#define AMT_MINOR_VERSION 1
-
-#define AMT_STATUS_SUCCESS 0x0
-#define AMT_STATUS_INTERNAL_ERROR 0x1
-#define AMT_STATUS_NOT_READY 0x2
-#define AMT_STATUS_INVALID_AMT_MODE 0x3
-#define AMT_STATUS_INVALID_MESSAGE_LENGTH 0x4
-
-#define AMT_STATUS_HOST_IF_EMPTY_RESPONSE 0x4000
-#define AMT_STATUS_SDK_RESOURCES 0x1004
-
-
-#define AMT_BIOS_VERSION_LEN 65
-#define AMT_VERSIONS_NUMBER 50
-#define AMT_UNICODE_STRING_LEN 20
-
-struct amt_unicode_string {
- uint16_t length;
- char string[AMT_UNICODE_STRING_LEN];
-} __attribute__((packed));
-
-struct amt_version_type {
- struct amt_unicode_string description;
- struct amt_unicode_string version;
-} __attribute__((packed));
-
-struct amt_version {
- uint8_t major;
- uint8_t minor;
-} __attribute__((packed));
-
-struct amt_code_versions {
- uint8_t bios[AMT_BIOS_VERSION_LEN];
- uint32_t count;
- struct amt_version_type versions[AMT_VERSIONS_NUMBER];
-} __attribute__((packed));
-
-/***************************************************************************
- * Intel Advanced Management Technology Host Interface
- ***************************************************************************/
-
-struct amt_host_if_msg_header {
- struct amt_version version;
- uint16_t _reserved;
- uint32_t command;
- uint32_t length;
-} __attribute__((packed));
-
-struct amt_host_if_resp_header {
- struct amt_host_if_msg_header header;
- uint32_t status;
- unsigned char data[0];
-} __attribute__((packed));
-
-const uuid_le MEI_IAMTHIF = UUID_LE(0x12f80028, 0xb4b7, 0x4b2d, \
- 0xac, 0xa8, 0x46, 0xe0, 0xff, 0x65, 0x81, 0x4c);
-
-#define AMT_HOST_IF_CODE_VERSIONS_REQUEST 0x0400001A
-#define AMT_HOST_IF_CODE_VERSIONS_RESPONSE 0x0480001A
-
-const struct amt_host_if_msg_header CODE_VERSION_REQ = {
- .version = {AMT_MAJOR_VERSION, AMT_MINOR_VERSION},
- ._reserved = 0,
- .command = AMT_HOST_IF_CODE_VERSIONS_REQUEST,
- .length = 0
-};
-
-
-struct amt_host_if {
- struct mei mei_cl;
- unsigned long send_timeout;
- bool initialized;
-};
-
-
-static bool amt_host_if_init(struct amt_host_if *acmd,
- unsigned long send_timeout, bool verbose)
-{
- acmd->send_timeout = (send_timeout) ? send_timeout : 20000;
- acmd->initialized = mei_init(&acmd->mei_cl, &MEI_IAMTHIF, 0, verbose);
- return acmd->initialized;
-}
-
-static void amt_host_if_deinit(struct amt_host_if *acmd)
-{
- mei_deinit(&acmd->mei_cl);
- acmd->initialized = false;
-}
-
-static uint32_t amt_verify_code_versions(const struct amt_host_if_resp_header *resp)
-{
- uint32_t status = AMT_STATUS_SUCCESS;
- struct amt_code_versions *code_ver;
- size_t code_ver_len;
- uint32_t ver_type_cnt;
- uint32_t len;
- uint32_t i;
-
- code_ver = (struct amt_code_versions *)resp->data;
- /* length - sizeof(status) */
- code_ver_len = resp->header.length - sizeof(uint32_t);
- ver_type_cnt = code_ver_len -
- sizeof(code_ver->bios) -
- sizeof(code_ver->count);
- if (code_ver->count != ver_type_cnt / sizeof(struct amt_version_type)) {
- status = AMT_STATUS_INTERNAL_ERROR;
- goto out;
- }
-
- for (i = 0; i < code_ver->count; i++) {
- len = code_ver->versions[i].description.length;
-
- if (len > AMT_UNICODE_STRING_LEN) {
- status = AMT_STATUS_INTERNAL_ERROR;
- goto out;
- }
-
- len = code_ver->versions[i].version.length;
- if (code_ver->versions[i].version.string[len] != '\0' ||
- len != strlen(code_ver->versions[i].version.string)) {
- status = AMT_STATUS_INTERNAL_ERROR;
- goto out;
- }
- }
-out:
- return status;
-}
-
-static uint32_t amt_verify_response_header(uint32_t command,
- const struct amt_host_if_msg_header *resp_hdr,
- uint32_t response_size)
-{
- if (response_size < sizeof(struct amt_host_if_resp_header)) {
- return AMT_STATUS_INTERNAL_ERROR;
- } else if (response_size != (resp_hdr->length +
- sizeof(struct amt_host_if_msg_header))) {
- return AMT_STATUS_INTERNAL_ERROR;
- } else if (resp_hdr->command != command) {
- return AMT_STATUS_INTERNAL_ERROR;
- } else if (resp_hdr->_reserved != 0) {
- return AMT_STATUS_INTERNAL_ERROR;
- } else if (resp_hdr->version.major != AMT_MAJOR_VERSION ||
- resp_hdr->version.minor < AMT_MINOR_VERSION) {
- return AMT_STATUS_INTERNAL_ERROR;
- }
- return AMT_STATUS_SUCCESS;
-}
-
-static uint32_t amt_host_if_call(struct amt_host_if *acmd,
- const unsigned char *command, ssize_t command_sz,
- uint8_t **read_buf, uint32_t rcmd,
- unsigned int expected_sz)
-{
- uint32_t in_buf_sz;
- uint32_t out_buf_sz;
- ssize_t written;
- uint32_t status;
- struct amt_host_if_resp_header *msg_hdr;
-
- in_buf_sz = acmd->mei_cl.buf_size;
- *read_buf = (uint8_t *)malloc(sizeof(uint8_t) * in_buf_sz);
- if (*read_buf == NULL)
- return AMT_STATUS_SDK_RESOURCES;
- memset(*read_buf, 0, in_buf_sz);
- msg_hdr = (struct amt_host_if_resp_header *)*read_buf;
-
- written = mei_send_msg(&acmd->mei_cl,
- command, command_sz, acmd->send_timeout);
- if (written != command_sz)
- return AMT_STATUS_INTERNAL_ERROR;
-
- out_buf_sz = mei_recv_msg(&acmd->mei_cl, *read_buf, in_buf_sz, 2000);
- if (out_buf_sz <= 0)
- return AMT_STATUS_HOST_IF_EMPTY_RESPONSE;
-
- status = msg_hdr->status;
- if (status != AMT_STATUS_SUCCESS)
- return status;
-
- status = amt_verify_response_header(rcmd,
- &msg_hdr->header, out_buf_sz);
- if (status != AMT_STATUS_SUCCESS)
- return status;
-
- if (expected_sz && expected_sz != out_buf_sz)
- return AMT_STATUS_INTERNAL_ERROR;
-
- return AMT_STATUS_SUCCESS;
-}
-
-
-static uint32_t amt_get_code_versions(struct amt_host_if *cmd,
- struct amt_code_versions *versions)
-{
- struct amt_host_if_resp_header *response = NULL;
- uint32_t status;
-
- status = amt_host_if_call(cmd,
- (const unsigned char *)&CODE_VERSION_REQ,
- sizeof(CODE_VERSION_REQ),
- (uint8_t **)&response,
- AMT_HOST_IF_CODE_VERSIONS_RESPONSE, 0);
-
- if (status != AMT_STATUS_SUCCESS)
- goto out;
-
- status = amt_verify_code_versions(response);
- if (status != AMT_STATUS_SUCCESS)
- goto out;
-
- memcpy(versions, response->data, sizeof(struct amt_code_versions));
-out:
- if (response != NULL)
- free(response);
-
- return status;
-}
-
-/************************** end of amt_host_if_command ***********************/
-int main(int argc, char **argv)
-{
- struct amt_code_versions ver;
- struct amt_host_if acmd;
- unsigned int i;
- uint32_t status;
- int ret;
- bool verbose;
-
- verbose = (argc > 1 && strcmp(argv[1], "-v") == 0);
-
- if (!amt_host_if_init(&acmd, 5000, verbose)) {
- ret = 1;
- goto out;
- }
-
- status = amt_get_code_versions(&acmd, &ver);
-
- amt_host_if_deinit(&acmd);
-
- switch (status) {
- case AMT_STATUS_HOST_IF_EMPTY_RESPONSE:
- printf("Intel AMT: DISABLED\n");
- ret = 0;
- break;
- case AMT_STATUS_SUCCESS:
- printf("Intel AMT: ENABLED\n");
- for (i = 0; i < ver.count; i++) {
- printf("%s:\t%s\n", ver.versions[i].description.string,
- ver.versions[i].version.string);
- }
- ret = 0;
- break;
- default:
- printf("An error has occurred\n");
- ret = 1;
- break;
- }
-
-out:
- return ret;
-}
diff --git a/samples/mei/.gitignore b/samples/mei/.gitignore
new file mode 100644
index 0000000..f356b81
--- /dev/null
+++ b/samples/mei/.gitignore
@@ -0,0 +1 @@
+mei-amt-version
diff --git a/samples/mei/Makefile b/samples/mei/Makefile
new file mode 100644
index 0000000..7aac216
--- /dev/null
+++ b/samples/mei/Makefile
@@ -0,0 +1,9 @@
+CC := $(CROSS_COMPILE)gcc
+CFLAGS := -I../../usr/include
+
+PROGS := mei-amt-version
+
+all: $(PROGS)
+
+clean:
+ rm -fr $(PROGS)
diff --git a/samples/mei/TODO b/samples/mei/TODO
new file mode 100644
index 0000000..6b3625d
--- /dev/null
+++ b/samples/mei/TODO
@@ -0,0 +1,2 @@
+TODO:
+ - Cleanup and split the timer function
diff --git a/samples/mei/mei-amt-version.c b/samples/mei/mei-amt-version.c
new file mode 100644
index 0000000..57d0d87
--- /dev/null
+++ b/samples/mei/mei-amt-version.c
@@ -0,0 +1,479 @@
+/******************************************************************************
+ * Intel Management Engine Interface (Intel MEI) Linux driver
+ * Intel MEI Interface Header
+ *
+ * This file is provided under a dual BSD/GPLv2 license. When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2012 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
+ * USA
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called LICENSE.GPL.
+ *
+ * Contact Information:
+ * Intel Corporation.
+ * linux-mei@linux.intel.com
+ * http://www.intel.com
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <bits/wordsize.h>
+#include <linux/mei.h>
+
+/*****************************************************************************
+ * Intel Management Engine Interface
+ *****************************************************************************/
+
+#define mei_msg(_me, fmt, ARGS...) do { \
+ if (_me->verbose) \
+ fprintf(stderr, fmt, ##ARGS); \
+} while (0)
+
+#define mei_err(_me, fmt, ARGS...) do { \
+ fprintf(stderr, "Error: " fmt, ##ARGS); \
+} while (0)
+
+struct mei {
+ uuid_le guid;
+ bool initialized;
+ bool verbose;
+ unsigned int buf_size;
+ unsigned char prot_ver;
+ int fd;
+};
+
+static void mei_deinit(struct mei *cl)
+{
+ if (cl->fd != -1)
+ close(cl->fd);
+ cl->fd = -1;
+ cl->buf_size = 0;
+ cl->prot_ver = 0;
+ cl->initialized = false;
+}
+
+static bool mei_init(struct mei *me, const uuid_le *guid,
+ unsigned char req_protocol_version, bool verbose)
+{
+ int result;
+ struct mei_client *cl;
+ struct mei_connect_client_data data;
+
+ me->verbose = verbose;
+
+ me->fd = open("/dev/mei", O_RDWR);
+ if (me->fd == -1) {
+ mei_err(me, "Cannot establish a handle to the Intel MEI driver\n");
+ goto err;
+ }
+ memcpy(&me->guid, guid, sizeof(*guid));
+ memset(&data, 0, sizeof(data));
+ me->initialized = true;
+
+ memcpy(&data.in_client_uuid, &me->guid, sizeof(me->guid));
+ result = ioctl(me->fd, IOCTL_MEI_CONNECT_CLIENT, &data);
+ if (result) {
+ mei_err(me, "IOCTL_MEI_CONNECT_CLIENT receive message. err=%d\n", result);
+ goto err;
+ }
+ cl = &data.out_client_properties;
+ mei_msg(me, "max_message_length %d\n", cl->max_msg_length);
+ mei_msg(me, "protocol_version %d\n", cl->protocol_version);
+
+ if ((req_protocol_version > 0) &&
+ (cl->protocol_version != req_protocol_version)) {
+ mei_err(me, "Intel MEI protocol version not supported\n");
+ goto err;
+ }
+
+ me->buf_size = cl->max_msg_length;
+ me->prot_ver = cl->protocol_version;
+
+ return true;
+err:
+ mei_deinit(me);
+ return false;
+}
+
+static ssize_t mei_recv_msg(struct mei *me, unsigned char *buffer,
+ ssize_t len, unsigned long timeout)
+{
+ ssize_t rc;
+
+ mei_msg(me, "call read length = %zd\n", len);
+
+ rc = read(me->fd, buffer, len);
+ if (rc < 0) {
+ mei_err(me, "read failed with status %zd %s\n",
+ rc, strerror(errno));
+ mei_deinit(me);
+ } else {
+ mei_msg(me, "read succeeded with result %zd\n", rc);
+ }
+ return rc;
+}
+
+static ssize_t mei_send_msg(struct mei *me, const unsigned char *buffer,
+ ssize_t len, unsigned long timeout)
+{
+ struct timeval tv;
+ ssize_t written;
+ ssize_t rc;
+ fd_set set;
+
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout % 1000) * 1000000;
+
+ mei_msg(me, "call write length = %zd\n", len);
+
+ written = write(me->fd, buffer, len);
+ if (written < 0) {
+ rc = -errno;
+ mei_err(me, "write failed with status %zd %s\n",
+ written, strerror(errno));
+ goto out;
+ }
+
+ FD_ZERO(&set);
+ FD_SET(me->fd, &set);
+ rc = select(me->fd + 1 , &set, NULL, NULL, &tv);
+ if (rc > 0 && FD_ISSET(me->fd, &set)) {
+ mei_msg(me, "write success\n");
+ } else if (rc == 0) {
+ mei_err(me, "write failed on timeout with status\n");
+ goto out;
+ } else { /* rc < 0 */
+ mei_err(me, "write failed on select with status %zd\n", rc);
+ goto out;
+ }
+
+ rc = written;
+out:
+ if (rc < 0)
+ mei_deinit(me);
+
+ return rc;
+}
+
+/***************************************************************************
+ * Intel Advanced Management Technology ME Client
+ ***************************************************************************/
+
+#define AMT_MAJOR_VERSION 1
+#define AMT_MINOR_VERSION 1
+
+#define AMT_STATUS_SUCCESS 0x0
+#define AMT_STATUS_INTERNAL_ERROR 0x1
+#define AMT_STATUS_NOT_READY 0x2
+#define AMT_STATUS_INVALID_AMT_MODE 0x3
+#define AMT_STATUS_INVALID_MESSAGE_LENGTH 0x4
+
+#define AMT_STATUS_HOST_IF_EMPTY_RESPONSE 0x4000
+#define AMT_STATUS_SDK_RESOURCES 0x1004
+
+
+#define AMT_BIOS_VERSION_LEN 65
+#define AMT_VERSIONS_NUMBER 50
+#define AMT_UNICODE_STRING_LEN 20
+
+struct amt_unicode_string {
+ uint16_t length;
+ char string[AMT_UNICODE_STRING_LEN];
+} __attribute__((packed));
+
+struct amt_version_type {
+ struct amt_unicode_string description;
+ struct amt_unicode_string version;
+} __attribute__((packed));
+
+struct amt_version {
+ uint8_t major;
+ uint8_t minor;
+} __attribute__((packed));
+
+struct amt_code_versions {
+ uint8_t bios[AMT_BIOS_VERSION_LEN];
+ uint32_t count;
+ struct amt_version_type versions[AMT_VERSIONS_NUMBER];
+} __attribute__((packed));
+
+/***************************************************************************
+ * Intel Advanced Management Technology Host Interface
+ ***************************************************************************/
+
+struct amt_host_if_msg_header {
+ struct amt_version version;
+ uint16_t _reserved;
+ uint32_t command;
+ uint32_t length;
+} __attribute__((packed));
+
+struct amt_host_if_resp_header {
+ struct amt_host_if_msg_header header;
+ uint32_t status;
+ unsigned char data[0];
+} __attribute__((packed));
+
+const uuid_le MEI_IAMTHIF = UUID_LE(0x12f80028, 0xb4b7, 0x4b2d, \
+ 0xac, 0xa8, 0x46, 0xe0, 0xff, 0x65, 0x81, 0x4c);
+
+#define AMT_HOST_IF_CODE_VERSIONS_REQUEST 0x0400001A
+#define AMT_HOST_IF_CODE_VERSIONS_RESPONSE 0x0480001A
+
+const struct amt_host_if_msg_header CODE_VERSION_REQ = {
+ .version = {AMT_MAJOR_VERSION, AMT_MINOR_VERSION},
+ ._reserved = 0,
+ .command = AMT_HOST_IF_CODE_VERSIONS_REQUEST,
+ .length = 0
+};
+
+
+struct amt_host_if {
+ struct mei mei_cl;
+ unsigned long send_timeout;
+ bool initialized;
+};
+
+
+static bool amt_host_if_init(struct amt_host_if *acmd,
+ unsigned long send_timeout, bool verbose)
+{
+ acmd->send_timeout = (send_timeout) ? send_timeout : 20000;
+ acmd->initialized = mei_init(&acmd->mei_cl, &MEI_IAMTHIF, 0, verbose);
+ return acmd->initialized;
+}
+
+static void amt_host_if_deinit(struct amt_host_if *acmd)
+{
+ mei_deinit(&acmd->mei_cl);
+ acmd->initialized = false;
+}
+
+static uint32_t amt_verify_code_versions(const struct amt_host_if_resp_header *resp)
+{
+ uint32_t status = AMT_STATUS_SUCCESS;
+ struct amt_code_versions *code_ver;
+ size_t code_ver_len;
+ uint32_t ver_type_cnt;
+ uint32_t len;
+ uint32_t i;
+
+ code_ver = (struct amt_code_versions *)resp->data;
+ /* length - sizeof(status) */
+ code_ver_len = resp->header.length - sizeof(uint32_t);
+ ver_type_cnt = code_ver_len -
+ sizeof(code_ver->bios) -
+ sizeof(code_ver->count);
+ if (code_ver->count != ver_type_cnt / sizeof(struct amt_version_type)) {
+ status = AMT_STATUS_INTERNAL_ERROR;
+ goto out;
+ }
+
+ for (i = 0; i < code_ver->count; i++) {
+ len = code_ver->versions[i].description.length;
+
+ if (len > AMT_UNICODE_STRING_LEN) {
+ status = AMT_STATUS_INTERNAL_ERROR;
+ goto out;
+ }
+
+ len = code_ver->versions[i].version.length;
+ if (code_ver->versions[i].version.string[len] != '\0' ||
+ len != strlen(code_ver->versions[i].version.string)) {
+ status = AMT_STATUS_INTERNAL_ERROR;
+ goto out;
+ }
+ }
+out:
+ return status;
+}
+
+static uint32_t amt_verify_response_header(uint32_t command,
+ const struct amt_host_if_msg_header *resp_hdr,
+ uint32_t response_size)
+{
+ if (response_size < sizeof(struct amt_host_if_resp_header)) {
+ return AMT_STATUS_INTERNAL_ERROR;
+ } else if (response_size != (resp_hdr->length +
+ sizeof(struct amt_host_if_msg_header))) {
+ return AMT_STATUS_INTERNAL_ERROR;
+ } else if (resp_hdr->command != command) {
+ return AMT_STATUS_INTERNAL_ERROR;
+ } else if (resp_hdr->_reserved != 0) {
+ return AMT_STATUS_INTERNAL_ERROR;
+ } else if (resp_hdr->version.major != AMT_MAJOR_VERSION ||
+ resp_hdr->version.minor < AMT_MINOR_VERSION) {
+ return AMT_STATUS_INTERNAL_ERROR;
+ }
+ return AMT_STATUS_SUCCESS;
+}
+
+static uint32_t amt_host_if_call(struct amt_host_if *acmd,
+ const unsigned char *command, ssize_t command_sz,
+ uint8_t **read_buf, uint32_t rcmd,
+ unsigned int expected_sz)
+{
+ uint32_t in_buf_sz;
+ uint32_t out_buf_sz;
+ ssize_t written;
+ uint32_t status;
+ struct amt_host_if_resp_header *msg_hdr;
+
+ in_buf_sz = acmd->mei_cl.buf_size;
+ *read_buf = (uint8_t *)malloc(sizeof(uint8_t) * in_buf_sz);
+ if (*read_buf == NULL)
+ return AMT_STATUS_SDK_RESOURCES;
+ memset(*read_buf, 0, in_buf_sz);
+ msg_hdr = (struct amt_host_if_resp_header *)*read_buf;
+
+ written = mei_send_msg(&acmd->mei_cl,
+ command, command_sz, acmd->send_timeout);
+ if (written != command_sz)
+ return AMT_STATUS_INTERNAL_ERROR;
+
+ out_buf_sz = mei_recv_msg(&acmd->mei_cl, *read_buf, in_buf_sz, 2000);
+ if (out_buf_sz <= 0)
+ return AMT_STATUS_HOST_IF_EMPTY_RESPONSE;
+
+ status = msg_hdr->status;
+ if (status != AMT_STATUS_SUCCESS)
+ return status;
+
+ status = amt_verify_response_header(rcmd,
+ &msg_hdr->header, out_buf_sz);
+ if (status != AMT_STATUS_SUCCESS)
+ return status;
+
+ if (expected_sz && expected_sz != out_buf_sz)
+ return AMT_STATUS_INTERNAL_ERROR;
+
+ return AMT_STATUS_SUCCESS;
+}
+
+
+static uint32_t amt_get_code_versions(struct amt_host_if *cmd,
+ struct amt_code_versions *versions)
+{
+ struct amt_host_if_resp_header *response = NULL;
+ uint32_t status;
+
+ status = amt_host_if_call(cmd,
+ (const unsigned char *)&CODE_VERSION_REQ,
+ sizeof(CODE_VERSION_REQ),
+ (uint8_t **)&response,
+ AMT_HOST_IF_CODE_VERSIONS_RESPONSE, 0);
+
+ if (status != AMT_STATUS_SUCCESS)
+ goto out;
+
+ status = amt_verify_code_versions(response);
+ if (status != AMT_STATUS_SUCCESS)
+ goto out;
+
+ memcpy(versions, response->data, sizeof(struct amt_code_versions));
+out:
+ if (response != NULL)
+ free(response);
+
+ return status;
+}
+
+/************************** end of amt_host_if_command ***********************/
+int main(int argc, char **argv)
+{
+ struct amt_code_versions ver;
+ struct amt_host_if acmd;
+ unsigned int i;
+ uint32_t status;
+ int ret;
+ bool verbose;
+
+ verbose = (argc > 1 && strcmp(argv[1], "-v") == 0);
+
+ if (!amt_host_if_init(&acmd, 5000, verbose)) {
+ ret = 1;
+ goto out;
+ }
+
+ status = amt_get_code_versions(&acmd, &ver);
+
+ amt_host_if_deinit(&acmd);
+
+ switch (status) {
+ case AMT_STATUS_HOST_IF_EMPTY_RESPONSE:
+ printf("Intel AMT: DISABLED\n");
+ ret = 0;
+ break;
+ case AMT_STATUS_SUCCESS:
+ printf("Intel AMT: ENABLED\n");
+ for (i = 0; i < ver.count; i++) {
+ printf("%s:\t%s\n", ver.versions[i].description.string,
+ ver.versions[i].version.string);
+ }
+ ret = 0;
+ break;
+ default:
+ printf("An error has occurred\n");
+ ret = 1;
+ break;
+ }
+
+out:
+ return ret;
+}
--
2.7.4
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 5/8] samples: move misc-devices/mei example code from Documentation
2016-09-19 14:47 ` [PATCH 5/8] samples: move misc-devices/mei " Shuah Khan
@ 2016-09-19 16:13 ` Jonathan Corbet
2016-09-20 6:17 ` Winkler, Tomas
0 siblings, 1 reply; 23+ messages in thread
From: Jonathan Corbet @ 2016-09-19 16:13 UTC (permalink / raw)
To: Shuah Khan
Cc: sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim, linux,
elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
On Mon, 19 Sep 2016 08:47:36 -0600
Shuah Khan <shuahkh@osg.samsung.com> wrote:
> Move misc-devices/mei examples to samples/mei and remove it from
> Documentation Makefile. Delete misc-devices/Makefile.
>
> Create a new Makefile to build samples/mei. It can be built from top
> level directory or from mei directory:
This one still has a fair amount of code hiding in the .txt files, but
that's a separate job.
Acked-by: Jonathan Corbet <corbet@lwn.net>
jon
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 23+ messages in thread
* RE: [PATCH 5/8] samples: move misc-devices/mei example code from Documentation
2016-09-19 16:13 ` Jonathan Corbet
@ 2016-09-20 6:17 ` Winkler, Tomas
2016-09-20 17:20 ` Shuah Khan
0 siblings, 1 reply; 23+ messages in thread
From: Winkler, Tomas @ 2016-09-20 6:17 UTC (permalink / raw)
To: Jonathan Corbet, Shuah Khan
Cc: Dutt, Sudeep, Dixit, Ashutosh, tglx@linutronix.de, wim@iguana.be,
linux@roeck-us.net, elfring@users.sourceforge.net,
nicolas.dichtel@6wind.com, davem@davemloft.net,
gregkh@linuxfoundation.org, Chandramouli, Dasaratharaman,
maheshkhanwalkar@gmail.com, mikedanese@google.com,
ben@decadent.org.uk, ghackmann@google.com,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pcmcia@lists.infradead.org, linux-watchdog@vger.kernel.org
> -----Original Message-----
> From: Jonathan Corbet [mailto:corbet@lwn.net]
> Sent: Monday, September 19, 2016 19:14
> To: Shuah Khan <shuahkh@osg.samsung.com>
> Cc: Dutt, Sudeep <sudeep.dutt@intel.com>; Dixit, Ashutosh
> <ashutosh.dixit@intel.com>; Winkler, Tomas <tomas.winkler@intel.com>;
> tglx@linutronix.de; wim@iguana.be; linux@roeck-us.net;
> elfring@users.sourceforge.net; nicolas.dichtel@6wind.com;
> davem@davemloft.net; gregkh@linuxfoundation.org; Chandramouli,
> Dasaratharaman <dasaratharaman.chandramouli@intel.com>;
> maheshkhanwalkar@gmail.com; mikedanese@google.com;
> ben@decadent.org.uk; ghackmann@google.com; linux-doc@vger.kernel.org;
> linux-kernel@vger.kernel.org; linux-pcmcia@lists.infradead.org; linux-
> watchdog@vger.kernel.org
> Subject: Re: [PATCH 5/8] samples: move misc-devices/mei example code
> from Documentation
>
> On Mon, 19 Sep 2016 08:47:36 -0600
> Shuah Khan <shuahkh@osg.samsung.com> wrote:
>
> > Move misc-devices/mei examples to samples/mei and remove it from
> > Documentation Makefile. Delete misc-devices/Makefile.
> >
> > Create a new Makefile to build samples/mei. It can be built from top
> > level directory or from mei directory:
>
> This one still has a fair amount of code hiding in the .txt files, but that's a
> separate job.
>
> Acked-by: Jonathan Corbet <corbet@lwn.net>
Shouldn't this update also the MAINTAINERS file?
Tomas
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 5/8] samples: move misc-devices/mei example code from Documentation
2016-09-20 6:17 ` Winkler, Tomas
@ 2016-09-20 17:20 ` Shuah Khan
0 siblings, 0 replies; 23+ messages in thread
From: Shuah Khan @ 2016-09-20 17:20 UTC (permalink / raw)
To: Winkler, Tomas, Jonathan Corbet
Cc: Dutt, Sudeep, Dixit, Ashutosh, tglx@linutronix.de, wim@iguana.be,
linux@roeck-us.net, elfring@users.sourceforge.net,
nicolas.dichtel@6wind.com, davem@davemloft.net,
gregkh@linuxfoundation.org, Chandramouli, Dasaratharaman,
maheshkhanwalkar@gmail.com, mikedanese@google.com,
ben@decadent.org.uk, ghackmann@google.com,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pcmcia@lists.infradead.org, linux-watchdog@vger.kernel.org,
Shuah Khan
On 09/20/2016 12:17 AM, Winkler, Tomas wrote:
>
>
>> -----Original Message-----
>> From: Jonathan Corbet [mailto:corbet@lwn.net]
>> Sent: Monday, September 19, 2016 19:14
>> To: Shuah Khan <shuahkh@osg.samsung.com>
>> Cc: Dutt, Sudeep <sudeep.dutt@intel.com>; Dixit, Ashutosh
>> <ashutosh.dixit@intel.com>; Winkler, Tomas <tomas.winkler@intel.com>;
>> tglx@linutronix.de; wim@iguana.be; linux@roeck-us.net;
>> elfring@users.sourceforge.net; nicolas.dichtel@6wind.com;
>> davem@davemloft.net; gregkh@linuxfoundation.org; Chandramouli,
>> Dasaratharaman <dasaratharaman.chandramouli@intel.com>;
>> maheshkhanwalkar@gmail.com; mikedanese@google.com;
>> ben@decadent.org.uk; ghackmann@google.com; linux-doc@vger.kernel.org;
>> linux-kernel@vger.kernel.org; linux-pcmcia@lists.infradead.org; linux-
>> watchdog@vger.kernel.org
>> Subject: Re: [PATCH 5/8] samples: move misc-devices/mei example code
>> from Documentation
>>
>> On Mon, 19 Sep 2016 08:47:36 -0600
>> Shuah Khan <shuahkh@osg.samsung.com> wrote:
>>
>>> Move misc-devices/mei examples to samples/mei and remove it from
>>> Documentation Makefile. Delete misc-devices/Makefile.
>>>
>>> Create a new Makefile to build samples/mei. It can be built from top
>>> level directory or from mei directory:
>>
>> This one still has a fair amount of code hiding in the .txt files, but that's a
>> separate job.
>>
>> Acked-by: Jonathan Corbet <corbet@lwn.net>
>
> Shouldn't this update also the MAINTAINERS file?
> Tomas
>
It has a catch all F: Documentation/misc-devices/mei/*
Yes. I think it would be a good idea to add a new F: entry
to INTEL MANAGEMENT ENGINE (mei) for these moved files.
I will take care of this in v2.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 6/8] samples: move pcmcia example code from Documentation
2016-09-19 14:47 [PATCH 0/8] Move runnable examples code from Documentation to samples Shuah Khan
` (3 preceding siblings ...)
2016-09-19 14:47 ` [PATCH 5/8] samples: move misc-devices/mei " Shuah Khan
@ 2016-09-19 14:47 ` Shuah Khan
2016-09-19 16:16 ` Jonathan Corbet
2016-09-19 14:47 ` [PATCH 7/8] samples: move timers " Shuah Khan
` (3 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Shuah Khan @ 2016-09-19 14:47 UTC (permalink / raw)
To: corbet, sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim,
linux, elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann
Cc: Shuah Khan, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
Move pcmcia examples to samples and remove it from Documentation
Makefile. Create a new Makefile to build pcmcia. It can be built
from top level directory or from pcmcia directory:
Run make -C samples/pcmcia or cd samples/pcmcia; make
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
Documentation/Makefile | 2 +-
Documentation/pcmcia/.gitignore | 1 -
Documentation/pcmcia/Makefile | 7 -------
Documentation/pcmcia/crc32hash.c | 32 --------------------------------
samples/pcmcia/.gitignore | 1 +
samples/pcmcia/Makefile | 9 +++++++++
samples/pcmcia/crc32hash.c | 32 ++++++++++++++++++++++++++++++++
7 files changed, 43 insertions(+), 41 deletions(-)
delete mode 100644 Documentation/pcmcia/.gitignore
delete mode 100644 Documentation/pcmcia/Makefile
delete mode 100644 Documentation/pcmcia/crc32hash.c
create mode 100644 samples/pcmcia/.gitignore
create mode 100644 samples/pcmcia/Makefile
create mode 100644 samples/pcmcia/crc32hash.c
diff --git a/Documentation/Makefile b/Documentation/Makefile
index ac7d68f..bd5f115 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -1 +1 @@
-subdir-y := blackfin pcmcia timers watchdog
+subdir-y := blackfin timers watchdog
diff --git a/Documentation/pcmcia/.gitignore b/Documentation/pcmcia/.gitignore
deleted file mode 100644
index 53d0813..0000000
--- a/Documentation/pcmcia/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-crc32hash
diff --git a/Documentation/pcmcia/Makefile b/Documentation/pcmcia/Makefile
deleted file mode 100644
index 47a8fa1..0000000
--- a/Documentation/pcmcia/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# List of programs to build
-hostprogs-y := crc32hash
-
-# Tell kbuild to always build the programs
-always := $(hostprogs-y)
-
-HOSTCFLAGS_crc32hash.o += -I$(objtree)/usr/include
diff --git a/Documentation/pcmcia/crc32hash.c b/Documentation/pcmcia/crc32hash.c
deleted file mode 100644
index 44f8bee..0000000
--- a/Documentation/pcmcia/crc32hash.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* crc32hash.c - derived from linux/lib/crc32.c, GNU GPL v2 */
-/* Usage example:
-$ ./crc32hash "Dual Speed"
-*/
-
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-
-static unsigned int crc32(unsigned char const *p, unsigned int len)
-{
- int i;
- unsigned int crc = 0;
- while (len--) {
- crc ^= *p++;
- for (i = 0; i < 8; i++)
- crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0);
- }
- return crc;
-}
-
-int main(int argc, char **argv) {
- unsigned int result;
- if (argc != 2) {
- printf("no string passed as argument\n");
- return -1;
- }
- result = crc32((unsigned char const *)argv[1], strlen(argv[1]));
- printf("0x%x\n", result);
- return 0;
-}
diff --git a/samples/pcmcia/.gitignore b/samples/pcmcia/.gitignore
new file mode 100644
index 0000000..53d0813
--- /dev/null
+++ b/samples/pcmcia/.gitignore
@@ -0,0 +1 @@
+crc32hash
diff --git a/samples/pcmcia/Makefile b/samples/pcmcia/Makefile
new file mode 100644
index 0000000..81a7498
--- /dev/null
+++ b/samples/pcmcia/Makefile
@@ -0,0 +1,9 @@
+CC := $(CROSS_COMPILE)gcc
+CFLAGS := -I../../usr/include
+
+PROGS := crc32hash
+
+all: $(PROGS)
+
+clean:
+ rm -fr $(PROGS)
diff --git a/samples/pcmcia/crc32hash.c b/samples/pcmcia/crc32hash.c
new file mode 100644
index 0000000..44f8bee
--- /dev/null
+++ b/samples/pcmcia/crc32hash.c
@@ -0,0 +1,32 @@
+/* crc32hash.c - derived from linux/lib/crc32.c, GNU GPL v2 */
+/* Usage example:
+$ ./crc32hash "Dual Speed"
+*/
+
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+static unsigned int crc32(unsigned char const *p, unsigned int len)
+{
+ int i;
+ unsigned int crc = 0;
+ while (len--) {
+ crc ^= *p++;
+ for (i = 0; i < 8; i++)
+ crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0);
+ }
+ return crc;
+}
+
+int main(int argc, char **argv) {
+ unsigned int result;
+ if (argc != 2) {
+ printf("no string passed as argument\n");
+ return -1;
+ }
+ result = crc32((unsigned char const *)argv[1], strlen(argv[1]));
+ printf("0x%x\n", result);
+ return 0;
+}
--
2.7.4
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 6/8] samples: move pcmcia example code from Documentation
2016-09-19 14:47 ` [PATCH 6/8] samples: move pcmcia " Shuah Khan
@ 2016-09-19 16:16 ` Jonathan Corbet
0 siblings, 0 replies; 23+ messages in thread
From: Jonathan Corbet @ 2016-09-19 16:16 UTC (permalink / raw)
To: Shuah Khan
Cc: sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim, linux,
elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
On Mon, 19 Sep 2016 08:47:37 -0600
Shuah Khan <shuahkh@osg.samsung.com> wrote:
> Move pcmcia examples to samples and remove it from Documentation
> Makefile. Create a new Makefile to build pcmcia. It can be built
> from top level directory or from pcmcia directory:
Does PCMCIA still exist/work? I guess it probably must somewhere. This
one might better qualify as a "tool."
Documentation/pcmcia/devicetable.txt needs an update, as does MAINTAINERS.
jon
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 7/8] samples: move timers example code from Documentation
2016-09-19 14:47 [PATCH 0/8] Move runnable examples code from Documentation to samples Shuah Khan
` (4 preceding siblings ...)
2016-09-19 14:47 ` [PATCH 6/8] samples: move pcmcia " Shuah Khan
@ 2016-09-19 14:47 ` Shuah Khan
2016-09-19 16:18 ` Jonathan Corbet
2016-09-19 14:47 ` [PATCH 8/8] samples: move watchdog " Shuah Khan
` (2 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Shuah Khan @ 2016-09-19 14:47 UTC (permalink / raw)
To: corbet, sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim,
linux, elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann
Cc: Shuah Khan, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
Move timers examples to samples and remove it from Documentation
Makefile. Create a new Makefile to build timers. It can be built
from top level directory or from timers directory:
Run make -C samples/timers or cd samples/timers; make
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
Documentation/Makefile | 2 +-
Documentation/timers/.gitignore | 1 -
Documentation/timers/Makefile | 5 -
Documentation/timers/hpet_example.c | 294 ------------------------------------
samples/timers/.gitignore | 1 +
samples/timers/Makefile | 15 ++
samples/timers/hpet_example.c | 294 ++++++++++++++++++++++++++++++++++++
7 files changed, 311 insertions(+), 301 deletions(-)
delete mode 100644 Documentation/timers/.gitignore
delete mode 100644 Documentation/timers/Makefile
delete mode 100644 Documentation/timers/hpet_example.c
create mode 100644 samples/timers/.gitignore
create mode 100644 samples/timers/Makefile
create mode 100644 samples/timers/hpet_example.c
diff --git a/Documentation/Makefile b/Documentation/Makefile
index bd5f115..9c3fe11 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -1 +1 @@
-subdir-y := blackfin timers watchdog
+subdir-y := blackfin watchdog
diff --git a/Documentation/timers/.gitignore b/Documentation/timers/.gitignore
deleted file mode 100644
index c5c45d7..0000000
--- a/Documentation/timers/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-hpet_example
diff --git a/Documentation/timers/Makefile b/Documentation/timers/Makefile
deleted file mode 100644
index 6c09ee6..0000000
--- a/Documentation/timers/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# List of programs to build
-hostprogs-$(CONFIG_X86) := hpet_example
-
-# Tell kbuild to always build the programs
-always := $(hostprogs-y)
diff --git a/Documentation/timers/hpet_example.c b/Documentation/timers/hpet_example.c
deleted file mode 100644
index 3ab4993..0000000
--- a/Documentation/timers/hpet_example.c
+++ /dev/null
@@ -1,294 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <memory.h>
-#include <malloc.h>
-#include <time.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/time.h>
-#include <linux/hpet.h>
-
-
-extern void hpet_open_close(int, const char **);
-extern void hpet_info(int, const char **);
-extern void hpet_poll(int, const char **);
-extern void hpet_fasync(int, const char **);
-extern void hpet_read(int, const char **);
-
-#include <sys/poll.h>
-#include <sys/ioctl.h>
-
-struct hpet_command {
- char *command;
- void (*func)(int argc, const char ** argv);
-} hpet_command[] = {
- {
- "open-close",
- hpet_open_close
- },
- {
- "info",
- hpet_info
- },
- {
- "poll",
- hpet_poll
- },
- {
- "fasync",
- hpet_fasync
- },
-};
-
-int
-main(int argc, const char ** argv)
-{
- unsigned int i;
-
- argc--;
- argv++;
-
- if (!argc) {
- fprintf(stderr, "-hpet: requires command\n");
- return -1;
- }
-
-
- for (i = 0; i < (sizeof (hpet_command) / sizeof (hpet_command[0])); i++)
- if (!strcmp(argv[0], hpet_command[i].command)) {
- argc--;
- argv++;
- fprintf(stderr, "-hpet: executing %s\n",
- hpet_command[i].command);
- hpet_command[i].func(argc, argv);
- return 0;
- }
-
- fprintf(stderr, "do_hpet: command %s not implemented\n", argv[0]);
-
- return -1;
-}
-
-void
-hpet_open_close(int argc, const char **argv)
-{
- int fd;
-
- if (argc != 1) {
- fprintf(stderr, "hpet_open_close: device-name\n");
- return;
- }
-
- fd = open(argv[0], O_RDONLY);
- if (fd < 0)
- fprintf(stderr, "hpet_open_close: open failed\n");
- else
- close(fd);
-
- return;
-}
-
-void
-hpet_info(int argc, const char **argv)
-{
- struct hpet_info info;
- int fd;
-
- if (argc != 1) {
- fprintf(stderr, "hpet_info: device-name\n");
- return;
- }
-
- fd = open(argv[0], O_RDONLY);
- if (fd < 0) {
- fprintf(stderr, "hpet_info: open of %s failed\n", argv[0]);
- return;
- }
-
- if (ioctl(fd, HPET_INFO, &info) < 0) {
- fprintf(stderr, "hpet_info: failed to get info\n");
- goto out;
- }
-
- fprintf(stderr, "hpet_info: hi_irqfreq 0x%lx hi_flags 0x%lx ",
- info.hi_ireqfreq, info.hi_flags);
- fprintf(stderr, "hi_hpet %d hi_timer %d\n",
- info.hi_hpet, info.hi_timer);
-
-out:
- close(fd);
- return;
-}
-
-void
-hpet_poll(int argc, const char **argv)
-{
- unsigned long freq;
- int iterations, i, fd;
- struct pollfd pfd;
- struct hpet_info info;
- struct timeval stv, etv;
- struct timezone tz;
- long usec;
-
- if (argc != 3) {
- fprintf(stderr, "hpet_poll: device-name freq iterations\n");
- return;
- }
-
- freq = atoi(argv[1]);
- iterations = atoi(argv[2]);
-
- fd = open(argv[0], O_RDONLY);
-
- if (fd < 0) {
- fprintf(stderr, "hpet_poll: open of %s failed\n", argv[0]);
- return;
- }
-
- if (ioctl(fd, HPET_IRQFREQ, freq) < 0) {
- fprintf(stderr, "hpet_poll: HPET_IRQFREQ failed\n");
- goto out;
- }
-
- if (ioctl(fd, HPET_INFO, &info) < 0) {
- fprintf(stderr, "hpet_poll: failed to get info\n");
- goto out;
- }
-
- fprintf(stderr, "hpet_poll: info.hi_flags 0x%lx\n", info.hi_flags);
-
- if (info.hi_flags && (ioctl(fd, HPET_EPI, 0) < 0)) {
- fprintf(stderr, "hpet_poll: HPET_EPI failed\n");
- goto out;
- }
-
- if (ioctl(fd, HPET_IE_ON, 0) < 0) {
- fprintf(stderr, "hpet_poll, HPET_IE_ON failed\n");
- goto out;
- }
-
- pfd.fd = fd;
- pfd.events = POLLIN;
-
- for (i = 0; i < iterations; i++) {
- pfd.revents = 0;
- gettimeofday(&stv, &tz);
- if (poll(&pfd, 1, -1) < 0)
- fprintf(stderr, "hpet_poll: poll failed\n");
- else {
- long data;
-
- gettimeofday(&etv, &tz);
- usec = stv.tv_sec * 1000000 + stv.tv_usec;
- usec = (etv.tv_sec * 1000000 + etv.tv_usec) - usec;
-
- fprintf(stderr,
- "hpet_poll: expired time = 0x%lx\n", usec);
-
- fprintf(stderr, "hpet_poll: revents = 0x%x\n",
- pfd.revents);
-
- if (read(fd, &data, sizeof(data)) != sizeof(data)) {
- fprintf(stderr, "hpet_poll: read failed\n");
- }
- else
- fprintf(stderr, "hpet_poll: data 0x%lx\n",
- data);
- }
- }
-
-out:
- close(fd);
- return;
-}
-
-static int hpet_sigio_count;
-
-static void
-hpet_sigio(int val)
-{
- fprintf(stderr, "hpet_sigio: called\n");
- hpet_sigio_count++;
-}
-
-void
-hpet_fasync(int argc, const char **argv)
-{
- unsigned long freq;
- int iterations, i, fd, value;
- sig_t oldsig;
- struct hpet_info info;
-
- hpet_sigio_count = 0;
- fd = -1;
-
- if ((oldsig = signal(SIGIO, hpet_sigio)) == SIG_ERR) {
- fprintf(stderr, "hpet_fasync: failed to set signal handler\n");
- return;
- }
-
- if (argc != 3) {
- fprintf(stderr, "hpet_fasync: device-name freq iterations\n");
- goto out;
- }
-
- fd = open(argv[0], O_RDONLY);
-
- if (fd < 0) {
- fprintf(stderr, "hpet_fasync: failed to open %s\n", argv[0]);
- return;
- }
-
-
- if ((fcntl(fd, F_SETOWN, getpid()) == 1) ||
- ((value = fcntl(fd, F_GETFL)) == 1) ||
- (fcntl(fd, F_SETFL, value | O_ASYNC) == 1)) {
- fprintf(stderr, "hpet_fasync: fcntl failed\n");
- goto out;
- }
-
- freq = atoi(argv[1]);
- iterations = atoi(argv[2]);
-
- if (ioctl(fd, HPET_IRQFREQ, freq) < 0) {
- fprintf(stderr, "hpet_fasync: HPET_IRQFREQ failed\n");
- goto out;
- }
-
- if (ioctl(fd, HPET_INFO, &info) < 0) {
- fprintf(stderr, "hpet_fasync: failed to get info\n");
- goto out;
- }
-
- fprintf(stderr, "hpet_fasync: info.hi_flags 0x%lx\n", info.hi_flags);
-
- if (info.hi_flags && (ioctl(fd, HPET_EPI, 0) < 0)) {
- fprintf(stderr, "hpet_fasync: HPET_EPI failed\n");
- goto out;
- }
-
- if (ioctl(fd, HPET_IE_ON, 0) < 0) {
- fprintf(stderr, "hpet_fasync, HPET_IE_ON failed\n");
- goto out;
- }
-
- for (i = 0; i < iterations; i++) {
- (void) pause();
- fprintf(stderr, "hpet_fasync: count = %d\n", hpet_sigio_count);
- }
-
-out:
- signal(SIGIO, oldsig);
-
- if (fd >= 0)
- close(fd);
-
- return;
-}
diff --git a/samples/timers/.gitignore b/samples/timers/.gitignore
new file mode 100644
index 0000000..c5c45d7
--- /dev/null
+++ b/samples/timers/.gitignore
@@ -0,0 +1 @@
+hpet_example
diff --git a/samples/timers/Makefile b/samples/timers/Makefile
new file mode 100644
index 0000000..a5c3c4a
--- /dev/null
+++ b/samples/timers/Makefile
@@ -0,0 +1,15 @@
+ifndef CROSS_COMPILE
+uname_M := $(shell uname -m 2>/dev/null || echo not)
+ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
+
+ifeq ($(ARCH),x86)
+CC := $(CROSS_COMPILE)gcc
+PROGS := hpet_example
+
+all: $(PROGS)
+
+clean:
+ rm -fr $(PROGS)
+
+endif
+endif
diff --git a/samples/timers/hpet_example.c b/samples/timers/hpet_example.c
new file mode 100644
index 0000000..3ab4993
--- /dev/null
+++ b/samples/timers/hpet_example.c
@@ -0,0 +1,294 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <memory.h>
+#include <malloc.h>
+#include <time.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <signal.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <linux/hpet.h>
+
+
+extern void hpet_open_close(int, const char **);
+extern void hpet_info(int, const char **);
+extern void hpet_poll(int, const char **);
+extern void hpet_fasync(int, const char **);
+extern void hpet_read(int, const char **);
+
+#include <sys/poll.h>
+#include <sys/ioctl.h>
+
+struct hpet_command {
+ char *command;
+ void (*func)(int argc, const char ** argv);
+} hpet_command[] = {
+ {
+ "open-close",
+ hpet_open_close
+ },
+ {
+ "info",
+ hpet_info
+ },
+ {
+ "poll",
+ hpet_poll
+ },
+ {
+ "fasync",
+ hpet_fasync
+ },
+};
+
+int
+main(int argc, const char ** argv)
+{
+ unsigned int i;
+
+ argc--;
+ argv++;
+
+ if (!argc) {
+ fprintf(stderr, "-hpet: requires command\n");
+ return -1;
+ }
+
+
+ for (i = 0; i < (sizeof (hpet_command) / sizeof (hpet_command[0])); i++)
+ if (!strcmp(argv[0], hpet_command[i].command)) {
+ argc--;
+ argv++;
+ fprintf(stderr, "-hpet: executing %s\n",
+ hpet_command[i].command);
+ hpet_command[i].func(argc, argv);
+ return 0;
+ }
+
+ fprintf(stderr, "do_hpet: command %s not implemented\n", argv[0]);
+
+ return -1;
+}
+
+void
+hpet_open_close(int argc, const char **argv)
+{
+ int fd;
+
+ if (argc != 1) {
+ fprintf(stderr, "hpet_open_close: device-name\n");
+ return;
+ }
+
+ fd = open(argv[0], O_RDONLY);
+ if (fd < 0)
+ fprintf(stderr, "hpet_open_close: open failed\n");
+ else
+ close(fd);
+
+ return;
+}
+
+void
+hpet_info(int argc, const char **argv)
+{
+ struct hpet_info info;
+ int fd;
+
+ if (argc != 1) {
+ fprintf(stderr, "hpet_info: device-name\n");
+ return;
+ }
+
+ fd = open(argv[0], O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "hpet_info: open of %s failed\n", argv[0]);
+ return;
+ }
+
+ if (ioctl(fd, HPET_INFO, &info) < 0) {
+ fprintf(stderr, "hpet_info: failed to get info\n");
+ goto out;
+ }
+
+ fprintf(stderr, "hpet_info: hi_irqfreq 0x%lx hi_flags 0x%lx ",
+ info.hi_ireqfreq, info.hi_flags);
+ fprintf(stderr, "hi_hpet %d hi_timer %d\n",
+ info.hi_hpet, info.hi_timer);
+
+out:
+ close(fd);
+ return;
+}
+
+void
+hpet_poll(int argc, const char **argv)
+{
+ unsigned long freq;
+ int iterations, i, fd;
+ struct pollfd pfd;
+ struct hpet_info info;
+ struct timeval stv, etv;
+ struct timezone tz;
+ long usec;
+
+ if (argc != 3) {
+ fprintf(stderr, "hpet_poll: device-name freq iterations\n");
+ return;
+ }
+
+ freq = atoi(argv[1]);
+ iterations = atoi(argv[2]);
+
+ fd = open(argv[0], O_RDONLY);
+
+ if (fd < 0) {
+ fprintf(stderr, "hpet_poll: open of %s failed\n", argv[0]);
+ return;
+ }
+
+ if (ioctl(fd, HPET_IRQFREQ, freq) < 0) {
+ fprintf(stderr, "hpet_poll: HPET_IRQFREQ failed\n");
+ goto out;
+ }
+
+ if (ioctl(fd, HPET_INFO, &info) < 0) {
+ fprintf(stderr, "hpet_poll: failed to get info\n");
+ goto out;
+ }
+
+ fprintf(stderr, "hpet_poll: info.hi_flags 0x%lx\n", info.hi_flags);
+
+ if (info.hi_flags && (ioctl(fd, HPET_EPI, 0) < 0)) {
+ fprintf(stderr, "hpet_poll: HPET_EPI failed\n");
+ goto out;
+ }
+
+ if (ioctl(fd, HPET_IE_ON, 0) < 0) {
+ fprintf(stderr, "hpet_poll, HPET_IE_ON failed\n");
+ goto out;
+ }
+
+ pfd.fd = fd;
+ pfd.events = POLLIN;
+
+ for (i = 0; i < iterations; i++) {
+ pfd.revents = 0;
+ gettimeofday(&stv, &tz);
+ if (poll(&pfd, 1, -1) < 0)
+ fprintf(stderr, "hpet_poll: poll failed\n");
+ else {
+ long data;
+
+ gettimeofday(&etv, &tz);
+ usec = stv.tv_sec * 1000000 + stv.tv_usec;
+ usec = (etv.tv_sec * 1000000 + etv.tv_usec) - usec;
+
+ fprintf(stderr,
+ "hpet_poll: expired time = 0x%lx\n", usec);
+
+ fprintf(stderr, "hpet_poll: revents = 0x%x\n",
+ pfd.revents);
+
+ if (read(fd, &data, sizeof(data)) != sizeof(data)) {
+ fprintf(stderr, "hpet_poll: read failed\n");
+ }
+ else
+ fprintf(stderr, "hpet_poll: data 0x%lx\n",
+ data);
+ }
+ }
+
+out:
+ close(fd);
+ return;
+}
+
+static int hpet_sigio_count;
+
+static void
+hpet_sigio(int val)
+{
+ fprintf(stderr, "hpet_sigio: called\n");
+ hpet_sigio_count++;
+}
+
+void
+hpet_fasync(int argc, const char **argv)
+{
+ unsigned long freq;
+ int iterations, i, fd, value;
+ sig_t oldsig;
+ struct hpet_info info;
+
+ hpet_sigio_count = 0;
+ fd = -1;
+
+ if ((oldsig = signal(SIGIO, hpet_sigio)) == SIG_ERR) {
+ fprintf(stderr, "hpet_fasync: failed to set signal handler\n");
+ return;
+ }
+
+ if (argc != 3) {
+ fprintf(stderr, "hpet_fasync: device-name freq iterations\n");
+ goto out;
+ }
+
+ fd = open(argv[0], O_RDONLY);
+
+ if (fd < 0) {
+ fprintf(stderr, "hpet_fasync: failed to open %s\n", argv[0]);
+ return;
+ }
+
+
+ if ((fcntl(fd, F_SETOWN, getpid()) == 1) ||
+ ((value = fcntl(fd, F_GETFL)) == 1) ||
+ (fcntl(fd, F_SETFL, value | O_ASYNC) == 1)) {
+ fprintf(stderr, "hpet_fasync: fcntl failed\n");
+ goto out;
+ }
+
+ freq = atoi(argv[1]);
+ iterations = atoi(argv[2]);
+
+ if (ioctl(fd, HPET_IRQFREQ, freq) < 0) {
+ fprintf(stderr, "hpet_fasync: HPET_IRQFREQ failed\n");
+ goto out;
+ }
+
+ if (ioctl(fd, HPET_INFO, &info) < 0) {
+ fprintf(stderr, "hpet_fasync: failed to get info\n");
+ goto out;
+ }
+
+ fprintf(stderr, "hpet_fasync: info.hi_flags 0x%lx\n", info.hi_flags);
+
+ if (info.hi_flags && (ioctl(fd, HPET_EPI, 0) < 0)) {
+ fprintf(stderr, "hpet_fasync: HPET_EPI failed\n");
+ goto out;
+ }
+
+ if (ioctl(fd, HPET_IE_ON, 0) < 0) {
+ fprintf(stderr, "hpet_fasync, HPET_IE_ON failed\n");
+ goto out;
+ }
+
+ for (i = 0; i < iterations; i++) {
+ (void) pause();
+ fprintf(stderr, "hpet_fasync: count = %d\n", hpet_sigio_count);
+ }
+
+out:
+ signal(SIGIO, oldsig);
+
+ if (fd >= 0)
+ close(fd);
+
+ return;
+}
--
2.7.4
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 7/8] samples: move timers example code from Documentation
2016-09-19 14:47 ` [PATCH 7/8] samples: move timers " Shuah Khan
@ 2016-09-19 16:18 ` Jonathan Corbet
0 siblings, 0 replies; 23+ messages in thread
From: Jonathan Corbet @ 2016-09-19 16:18 UTC (permalink / raw)
To: Shuah Khan
Cc: sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim, linux,
elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
On Mon, 19 Sep 2016 08:47:38 -0600
Shuah Khan <shuahkh@osg.samsung.com> wrote:
> Move timers examples to samples and remove it from Documentation
> Makefile. Create a new Makefile to build timers. It can be built
> from top level directory or from timers directory:
Documentation/timers/hpet.txt needs updating. Otherwise
Acked-by: Jonathan Corbet <corbet@lwn.net>
jon
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 8/8] samples: move watchdog example code from Documentation
2016-09-19 14:47 [PATCH 0/8] Move runnable examples code from Documentation to samples Shuah Khan
` (5 preceding siblings ...)
2016-09-19 14:47 ` [PATCH 7/8] samples: move timers " Shuah Khan
@ 2016-09-19 14:47 ` Shuah Khan
2016-09-19 16:20 ` Jonathan Corbet
2016-09-19 15:42 ` [PATCH 0/8] Move runnable examples code from Documentation to samples Jani Nikula
[not found] ` <35cb90958701b063c5dd9874b08b5c5e970c0ce6.1474073857.git.shuahkh@osg.samsung.com>
8 siblings, 1 reply; 23+ messages in thread
From: Shuah Khan @ 2016-09-19 14:47 UTC (permalink / raw)
To: corbet, sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim,
linux, elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann
Cc: Shuah Khan, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
Move watchdog examples to samples and remove it from Documentation
Makefile. Create a new Makefile to build watchdog. It can be built
from top level directory or from watchdog directory:
Run make -C samples/watchdog or cd samples/watchdog; make
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
Documentation/Makefile | 2 +-
Documentation/watchdog/Makefile | 1 -
Documentation/watchdog/src/.gitignore | 1 -
Documentation/watchdog/src/Makefile | 5 -----
Documentation/watchdog/src/watchdog-simple.c | 24 ------------------------
samples/watchdog/.gitignore | 1 +
samples/watchdog/Makefile | 8 ++++++++
samples/watchdog/watchdog-simple.c | 24 ++++++++++++++++++++++++
8 files changed, 34 insertions(+), 32 deletions(-)
delete mode 100644 Documentation/watchdog/Makefile
delete mode 100644 Documentation/watchdog/src/.gitignore
delete mode 100644 Documentation/watchdog/src/Makefile
delete mode 100644 Documentation/watchdog/src/watchdog-simple.c
create mode 100644 samples/watchdog/.gitignore
create mode 100644 samples/watchdog/Makefile
create mode 100644 samples/watchdog/watchdog-simple.c
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 9c3fe11..8435965 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -1 +1 @@
-subdir-y := blackfin watchdog
+subdir-y := blackfin
diff --git a/Documentation/watchdog/Makefile b/Documentation/watchdog/Makefile
deleted file mode 100644
index 6018f45..0000000
--- a/Documentation/watchdog/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-subdir-y := src
diff --git a/Documentation/watchdog/src/.gitignore b/Documentation/watchdog/src/.gitignore
deleted file mode 100644
index ff0ebb5..0000000
--- a/Documentation/watchdog/src/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-watchdog-simple
diff --git a/Documentation/watchdog/src/Makefile b/Documentation/watchdog/src/Makefile
deleted file mode 100644
index 47be791..0000000
--- a/Documentation/watchdog/src/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# List of programs to build
-hostprogs-y := watchdog-simple
-
-# Tell kbuild to always build the programs
-always := $(hostprogs-y)
diff --git a/Documentation/watchdog/src/watchdog-simple.c b/Documentation/watchdog/src/watchdog-simple.c
deleted file mode 100644
index ba45803..0000000
--- a/Documentation/watchdog/src/watchdog-simple.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-int main(void)
-{
- int fd = open("/dev/watchdog", O_WRONLY);
- int ret = 0;
- if (fd == -1) {
- perror("watchdog");
- exit(EXIT_FAILURE);
- }
- while (1) {
- ret = write(fd, "\0", 1);
- if (ret != 1) {
- ret = -1;
- break;
- }
- sleep(10);
- }
- close(fd);
- return ret;
-}
diff --git a/samples/watchdog/.gitignore b/samples/watchdog/.gitignore
new file mode 100644
index 0000000..ff0ebb5
--- /dev/null
+++ b/samples/watchdog/.gitignore
@@ -0,0 +1 @@
+watchdog-simple
diff --git a/samples/watchdog/Makefile b/samples/watchdog/Makefile
new file mode 100644
index 0000000..9b53d89
--- /dev/null
+++ b/samples/watchdog/Makefile
@@ -0,0 +1,8 @@
+CC := $(CROSS_COMPILE)gcc
+PROGS := watchdog-simple
+
+all: $(PROGS)
+
+clean:
+ rm -fr $(PROGS)
+
diff --git a/samples/watchdog/watchdog-simple.c b/samples/watchdog/watchdog-simple.c
new file mode 100644
index 0000000..ba45803
--- /dev/null
+++ b/samples/watchdog/watchdog-simple.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+int main(void)
+{
+ int fd = open("/dev/watchdog", O_WRONLY);
+ int ret = 0;
+ if (fd == -1) {
+ perror("watchdog");
+ exit(EXIT_FAILURE);
+ }
+ while (1) {
+ ret = write(fd, "\0", 1);
+ if (ret != 1) {
+ ret = -1;
+ break;
+ }
+ sleep(10);
+ }
+ close(fd);
+ return ret;
+}
--
2.7.4
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 8/8] samples: move watchdog example code from Documentation
2016-09-19 14:47 ` [PATCH 8/8] samples: move watchdog " Shuah Khan
@ 2016-09-19 16:20 ` Jonathan Corbet
0 siblings, 0 replies; 23+ messages in thread
From: Jonathan Corbet @ 2016-09-19 16:20 UTC (permalink / raw)
To: Shuah Khan
Cc: sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim, linux,
elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
On Mon, 19 Sep 2016 08:47:39 -0600
Shuah Khan <shuahkh@osg.samsung.com> wrote:
> Move watchdog examples to samples and remove it from Documentation
> Makefile. Create a new Makefile to build watchdog. It can be built
> from top level directory or from watchdog directory:
Updates needed to watchdog-api.txt and wdt.txt; probably MAINTAINERS too.
(In all of these cases, please feel free to carry the doc file updates
with the rest, they don't need to come through me).
jon
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 0/8] Move runnable examples code from Documentation to samples
2016-09-19 14:47 [PATCH 0/8] Move runnable examples code from Documentation to samples Shuah Khan
` (6 preceding siblings ...)
2016-09-19 14:47 ` [PATCH 8/8] samples: move watchdog " Shuah Khan
@ 2016-09-19 15:42 ` Jani Nikula
[not found] ` <35cb90958701b063c5dd9874b08b5c5e970c0ce6.1474073857.git.shuahkh@osg.samsung.com>
8 siblings, 0 replies; 23+ messages in thread
From: Jani Nikula @ 2016-09-19 15:42 UTC (permalink / raw)
To: Shuah Khan, corbet, sudeep.dutt, ashutosh.dixit, tomas.winkler,
tglx, wim, linux, elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann
Cc: Shuah Khan, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
On Mon, 19 Sep 2016, Shuah Khan <shuahkh@osg.samsung.com> wrote:
> Move runnable examples code from Documentation to samples. I moved
> just the example code, and left documentation files as is.
FWIW I like this.
BR,
Jani.
--
Jani Nikula, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 23+ messages in thread[parent not found: <35cb90958701b063c5dd9874b08b5c5e970c0ce6.1474073857.git.shuahkh@osg.samsung.com>]
* Re: [PATCH 4/8] samples: move mic/mpssd example code from Documentation
[not found] ` <35cb90958701b063c5dd9874b08b5c5e970c0ce6.1474073857.git.shuahkh@osg.samsung.com>
@ 2016-09-19 16:11 ` Jonathan Corbet
0 siblings, 0 replies; 23+ messages in thread
From: Jonathan Corbet @ 2016-09-19 16:11 UTC (permalink / raw)
To: Shuah Khan
Cc: sudeep.dutt, ashutosh.dixit, tomas.winkler, tglx, wim, linux,
elfring, nicolas.dichtel, davem, gregkh,
dasaratharaman.chandramouli, maheshkhanwalkar, mikedanese, ben,
ghackmann, linux-doc, linux-kernel, linux-pcmcia, linux-watchdog
On Mon, 19 Sep 2016 08:47:35 -0600
Shuah Khan <shuahkh@osg.samsung.com> wrote:
> Move mic/mpssd examples to samples and remove it from Documentation
> Makefile. Create a new Makefile to build mic/mpssd. It can be built
> from top level directory or from mic/mpssd directory:
>
> Run make -C samples/mic/mpssd or cd samples/mic/mpssd; make
This one seems good as-is
Acked-by: Jonathan Corbet <corbet@lwn.net>
jon
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 23+ messages in thread