From: Lv Zheng <lv.zheng@intel.com>
To: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Len Brown <len.brown@intel.com>
Cc: Lv Zheng <lv.zheng@intel.com>, Lv Zheng <zetalog@gmail.com>,
<linux-kernel@vger.kernel.org>,
linux-acpi@vger.kernel.org
Subject: [PATCH v3 2/3] tools/power/acpi/acpidbg: Use new flushing mechanism
Date: Fri, 22 Jul 2016 12:17:05 +0800 [thread overview]
Message-ID: <b8d45e07cbdb73252e5b152bbf31afec321f5a1c.1469155242.git.lv.zheng@intel.com> (raw)
In-Reply-To: <cover.1469155242.git.lv.zheng@intel.com>
This patch converts tools/power/acpi/tools/acpidbg/acpidbg to use the new
flushing mechanism.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
tools/power/acpi/tools/acpidbg/acpidbg.c | 51 ++++--------------------------
1 file changed, 7 insertions(+), 44 deletions(-)
diff --git a/tools/power/acpi/tools/acpidbg/acpidbg.c b/tools/power/acpi/tools/acpidbg/acpidbg.c
index a88ac45..f5542b9 100644
--- a/tools/power/acpi/tools/acpidbg/acpidbg.c
+++ b/tools/power/acpi/tools/acpidbg/acpidbg.c
@@ -15,7 +15,9 @@
#include <stdbool.h>
#include <fcntl.h>
#include <assert.h>
+#include <sys/ioctl.h>
#include <linux/circ_buf.h>
+#include <uapi/linux/acpi-ioctls.h>
#define ACPI_AML_FILE "/sys/kernel/debug/acpi/acpidbg"
#define ACPI_AML_SEC_TICK 1
@@ -83,7 +85,6 @@ static const char *acpi_aml_file_path = ACPI_AML_FILE;
static unsigned long acpi_aml_mode = ACPI_AML_INTERACTIVE;
static bool acpi_aml_exit;
-static bool acpi_aml_batch_drain;
static unsigned long acpi_aml_batch_state;
static char acpi_aml_batch_prompt;
static char acpi_aml_batch_roll;
@@ -239,11 +240,9 @@ static int acpi_aml_write_batch_log(int fd, struct circ_buf *crc)
p = &crc->buf[crc->tail];
len = circ_count_to_end(crc);
- if (!acpi_aml_batch_drain) {
- len = write(fd, p, len);
- if (len < 0)
- perror("write");
- }
+ len = write(fd, p, len);
+ if (len < 0)
+ perror("write");
if (len > 0)
crc->tail = (crc->tail + len) & (ACPI_AML_BUF_SIZE - 1);
return len;
@@ -270,10 +269,7 @@ static void acpi_aml_loop(int fd)
if (acpi_aml_mode == ACPI_AML_BATCH) {
acpi_aml_log_state = ACPI_AML_LOG_START;
acpi_aml_batch_pos = acpi_aml_batch_cmd;
- if (acpi_aml_batch_drain)
- acpi_aml_batch_state = ACPI_AML_BATCH_READ_LOG;
- else
- acpi_aml_batch_state = ACPI_AML_BATCH_WRITE_CMD;
+ acpi_aml_batch_state = ACPI_AML_BATCH_WRITE_CMD;
}
acpi_aml_exit = false;
while (!acpi_aml_exit) {
@@ -330,39 +326,6 @@ static void acpi_aml_loop(int fd)
}
}
-static bool acpi_aml_readable(int fd)
-{
- fd_set rfds;
- struct timeval tv;
- int ret;
- int maxfd = 0;
-
- tv.tv_sec = 0;
- tv.tv_usec = ACPI_AML_USEC_PEEK;
- FD_ZERO(&rfds);
- maxfd = acpi_aml_set_fd(fd, maxfd, &rfds);
- ret = select(maxfd+1, &rfds, NULL, NULL, &tv);
- if (ret < 0)
- perror("select");
- if (ret > 0 && FD_ISSET(fd, &rfds))
- return true;
- return false;
-}
-
-/*
- * This is a userspace IO flush implementation, replying on the prompt
- * characters and can be turned into a flush() call after kernel implements
- * .flush() filesystem operation.
- */
-static void acpi_aml_flush(int fd)
-{
- while (acpi_aml_readable(fd)) {
- acpi_aml_batch_drain = true;
- acpi_aml_loop(fd);
- acpi_aml_batch_drain = false;
- }
-}
-
void usage(FILE *file, char *progname)
{
fprintf(file, "usage: %s [-b cmd] [-f file] [-h]\n", progname);
@@ -426,7 +389,7 @@ int main(int argc, char **argv)
acpi_aml_set_fl(STDOUT_FILENO, O_NONBLOCK);
if (acpi_aml_mode == ACPI_AML_BATCH)
- acpi_aml_flush(fd);
+ ioctl(fd, ACPI_IOCTL_DEBUGGER_FLUSH);
acpi_aml_loop(fd);
exit:
--
1.7.10
next prev parent reply other threads:[~2016-07-22 4:17 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-14 2:52 [PATCH 0/3] ACPI / debugger: Add kernel flushing support Lv Zheng
2016-07-14 2:52 ` [PATCH 1/3] debugfs: Add .fsync() callback proxy support Lv Zheng
2016-07-19 8:13 ` Zheng, Lv
2016-07-14 2:52 ` [PATCH 2/3] ACPI / debugger: Add kernel flushing support Lv Zheng
2016-07-14 2:52 ` [PATCH 3/3] tools/power/acpi/acpidbg: Use new flushing mechanism Lv Zheng
2016-07-19 10:00 ` [PATCH v2 0/2] ACPI / debugger: Add kernel flushing support Lv Zheng
2016-07-19 10:00 ` [PATCH v2 1/2] " Lv Zheng
2016-07-21 13:43 ` Rafael J. Wysocki
2016-07-22 0:34 ` Zheng, Lv
2016-07-19 10:00 ` [PATCH v2 2/2] tools/power/acpi/acpidbg: Use new flushing mechanism Lv Zheng
2016-07-20 8:12 ` [PATCH] tools/power/acpi/tools/acpidbg: Add multi-commands support in batch mode Lv Zheng
2016-07-21 13:45 ` Rafael J. Wysocki
2016-07-22 0:26 ` Zheng, Lv
2016-07-22 4:16 ` [PATCH v3 0/3] ACPI / debugger: Add kernel flushing support Lv Zheng
2016-07-22 4:16 ` [PATCH v3 1/3] " Lv Zheng
2016-07-22 4:17 ` Lv Zheng [this message]
2016-07-22 4:17 ` [PATCH v3 3/3] tools/power/acpi/acpidbg: Add multi-commands support in batch mode Lv Zheng
2016-07-26 11:01 ` [PATCH v4 0/3] ACPI / debugger: Add kernel flushing support Lv Zheng
2016-07-26 11:01 ` [PATCH v4 1/3] " Lv Zheng
2016-08-17 0:25 ` Rafael J. Wysocki
2016-08-17 2:39 ` Zheng, Lv
2016-07-26 11:01 ` [PATCH v4 2/3] tools/power/acpi/acpidbg: Use new flushing mechanism Lv Zheng
2016-08-17 0:29 ` Rafael J. Wysocki
2016-08-17 2:41 ` Zheng, Lv
2016-07-26 11:01 ` [PATCH v4 3/3] tools/power/acpi/acpidbg: Add multi-commands support in batch mode Lv Zheng
2016-08-17 0:30 ` Rafael J. Wysocki
2016-08-17 4:31 ` Zheng, Lv
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b8d45e07cbdb73252e5b152bbf31afec321f5a1c.1469155242.git.lv.zheng@intel.com \
--to=lv.zheng@intel.com \
--cc=len.brown@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rjw@rjwysocki.net \
--cc=zetalog@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).