All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Move runnable examples code from Documentation to samples
@ 2016-09-21 19:47 Shuah Khan
  2016-09-21 19:47 ` [PATCH v2 1/4] samples: move misc-devices/mei example code from Documentation Shuah Khan
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Shuah Khan @ 2016-09-21 19:47 UTC (permalink / raw)
  To: corbet, tomas.winkler, tglx, clemens, wim, linux, davem, geert,
	akpm, gregkh, kvalo, mchehab, ghackmann, ben, maheshkhanwalkar
  Cc: Shuah Khan, linux-doc, linux-kernel, linux-watchdog

Move runnable examples code from Documentation to samples. I moved
just the example code, and left documentation files as is.

I dropped accounting, laptops, and pcmcia from this v2 series as per
the v1 feedback on these being a better fit under tools. I will send
a separate v2 for them.

If v2 patches look good, and if I get an okay, I will try to get these
into 4.9-rc1

Changes since v1:
- Updated location information in .txt for timers, watchdog, and
  auxdisplay
- Updated MAINTAINERS file for misc-devices/mei based on feedback
  from Tomas Winkler
- Added Acked-by from Jon Corbet for timers, and misc-devices/mei

Shuah Khan (4):
  samples: move misc-devices/mei example code from Documentation
  samples: move timers example code from Documentation
  samples: move watchdog example code from Documentation
  samples: move auxdisplay example code from Documentation

 Documentation/Makefile                           |   4 +-
 Documentation/auxdisplay/.gitignore              |   1 -
 Documentation/auxdisplay/Makefile                |   7 -
 Documentation/auxdisplay/cfag12864b              |   2 +-
 Documentation/auxdisplay/cfag12864b-example.c    | 281 -------------
 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/timers/.gitignore                  |   1 -
 Documentation/timers/Makefile                    |   5 -
 Documentation/timers/hpet.txt                    |   2 +-
 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 --
 Documentation/watchdog/watchdog-api.txt          |   2 +-
 Documentation/watchdog/wdt.txt                   |   2 +-
 MAINTAINERS                                      |   1 +
 samples/auxdisplay/.gitignore                    |   1 +
 samples/auxdisplay/Makefile                      |   9 +
 samples/auxdisplay/cfag12864b-example.c          | 281 +++++++++++++
 samples/mei/.gitignore                           |   1 +
 samples/mei/Makefile                             |   9 +
 samples/mei/TODO                                 |   2 +
 samples/mei/mei-amt-version.c                    | 479 +++++++++++++++++++++++
 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 ++
 34 files changed, 1132 insertions(+), 1114 deletions(-)
 delete mode 100644 Documentation/auxdisplay/.gitignore
 delete mode 100644 Documentation/auxdisplay/Makefile
 delete mode 100644 Documentation/auxdisplay/cfag12864b-example.c
 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
 delete mode 100644 Documentation/timers/.gitignore
 delete mode 100644 Documentation/timers/Makefile
 delete mode 100644 Documentation/timers/hpet_example.c
 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/auxdisplay/.gitignore
 create mode 100644 samples/auxdisplay/Makefile
 create mode 100644 samples/auxdisplay/cfag12864b-example.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
 create mode 100644 samples/timers/.gitignore
 create mode 100644 samples/timers/Makefile
 create mode 100644 samples/timers/hpet_example.c
 create mode 100644 samples/watchdog/.gitignore
 create mode 100644 samples/watchdog/Makefile
 create mode 100644 samples/watchdog/watchdog-simple.c

-- 
2.7.4

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/4] samples: move misc-devices/mei example code from Documentation
  2016-09-21 19:47 [PATCH v2 0/4] Move runnable examples code from Documentation to samples Shuah Khan
@ 2016-09-21 19:47 ` Shuah Khan
  2016-09-21 19:52   ` Greg KH
  2016-09-21 21:00   ` Winkler, Tomas
  2016-09-21 19:47 ` [PATCH v2 2/4] samples: move timers " Shuah Khan
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 10+ messages in thread
From: Shuah Khan @ 2016-09-21 19:47 UTC (permalink / raw)
  To: corbet, tomas.winkler, tglx, clemens, wim, linux, davem, geert,
	akpm, gregkh, kvalo, mchehab, ghackmann, ben, maheshkhanwalkar
  Cc: Shuah Khan, linux-doc, linux-kernel, 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

Acked-by: Jonathan Corbet <corbet@lwn.net>
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 -----------------------
 MAINTAINERS                                      |   1 +
 samples/mei/.gitignore                           |   1 +
 samples/mei/Makefile                             |   9 +
 samples/mei/TODO                                 |   2 +
 samples/mei/mei-amt-version.c                    | 479 +++++++++++++++++++++++
 11 files changed, 493 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 80b5bdc..3c2a207 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -1,2 +1,2 @@
 subdir-y := accounting auxdisplay blackfin \
-	laptops misc-devices pcmcia timers watchdog
+	laptops 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/MAINTAINERS b/MAINTAINERS
index a5e1270..afd3577 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6261,6 +6261,7 @@ F:	include/linux/mei_cl_bus.h
 F:	drivers/misc/mei/*
 F:	drivers/watchdog/mei_wdt.c
 F:	Documentation/misc-devices/mei/*
+F:	samples/mei/*
 
 INTEL MIC DRIVERS (mic)
 M:	Sudeep Dutt <sudeep.dutt@intel.com>
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] 10+ messages in thread

* [PATCH v2 2/4] samples: move timers example code from Documentation
  2016-09-21 19:47 [PATCH v2 0/4] Move runnable examples code from Documentation to samples Shuah Khan
  2016-09-21 19:47 ` [PATCH v2 1/4] samples: move misc-devices/mei example code from Documentation Shuah Khan
@ 2016-09-21 19:47 ` Shuah Khan
  2016-09-21 21:47   ` Clemens Ladisch
  2016-09-21 19:47 ` [PATCH v2 3/4] samples: move watchdog " Shuah Khan
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Shuah Khan @ 2016-09-21 19:47 UTC (permalink / raw)
  To: corbet, tomas.winkler, tglx, clemens, wim, linux, davem, geert,
	akpm, gregkh, kvalo, mchehab, ghackmann, ben, maheshkhanwalkar
  Cc: Shuah Khan, linux-doc, linux-kernel, 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

Acked-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
 Documentation/Makefile              |   2 +-
 Documentation/timers/.gitignore     |   1 -
 Documentation/timers/Makefile       |   5 -
 Documentation/timers/hpet.txt       |   2 +-
 Documentation/timers/hpet_example.c | 294 ------------------------------------
 samples/timers/.gitignore           |   1 +
 samples/timers/Makefile             |  15 ++
 samples/timers/hpet_example.c       | 294 ++++++++++++++++++++++++++++++++++++
 8 files changed, 312 insertions(+), 302 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 3c2a207..fc386b7 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -1,2 +1,2 @@
 subdir-y := accounting auxdisplay blackfin \
-	laptops pcmcia timers watchdog
+	laptops pcmcia 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.txt b/Documentation/timers/hpet.txt
index a484d2c..895345e 100644
--- a/Documentation/timers/hpet.txt
+++ b/Documentation/timers/hpet.txt
@@ -25,4 +25,4 @@ arch/x86/kernel/hpet.c.
 
 The driver provides a userspace API which resembles the API found in the
 RTC driver framework.  An example user space program is provided in
-file:Documentation/timers/hpet_example.c
+file:samples/timers/hpet_example.c
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] 10+ messages in thread

* [PATCH v2 3/4] samples: move watchdog example code from Documentation
  2016-09-21 19:47 [PATCH v2 0/4] Move runnable examples code from Documentation to samples Shuah Khan
  2016-09-21 19:47 ` [PATCH v2 1/4] samples: move misc-devices/mei example code from Documentation Shuah Khan
  2016-09-21 19:47 ` [PATCH v2 2/4] samples: move timers " Shuah Khan
@ 2016-09-21 19:47 ` Shuah Khan
  2016-09-21 19:47 ` [PATCH v2 4/4] samples: move auxdisplay " Shuah Khan
  2016-09-21 20:18   ` Jonathan Corbet
  4 siblings, 0 replies; 10+ messages in thread
From: Shuah Khan @ 2016-09-21 19:47 UTC (permalink / raw)
  To: corbet, tomas.winkler, tglx, clemens, wim, linux, davem, geert,
	akpm, gregkh, kvalo, mchehab, ghackmann, ben, maheshkhanwalkar
  Cc: Shuah Khan, linux-doc, linux-kernel, 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 ------------------------
 Documentation/watchdog/watchdog-api.txt      |  2 +-
 Documentation/watchdog/wdt.txt               |  2 +-
 samples/watchdog/.gitignore                  |  1 +
 samples/watchdog/Makefile                    |  8 ++++++++
 samples/watchdog/watchdog-simple.c           | 24 ++++++++++++++++++++++++
 10 files changed, 36 insertions(+), 34 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 fc386b7..b2210b7 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -1,2 +1,2 @@
 subdir-y := accounting auxdisplay blackfin \
-	laptops pcmcia watchdog
+	laptops pcmcia
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/Documentation/watchdog/watchdog-api.txt b/Documentation/watchdog/watchdog-api.txt
index b3a701f..0e62ba3 100644
--- a/Documentation/watchdog/watchdog-api.txt
+++ b/Documentation/watchdog/watchdog-api.txt
@@ -37,7 +37,7 @@ activates as soon as /dev/watchdog is opened and will reboot unless
 the watchdog is pinged within a certain time, this time is called the
 timeout or margin.  The simplest way to ping the watchdog is to write
 some data to the device.  So a very simple watchdog daemon would look
-like this source file:  see Documentation/watchdog/src/watchdog-simple.c
+like this source file:  see samples/watchdog/watchdog-simple.c
 
 A more advanced driver could for example check that a HTTP server is
 still responding before doing the write call to ping the watchdog.
diff --git a/Documentation/watchdog/wdt.txt b/Documentation/watchdog/wdt.txt
index 061c2e3..ed2f0b8 100644
--- a/Documentation/watchdog/wdt.txt
+++ b/Documentation/watchdog/wdt.txt
@@ -47,4 +47,4 @@ The external event interfaces on the WDT boards are not currently supported.
 Minor numbers are however allocated for it.
 
 
-Example Watchdog Driver:  see Documentation/watchdog/src/watchdog-simple.c
+Example Watchdog Driver:  see samples/watchdog/watchdog-simple.c
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] 10+ messages in thread

* [PATCH v2 4/4] samples: move auxdisplay example code from Documentation
  2016-09-21 19:47 [PATCH v2 0/4] Move runnable examples code from Documentation to samples Shuah Khan
                   ` (2 preceding siblings ...)
  2016-09-21 19:47 ` [PATCH v2 3/4] samples: move watchdog " Shuah Khan
@ 2016-09-21 19:47 ` Shuah Khan
  2016-09-21 20:18   ` Jonathan Corbet
  4 siblings, 0 replies; 10+ messages in thread
From: Shuah Khan @ 2016-09-21 19:47 UTC (permalink / raw)
  To: corbet, tomas.winkler, tglx, clemens, wim, linux, davem, geert,
	akpm, gregkh, kvalo, mchehab, ghackmann, ben, maheshkhanwalkar
  Cc: Shuah Khan, linux-doc, linux-kernel, 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                        |   2 +-
 Documentation/auxdisplay/.gitignore           |   1 -
 Documentation/auxdisplay/Makefile             |   7 -
 Documentation/auxdisplay/cfag12864b           |   2 +-
 Documentation/auxdisplay/cfag12864b-example.c | 281 --------------------------
 samples/auxdisplay/.gitignore                 |   1 +
 samples/auxdisplay/Makefile                   |   9 +
 samples/auxdisplay/cfag12864b-example.c       | 281 ++++++++++++++++++++++++++
 8 files changed, 293 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 b2210b7..0b8cd50 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -1,2 +1,2 @@
-subdir-y := accounting auxdisplay blackfin \
+subdir-y := accounting blackfin \
 	laptops pcmcia
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 b/Documentation/auxdisplay/cfag12864b
index eb7be39..12fd51b 100644
--- a/Documentation/auxdisplay/cfag12864b
+++ b/Documentation/auxdisplay/cfag12864b
@@ -101,5 +101,5 @@ Although the LCD won't get updated until the next refresh time arrives.
 Also, you can mmap the framebuffer: open & mmap, munmap & close...
 which is the best option for most uses.
 
-Check Documentation/auxdisplay/cfag12864b-example.c
+Check samples/auxdisplay/cfag12864b-example.c
 for a real working userspace complete program with usage examples.
diff --git a/Documentation/auxdisplay/cfag12864b-example.c b/Documentation/auxdisplay/cfag12864b-example.c
deleted file mode 100644
index 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] 10+ messages in thread

* Re: [PATCH v2 1/4] samples: move misc-devices/mei example code from Documentation
  2016-09-21 19:47 ` [PATCH v2 1/4] samples: move misc-devices/mei example code from Documentation Shuah Khan
@ 2016-09-21 19:52   ` Greg KH
  2016-09-21 21:00   ` Winkler, Tomas
  1 sibling, 0 replies; 10+ messages in thread
From: Greg KH @ 2016-09-21 19:52 UTC (permalink / raw)
  To: Shuah Khan
  Cc: corbet, tomas.winkler, tglx, clemens, wim, linux, davem, geert,
	akpm, kvalo, mchehab, ghackmann, ben, maheshkhanwalkar,
	linux-doc, linux-kernel, linux-watchdog

On Wed, Sep 21, 2016 at 01:47:30PM -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:
> 
> Run make -C samples/mei or cd samples/mei; make
> 
> Acked-by: Jonathan Corbet <corbet@lwn.net>
> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
> ---


Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/4] Move runnable examples code from Documentation to samples
  2016-09-21 19:47 [PATCH v2 0/4] Move runnable examples code from Documentation to samples Shuah Khan
@ 2016-09-21 20:18   ` Jonathan Corbet
  2016-09-21 19:47 ` [PATCH v2 2/4] samples: move timers " Shuah Khan
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Jonathan Corbet @ 2016-09-21 20:18 UTC (permalink / raw)
  To: Shuah Khan
  Cc: tomas.winkler, tglx, clemens, wim, linux, davem, geert, akpm,
	gregkh, kvalo, mchehab, ghackmann, ben, maheshkhanwalkar,
	linux-doc, linux-kernel, linux-watchdog

On Wed, 21 Sep 2016 13:47:29 -0600
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.
> 
> I dropped accounting, laptops, and pcmcia from this v2 series as per
> the v1 feedback on these being a better fit under tools. I will send
> a separate v2 for them.
> 
> If v2 patches look good, and if I get an okay, I will try to get these
> into 4.9-rc1
> 
> Changes since v1:
> - Updated location information in .txt for timers, watchdog, and
>   auxdisplay
> - Updated MAINTAINERS file for misc-devices/mei based on feedback
>   from Tomas Winkler
> - Added Acked-by from Jon Corbet for timers, and misc-devices/mei

Looks good, feel free to add my ack to the rest.

jon

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/4] Move runnable examples code from Documentation to samples
@ 2016-09-21 20:18   ` Jonathan Corbet
  0 siblings, 0 replies; 10+ messages in thread
From: Jonathan Corbet @ 2016-09-21 20:18 UTC (permalink / raw)
  To: Shuah Khan
  Cc: tomas.winkler, tglx, clemens, wim, linux, davem, geert, akpm,
	gregkh, kvalo, mchehab, ghackmann, ben, maheshkhanwalkar,
	linux-doc, linux-kernel, linux-watchdog

On Wed, 21 Sep 2016 13:47:29 -0600
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.
> 
> I dropped accounting, laptops, and pcmcia from this v2 series as per
> the v1 feedback on these being a better fit under tools. I will send
> a separate v2 for them.
> 
> If v2 patches look good, and if I get an okay, I will try to get these
> into 4.9-rc1
> 
> Changes since v1:
> - Updated location information in .txt for timers, watchdog, and
>   auxdisplay
> - Updated MAINTAINERS file for misc-devices/mei based on feedback
>   from Tomas Winkler
> - Added Acked-by from Jon Corbet for timers, and misc-devices/mei

Looks good, feel free to add my ack to the rest.

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] 10+ messages in thread

* RE: [PATCH v2 1/4] samples: move misc-devices/mei example code from Documentation
  2016-09-21 19:47 ` [PATCH v2 1/4] samples: move misc-devices/mei example code from Documentation Shuah Khan
  2016-09-21 19:52   ` Greg KH
@ 2016-09-21 21:00   ` Winkler, Tomas
  1 sibling, 0 replies; 10+ messages in thread
From: Winkler, Tomas @ 2016-09-21 21:00 UTC (permalink / raw)
  To: Shuah Khan, corbet, tglx, clemens, wim, linux, davem, geert,
	akpm, gregkh, kvalo, mchehab, ghackmann, ben, maheshkhanwalkar
  Cc: linux-doc, linux-kernel, 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
> 
> Acked-by: Jonathan Corbet <corbet@lwn.net>
> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>


Acked-by: Tomas Winkler <tomas.winkler@intel.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 --------------------
> ---
>  MAINTAINERS                                      |   1 +
>  samples/mei/.gitignore                           |   1 +
>  samples/mei/Makefile                             |   9 +
>  samples/mei/TODO                                 |   2 +
>  samples/mei/mei-amt-version.c                    | 479
> +++++++++++++++++++++++
>  11 files changed, 493 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
> 80b5bdc..3c2a207 100644
> --- a/Documentation/Makefile
> +++ b/Documentation/Makefile
> @@ -1,2 +1,2 @@
>  subdir-y := accounting auxdisplay blackfin \
> -	laptops misc-devices pcmcia timers watchdog
> +	laptops 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/MAINTAINERS b/MAINTAINERS
> index a5e1270..afd3577 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6261,6 +6261,7 @@ F:	include/linux/mei_cl_bus.h
>  F:	drivers/misc/mei/*
>  F:	drivers/watchdog/mei_wdt.c
>  F:	Documentation/misc-devices/mei/*
> +F:	samples/mei/*
> 
>  INTEL MIC DRIVERS (mic)
>  M:	Sudeep Dutt <sudeep.dutt@intel.com>
> 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	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/4] samples: move timers example code from Documentation
  2016-09-21 19:47 ` [PATCH v2 2/4] samples: move timers " Shuah Khan
@ 2016-09-21 21:47   ` Clemens Ladisch
  0 siblings, 0 replies; 10+ messages in thread
From: Clemens Ladisch @ 2016-09-21 21:47 UTC (permalink / raw)
  To: Shuah Khan, corbet, tglx; +Cc: linux-doc, linux-kernel

Shuah Khan 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:
>
> Run make -C samples/timers or cd samples/timers; make
>
> Acked-by: Jonathan Corbet <corbet@lwn.net>
> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>

Acked-by: Clemens Ladisch <clemens@ladisch.de>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-09-21 21:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-21 19:47 [PATCH v2 0/4] Move runnable examples code from Documentation to samples Shuah Khan
2016-09-21 19:47 ` [PATCH v2 1/4] samples: move misc-devices/mei example code from Documentation Shuah Khan
2016-09-21 19:52   ` Greg KH
2016-09-21 21:00   ` Winkler, Tomas
2016-09-21 19:47 ` [PATCH v2 2/4] samples: move timers " Shuah Khan
2016-09-21 21:47   ` Clemens Ladisch
2016-09-21 19:47 ` [PATCH v2 3/4] samples: move watchdog " Shuah Khan
2016-09-21 19:47 ` [PATCH v2 4/4] samples: move auxdisplay " Shuah Khan
2016-09-21 20:18 ` [PATCH v2 0/4] Move runnable examples code from Documentation to samples Jonathan Corbet
2016-09-21 20:18   ` Jonathan Corbet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.