Re: [PATCH 5/8] samples: move misc-devices/mei example code from Documentation

2016-09-19 Thread Jonathan Corbet
On Mon, 19 Sep 2016 08:47:36 -0600
Shuah Khan  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 

jon

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 4/8] samples: move mic/mpssd example code from Documentation

2016-09-19 Thread Jonathan Corbet
On Mon, 19 Sep 2016 08:47:35 -0600
Shuah Khan  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 

jon

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 3/8] samples: move laptops example code from Documentation

2016-09-19 Thread Jonathan Corbet
On Mon, 19 Sep 2016 08:47:34 -0600
Shuah Khan  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

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 2/8] samples: move auxdisplay example code from Documentation

2016-09-19 Thread Jonathan Corbet
On Mon, 19 Sep 2016 08:47:33 -0600
Shuah Khan  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

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 1/8] samples: move accounting example code from Documentation

2016-09-19 Thread Jonathan Corbet
On Mon, 19 Sep 2016 08:47:32 -0600
Shuah Khan  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

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 0/8] Move runnable examples code from Documentation to samples

2016-09-19 Thread Jani Nikula
On Mon, 19 Sep 2016, Shuah Khan  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

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 1/8] samples: move accounting example code from Documentation

2016-09-19 Thread Shuah Khan
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 
---
 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..000
--- 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..000
--- 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..000
--- a/Documentation/accounting/getdelays.c
+++ /dev/null
@@ -1,550 +0,0 @@
-/* getdelays.c
- *
- * Utility to get per-pid and per-tgid delay accounting statistics
- * Also illustrates usage of the taskstats interface
- *
- * Copyright (C) Shailabh Nagar, IBM Corp. 2005
- * Copyright (C) Balbir Singh, IBM Corp. 2006
- * Copyright (c) Jay Lan, SGI. 2006
- *
- * Compile with
- * gcc -I/usr/src/linux/include getdelays.c -o getdelays
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-
-/*
- * Generic macros for dealing with netlink sockets. Might be duplicated
- * elsewhere. It is recommended that commercial grade applications use
- * libnl or libnetlink and use the interfaces provided by the library
- */
-#define GENLMSG_DATA(glh)  ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
-#define GENLMSG_PAYLOAD(glh)   (NLMSG_PAYLOAD(glh, 0) - GENL_HDRLEN)
-#define NLA_DATA(na)   ((void *)((char*)(na) + NLA_HDRLEN))
-#define NLA_PAYLOAD(len)   (len - NLA_HDRLEN)
-
-#define err(code, fmt, arg...) \
-   do {\
-   fprintf(stderr, fmt, ##arg);\
-   exit(code); \
-   } while (0)
-
-int done;
-int rcvbufsz;
-char name[100];
-int dbg;
-int print_delays;
-int print_io_accounting;
-int print_task_context_switch_counts;
-
-#define PRINTF(fmt, arg...) {  \
-   if (dbg) {  \
-   printf(fmt, ##arg); \
-   }   \
-   }
-
-/* Maximum size of response requested or message sent */
-#define MAX_MSG_SIZE   1024
-/* Maximum number of cpus expected to be specified in a cpumask */
-#define MAX_CPUS   32
-
-struct msgtemplate {
-   struct nlmsghdr n;
-   struct genlmsghdr g;
-   char buf[MAX_MSG_SIZE];
-};
-
-char cpumask[100+6*MAX_CPUS];
-
-static void usage(void)
-{
-   fprintf(stderr, "getdelays [-dilv] [-w logfile] [-r bufsize] "
-   "[-m cpumask] [-t tgid] [-p pid]\n");
-   fprintf(stderr, "  -d: print delayacct stats\n");
-   fprintf(stderr, "  -i: print IO accounting (works only with -p)\n");
-   fprintf(stderr, "  -l: listen forever\n");
-   fprintf(stderr, "  -v: debug on\n");
-   fprintf(stderr, "  -C: container path\n");
-}
-
-/*
- * Create a raw netlink socket and bind
- */
-static int create_nl_socket(int protocol)
-{
-   int fd;
-   struct sockaddr_nl local;
-
-   fd = socket(AF_NETLINK, SOCK_RAW, protocol);
-   if (fd < 0)
-   return -1;
-
-   if (rcvbufsz)
-   if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF,
-   , sizeof(rcvbufsz)) < 0) {
-   

[PATCH 5/8] samples: move misc-devices/mei example code from Documentation

2016-09-19 Thread Shuah Khan
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 
---
 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..000
--- 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..000
--- 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..000
--- 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..000
--- 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..000
--- 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-...@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 

[PATCH 7/8] samples: move timers example code from Documentation

2016-09-19 Thread Shuah Khan
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 
---
 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..000
--- 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..000
--- 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..000
--- a/Documentation/timers/hpet_example.c
+++ /dev/null
@@ -1,294 +0,0 @@
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-
-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 
-#include 
-
-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 inti;
-
-   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_infoinfo;
-   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, ) < 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   

[PATCH 8/8] samples: move watchdog example code from Documentation

2016-09-19 Thread Shuah Khan
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 
---
 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..000
--- 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..000
--- 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..000
--- 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..000
--- a/Documentation/watchdog/src/watchdog-simple.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include 
-#include 
-#include 
-#include 
-
-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 000..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 000..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 000..ba45803
--- /dev/null
+++ b/samples/watchdog/watchdog-simple.c
@@ -0,0 +1,24 @@
+#include 
+#include 
+#include 
+#include 
+
+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


___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 0/8] Move runnable examples code from Documentation to samples

2016-09-19 Thread Shuah Khan
Move runnable examples code from Documentation to samples. I moved
just the example code, and left documentation files as is.

blackfin gptimers example code needs a bit of special handling since
it is a module. I will address it in a separate patch. 00-Index files
need to be updated due to this move which will be done another patch.

Shuah Khan (8):
  samples: move accounting example code from Documentation
  samples: move auxdisplay example code from Documentation
  samples: move laptops example code from Documentation
  samples: move mic/mpssd example code from Documentation
  samples: move misc-devices/mei example code from Documentation
  samples: move pcmcia example code from Documentation
  samples: move timers example code from Documentation
  samples: move watchdog example code from Documentation

 Documentation/Makefile   |3 +-
 Documentation/accounting/.gitignore  |1 -
 Documentation/accounting/Makefile|7 -
 Documentation/accounting/getdelays.c |  550 ---
 Documentation/auxdisplay/.gitignore  |1 -
 Documentation/auxdisplay/Makefile|7 -
 Documentation/auxdisplay/cfag12864b-example.c|  281 
 Documentation/laptops/.gitignore |1 -
 Documentation/laptops/Makefile   |5 -
 Documentation/laptops/dslm.c |  166 --
 Documentation/mic/Makefile   |1 -
 Documentation/mic/mpssd/.gitignore   |1 -
 Documentation/mic/mpssd/Makefile |   21 -
 Documentation/mic/mpssd/micctrl  |  173 --
 Documentation/mic/mpssd/mpss |  200 ---
 Documentation/mic/mpssd/mpssd.c  | 1826 --
 Documentation/mic/mpssd/mpssd.h  |  103 --
 Documentation/mic/mpssd/sysfs.c  |  102 --
 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 --
 Documentation/pcmcia/.gitignore  |1 -
 Documentation/pcmcia/Makefile|7 -
 Documentation/pcmcia/crc32hash.c |   32 -
 Documentation/timers/.gitignore  |1 -
 Documentation/timers/Makefile|5 -
 Documentation/timers/hpet_example.c  |  294 
 Documentation/watchdog/Makefile  |1 -
 Documentation/watchdog/src/.gitignore|1 -
 Documentation/watchdog/src/Makefile  |5 -
 Documentation/watchdog/src/watchdog-simple.c |   24 -
 samples/accounting/.gitignore|1 +
 samples/accounting/Makefile  |9 +
 samples/accounting/getdelays.c   |  550 +++
 samples/auxdisplay/.gitignore|1 +
 samples/auxdisplay/Makefile  |9 +
 samples/auxdisplay/cfag12864b-example.c  |  281 
 samples/laptops/.gitignore   |1 +
 samples/laptops/Makefile |9 +
 samples/laptops/dslm.c   |  166 ++
 samples/mei/.gitignore   |1 +
 samples/mei/Makefile |9 +
 samples/mei/TODO |2 +
 samples/mei/mei-amt-version.c|  479 ++
 samples/mic/mpssd/.gitignore |1 +
 samples/mic/mpssd/Makefile   |   27 +
 samples/mic/mpssd/micctrl|  173 ++
 samples/mic/mpssd/mpss   |  200 +++
 samples/mic/mpssd/mpssd.c| 1826 ++
 samples/mic/mpssd/mpssd.h|  103 ++
 samples/mic/mpssd/sysfs.c|  102 ++
 samples/pcmcia/.gitignore|1 +
 samples/pcmcia/Makefile  |9 +
 samples/pcmcia/crc32hash.c   |   32 +
 samples/timers/.gitignore|1 +
 samples/timers/Makefile  |   15 +
 samples/timers/hpet_example.c|  294 
 samples/watchdog/.gitignore  |1 +
 samples/watchdog/Makefile|8 +
 samples/watchdog/watchdog-simple.c   |   24 +
 62 files changed, 4336 insertions(+), 4307 deletions(-)
 delete mode 100644 Documentation/accounting/.gitignore
 delete mode 100644 Documentation/accounting/Makefile
 delete mode 100644 Documentation/accounting/getdelays.c
 delete mode 100644 Documentation/auxdisplay/.gitignore
 delete mode 100644 Documentation/auxdisplay/Makefile
 delete mode 100644 Documentation/auxdisplay/cfag12864b-example.c
 delete mode 100644 

[PATCH 3/8] samples: move laptops example code from Documentation

2016-09-19 Thread Shuah Khan
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 
---
 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..000
--- 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..000
--- 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..000
--- a/Documentation/laptops/dslm.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * dslm.c
- * Simple Disk Sleep Monitor
- *  by Bartek Kania
- * Licensed under the GPL
- */
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#ifdef DEBUG
-#define D(x) x
-#else
-#define D(x)
-#endif
-
-int endit = 0;
-
-/* Check if the disk is in powersave-mode
- * Most of the code is stolen from hdparm.
- * 1 = active, 0 = standby/sleep, -1 = unknown */
-static int check_powermode(int fd)
-{
-unsigned char args[4] = {WIN_CHECKPOWERMODE1,0,0,0};
-int state;
-
-if (ioctl(fd, HDIO_DRIVE_CMD, )
-   && (args[0] = WIN_CHECKPOWERMODE2) /* try again with 0x98 */
-   && ioctl(fd, HDIO_DRIVE_CMD, )) {
-   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();
-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",