Re: [PATCH v5] ACPI / APEI: fix the regression of synchronous external aborts occur in user-mode

2021-04-10 Thread Xiaofei Tan

Hi James, Boris

a friendly ping..
any comments for this ?

On 2021/2/5 20:55, Rafael J. Wysocki wrote:

On Tue, Jan 26, 2021 at 2:32 PM tanxiaofei  wrote:


@James
Hi James, please help to review this patch. Thank you very much. :)


James, Boris, any comments?


On 2020/12/10 20:09, Xiaofei Tan wrote:

After the commit 8fcc4ae6faf8 ("arm64: acpi: Make apei_claim_sea()
synchronise with APEI's irq work") applied, do_sea() return directly
for user-mode if apei_claim_sea() handled any error record. Therefore,
each error record reported by the user-mode SEA must be effectively
processed in APEI GHES driver.

Currently, GHES driver only processes Memory Error Section.(Ignore PCIe
Error Section, as it has nothing to do with SEA). It is not enough.
Because ARM Processor Error could also be used for SEA in some hardware
platforms, such as Kunpeng9xx series. We can't ask them to switch to
use Memory Error Section for two reasons:
1)The server was delivered to customers, and it will introduce
compatibility issue.
2)It make sense to use ARM Processor Error Section. Because either
cache or memory errors could generate SEA when consumed by a processor.

Do memory failure handling for ARM Processor Error Section just like
for Memory Error Section.

Signed-off-by: Xiaofei Tan 
---
Changes since v4:
- 1. Change the patch name from " ACPI / APEI: do memory failure on the
physical address reported by ARM processor error section" to this
more proper one.
- 2. Add a comment in the code to tell why not filter out corrected
error in an uncorrected section.

Changes since v3:
- Print unhandled error following James Morse's advice.

Changes since v2:
- Updated commit log
---
 drivers/acpi/apei/ghes.c | 76 +---
 1 file changed, 59 insertions(+), 17 deletions(-)

diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index fce7ade..0893968 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -441,28 +441,35 @@ static void ghes_kick_task_work(struct callback_head 
*head)
  gen_pool_free(ghes_estatus_pool, (unsigned long)estatus_node, node_len);
 }

-static bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata,
-int sev)
+static bool ghes_do_memory_failure(u64 physical_addr, int flags)
 {
  unsigned long pfn;
- int flags = -1;
- int sec_sev = ghes_severity(gdata->error_severity);
- struct cper_sec_mem_err *mem_err = acpi_hest_get_payload(gdata);

  if (!IS_ENABLED(CONFIG_ACPI_APEI_MEMORY_FAILURE))
  return false;

- if (!(mem_err->validation_bits & CPER_MEM_VALID_PA))
- return false;
-
- pfn = mem_err->physical_addr >> PAGE_SHIFT;
+ pfn = PHYS_PFN(physical_addr);
  if (!pfn_valid(pfn)) {
  pr_warn_ratelimited(FW_WARN GHES_PFX
  "Invalid address in generic error data: %#llx\n",
- mem_err->physical_addr);
+ physical_addr);
  return false;
  }

+ memory_failure_queue(pfn, flags);
+ return true;
+}
+
+static bool ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata,
+int sev)
+{
+ int flags = -1;
+ int sec_sev = ghes_severity(gdata->error_severity);
+ struct cper_sec_mem_err *mem_err = acpi_hest_get_payload(gdata);
+
+ if (!(mem_err->validation_bits & CPER_MEM_VALID_PA))
+ return false;
+
  /* iff following two events can be handled properly by now */
  if (sec_sev == GHES_SEV_CORRECTED &&
  (gdata->flags & CPER_SEC_ERROR_THRESHOLD_EXCEEDED))
@@ -470,14 +477,51 @@ static bool ghes_handle_memory_failure(struct 
acpi_hest_generic_data *gdata,
  if (sev == GHES_SEV_RECOVERABLE && sec_sev == GHES_SEV_RECOVERABLE)
  flags = 0;

- if (flags != -1) {
- memory_failure_queue(pfn, flags);
- return true;
- }
+ if (flags != -1)
+ return ghes_do_memory_failure(mem_err->physical_addr, flags);

  return false;
 }

+static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata, int 
sev)
+{
+ struct cper_sec_proc_arm *err = acpi_hest_get_payload(gdata);
+ struct cper_arm_err_info *err_info;
+ bool queued = false;
+ int sec_sev, i;
+
+ log_arm_hw_error(err);
+
+ sec_sev = ghes_severity(gdata->error_severity);
+ if (sev != GHES_SEV_RECOVERABLE || sec_sev != GHES_SEV_RECOVERABLE)
+ return false;
+
+ err_info = (struct cper_arm_err_info *) (err + 1);
+ for (i = 0; i < err->err_info_num; i++, err_info++) {
+ bool is_cache = (err_info->type == CPER_ARM_CACHE_ERROR);
+ bool has_pa = (err_info->validation_bits & 
CPER_ARM_INFO_VALID_PHYSICAL_ADDR);
+
+ /*
+  * The field (err_info->error_info & BIT(26)) is fixed to set to
+

[PATCH v3 06/10] tty: tty_ldisc: Fix an issue of code indent should use tabs

2021-04-07 Thread Xiaofei Tan
Fix an issue of code indent should use tabs, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_ldisc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 1ba74d6..2992319 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -459,7 +459,7 @@ static int tty_ldisc_open(struct tty_struct *tty, struct 
tty_ldisc *ld)
WARN_ON(test_and_set_bit(TTY_LDISC_OPEN, >flags));
if (ld->ops->open) {
int ret;
-/* BTM here locks versus a hangup event */
+   /* BTM here locks versus a hangup event */
ret = ld->ops->open(tty);
if (ret)
clear_bit(TTY_LDISC_OPEN, >flags);
-- 
2.8.1



[PATCH v3 08/10] tty: tty_ldisc: Fix coding style issues of block comments

2021-04-07 Thread Xiaofei Tan
Fix coding style issues of block comments, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_ldisc.c | 32 
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index df0b589..874d238 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -529,9 +529,11 @@ static void tty_ldisc_restore(struct tty_struct *tty, 
struct tty_ldisc *old)
const char *name = tty_name(tty);
 
pr_warn("Falling back ldisc for %s.\n", name);
-   /* The traditional behaviour is to fall back to N_TTY, we
-  want to avoid falling back to N_NULL unless we have no
-  choice to avoid the risk of breaking anything */
+   /*
+* The traditional behaviour is to fall back to N_TTY, we
+* want to avoid falling back to N_NULL unless we have no
+* choice to avoid the risk of breaking anything
+*/
if (tty_ldisc_failto(tty, N_TTY) < 0 &&
tty_ldisc_failto(tty, N_NULL) < 0)
panic("Couldn't open N_NULL ldisc for %s.", name);
@@ -600,17 +602,21 @@ int tty_set_ldisc(struct tty_struct *tty, int disc)
up_read(>termios_rwsem);
}
 
-   /* At this point we hold a reference to the new ldisc and a
-  reference to the old ldisc, or we hold two references to
-  the old ldisc (if it was restored as part of error cleanup
-  above). In either case, releasing a single reference from
-  the old ldisc is correct. */
+   /*
+* At this point we hold a reference to the new ldisc and a
+* reference to the old ldisc, or we hold two references to
+* the old ldisc (if it was restored as part of error cleanup
+* above). In either case, releasing a single reference from
+* the old ldisc is correct.
+*/
new_ldisc = old_ldisc;
 out:
tty_ldisc_unlock(tty);
 
-   /* Restart the work queue in case no characters kick it off. Safe if
-  already running */
+   /*
+* Restart the work queue in case no characters kick it off. Safe if
+* already running
+*/
tty_buffer_restart_work(tty->port);
 err:
tty_ldisc_put(new_ldisc);   /* drop the extra reference */
@@ -812,8 +818,10 @@ void tty_ldisc_release(struct tty_struct *tty)
tty_ldisc_kill(o_tty);
tty_ldisc_unlock_pair(tty, o_tty);
 
-   /* And the memory resources remaining (buffers, termios) will be
-  disposed of when the kref hits zero */
+   /*
+* And the memory resources remaining (buffers, termios) will be
+* disposed of when the kref hits zero
+*/
 
tty_ldisc_debug(tty, "released\n");
 }
-- 
2.8.1



[PATCH v3 10/10] tty: tty_ldisc: Remove the repeated word 'the'

2021-04-07 Thread Xiaofei Tan
Remove the repeated word 'the' following advice of checkpatch.pl

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_ldisc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 56e67f7..fdc4fa3 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -147,7 +147,7 @@ static int tty_ldisc_autoload = 
IS_BUILTIN(CONFIG_LDISC_AUTOLOAD);
  * Returns: -EINVAL if the discipline index is not [N_TTY..NR_LDISCS] or
  *  if the discipline is not registered
  *  -EAGAIN if request_module() failed to load or register the
- *  the discipline
+ *  discipline
  *  -ENOMEM if allocation failure
  *
  *  Otherwise, returns a pointer to the discipline and bumps the
-- 
2.8.1



[PATCH v3 04/10] tty: tty_jobctrl: Fix coding style issues of block comments

2021-04-07 Thread Xiaofei Tan
Fix coding style issues of block comments, reported by checkpatch.pl.
Besides, do some expression optimization for the sentenses.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_jobctrl.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c
index 86070f7..5b4ab16 100644
--- a/drivers/tty/tty_jobctrl.c
+++ b/drivers/tty/tty_jobctrl.c
@@ -204,8 +204,10 @@ int tty_signal_session_leader(struct tty_struct *tty, int 
exit_session)
spin_lock_irq(>sighand->siglock);
if (p->signal->tty == tty) {
p->signal->tty = NULL;
-   /* We defer the dereferences outside fo
-  the tasklist lock */
+   /*
+* We defer the dereferences outside of
+* the tasklist lock.
+*/
refs++;
}
if (!p->signal->leader) {
@@ -328,9 +330,11 @@ void disassociate_ctty(int on_exit)
  */
 void no_tty(void)
 {
-   /* FIXME: Review locking here. The tty_lock never covered any race
-  between a new association and proc_clear_tty but possible we need
-  to protect against this anyway */
+   /*
+* FIXME: Review locking here. The tty_lock never covered any race
+* between a new association and proc_clear_tty but possibly we need
+* to protect against this anyway.
+*/
struct task_struct *tsk = current;
 
disassociate_ctty(0);
@@ -536,7 +540,7 @@ static int tiocgsid(struct tty_struct *tty, struct 
tty_struct *real_tty, pid_t _
/*
 * (tty == real_tty) is a cheap way of
 * testing if the tty is NOT a master pty.
-   */
+*/
if (tty == real_tty && current->signal->tty != real_tty)
return -ENOTTY;
 
-- 
2.8.1



[PATCH v3 09/10] tty: tty_ldisc: Do not use assignment in if condition

2021-04-07 Thread Xiaofei Tan
Do not use assignment in if condition following the advice of
checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_ldisc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 874d238..56e67f7 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -508,7 +508,8 @@ static int tty_ldisc_failto(struct tty_struct *tty, int ld)
return PTR_ERR(disc);
tty->ldisc = disc;
tty_set_termios_ldisc(tty, ld);
-   if ((r = tty_ldisc_open(tty, disc)) < 0)
+   r = tty_ldisc_open(tty, disc);
+   if (r < 0)
tty_ldisc_put(disc);
return r;
 }
-- 
2.8.1



[PATCH v3 05/10] tty: tty_jobctrl: Remove spaces before tabs

2021-04-07 Thread Xiaofei Tan
Remove spaces before tabs following the advice of checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_jobctrl.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c
index 5b4ab16..72df97b 100644
--- a/drivers/tty/tty_jobctrl.c
+++ b/drivers/tty/tty_jobctrl.c
@@ -244,10 +244,10 @@ int tty_signal_session_leader(struct tty_struct *tty, int 
exit_session)
  * it wants to disassociate itself from its controlling tty.
  *
  * It performs the following functions:
- * (1)  Sends a SIGHUP and SIGCONT to the foreground process group
- * (2)  Clears the tty from being controlling the session
- * (3)  Clears the controlling tty for all processes in the
- * session group.
+ * (1)  Sends a SIGHUP and SIGCONT to the foreground process group
+ * (2)  Clears the tty from being controlling the session
+ * (3)  Clears the controlling tty for all processes in the
+ * session group.
  *
  * The argument on_exit is set to 1 if called when a process is
  * exiting; it is 0 if called by the ioctl TIOCNOTTY.
-- 
2.8.1



[PATCH v3 07/10] tty: tty_ldisc: Add a blank line after declarations

2021-04-07 Thread Xiaofei Tan
Add a blank line after declarations, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_ldisc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 2992319..df0b589 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -771,6 +771,7 @@ void tty_ldisc_hangup(struct tty_struct *tty, bool reinit)
 int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty)
 {
int retval = tty_ldisc_open(tty, tty->ldisc);
+
if (retval)
return retval;
 
@@ -829,6 +830,7 @@ EXPORT_SYMBOL_GPL(tty_ldisc_release);
 int tty_ldisc_init(struct tty_struct *tty)
 {
struct tty_ldisc *ld = tty_ldisc_get(tty, N_TTY);
+
if (IS_ERR(ld))
return PTR_ERR(ld);
tty->ldisc = ld;
-- 
2.8.1



[PATCH v3 02/10] tty/sysrq: Fix issues of code indent should use tabs

2021-04-07 Thread Xiaofei Tan
Fix issues of code indent should use tabs, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/sysrq.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 0372ed7..6628792 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -548,22 +548,22 @@ static int sysrq_key_table_key2index(int key)
  */
 static const struct sysrq_key_op *__sysrq_get_key_op(int key)
 {
-const struct sysrq_key_op *op_p = NULL;
-int i;
+   const struct sysrq_key_op *op_p = NULL;
+   int i;
 
i = sysrq_key_table_key2index(key);
if (i != -1)
-   op_p = sysrq_key_table[i];
+   op_p = sysrq_key_table[i];
 
-return op_p;
+   return op_p;
 }
 
 static void __sysrq_put_key_op(int key, const struct sysrq_key_op *op_p)
 {
-int i = sysrq_key_table_key2index(key);
+   int i = sysrq_key_table_key2index(key);
 
-if (i != -1)
-sysrq_key_table[i] = op_p;
+   if (i != -1)
+   sysrq_key_table[i] = op_p;
 }
 
 void __handle_sysrq(int key, bool check_mask)
@@ -587,8 +587,8 @@ void __handle_sysrq(int key, bool check_mask)
orig_log_level = console_loglevel;
console_loglevel = CONSOLE_LOGLEVEL_DEFAULT;
 
-op_p = __sysrq_get_key_op(key);
-if (op_p) {
+   op_p = __sysrq_get_key_op(key);
+   if (op_p) {
/*
 * Should we check for enabled operations (/proc/sysrq-trigger
 * should not) and is the invoked operation enabled?
@@ -637,13 +637,13 @@ static int sysrq_reset_downtime_ms;
 
 /* Simple translation table for the SysRq keys */
 static const unsigned char sysrq_xlate[KEY_CNT] =
-"\000\0331234567890-=\177\t"/* 0x00 - 0x0f */
-"qwertyuiop[]\r\000as"  /* 0x10 - 0x1f */
-"dfghjkl;'`\000\\zxcv"  /* 0x20 - 0x2f */
-"bnm,./\000*\000 \000\201\202\203\204\205"  /* 0x30 - 0x3f */
-"\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
-"230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 
0x50 - 0x5f */
-"\r\000/";  /* 0x60 - 0x6f */
+   "\000\0331234567890-=\177\t"/* 0x00 - 0x0f */
+   "qwertyuiop[]\r\000as"  /* 0x10 - 0x1f */
+   "dfghjkl;'`\000\\zxcv"  /* 0x20 - 0x2f */
+   "bnm,./\000*\000 \000\201\202\203\204\205"  /* 0x30 - 0x3f */
+   "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
+   "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 
0x50 - 0x5f */
+   "\r\000/";  /* 0x60 - 0x6f */
 
 struct sysrq_state {
struct input_handle handle;
@@ -1108,7 +1108,7 @@ int sysrq_toggle_support(int enable_mask)
 EXPORT_SYMBOL_GPL(sysrq_toggle_support);
 
 static int __sysrq_swap_key_ops(int key, const struct sysrq_key_op 
*insert_op_p,
-const struct sysrq_key_op *remove_op_p)
+   const struct sysrq_key_op *remove_op_p)
 {
int retval;
 
-- 
2.8.1



[PATCH v3 01/10] tty/sysrq: Add a blank line after declarations

2021-04-07 Thread Xiaofei Tan
Add a blank line after declarations, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/sysrq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 959f9e1..0372ed7 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -118,6 +118,7 @@ static const struct sysrq_key_op sysrq_loglevel_op = {
 static void sysrq_handle_SAK(int key)
 {
struct work_struct *SAK_work = _cons[fg_console].SAK_work;
+
schedule_work(SAK_work);
 }
 static const struct sysrq_key_op sysrq_SAK_op = {
-- 
2.8.1



[PATCH v3 00/10] tty: Fix some coding style issues

2021-04-07 Thread Xiaofei Tan
Fix some issues reported by checkpatch.pl. All of them are
coding style issues, no function changes.

Differences from v2 to v3:
- Fix the misunderstanding of 'period' for the patch 04/10.

Differences from v1 to v2:
- Remove one redundant tab for the patch 02/10.
- Add some expression optimization for some sentenses following
- Jiri's advice for the patch 04/10.

Xiaofei Tan (10):
  tty/sysrq: Add a blank line after declarations
  tty/sysrq: Fix issues of code indent should use tabs
  tty: tty_jobctrl: Add a blank line after declarations
  tty: tty_jobctrl: Fix coding style issues of block comments
  tty: tty_jobctrl: Remove spaces before tabs
  tty: tty_ldisc: Fix an issue of code indent should use tabs
  tty: tty_ldisc: Add a blank line after declarations
  tty: tty_ldisc: Fix coding style issues of block comments
  tty: tty_ldisc: Do not use assignment in if condition
  tty: tty_ldisc: Remove the repeated word 'the'

 drivers/tty/sysrq.c   | 35 ++-
 drivers/tty/tty_jobctrl.c | 29 +++--
 drivers/tty/tty_ldisc.c   | 41 ++---
 3 files changed, 63 insertions(+), 42 deletions(-)

-- 
2.8.1



[PATCH v3 03/10] tty: tty_jobctrl: Add a blank line after declarations

2021-04-07 Thread Xiaofei Tan
Add a blank line after declarations, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_jobctrl.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c
index 4b751b9..86070f7 100644
--- a/drivers/tty/tty_jobctrl.c
+++ b/drivers/tty/tty_jobctrl.c
@@ -75,6 +75,7 @@ void proc_clear_tty(struct task_struct *p)
 {
unsigned long flags;
struct tty_struct *tty;
+
spin_lock_irqsave(>sighand->siglock, flags);
tty = p->signal->tty;
p->signal->tty = NULL;
@@ -173,6 +174,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
 void session_clear_tty(struct pid *session)
 {
struct task_struct *p;
+
do_each_pid_task(session, PIDTYPE_SID, p) {
proc_clear_tty(p);
} while_each_pid_task(session, PIDTYPE_SID, p);
@@ -269,6 +271,7 @@ void disassociate_ctty(int on_exit)
tty_vhangup_session(tty);
} else {
struct pid *tty_pgrp = tty_get_pgrp(tty);
+
if (tty_pgrp) {
kill_pgrp(tty_pgrp, SIGHUP, on_exit);
if (!on_exit)
@@ -280,6 +283,7 @@ void disassociate_ctty(int on_exit)
 
} else if (on_exit) {
struct pid *old_pgrp;
+
spin_lock_irq(>sighand->siglock);
old_pgrp = current->signal->tty_old_pgrp;
current->signal->tty_old_pgrp = NULL;
@@ -328,6 +332,7 @@ void no_tty(void)
   between a new association and proc_clear_tty but possible we need
   to protect against this anyway */
struct task_struct *tsk = current;
+
disassociate_ctty(0);
proc_clear_tty(tsk);
 }
-- 
2.8.1



Re: [PATCH v2 04/10] tty: tty_jobctrl: Fix coding style issues of block comments

2021-04-07 Thread Xiaofei Tan

Hi Jiri,

On 2021/4/7 13:26, Jiri Slaby wrote:

On 06. 04. 21, 13:24, Xiaofei Tan wrote:

Fix coding style issues of block comments, reported by checkpatch.pl.
Besides, do some expression optimization for the sentenses.

Signed-off-by: Xiaofei Tan 
---
  drivers/tty/tty_jobctrl.c | 16 ++--
  1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c
index 86070f7..7003b6b 100644
--- a/drivers/tty/tty_jobctrl.c
+++ b/drivers/tty/tty_jobctrl.c
@@ -204,8 +204,10 @@ int tty_signal_session_leader(struct tty_struct
*tty, int exit_session)
  spin_lock_irq(>sighand->siglock);
  if (p->signal->tty == tty) {
  p->signal->tty = NULL;
-/* We defer the dereferences outside fo
-   the tasklist lock */
+/*
+ * We defer the dereferences outside of
+ * the tasklist lock period


:). No, I meant "period" as this punctuation mark: .



Oh, my misunderstanding. I will send v3 later. thanks. :)


+ */
  refs++;
  }
  if (!p->signal->leader) {
@@ -328,9 +330,11 @@ void disassociate_ctty(int on_exit)
   */
  void no_tty(void)
  {
-/* FIXME: Review locking here. The tty_lock never covered any race
-   between a new association and proc_clear_tty but possible we need
-   to protect against this anyway */
+/*
+ * FIXME: Review locking here. The tty_lock never covered any race
+ * between a new association and proc_clear_tty but possibly we need
+ * to protect against this period anyway


The same here.



Sure


+ */
  struct task_struct *tsk = current;
disassociate_ctty(0);
@@ -536,7 +540,7 @@ static int tiocgsid(struct tty_struct *tty, struct
tty_struct *real_tty, pid_t _
  /*
   * (tty == real_tty) is a cheap way of
   * testing if the tty is NOT a master pty.
-*/
+ */
  if (tty == real_tty && current->signal->tty != real_tty)
  return -ENOTTY;








[PATCH v2 09/10] tty: tty_ldisc: Do not use assignment in if condition

2021-04-06 Thread Xiaofei Tan
Do not use assignment in if condition following the advice of
checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_ldisc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 874d238..56e67f7 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -508,7 +508,8 @@ static int tty_ldisc_failto(struct tty_struct *tty, int ld)
return PTR_ERR(disc);
tty->ldisc = disc;
tty_set_termios_ldisc(tty, ld);
-   if ((r = tty_ldisc_open(tty, disc)) < 0)
+   r = tty_ldisc_open(tty, disc);
+   if (r < 0)
tty_ldisc_put(disc);
return r;
 }
-- 
2.8.1



[PATCH v2 02/10] tty/sysrq: Fix issues of code indent should use tabs

2021-04-06 Thread Xiaofei Tan
Fix issues of code indent should use tabs, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/sysrq.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 0372ed7..6628792 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -548,22 +548,22 @@ static int sysrq_key_table_key2index(int key)
  */
 static const struct sysrq_key_op *__sysrq_get_key_op(int key)
 {
-const struct sysrq_key_op *op_p = NULL;
-int i;
+   const struct sysrq_key_op *op_p = NULL;
+   int i;
 
i = sysrq_key_table_key2index(key);
if (i != -1)
-   op_p = sysrq_key_table[i];
+   op_p = sysrq_key_table[i];
 
-return op_p;
+   return op_p;
 }
 
 static void __sysrq_put_key_op(int key, const struct sysrq_key_op *op_p)
 {
-int i = sysrq_key_table_key2index(key);
+   int i = sysrq_key_table_key2index(key);
 
-if (i != -1)
-sysrq_key_table[i] = op_p;
+   if (i != -1)
+   sysrq_key_table[i] = op_p;
 }
 
 void __handle_sysrq(int key, bool check_mask)
@@ -587,8 +587,8 @@ void __handle_sysrq(int key, bool check_mask)
orig_log_level = console_loglevel;
console_loglevel = CONSOLE_LOGLEVEL_DEFAULT;
 
-op_p = __sysrq_get_key_op(key);
-if (op_p) {
+   op_p = __sysrq_get_key_op(key);
+   if (op_p) {
/*
 * Should we check for enabled operations (/proc/sysrq-trigger
 * should not) and is the invoked operation enabled?
@@ -637,13 +637,13 @@ static int sysrq_reset_downtime_ms;
 
 /* Simple translation table for the SysRq keys */
 static const unsigned char sysrq_xlate[KEY_CNT] =
-"\000\0331234567890-=\177\t"/* 0x00 - 0x0f */
-"qwertyuiop[]\r\000as"  /* 0x10 - 0x1f */
-"dfghjkl;'`\000\\zxcv"  /* 0x20 - 0x2f */
-"bnm,./\000*\000 \000\201\202\203\204\205"  /* 0x30 - 0x3f */
-"\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
-"230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 
0x50 - 0x5f */
-"\r\000/";  /* 0x60 - 0x6f */
+   "\000\0331234567890-=\177\t"/* 0x00 - 0x0f */
+   "qwertyuiop[]\r\000as"  /* 0x10 - 0x1f */
+   "dfghjkl;'`\000\\zxcv"  /* 0x20 - 0x2f */
+   "bnm,./\000*\000 \000\201\202\203\204\205"  /* 0x30 - 0x3f */
+   "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
+   "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 
0x50 - 0x5f */
+   "\r\000/";  /* 0x60 - 0x6f */
 
 struct sysrq_state {
struct input_handle handle;
@@ -1108,7 +1108,7 @@ int sysrq_toggle_support(int enable_mask)
 EXPORT_SYMBOL_GPL(sysrq_toggle_support);
 
 static int __sysrq_swap_key_ops(int key, const struct sysrq_key_op 
*insert_op_p,
-const struct sysrq_key_op *remove_op_p)
+   const struct sysrq_key_op *remove_op_p)
 {
int retval;
 
-- 
2.8.1



[PATCH v2 07/10] tty: tty_ldisc: Add a blank line after declarations

2021-04-06 Thread Xiaofei Tan
Add a blank line after declarations, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_ldisc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 2992319..df0b589 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -771,6 +771,7 @@ void tty_ldisc_hangup(struct tty_struct *tty, bool reinit)
 int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty)
 {
int retval = tty_ldisc_open(tty, tty->ldisc);
+
if (retval)
return retval;
 
@@ -829,6 +830,7 @@ EXPORT_SYMBOL_GPL(tty_ldisc_release);
 int tty_ldisc_init(struct tty_struct *tty)
 {
struct tty_ldisc *ld = tty_ldisc_get(tty, N_TTY);
+
if (IS_ERR(ld))
return PTR_ERR(ld);
tty->ldisc = ld;
-- 
2.8.1



[PATCH v2 03/10] tty: tty_jobctrl: Add a blank line after declarations

2021-04-06 Thread Xiaofei Tan
Add a blank line after declarations, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_jobctrl.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c
index 4b751b9..86070f7 100644
--- a/drivers/tty/tty_jobctrl.c
+++ b/drivers/tty/tty_jobctrl.c
@@ -75,6 +75,7 @@ void proc_clear_tty(struct task_struct *p)
 {
unsigned long flags;
struct tty_struct *tty;
+
spin_lock_irqsave(>sighand->siglock, flags);
tty = p->signal->tty;
p->signal->tty = NULL;
@@ -173,6 +174,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
 void session_clear_tty(struct pid *session)
 {
struct task_struct *p;
+
do_each_pid_task(session, PIDTYPE_SID, p) {
proc_clear_tty(p);
} while_each_pid_task(session, PIDTYPE_SID, p);
@@ -269,6 +271,7 @@ void disassociate_ctty(int on_exit)
tty_vhangup_session(tty);
} else {
struct pid *tty_pgrp = tty_get_pgrp(tty);
+
if (tty_pgrp) {
kill_pgrp(tty_pgrp, SIGHUP, on_exit);
if (!on_exit)
@@ -280,6 +283,7 @@ void disassociate_ctty(int on_exit)
 
} else if (on_exit) {
struct pid *old_pgrp;
+
spin_lock_irq(>sighand->siglock);
old_pgrp = current->signal->tty_old_pgrp;
current->signal->tty_old_pgrp = NULL;
@@ -328,6 +332,7 @@ void no_tty(void)
   between a new association and proc_clear_tty but possible we need
   to protect against this anyway */
struct task_struct *tsk = current;
+
disassociate_ctty(0);
proc_clear_tty(tsk);
 }
-- 
2.8.1



[PATCH v2 10/10] tty: tty_ldisc: Remove the repeated word 'the'

2021-04-06 Thread Xiaofei Tan
Remove the repeated word 'the' following advice of checkpatch.pl

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_ldisc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 56e67f7..fdc4fa3 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -147,7 +147,7 @@ static int tty_ldisc_autoload = 
IS_BUILTIN(CONFIG_LDISC_AUTOLOAD);
  * Returns: -EINVAL if the discipline index is not [N_TTY..NR_LDISCS] or
  *  if the discipline is not registered
  *  -EAGAIN if request_module() failed to load or register the
- *  the discipline
+ *  discipline
  *  -ENOMEM if allocation failure
  *
  *  Otherwise, returns a pointer to the discipline and bumps the
-- 
2.8.1



[PATCH v2 08/10] tty: tty_ldisc: Fix coding style issues of block comments

2021-04-06 Thread Xiaofei Tan
Fix coding style issues of block comments, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_ldisc.c | 32 
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index df0b589..874d238 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -529,9 +529,11 @@ static void tty_ldisc_restore(struct tty_struct *tty, 
struct tty_ldisc *old)
const char *name = tty_name(tty);
 
pr_warn("Falling back ldisc for %s.\n", name);
-   /* The traditional behaviour is to fall back to N_TTY, we
-  want to avoid falling back to N_NULL unless we have no
-  choice to avoid the risk of breaking anything */
+   /*
+* The traditional behaviour is to fall back to N_TTY, we
+* want to avoid falling back to N_NULL unless we have no
+* choice to avoid the risk of breaking anything
+*/
if (tty_ldisc_failto(tty, N_TTY) < 0 &&
tty_ldisc_failto(tty, N_NULL) < 0)
panic("Couldn't open N_NULL ldisc for %s.", name);
@@ -600,17 +602,21 @@ int tty_set_ldisc(struct tty_struct *tty, int disc)
up_read(>termios_rwsem);
}
 
-   /* At this point we hold a reference to the new ldisc and a
-  reference to the old ldisc, or we hold two references to
-  the old ldisc (if it was restored as part of error cleanup
-  above). In either case, releasing a single reference from
-  the old ldisc is correct. */
+   /*
+* At this point we hold a reference to the new ldisc and a
+* reference to the old ldisc, or we hold two references to
+* the old ldisc (if it was restored as part of error cleanup
+* above). In either case, releasing a single reference from
+* the old ldisc is correct.
+*/
new_ldisc = old_ldisc;
 out:
tty_ldisc_unlock(tty);
 
-   /* Restart the work queue in case no characters kick it off. Safe if
-  already running */
+   /*
+* Restart the work queue in case no characters kick it off. Safe if
+* already running
+*/
tty_buffer_restart_work(tty->port);
 err:
tty_ldisc_put(new_ldisc);   /* drop the extra reference */
@@ -812,8 +818,10 @@ void tty_ldisc_release(struct tty_struct *tty)
tty_ldisc_kill(o_tty);
tty_ldisc_unlock_pair(tty, o_tty);
 
-   /* And the memory resources remaining (buffers, termios) will be
-  disposed of when the kref hits zero */
+   /*
+* And the memory resources remaining (buffers, termios) will be
+* disposed of when the kref hits zero
+*/
 
tty_ldisc_debug(tty, "released\n");
 }
-- 
2.8.1



[PATCH v2 01/10] tty/sysrq: Add a blank line after declarations

2021-04-06 Thread Xiaofei Tan
Add a blank line after declarations, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/sysrq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 959f9e1..0372ed7 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -118,6 +118,7 @@ static const struct sysrq_key_op sysrq_loglevel_op = {
 static void sysrq_handle_SAK(int key)
 {
struct work_struct *SAK_work = _cons[fg_console].SAK_work;
+
schedule_work(SAK_work);
 }
 static const struct sysrq_key_op sysrq_SAK_op = {
-- 
2.8.1



[PATCH v2 04/10] tty: tty_jobctrl: Fix coding style issues of block comments

2021-04-06 Thread Xiaofei Tan
Fix coding style issues of block comments, reported by checkpatch.pl.
Besides, do some expression optimization for the sentenses.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_jobctrl.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c
index 86070f7..7003b6b 100644
--- a/drivers/tty/tty_jobctrl.c
+++ b/drivers/tty/tty_jobctrl.c
@@ -204,8 +204,10 @@ int tty_signal_session_leader(struct tty_struct *tty, int 
exit_session)
spin_lock_irq(>sighand->siglock);
if (p->signal->tty == tty) {
p->signal->tty = NULL;
-   /* We defer the dereferences outside fo
-  the tasklist lock */
+   /*
+* We defer the dereferences outside of
+* the tasklist lock period
+*/
refs++;
}
if (!p->signal->leader) {
@@ -328,9 +330,11 @@ void disassociate_ctty(int on_exit)
  */
 void no_tty(void)
 {
-   /* FIXME: Review locking here. The tty_lock never covered any race
-  between a new association and proc_clear_tty but possible we need
-  to protect against this anyway */
+   /*
+* FIXME: Review locking here. The tty_lock never covered any race
+* between a new association and proc_clear_tty but possibly we need
+* to protect against this period anyway
+*/
struct task_struct *tsk = current;
 
disassociate_ctty(0);
@@ -536,7 +540,7 @@ static int tiocgsid(struct tty_struct *tty, struct 
tty_struct *real_tty, pid_t _
/*
 * (tty == real_tty) is a cheap way of
 * testing if the tty is NOT a master pty.
-   */
+*/
if (tty == real_tty && current->signal->tty != real_tty)
return -ENOTTY;
 
-- 
2.8.1



[PATCH v2 00/10] tty: Fix some coding style issues

2021-04-06 Thread Xiaofei Tan
Fix some issues reported by checkpatch.pl. All of them are
coding style issues, no function changes.

Differences from v1 to v2:
- Remove one redundant tab for the patch 02/10.
- Add some expression optimization for some sentenses following
- Jiri's advice for the patch 04/10.

Xiaofei Tan (10):
  tty/sysrq: Add a blank line after declarations
  tty/sysrq: Fix issues of code indent should use tabs
  tty: tty_jobctrl: Add a blank line after declarations
  tty: tty_jobctrl: Fix coding style issues of block comments
  tty: tty_jobctrl: Remove spaces before tabs
  tty: tty_ldisc: Fix an issue of code indent should use tabs
  tty: tty_ldisc: Add a blank line after declarations
  tty: tty_ldisc: Fix coding style issues of block comments
  tty: tty_ldisc: Do not use assignment in if condition
  tty: tty_ldisc: Remove the repeated word 'the'

 drivers/tty/sysrq.c   | 35 ++-
 drivers/tty/tty_jobctrl.c | 29 +++--
 drivers/tty/tty_ldisc.c   | 41 ++---
 3 files changed, 63 insertions(+), 42 deletions(-)

-- 
2.8.1



[PATCH v2 06/10] tty: tty_ldisc: Fix an issue of code indent should use tabs

2021-04-06 Thread Xiaofei Tan
Fix an issue of code indent should use tabs, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_ldisc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 1ba74d6..2992319 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -459,7 +459,7 @@ static int tty_ldisc_open(struct tty_struct *tty, struct 
tty_ldisc *ld)
WARN_ON(test_and_set_bit(TTY_LDISC_OPEN, >flags));
if (ld->ops->open) {
int ret;
-/* BTM here locks versus a hangup event */
+   /* BTM here locks versus a hangup event */
ret = ld->ops->open(tty);
if (ret)
clear_bit(TTY_LDISC_OPEN, >flags);
-- 
2.8.1



[PATCH v2 05/10] tty: tty_jobctrl: Remove spaces before tabs

2021-04-06 Thread Xiaofei Tan
Remove spaces before tabs following the advice of checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_jobctrl.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c
index 7003b6b..9cbb08a 100644
--- a/drivers/tty/tty_jobctrl.c
+++ b/drivers/tty/tty_jobctrl.c
@@ -244,10 +244,10 @@ int tty_signal_session_leader(struct tty_struct *tty, int 
exit_session)
  * it wants to disassociate itself from its controlling tty.
  *
  * It performs the following functions:
- * (1)  Sends a SIGHUP and SIGCONT to the foreground process group
- * (2)  Clears the tty from being controlling the session
- * (3)  Clears the controlling tty for all processes in the
- * session group.
+ * (1)  Sends a SIGHUP and SIGCONT to the foreground process group
+ * (2)  Clears the tty from being controlling the session
+ * (3)  Clears the controlling tty for all processes in the
+ * session group.
  *
  * The argument on_exit is set to 1 if called when a process is
  * exiting; it is 0 if called by the ioctl TIOCNOTTY.
-- 
2.8.1



Re: [PATCH 04/10] tty: tty_jobctrl: Fix coding style issues of block comments

2021-04-06 Thread Xiaofei Tan

Hi Jiri,

On 2021/4/6 12:42, Jiri Slaby wrote:

On 05. 04. 21, 5:34, Xiaofei Tan wrote:

Fix coding style issues of block comments, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
  drivers/tty/tty_jobctrl.c | 16 ++--
  1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c
index 86070f7..4d78422 100644
--- a/drivers/tty/tty_jobctrl.c
+++ b/drivers/tty/tty_jobctrl.c
@@ -204,8 +204,10 @@ int tty_signal_session_leader(struct tty_struct
*tty, int exit_session)
  spin_lock_irq(>sighand->siglock);
  if (p->signal->tty == tty) {
  p->signal->tty = NULL;
-/* We defer the dereferences outside fo
-   the tasklist lock */
+/*
+ * We defer the dereferences outside fo
+ * the tasklist lock


I don't know if it deserves its own patch, but fo -> of fix would be
nice. And add a period at the end of the sentence.



OK.I will add this fixes.


+ */
  refs++;
  }
  if (!p->signal->leader) {
@@ -328,9 +330,11 @@ void disassociate_ctty(int on_exit)
   */
  void no_tty(void)
  {
-/* FIXME: Review locking here. The tty_lock never covered any race
-   between a new association and proc_clear_tty but possible we need
-   to protect against this anyway */
+/*
+ * FIXME: Review locking here. The tty_lock never covered any race
+ * between a new association and proc_clear_tty but possible we need


"possibly" or "it's possible", I think (as a non-native).



OK


+ * to protect against this anyway


Period.


OK




+ */
  struct task_struct *tsk = current;
disassociate_ctty(0);
@@ -536,7 +540,7 @@ static int tiocgsid(struct tty_struct *tty, struct
tty_struct *real_tty, pid_t _
  /*
   * (tty == real_tty) is a cheap way of
   * testing if the tty is NOT a master pty.
-*/
+ */
  if (tty == real_tty && current->signal->tty != real_tty)
  return -ENOTTY;








Re: [PATCH 02/10] tty/sysrq: Fix issues of code indent should use tabs

2021-04-05 Thread Xiaofei Tan




On 2021/4/5 11:34, Xiaofei Tan wrote:

Fix issues of code indent should use tabs, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/sysrq.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 0372ed7..1ece100 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -548,22 +548,22 @@ static int sysrq_key_table_key2index(int key)
  */
 static const struct sysrq_key_op *__sysrq_get_key_op(int key)
 {
-const struct sysrq_key_op *op_p = NULL;
-int i;
+   const struct sysrq_key_op *op_p = NULL;
+   int i;

i = sysrq_key_table_key2index(key);
if (i != -1)
-   op_p = sysrq_key_table[i];
+   op_p = sysrq_key_table[i];

-return op_p;
+   return op_p;


Wow, one redundant tab here.


 }

 static void __sysrq_put_key_op(int key, const struct sysrq_key_op *op_p)
 {
-int i = sysrq_key_table_key2index(key);
+   int i = sysrq_key_table_key2index(key);

-if (i != -1)
-sysrq_key_table[i] = op_p;
+   if (i != -1)
+   sysrq_key_table[i] = op_p;
 }

 void __handle_sysrq(int key, bool check_mask)
@@ -587,8 +587,8 @@ void __handle_sysrq(int key, bool check_mask)
orig_log_level = console_loglevel;
console_loglevel = CONSOLE_LOGLEVEL_DEFAULT;

-op_p = __sysrq_get_key_op(key);
-if (op_p) {
+   op_p = __sysrq_get_key_op(key);
+   if (op_p) {
/*
 * Should we check for enabled operations (/proc/sysrq-trigger
 * should not) and is the invoked operation enabled?
@@ -637,13 +637,13 @@ static int sysrq_reset_downtime_ms;

 /* Simple translation table for the SysRq keys */
 static const unsigned char sysrq_xlate[KEY_CNT] =
-"\000\0331234567890-=\177\t"/* 0x00 - 0x0f */
-"qwertyuiop[]\r\000as"  /* 0x10 - 0x1f */
-"dfghjkl;'`\000\\zxcv"  /* 0x20 - 0x2f */
-"bnm,./\000*\000 \000\201\202\203\204\205"  /* 0x30 - 0x3f */
-"\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
-"230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 
0x50 - 0x5f */
-"\r\000/";  /* 0x60 - 0x6f */
+   "\000\0331234567890-=\177\t"/* 0x00 - 0x0f */
+   "qwertyuiop[]\r\000as"  /* 0x10 - 0x1f */
+   "dfghjkl;'`\000\\zxcv"  /* 0x20 - 0x2f */
+   "bnm,./\000*\000 \000\201\202\203\204\205"  /* 0x30 - 0x3f */
+   "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
+   "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 
0x50 - 0x5f */
+   "\r\000/";  /* 0x60 - 0x6f */

 struct sysrq_state {
struct input_handle handle;
@@ -1108,7 +1108,7 @@ int sysrq_toggle_support(int enable_mask)
 EXPORT_SYMBOL_GPL(sysrq_toggle_support);

 static int __sysrq_swap_key_ops(int key, const struct sysrq_key_op 
*insert_op_p,
-const struct sysrq_key_op *remove_op_p)
+   const struct sysrq_key_op *remove_op_p)
 {
int retval;






[PATCH 10/10] tty: tty_ldisc: Remove the repeated word 'the'

2021-04-04 Thread Xiaofei Tan
Remove the repeated word 'the' following advice of checkpatch.pl

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_ldisc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 56e67f7..fdc4fa3 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -147,7 +147,7 @@ static int tty_ldisc_autoload = 
IS_BUILTIN(CONFIG_LDISC_AUTOLOAD);
  * Returns: -EINVAL if the discipline index is not [N_TTY..NR_LDISCS] or
  *  if the discipline is not registered
  *  -EAGAIN if request_module() failed to load or register the
- *  the discipline
+ *  discipline
  *  -ENOMEM if allocation failure
  *
  *  Otherwise, returns a pointer to the discipline and bumps the
-- 
2.8.1



[PATCH 06/10] tty: tty_ldisc: Fix an issue of code indent should use tabs

2021-04-04 Thread Xiaofei Tan
Fix an issue of code indent should use tabs, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_ldisc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 1ba74d6..2992319 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -459,7 +459,7 @@ static int tty_ldisc_open(struct tty_struct *tty, struct 
tty_ldisc *ld)
WARN_ON(test_and_set_bit(TTY_LDISC_OPEN, >flags));
if (ld->ops->open) {
int ret;
-/* BTM here locks versus a hangup event */
+   /* BTM here locks versus a hangup event */
ret = ld->ops->open(tty);
if (ret)
clear_bit(TTY_LDISC_OPEN, >flags);
-- 
2.8.1



[PATCH 08/10] tty: tty_ldisc: Fix coding style issues of block comments

2021-04-04 Thread Xiaofei Tan
Fix coding style issues of block comments, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_ldisc.c | 32 
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index df0b589..874d238 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -529,9 +529,11 @@ static void tty_ldisc_restore(struct tty_struct *tty, 
struct tty_ldisc *old)
const char *name = tty_name(tty);
 
pr_warn("Falling back ldisc for %s.\n", name);
-   /* The traditional behaviour is to fall back to N_TTY, we
-  want to avoid falling back to N_NULL unless we have no
-  choice to avoid the risk of breaking anything */
+   /*
+* The traditional behaviour is to fall back to N_TTY, we
+* want to avoid falling back to N_NULL unless we have no
+* choice to avoid the risk of breaking anything
+*/
if (tty_ldisc_failto(tty, N_TTY) < 0 &&
tty_ldisc_failto(tty, N_NULL) < 0)
panic("Couldn't open N_NULL ldisc for %s.", name);
@@ -600,17 +602,21 @@ int tty_set_ldisc(struct tty_struct *tty, int disc)
up_read(>termios_rwsem);
}
 
-   /* At this point we hold a reference to the new ldisc and a
-  reference to the old ldisc, or we hold two references to
-  the old ldisc (if it was restored as part of error cleanup
-  above). In either case, releasing a single reference from
-  the old ldisc is correct. */
+   /*
+* At this point we hold a reference to the new ldisc and a
+* reference to the old ldisc, or we hold two references to
+* the old ldisc (if it was restored as part of error cleanup
+* above). In either case, releasing a single reference from
+* the old ldisc is correct.
+*/
new_ldisc = old_ldisc;
 out:
tty_ldisc_unlock(tty);
 
-   /* Restart the work queue in case no characters kick it off. Safe if
-  already running */
+   /*
+* Restart the work queue in case no characters kick it off. Safe if
+* already running
+*/
tty_buffer_restart_work(tty->port);
 err:
tty_ldisc_put(new_ldisc);   /* drop the extra reference */
@@ -812,8 +818,10 @@ void tty_ldisc_release(struct tty_struct *tty)
tty_ldisc_kill(o_tty);
tty_ldisc_unlock_pair(tty, o_tty);
 
-   /* And the memory resources remaining (buffers, termios) will be
-  disposed of when the kref hits zero */
+   /*
+* And the memory resources remaining (buffers, termios) will be
+* disposed of when the kref hits zero
+*/
 
tty_ldisc_debug(tty, "released\n");
 }
-- 
2.8.1



[PATCH 09/10] tty: tty_ldisc: Do not use assignment in if condition

2021-04-04 Thread Xiaofei Tan
Do not use assignment in if condition following the advice of
checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_ldisc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 874d238..56e67f7 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -508,7 +508,8 @@ static int tty_ldisc_failto(struct tty_struct *tty, int ld)
return PTR_ERR(disc);
tty->ldisc = disc;
tty_set_termios_ldisc(tty, ld);
-   if ((r = tty_ldisc_open(tty, disc)) < 0)
+   r = tty_ldisc_open(tty, disc);
+   if (r < 0)
tty_ldisc_put(disc);
return r;
 }
-- 
2.8.1



[PATCH 01/10] tty/sysrq: Add a blank line after declarations

2021-04-04 Thread Xiaofei Tan
Add a blank line after declarations, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/sysrq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 959f9e1..0372ed7 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -118,6 +118,7 @@ static const struct sysrq_key_op sysrq_loglevel_op = {
 static void sysrq_handle_SAK(int key)
 {
struct work_struct *SAK_work = _cons[fg_console].SAK_work;
+
schedule_work(SAK_work);
 }
 static const struct sysrq_key_op sysrq_SAK_op = {
-- 
2.8.1



[PATCH 05/10] tty: tty_jobctrl: Remove spaces before tabs

2021-04-04 Thread Xiaofei Tan
Remove spaces before tabs following the advice of checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_jobctrl.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c
index 4d78422..2f7d4ba 100644
--- a/drivers/tty/tty_jobctrl.c
+++ b/drivers/tty/tty_jobctrl.c
@@ -244,10 +244,10 @@ int tty_signal_session_leader(struct tty_struct *tty, int 
exit_session)
  * it wants to disassociate itself from its controlling tty.
  *
  * It performs the following functions:
- * (1)  Sends a SIGHUP and SIGCONT to the foreground process group
- * (2)  Clears the tty from being controlling the session
- * (3)  Clears the controlling tty for all processes in the
- * session group.
+ * (1)  Sends a SIGHUP and SIGCONT to the foreground process group
+ * (2)  Clears the tty from being controlling the session
+ * (3)  Clears the controlling tty for all processes in the
+ * session group.
  *
  * The argument on_exit is set to 1 if called when a process is
  * exiting; it is 0 if called by the ioctl TIOCNOTTY.
-- 
2.8.1



[PATCH 04/10] tty: tty_jobctrl: Fix coding style issues of block comments

2021-04-04 Thread Xiaofei Tan
Fix coding style issues of block comments, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_jobctrl.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c
index 86070f7..4d78422 100644
--- a/drivers/tty/tty_jobctrl.c
+++ b/drivers/tty/tty_jobctrl.c
@@ -204,8 +204,10 @@ int tty_signal_session_leader(struct tty_struct *tty, int 
exit_session)
spin_lock_irq(>sighand->siglock);
if (p->signal->tty == tty) {
p->signal->tty = NULL;
-   /* We defer the dereferences outside fo
-  the tasklist lock */
+   /*
+* We defer the dereferences outside fo
+* the tasklist lock
+*/
refs++;
}
if (!p->signal->leader) {
@@ -328,9 +330,11 @@ void disassociate_ctty(int on_exit)
  */
 void no_tty(void)
 {
-   /* FIXME: Review locking here. The tty_lock never covered any race
-  between a new association and proc_clear_tty but possible we need
-  to protect against this anyway */
+   /*
+* FIXME: Review locking here. The tty_lock never covered any race
+* between a new association and proc_clear_tty but possible we need
+* to protect against this anyway
+*/
struct task_struct *tsk = current;
 
disassociate_ctty(0);
@@ -536,7 +540,7 @@ static int tiocgsid(struct tty_struct *tty, struct 
tty_struct *real_tty, pid_t _
/*
 * (tty == real_tty) is a cheap way of
 * testing if the tty is NOT a master pty.
-   */
+*/
if (tty == real_tty && current->signal->tty != real_tty)
return -ENOTTY;
 
-- 
2.8.1



[PATCH 07/10] tty: tty_ldisc: Add a blank line after declarations

2021-04-04 Thread Xiaofei Tan
Add a blank line after declarations, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_ldisc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 2992319..df0b589 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -771,6 +771,7 @@ void tty_ldisc_hangup(struct tty_struct *tty, bool reinit)
 int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty)
 {
int retval = tty_ldisc_open(tty, tty->ldisc);
+
if (retval)
return retval;
 
@@ -829,6 +830,7 @@ EXPORT_SYMBOL_GPL(tty_ldisc_release);
 int tty_ldisc_init(struct tty_struct *tty)
 {
struct tty_ldisc *ld = tty_ldisc_get(tty, N_TTY);
+
if (IS_ERR(ld))
return PTR_ERR(ld);
tty->ldisc = ld;
-- 
2.8.1



[PATCH 02/10] tty/sysrq: Fix issues of code indent should use tabs

2021-04-04 Thread Xiaofei Tan
Fix issues of code indent should use tabs, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/sysrq.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 0372ed7..1ece100 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -548,22 +548,22 @@ static int sysrq_key_table_key2index(int key)
  */
 static const struct sysrq_key_op *__sysrq_get_key_op(int key)
 {
-const struct sysrq_key_op *op_p = NULL;
-int i;
+   const struct sysrq_key_op *op_p = NULL;
+   int i;
 
i = sysrq_key_table_key2index(key);
if (i != -1)
-   op_p = sysrq_key_table[i];
+   op_p = sysrq_key_table[i];
 
-return op_p;
+   return op_p;
 }
 
 static void __sysrq_put_key_op(int key, const struct sysrq_key_op *op_p)
 {
-int i = sysrq_key_table_key2index(key);
+   int i = sysrq_key_table_key2index(key);
 
-if (i != -1)
-sysrq_key_table[i] = op_p;
+   if (i != -1)
+   sysrq_key_table[i] = op_p;
 }
 
 void __handle_sysrq(int key, bool check_mask)
@@ -587,8 +587,8 @@ void __handle_sysrq(int key, bool check_mask)
orig_log_level = console_loglevel;
console_loglevel = CONSOLE_LOGLEVEL_DEFAULT;
 
-op_p = __sysrq_get_key_op(key);
-if (op_p) {
+   op_p = __sysrq_get_key_op(key);
+   if (op_p) {
/*
 * Should we check for enabled operations (/proc/sysrq-trigger
 * should not) and is the invoked operation enabled?
@@ -637,13 +637,13 @@ static int sysrq_reset_downtime_ms;
 
 /* Simple translation table for the SysRq keys */
 static const unsigned char sysrq_xlate[KEY_CNT] =
-"\000\0331234567890-=\177\t"/* 0x00 - 0x0f */
-"qwertyuiop[]\r\000as"  /* 0x10 - 0x1f */
-"dfghjkl;'`\000\\zxcv"  /* 0x20 - 0x2f */
-"bnm,./\000*\000 \000\201\202\203\204\205"  /* 0x30 - 0x3f */
-"\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
-"230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 
0x50 - 0x5f */
-"\r\000/";  /* 0x60 - 0x6f */
+   "\000\0331234567890-=\177\t"/* 0x00 - 0x0f */
+   "qwertyuiop[]\r\000as"  /* 0x10 - 0x1f */
+   "dfghjkl;'`\000\\zxcv"  /* 0x20 - 0x2f */
+   "bnm,./\000*\000 \000\201\202\203\204\205"  /* 0x30 - 0x3f */
+   "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
+   "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 
0x50 - 0x5f */
+   "\r\000/";  /* 0x60 - 0x6f */
 
 struct sysrq_state {
struct input_handle handle;
@@ -1108,7 +1108,7 @@ int sysrq_toggle_support(int enable_mask)
 EXPORT_SYMBOL_GPL(sysrq_toggle_support);
 
 static int __sysrq_swap_key_ops(int key, const struct sysrq_key_op 
*insert_op_p,
-const struct sysrq_key_op *remove_op_p)
+   const struct sysrq_key_op *remove_op_p)
 {
int retval;
 
-- 
2.8.1



[PATCH 00/10] tty: Fix some coding style issues

2021-04-04 Thread Xiaofei Tan
Fix some issues reported by checkpatch.pl. All of them are
coding style issues, no function changes.

Xiaofei Tan (10):
  tty/sysrq: Add a blank line after declarations
  tty/sysrq: Fix issues of code indent should use tabs
  tty: tty_jobctrl: Add a blank line after declarations
  tty: tty_jobctrl: Fix coding style issues of block comments
  tty: tty_jobctrl: Remove spaces before tabs
  tty: tty_ldisc: Fix an issue of code indent should use tabs
  tty: tty_ldisc: Add a blank line after declarations
  tty: tty_ldisc: Fix coding style issues of block comments
  tty: tty_ldisc: Do not use assignment in if condition
  tty: tty_ldisc: Remove the repeated word 'the'

 drivers/tty/sysrq.c   | 35 ++-
 drivers/tty/tty_jobctrl.c | 29 +++--
 drivers/tty/tty_ldisc.c   | 41 ++---
 3 files changed, 63 insertions(+), 42 deletions(-)

-- 
2.8.1



[PATCH 03/10] tty: tty_jobctrl: Add a blank line after declarations

2021-04-04 Thread Xiaofei Tan
Add a blank line after declarations, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/tty_jobctrl.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/tty/tty_jobctrl.c b/drivers/tty/tty_jobctrl.c
index 4b751b9..86070f7 100644
--- a/drivers/tty/tty_jobctrl.c
+++ b/drivers/tty/tty_jobctrl.c
@@ -75,6 +75,7 @@ void proc_clear_tty(struct task_struct *p)
 {
unsigned long flags;
struct tty_struct *tty;
+
spin_lock_irqsave(>sighand->siglock, flags);
tty = p->signal->tty;
p->signal->tty = NULL;
@@ -173,6 +174,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
 void session_clear_tty(struct pid *session)
 {
struct task_struct *p;
+
do_each_pid_task(session, PIDTYPE_SID, p) {
proc_clear_tty(p);
} while_each_pid_task(session, PIDTYPE_SID, p);
@@ -269,6 +271,7 @@ void disassociate_ctty(int on_exit)
tty_vhangup_session(tty);
} else {
struct pid *tty_pgrp = tty_get_pgrp(tty);
+
if (tty_pgrp) {
kill_pgrp(tty_pgrp, SIGHUP, on_exit);
if (!on_exit)
@@ -280,6 +283,7 @@ void disassociate_ctty(int on_exit)
 
} else if (on_exit) {
struct pid *old_pgrp;
+
spin_lock_irq(>sighand->siglock);
old_pgrp = current->signal->tty_old_pgrp;
current->signal->tty_old_pgrp = NULL;
@@ -328,6 +332,7 @@ void no_tty(void)
   between a new association and proc_clear_tty but possible we need
   to protect against this anyway */
struct task_struct *tsk = current;
+
disassociate_ctty(0);
proc_clear_tty(tsk);
 }
-- 
2.8.1



[PATCH] tty: pty: Add a blank line after declarations

2021-04-02 Thread Xiaofei Tan
Add a blank line after declarations, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/tty/pty.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 5e23745..106265a 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -159,6 +159,7 @@ static int pty_chars_in_buffer(struct tty_struct *tty)
 static int pty_set_lock(struct tty_struct *tty, int __user *arg)
 {
int val;
+
if (get_user(val, arg))
return -EFAULT;
if (val)
@@ -171,6 +172,7 @@ static int pty_set_lock(struct tty_struct *tty, int __user 
*arg)
 static int pty_get_lock(struct tty_struct *tty, int __user *arg)
 {
int locked = test_bit(TTY_PTY_LOCK, >flags);
+
return put_user(locked, arg);
 }
 
@@ -200,6 +202,7 @@ static int pty_set_pktmode(struct tty_struct *tty, int 
__user *arg)
 static int pty_get_pktmode(struct tty_struct *tty, int __user *arg)
 {
int pktmode = tty->packet;
+
return put_user(pktmode, arg);
 }
 
@@ -463,6 +466,7 @@ static int pty_install(struct tty_driver *driver, struct 
tty_struct *tty)
 static void pty_remove(struct tty_driver *driver, struct tty_struct *tty)
 {
struct tty_struct *pair = tty->link;
+
driver->ttys[tty->index] = NULL;
if (pair)
pair->driver->ttys[pair->index] = NULL;
-- 
2.8.1



[PATCH RFC for-next 1/1] arm64: sve: Fix some compile errors about sve_cond_update_zcr_vq

2021-03-31 Thread Xiaofei Tan
There are some compile errors of ARM64 KVM when ARM64_SVE is not
selected, in the locations of sve_cond_update_zcr_vq used.
One error log is as following:

  CC  arch/arm64/kvm/sys_regs.o
In file included from arch/arm64/kvm/hyp/vhe/switch.c:8:0:
./arch/arm64/kvm/hyp/include/hyp/switch.h: In function 
‘__hyp_sve_restore_guest’:
./arch/arm64/kvm/hyp/include/hyp/switch.h:220:2: error: implicit declaration of
function ‘sve_cond_update_zcr_vq’; did you mean
‘kvm_pmu_update_run’? [-Werror=implicit-function-declaration]
  sve_cond_update_zcr_vq(vcpu_sve_max_vq(vcpu) - 1, SYS_ZCR_EL2);
  ^~
  kvm_pmu_update_run

The root cause is that sve_cond_update_zcr_vq is not defined when
ARM64_SVE is not selected. Fix it by adding an empty definition
when CONFIG_ARM64_SVE=n.

Signed-off-by: Xiaofei Tan 
---
 arch/arm64/include/asm/fpsimd.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h
index 05c9c55..3f93b63 100644
--- a/arch/arm64/include/asm/fpsimd.h
+++ b/arch/arm64/include/asm/fpsimd.h
@@ -168,6 +168,8 @@ static inline int sve_get_current_vl(void)
 static inline void sve_user_disable(void) { BUILD_BUG(); }
 static inline void sve_user_enable(void) { BUILD_BUG(); }
 
+#define sve_cond_update_zcr_vq(val, reg)
+
 static inline void sve_init_vq_map(void) { }
 static inline void sve_update_vq_map(void) { }
 static inline int sve_verify_vq_map(void) { return 0; }
-- 
2.8.1



Re: [PATCH v2 04/15] ACPI: table: replace __attribute__((packed)) by __packed

2021-03-29 Thread Xiaofei Tan

Hi David,

On 2021/3/29 18:09, David Laight wrote:

From: Xiaofei Tan

Sent: 27 March 2021 07:46

Replace __attribute__((packed)) by __packed following the
advice of checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_fpdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/acpi_fpdt.c b/drivers/acpi/acpi_fpdt.c
index a89a806..690a88a 100644
--- a/drivers/acpi/acpi_fpdt.c
+++ b/drivers/acpi/acpi_fpdt.c
@@ -53,7 +53,7 @@ struct resume_performance_record {
u32 resume_count;
u64 resume_prev;
u64 resume_avg;
-} __attribute__((packed));
+} __packed;

 struct boot_performance_record {
struct fpdt_record_header header;
@@ -63,13 +63,13 @@ struct boot_performance_record {
u64 bootloader_launch;
u64 exitbootservice_start;
u64 exitbootservice_end;
-} __attribute__((packed));
+} __packed;

 struct suspend_performance_record {
struct fpdt_record_header header;
u64 suspend_start;
u64 suspend_end;
-} __attribute__((packed));
+} __packed;


My standard question about 'packed' is whether it is actually needed.
It should only be used if the structures might be misaligned in memory.
If the only problem is that a 64bit item needs to be 32bit aligned
then a suitable type should be used for those specific fields.

Those all look very dubious - the standard header isn't packed
so everything must eb assumed to be at least 32bit aligned.

There are also other sub-structures that contain 64bit values.
These don't contain padding - but that requires 64bit alignement.

The only problematic structure is the last one - which would have
a 32bit pad after the header.
Is this even right given than there are explicit alignment pads
in some of the other structures.

If 64bit alignment isn't guaranteed then a '64bit aligned to 32bit'
type should be used for the u64 fields.



Yes, some of them has been aligned already, then nothing changed when 
add this "packed ". Maybe the purpose of the original author is for 
extension, and can tell others that this struct need be packed.



David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, 
UK
Registration No: 1397386 (Wales)


.





Re: [Linuxarm] Re: [PATCH v3 00/12] acpi: fix some coding style issues

2021-03-29 Thread Xiaofei Tan

Hi Rafael,

On 2021/3/29 20:50, Rafael J. Wysocki wrote:

On Sat, Mar 27, 2021 at 1:11 PM Xiaofei Tan  wrote:


Fix some coding style issues reported by checkpatch.pl.
Only cleanup and no function changes.

Differences from v2 to v3:
- Remove the modifications that may cause function change.

Differences from v1 to v2:
- Add subsystem and module name in the name of patch 05/15.
- Change to use more proper module name for some patch names.

Xiaofei Tan (12):
  ACPI: APD: fix a block comment align issue
  ACPI: processor: fix some coding style issues
  ACPI: ipmi: remove useless return statement for void function
  ACPI: LPSS: add a missed blank line after declarations
  ACPI: acpi_pad: add a missed blank line after declarations
  ACPI: battery: fix some coding style issues
  ACPI: button: fix some coding style issues
  ACPI: CPPC: fix some coding style issues
  ACPI: custom_method: fix a coding style issue
  ACPI: PM: add a missed blank line after declarations
  ACPI: sysfs: fix some coding style issues
  ACPI: dock: fix some coding style issues

 drivers/acpi/acpi_apd.c   |  8 ++---
 drivers/acpi/acpi_ipmi.c  |  1 -
 drivers/acpi/acpi_lpss.c  |  2 ++
 drivers/acpi/acpi_pad.c   |  4 +++
 drivers/acpi/acpi_processor.c | 18 +++
 drivers/acpi/battery.c| 63 --
 drivers/acpi/button.c |  9 ++
 drivers/acpi/cppc_acpi.c  | 71 ++-
 drivers/acpi/custom_method.c  |  2 +-
 drivers/acpi/device_pm.c  |  3 ++
 drivers/acpi/device_sysfs.c   | 15 ++---
 drivers/acpi/dock.c   |  7 +++--
 12 files changed, 106 insertions(+), 97 deletions(-)

--


Can you please stop sending new versions of this for a while?



OK.



You've sent three of them over the last weekend and honestly I haven't
had a chance to look at the first one even.



I tried to fix a low-level mistake as quickly as possible. I'm sorry for 
that





___
Linuxarm mailing list -- linux...@openeuler.org
To unsubscribe send an email to linuxarm-le...@openeuler.org





[PATCH v3 04/12] ACPI: LPSS: add a missed blank line after declarations

2021-03-27 Thread Xiaofei Tan
Add a missed blank line after declarations, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_lpss.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index be73974..ca742f1 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -377,6 +377,7 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = 
{
 static int is_memory(struct acpi_resource *res, void *not_used)
 {
struct resource r;
+
return !acpi_dev_resource_memory(res, );
 }
 
@@ -1200,6 +1201,7 @@ static int acpi_lpss_poweroff_noirq(struct device *dev)
if (pdata->dev_desc->resume_from_noirq) {
/* This is analogous to the acpi_lpss_suspend_noirq() case. */
int ret = acpi_lpss_do_poweroff_late(dev);
+
if (ret)
return ret;
}
-- 
2.8.1



[PATCH v3 09/12] ACPI: custom_method: fix a coding style issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

ERROR: "foo * bar" should be "foo *bar"
FILE: drivers/acpi/custom_method.c:22:
+static ssize_t cm_write(struct file *file, const char __user * user_buf,

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/custom_method.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
index 7b54dc9..443fdf62 100644
--- a/drivers/acpi/custom_method.c
+++ b/drivers/acpi/custom_method.c
@@ -19,7 +19,7 @@ static struct dentry *cm_dentry;
 
 /* /sys/kernel/debug/acpi/custom_method */
 
-static ssize_t cm_write(struct file *file, const char __user * user_buf,
+static ssize_t cm_write(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos)
 {
static char *buf;
-- 
2.8.1



[PATCH v3 01/12] ACPI: APD: fix a block comment align issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl.
WARNING: Block comments should align the * on each line
+/**
+* Create platform device during acpi scan attach handle.

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_apd.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
index 39359ce..0ec5b3f 100644
--- a/drivers/acpi/acpi_apd.c
+++ b/drivers/acpi/acpi_apd.c
@@ -176,10 +176,10 @@ static const struct apd_device_desc hip08_spi_desc = {
 
 #endif
 
-/**
-* Create platform device during acpi scan attach handle.
-* Return value > 0 on success of creating device.
-*/
+/*
+ * Create platform device during acpi scan attach handle.
+ * Return value > 0 on success of creating device.
+ */
 static int acpi_apd_create_device(struct acpi_device *adev,
   const struct acpi_device_id *id)
 {
-- 
2.8.1



[PATCH v3 03/12] ACPI: ipmi: remove useless return statement for void function

2021-03-27 Thread Xiaofei Tan
Remove useless return statement for void function, reported by
checkpatch.pl.

WARNING: void function return statements are not generally useful
FILE: drivers/acpi/acpi_ipmi.c:482:
+   return;
+}

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_ipmi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/acpi/acpi_ipmi.c b/drivers/acpi/acpi_ipmi.c
index 9d6c0fc..bbd00d9 100644
--- a/drivers/acpi/acpi_ipmi.c
+++ b/drivers/acpi/acpi_ipmi.c
@@ -478,7 +478,6 @@ static void ipmi_register_bmc(int iface, struct device *dev)
ipmi_dev_release(ipmi_device);
 err_ref:
put_device(smi_data.dev);
-   return;
 }
 
 static void ipmi_bmc_gone(int iface)
-- 
2.8.1



[PATCH v3 05/12] ACPI: acpi_pad: add a missed blank line after declarations

2021-03-27 Thread Xiaofei Tan
Add a missed blank line after declarations, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_pad.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index b84ab72..df4adeb 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -128,6 +128,7 @@ static void round_robin_cpu(unsigned int tsk_index)
 static void exit_round_robin(unsigned int tsk_index)
 {
struct cpumask *pad_busy_cpus = to_cpumask(pad_busy_cpus_bits);
+
cpumask_clear_cpu(tsk_in_cpu[tsk_index], pad_busy_cpus);
tsk_in_cpu[tsk_index] = -1;
 }
@@ -265,6 +266,7 @@ static ssize_t rrtime_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
unsigned long num;
+
if (kstrtoul(buf, 0, ))
return -EINVAL;
if (num < 1 || num >= 100)
@@ -286,6 +288,7 @@ static ssize_t idlepct_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
unsigned long num;
+
if (kstrtoul(buf, 0, ))
return -EINVAL;
if (num < 1 || num >= 100)
@@ -307,6 +310,7 @@ static ssize_t idlecpus_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
unsigned long num;
+
if (kstrtoul(buf, 0, ))
return -EINVAL;
mutex_lock(_cpus_lock);
-- 
2.8.1



[PATCH v3 11/12] ACPI: sysfs: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Missing a blank line after declarations
WARNING: Block comments should align the * on each line
ERROR: open brace '{' following function definitions go on the next line

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/device_sysfs.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index da4ff2a..a07d4ad 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -73,6 +73,7 @@ static const struct sysfs_ops acpi_data_node_sysfs_ops = {
 static void acpi_data_node_release(struct kobject *kobj)
 {
struct acpi_data_node *dn = to_data_node(kobj);
+
complete(>kobj_done);
 }
 
@@ -130,7 +131,7 @@ static void acpi_hide_nondev_subnodes(struct 
acpi_device_data *data)
  * Return: 0: no _HID and no _CID
  * -EINVAL: output error
  * -ENOMEM: output is truncated
-*/
+ */
 static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias,
   int size)
 {
@@ -431,7 +432,8 @@ static DEVICE_ATTR_RO(path);
 /* sysfs file that shows description text from the ACPI _STR method */
 static ssize_t description_show(struct device *dev,
struct device_attribute *attr,
-   char *buf) {
+   char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
int result;
 
@@ -456,7 +458,8 @@ static DEVICE_ATTR_RO(description);
 
 static ssize_t
 sun_show(struct device *dev, struct device_attribute *attr,
-char *buf) {
+char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
acpi_status status;
unsigned long long sun;
@@ -471,7 +474,8 @@ static DEVICE_ATTR_RO(sun);
 
 static ssize_t
 hrv_show(struct device *dev, struct device_attribute *attr,
-char *buf) {
+char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
acpi_status status;
unsigned long long hrv;
@@ -485,7 +489,8 @@ hrv_show(struct device *dev, struct device_attribute *attr,
 static DEVICE_ATTR_RO(hrv);
 
 static ssize_t status_show(struct device *dev, struct device_attribute *attr,
-   char *buf) {
+   char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
acpi_status status;
unsigned long long sta;
-- 
2.8.1



[PATCH v3 06/12] ACPI: battery: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Block comments use * on subsequent lines
WARNING: Block comments use a trailing */ on a separate line
ERROR: code indent should use tabs where possible
WARNING: Missing a blank line after declarations
ERROR: spaces required around that '?' (ctx:WxV)
WARNING: Block comments should align the * on each line

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/battery.c | 63 +++---
 1 file changed, 34 insertions(+), 29 deletions(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index b822f77..dae91f9 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -74,16 +74,17 @@ enum {
ACPI_BATTERY_XINFO_PRESENT,
ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY,
/* On Lenovo Thinkpad models from 2010 and 2011, the power unit
-  switches between mWh and mAh depending on whether the system
-  is running on battery or not.  When mAh is the unit, most
-  reported values are incorrect and need to be adjusted by
-  1/design_voltage.  Verified on x201, t410, t410s, and x220.
-  Pre-2010 and 2012 models appear to always report in mWh and
-  are thus unaffected (tested with t42, t61, t500, x200, x300,
-  and x230).  Also, in mid-2012 Lenovo issued a BIOS update for
-  the 2011 models that fixes the issue (tested on x220 with a
-  post-1.29 BIOS), but as of Nov. 2012, no such update is
-  available for the 2010 models.  */
+* switches between mWh and mAh depending on whether the system
+* is running on battery or not.  When mAh is the unit, most
+* reported values are incorrect and need to be adjusted by
+* 1/design_voltage.  Verified on x201, t410, t410s, and x220.
+* Pre-2010 and 2012 models appear to always report in mWh and
+* are thus unaffected (tested with t42, t61, t500, x200, x300,
+* and x230).  Also, in mid-2012 Lenovo issued a BIOS update for
+*  the 2011 models that fixes the issue (tested on x220 with a
+* post-1.29 BIOS), but as of Nov. 2012, no such update is
+* available for the 2010 models.
+*/
ACPI_BATTERY_QUIRK_THINKPAD_MAH,
/* for batteries reporting current capacity with design capacity
 * on a full charge, but showing degradation in full charge cap.
@@ -371,9 +372,7 @@ static enum power_supply_property 
energy_battery_full_cap_broken_props[] = {
POWER_SUPPLY_PROP_SERIAL_NUMBER,
 };
 
-/* --
-   Battery Management
-   -- 
*/
+/* Battery Management */
 struct acpi_offsets {
size_t offset;  /* offset inside struct acpi_sbs_battery */
u8 mode;/* int or string? */
@@ -431,6 +430,7 @@ static int extract_package(struct acpi_battery *battery,
 {
int i;
union acpi_object *element;
+
if (package->type != ACPI_TYPE_PACKAGE)
return -EFAULT;
for (i = 0; i < num; ++i) {
@@ -439,6 +439,7 @@ static int extract_package(struct acpi_battery *battery,
element = >package.elements[i];
if (offsets[i].mode) {
u8 *ptr = (u8 *)battery + offsets[i].offset;
+
if (element->type == ACPI_TYPE_STRING ||
element->type == ACPI_TYPE_BUFFER)
strncpy(ptr, element->string.pointer, 32);
@@ -497,10 +498,12 @@ static int extract_battery_info(const int use_bix,
battery->design_capacity_warning *
1 / battery->design_voltage;
/* Curiously, design_capacity_low, unlike the rest of them,
-  is correct.  */
+*  is correct.
+*/
/* capacity_granularity_* equal 1 on the systems tested, so
-  it's impossible to tell if they would need an adjustment
-  or not if their values were higher.  */
+* it's impossible to tell if they would need an adjustment
+* or not if their values were higher.
+*/
}
if (test_bit(ACPI_BATTERY_QUIRK_DEGRADED_FULL_CHARGE, >flags) 
&&
battery->capacity_now > battery->full_charge_capacity)
@@ -532,8 +535,8 @@ static int acpi_battery_get_info(struct acpi_battery 
*battery)
if (ACPI_FAILURE(status)) {
acpi_handle_info(battery->device->handle,
 "%s evaluation failed: %s\n",
-use_bix ?"_BIX":"_BIF",
-

[PATCH v3 12/12] ACPI: dock: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Missing a blank line after declarations
ERROR: spaces required around that ':'
WARNING: Statements should start on a tabstop

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/dock.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 0937cea..7cf9215 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -271,6 +271,7 @@ static void hotplug_dock_devices(struct dock_station *ds, 
u32 event)
 
if (!acpi_device_enumerated(adev)) {
int ret = acpi_bus_scan(adev->handle);
+
if (ret)
dev_dbg(>dev, "scan error %d\n", -ret);
}
@@ -502,6 +503,7 @@ static ssize_t flags_show(struct device *dev,
  struct device_attribute *attr, char *buf)
 {
struct dock_station *dock_station = dev->platform_data;
+
return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
 
 }
@@ -523,7 +525,7 @@ static ssize_t undock_store(struct device *dev, struct 
device_attribute *attr,
begin_undock(dock_station);
ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST);
acpi_scan_lock_release();
-   return ret ? ret: count;
+   return ret ? ret : count;
 }
 static DEVICE_ATTR_WO(undock);
 
@@ -535,10 +537,11 @@ static ssize_t uid_show(struct device *dev,
 {
unsigned long long lbuf;
struct dock_station *dock_station = dev->platform_data;
+
acpi_status status = acpi_evaluate_integer(dock_station->handle,
"_UID", NULL, );
if (ACPI_FAILURE(status))
-   return 0;
+   return 0;
 
return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
 }
-- 
2.8.1



[PATCH v3 10/12] ACPI: PM: add a missed blank line after declarations

2021-03-27 Thread Xiaofei Tan
Add a missed blank line after declarations, reported by checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/device_pm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 0961537..16c0fe8 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -966,6 +966,7 @@ EXPORT_SYMBOL_GPL(acpi_dev_resume);
 int acpi_subsys_runtime_suspend(struct device *dev)
 {
int ret = pm_generic_runtime_suspend(dev);
+
return ret ? ret : acpi_dev_suspend(dev, true);
 }
 EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend);
@@ -980,6 +981,7 @@ EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend);
 int acpi_subsys_runtime_resume(struct device *dev)
 {
int ret = acpi_dev_resume(dev);
+
return ret ? ret : pm_generic_runtime_resume(dev);
 }
 EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume);
@@ -1171,6 +1173,7 @@ EXPORT_SYMBOL_GPL(acpi_subsys_freeze);
 int acpi_subsys_restore_early(struct device *dev)
 {
int ret = acpi_dev_resume(dev);
+
return ret ? ret : pm_generic_restore_early(dev);
 }
 EXPORT_SYMBOL_GPL(acpi_subsys_restore_early);
-- 
2.8.1



[PATCH v3 00/12] acpi: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl.
Only cleanup and no function changes.

Differences from v2 to v3:
- Remove the modifications that may cause function change.

Differences from v1 to v2:
- Add subsystem and module name in the name of patch 05/15.
- Change to use more proper module name for some patch names.

Xiaofei Tan (12):
  ACPI: APD: fix a block comment align issue
  ACPI: processor: fix some coding style issues
  ACPI: ipmi: remove useless return statement for void function
  ACPI: LPSS: add a missed blank line after declarations
  ACPI: acpi_pad: add a missed blank line after declarations
  ACPI: battery: fix some coding style issues
  ACPI: button: fix some coding style issues
  ACPI: CPPC: fix some coding style issues
  ACPI: custom_method: fix a coding style issue
  ACPI: PM: add a missed blank line after declarations
  ACPI: sysfs: fix some coding style issues
  ACPI: dock: fix some coding style issues

 drivers/acpi/acpi_apd.c   |  8 ++---
 drivers/acpi/acpi_ipmi.c  |  1 -
 drivers/acpi/acpi_lpss.c  |  2 ++
 drivers/acpi/acpi_pad.c   |  4 +++
 drivers/acpi/acpi_processor.c | 18 +++
 drivers/acpi/battery.c| 63 --
 drivers/acpi/button.c |  9 ++
 drivers/acpi/cppc_acpi.c  | 71 ++-
 drivers/acpi/custom_method.c  |  2 +-
 drivers/acpi/device_pm.c  |  3 ++
 drivers/acpi/device_sysfs.c   | 15 ++---
 drivers/acpi/dock.c   |  7 +++--
 12 files changed, 106 insertions(+), 97 deletions(-)

-- 
2.8.1



[PATCH v3 08/12] ACPI: CPPC: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Missing a blank line after declarations
WARNING: unnecessary whitespace before a quoted newline
ERROR: spaces required around that '>='
ERROR: switch and case should be at the same indent

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/cppc_acpi.c | 71 
 1 file changed, 36 insertions(+), 35 deletions(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index ae53740..3dbaf47 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -326,6 +326,7 @@ static int send_pcc_cmd(int pcc_ss_id, u16 cmd)
if (unlikely(ret)) {
for_each_possible_cpu(i) {
struct cpc_desc *desc = per_cpu(cpc_desc_ptr, 
i);
+
if (!desc)
continue;
 
@@ -777,7 +778,7 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
cpc_ptr->cpc_regs[i-2].type = ACPI_TYPE_BUFFER;
memcpy(_ptr->cpc_regs[i-2].cpc_entry.reg, gas_t, 
sizeof(*gas_t));
} else {
-   pr_debug("Err in entry:%d in CPC table of CPU:%d \n", 
i, pr->id);
+   pr_debug("Err in entry:%d in CPC table of CPU:%d\n", i, 
pr->id);
goto out_free;
}
}
@@ -867,7 +868,7 @@ void acpi_cppc_processor_exit(struct acpi_processor *pr)
void __iomem *addr;
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, pr->id);
 
-   if (pcc_ss_id >=0 && pcc_data[pcc_ss_id]) {
+   if (pcc_ss_id >= 0 && pcc_data[pcc_ss_id]) {
if (pcc_data[pcc_ss_id]->pcc_channel_acquired) {
pcc_data[pcc_ss_id]->refcount--;
if (!pcc_data[pcc_ss_id]->refcount) {
@@ -954,22 +955,22 @@ static int cpc_read(int cpu, struct cpc_register_resource 
*reg_res, u64 *val)
val, reg->bit_width);
 
switch (reg->bit_width) {
-   case 8:
-   *val = readb_relaxed(vaddr);
-   break;
-   case 16:
-   *val = readw_relaxed(vaddr);
-   break;
-   case 32:
-   *val = readl_relaxed(vaddr);
-   break;
-   case 64:
-   *val = readq_relaxed(vaddr);
-   break;
-   default:
-   pr_debug("Error: Cannot read %u bit width from PCC for 
ss: %d\n",
-reg->bit_width, pcc_ss_id);
-   ret_val = -EFAULT;
+   case 8:
+   *val = readb_relaxed(vaddr);
+   break;
+   case 16:
+   *val = readw_relaxed(vaddr);
+   break;
+   case 32:
+   *val = readl_relaxed(vaddr);
+   break;
+   case 64:
+   *val = readq_relaxed(vaddr);
+   break;
+   default:
+   pr_debug("Error: Cannot read %u bit width from PCC for ss: 
%d\n",
+reg->bit_width, pcc_ss_id);
+   ret_val = -EFAULT;
}
 
return ret_val;
@@ -993,23 +994,23 @@ static int cpc_write(int cpu, struct 
cpc_register_resource *reg_res, u64 val)
val, reg->bit_width);
 
switch (reg->bit_width) {
-   case 8:
-   writeb_relaxed(val, vaddr);
-   break;
-   case 16:
-   writew_relaxed(val, vaddr);
-   break;
-   case 32:
-   writel_relaxed(val, vaddr);
-   break;
-   case 64:
-   writeq_relaxed(val, vaddr);
-   break;
-   default:
-   pr_debug("Error: Cannot write %u bit width to PCC for 
ss: %d\n",
-reg->bit_width, pcc_ss_id);
-   ret_val = -EFAULT;
-   break;
+   case 8:
+   writeb_relaxed(val, vaddr);
+   break;
+   case 16:
+   writew_relaxed(val, vaddr);
+   break;
+   case 32:
+   writel_relaxed(val, vaddr);
+   break;
+   case 64:
+   writeq_relaxed(val, vaddr);
+   break;
+   default:
+   pr_debug("Error: Cannot write %u bit width to PCC for ss: %d\n",
+reg->bit_width, pcc_ss_id);
+   ret_val = -EFAULT;
+   break;
}
 
return ret_val;
-- 
2.8.1



[PATCH v3 02/12] ACPI: processor: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

ERROR: code indent should use tabs where possible
WARNING: Block comments use a trailing */ on a separate line
WARNING: Missing a blank line after declarations
WARNING: labels should not be indented

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_processor.c | 18 +-
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index fc89f3a..2d5bd2a 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -25,10 +25,7 @@
 DEFINE_PER_CPU(struct acpi_processor *, processors);
 EXPORT_PER_CPU_SYMBOL(processors);
 
-/* --
-Errata Handling
-   -- 
*/
-
+/* Errata Handling */
 struct acpi_processor_errata errata __read_mostly;
 EXPORT_SYMBOL_GPL(errata);
 
@@ -151,10 +148,7 @@ static int acpi_processor_errata(void)
return result;
 }
 
-/* --
-Initialization
-   -- 
*/
-
+/* Initialization */
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
 int __weak acpi_map_cpu(acpi_handle handle,
phys_cpuid_t physid, u32 acpi_id, int *pcpu)
@@ -306,6 +300,7 @@ static int acpi_processor_get_info(struct acpi_device 
*device)
 */
if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) {
int ret = acpi_processor_hotadd_init(pr);
+
if (ret)
return ret;
}
@@ -431,10 +426,7 @@ static int acpi_processor_add(struct acpi_device *device,
 }
 
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
-/* --
-Removal
-   -- 
*/
-
+/* Removal */
 static void acpi_processor_remove(struct acpi_device *device)
 {
struct acpi_processor *pr;
@@ -892,7 +884,7 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
 
info->count = last_index;
 
-  end:
+end:
kfree(buffer.pointer);
 
return ret;
-- 
2.8.1



[PATCH v3 07/12] ACPI: button: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Block comments use * on subsequent lines
WARNING: Block comments use a trailing */ on a separate line
ERROR: code indent should use tabs where possible

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/button.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 85e5e03..f25bd33 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -156,10 +156,7 @@ static unsigned long lid_report_interval __read_mostly = 
500;
 module_param(lid_report_interval, ulong, 0644);
 MODULE_PARM_DESC(lid_report_interval, "Interval (ms) between lid key events");
 
-/* --
-  FS Interface (/proc)
-   -- 
*/
-
+/* FS Interface (/proc) */
 static struct proc_dir_entry *acpi_button_dir;
 static struct proc_dir_entry *acpi_lid_dir;
 
@@ -348,9 +345,7 @@ static int acpi_button_remove_fs(struct acpi_device *device)
return 0;
 }
 
-/* --
-Driver Interface
-   -- 
*/
+/* Driver Interface */
 int acpi_lid_open(void)
 {
if (!lid_device)
-- 
2.8.1



Re: [PATCH 00/15] acpi: fix some coding style issues

2021-03-27 Thread Xiaofei Tan

OK. thanks for reviewing this patch set.

On 2021/3/27 16:21, Andy Shevchenko wrote:



On Saturday, March 27, 2021, Xiaofei Tan mailto:tanxiao...@huawei.com>> wrote:

Fix some coding style issues reported by checkpatch.pl
<http://checkpatch.pl>.



NAK until it’s proven that you have tested each change on the real
system (virtual more or less okay).



Differences from v1 to v2:
- Add subsystem and module name in the name of patch 05/15.
- Change to use more proper module name for some patch names.

    Xiaofei Tan (15):
  ACPI: APD: fix a block comment align issue
  ACPI: processor: fix some coding style issues
  ACPI: debug: fix some coding style issues
  ACPI: table: replace __attribute__((packed)) by __packed
  ACPI: ipmi: remove useless return statement for void function
  ACPI: LPSS: fix some coding style issues
  ACPI: memhotplug: fix a coding style issue
  ACPI: acpi_pad: fix a coding style issue
  ACPI: battery: fix some coding style issues
  ACPI: button: fix some coding style issues
  ACPI: CPPC: fix some coding style issues
  ACPI: custom_method: fix a coding style issue
  ACPI: PM: fix some coding style issues
  ACPI: sysfs: fix some coding style issues
  ACPI: dock: fix some coding style issues

 drivers/acpi/acpi_apd.c|  8 ++---
 drivers/acpi/acpi_dbg.c| 40 +++-
 drivers/acpi/acpi_fpdt.c   |  6 ++--
 drivers/acpi/acpi_ipmi.c   |  1 -
 drivers/acpi/acpi_lpss.c   |  4 ++-
 drivers/acpi/acpi_memhotplug.c |  2 +-
 drivers/acpi/acpi_pad.c|  4 +++
 drivers/acpi/acpi_processor.c  | 18 +++
 drivers/acpi/battery.c | 64
+
 drivers/acpi/button.c  | 10 +++---
 drivers/acpi/cppc_acpi.c   | 71
+-
 drivers/acpi/custom_method.c   |  2 +-
 drivers/acpi/device_pm.c   |  3 ++
 drivers/acpi/device_sysfs.c| 15 ++---
 drivers/acpi/dock.c|  7 +++--
 15 files changed, 138 insertions(+), 117 deletions(-)

--
2.8.1



--
With Best Regards,
Andy Shevchenko






Re: [PATCH v2 06/15] ACPI: LPSS: fix some coding style issues

2021-03-27 Thread Xiaofei Tan

Hi Andy,

On 2021/3/27 16:19, Andy Shevchenko wrote:



On Saturday, March 27, 2021, Xiaofei Tan mailto:tanxiao...@huawei.com>> wrote:

Fix some coding style issues reported by checkpatch.pl
<http://checkpatch.pl>, including
following types:

WARNING: simple_strtol is obsolete, use kstrtol instead


And one more thing, the above message is bogus. Read what the comments
in the code says about use cases for simple_*() vs. kstrto*() ones.



OK. I would remove this modification from the patch.


Joe?


WARNING: Missing a blank line after declarations

Signed-off-by: Xiaofei Tan mailto:tanxiao...@huawei.com>>
---
 drivers/acpi/acpi_lpss.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index be73974..2df231e 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -187,7 +187,7 @@ static void byt_i2c_setup(struct
lpss_private_data *pdata)

/* Expected to always be true, but better safe then sorry */
if (uid_str)
-   uid = simple_strtol(uid_str, NULL, 10);
+   uid = kstrtol(uid_str, NULL, 10);

/* Detect I2C bus shared with PUNIT and ignore its d3 status */
status = acpi_evaluate_integer(handle, "_SEM", NULL,
_host);
@@ -377,6 +377,7 @@ static const struct acpi_device_id
acpi_lpss_device_ids[] = {
 static int is_memory(struct acpi_resource *res, void *not_used)
 {
struct resource r;
+
return !acpi_dev_resource_memory(res, );
 }

@@ -1200,6 +1201,7 @@ static int acpi_lpss_poweroff_noirq(struct
device *dev)
if (pdata->dev_desc->resume_from_noirq) {
/* This is analogous to the
acpi_lpss_suspend_noirq() case. */
int ret = acpi_lpss_do_poweroff_late(dev);
+
if (ret)
return ret;
}
--
2.8.1



--
With Best Regards,
Andy Shevchenko






Re: [PATCH v2 06/15] ACPI: LPSS: fix some coding style issues

2021-03-27 Thread Xiaofei Tan

Hi Andy,

On 2021/3/27 16:17, Andy Shevchenko wrote:



On Saturday, March 27, 2021, Xiaofei Tan mailto:tanxiao...@huawei.com>> wrote:

Fix some coding style issues reported by checkpatch.pl
<http://checkpatch.pl>, including
following types:

WARNING: simple_strtol is obsolete, use kstrtol instead
WARNING: Missing a blank line after declarations



First of all, two changes ==> two patches.



I thought it would be better to include more simple cleanup in one patch.




Signed-off-by: Xiaofei Tan mailto:tanxiao...@huawei.com>>
---
 drivers/acpi/acpi_lpss.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index be73974..2df231e 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -187,7 +187,7 @@ static void byt_i2c_setup(struct
lpss_private_data *pdata)

/* Expected to always be true, but better safe then sorry */
if (uid_str)
-   uid = simple_strtol(uid_str, NULL, 10);
+   uid = kstrtol(uid_str, NULL, 10);


How did you test this? Is there any guarantee that input is
null-terminated number?

Where is the check of returned value from `kstrtol()`?

Yes, you haven’t tested that at all. Don’t submit patches you are not
able to test and haven’t tested.



It's my fault. Sorry for that, i will fix it.


NAK.


/* Detect I2C bus shared with PUNIT and ignore its d3 status */
status = acpi_evaluate_integer(handle, "_SEM", NULL,
_host);
@@ -377,6 +377,7 @@ static const struct acpi_device_id
acpi_lpss_device_ids[] = {
 static int is_memory(struct acpi_resource *res, void *not_used)
 {
struct resource r;
+
return !acpi_dev_resource_memory(res, );
 }

@@ -1200,6 +1201,7 @@ static int acpi_lpss_poweroff_noirq(struct
device *dev)
if (pdata->dev_desc->resume_from_noirq) {
/* This is analogous to the
acpi_lpss_suspend_noirq() case. */
int ret = acpi_lpss_do_poweroff_late(dev);
+
if (ret)
return ret;
}
--
2.8.1



--
With Best Regards,
Andy Shevchenko






[PATCH v2 02/15] ACPI: processor: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

ERROR: code indent should use tabs where possible
WARNING: Block comments use a trailing */ on a separate line
WARNING: Missing a blank line after declarations
WARNING: labels should not be indented

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_processor.c | 18 +-
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index fc89f3a..2d5bd2a 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -25,10 +25,7 @@
 DEFINE_PER_CPU(struct acpi_processor *, processors);
 EXPORT_PER_CPU_SYMBOL(processors);
 
-/* --
-Errata Handling
-   -- 
*/
-
+/* Errata Handling */
 struct acpi_processor_errata errata __read_mostly;
 EXPORT_SYMBOL_GPL(errata);
 
@@ -151,10 +148,7 @@ static int acpi_processor_errata(void)
return result;
 }
 
-/* --
-Initialization
-   -- 
*/
-
+/* Initialization */
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
 int __weak acpi_map_cpu(acpi_handle handle,
phys_cpuid_t physid, u32 acpi_id, int *pcpu)
@@ -306,6 +300,7 @@ static int acpi_processor_get_info(struct acpi_device 
*device)
 */
if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) {
int ret = acpi_processor_hotadd_init(pr);
+
if (ret)
return ret;
}
@@ -431,10 +426,7 @@ static int acpi_processor_add(struct acpi_device *device,
 }
 
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
-/* --
-Removal
-   -- 
*/
-
+/* Removal */
 static void acpi_processor_remove(struct acpi_device *device)
 {
struct acpi_processor *pr;
@@ -892,7 +884,7 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
 
info->count = last_index;
 
-  end:
+end:
kfree(buffer.pointer);
 
return ret;
-- 
2.8.1



[PATCH v2 10/15] ACPI: button: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Block comments use * on subsequent lines
WARNING: Block comments use a trailing */ on a separate line
ERROR: code indent should use tabs where possible

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/button.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 85e5e03..c66db72 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -157,8 +157,9 @@ module_param(lid_report_interval, ulong, 0644);
 MODULE_PARM_DESC(lid_report_interval, "Interval (ms) between lid key events");
 
 /* --
-  FS Interface (/proc)
-   -- 
*/
+ * FS Interface (/proc)
+ * --
+ */
 
 static struct proc_dir_entry *acpi_button_dir;
 static struct proc_dir_entry *acpi_lid_dir;
@@ -349,8 +350,9 @@ static int acpi_button_remove_fs(struct acpi_device *device)
 }
 
 /* --
-Driver Interface
-   -- 
*/
+ * Driver Interface
+ * --
+ */
 int acpi_lid_open(void)
 {
if (!lid_device)
-- 
2.8.1



[PATCH v2 11/15] ACPI: CPPC: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Missing a blank line after declarations
WARNING: unnecessary whitespace before a quoted newline
ERROR: spaces required around that '>='
ERROR: switch and case should be at the same indent

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/cppc_acpi.c | 71 
 1 file changed, 36 insertions(+), 35 deletions(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index ae53740..3dbaf47 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -326,6 +326,7 @@ static int send_pcc_cmd(int pcc_ss_id, u16 cmd)
if (unlikely(ret)) {
for_each_possible_cpu(i) {
struct cpc_desc *desc = per_cpu(cpc_desc_ptr, 
i);
+
if (!desc)
continue;
 
@@ -777,7 +778,7 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
cpc_ptr->cpc_regs[i-2].type = ACPI_TYPE_BUFFER;
memcpy(_ptr->cpc_regs[i-2].cpc_entry.reg, gas_t, 
sizeof(*gas_t));
} else {
-   pr_debug("Err in entry:%d in CPC table of CPU:%d \n", 
i, pr->id);
+   pr_debug("Err in entry:%d in CPC table of CPU:%d\n", i, 
pr->id);
goto out_free;
}
}
@@ -867,7 +868,7 @@ void acpi_cppc_processor_exit(struct acpi_processor *pr)
void __iomem *addr;
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, pr->id);
 
-   if (pcc_ss_id >=0 && pcc_data[pcc_ss_id]) {
+   if (pcc_ss_id >= 0 && pcc_data[pcc_ss_id]) {
if (pcc_data[pcc_ss_id]->pcc_channel_acquired) {
pcc_data[pcc_ss_id]->refcount--;
if (!pcc_data[pcc_ss_id]->refcount) {
@@ -954,22 +955,22 @@ static int cpc_read(int cpu, struct cpc_register_resource 
*reg_res, u64 *val)
val, reg->bit_width);
 
switch (reg->bit_width) {
-   case 8:
-   *val = readb_relaxed(vaddr);
-   break;
-   case 16:
-   *val = readw_relaxed(vaddr);
-   break;
-   case 32:
-   *val = readl_relaxed(vaddr);
-   break;
-   case 64:
-   *val = readq_relaxed(vaddr);
-   break;
-   default:
-   pr_debug("Error: Cannot read %u bit width from PCC for 
ss: %d\n",
-reg->bit_width, pcc_ss_id);
-   ret_val = -EFAULT;
+   case 8:
+   *val = readb_relaxed(vaddr);
+   break;
+   case 16:
+   *val = readw_relaxed(vaddr);
+   break;
+   case 32:
+   *val = readl_relaxed(vaddr);
+   break;
+   case 64:
+   *val = readq_relaxed(vaddr);
+   break;
+   default:
+   pr_debug("Error: Cannot read %u bit width from PCC for ss: 
%d\n",
+reg->bit_width, pcc_ss_id);
+   ret_val = -EFAULT;
}
 
return ret_val;
@@ -993,23 +994,23 @@ static int cpc_write(int cpu, struct 
cpc_register_resource *reg_res, u64 val)
val, reg->bit_width);
 
switch (reg->bit_width) {
-   case 8:
-   writeb_relaxed(val, vaddr);
-   break;
-   case 16:
-   writew_relaxed(val, vaddr);
-   break;
-   case 32:
-   writel_relaxed(val, vaddr);
-   break;
-   case 64:
-   writeq_relaxed(val, vaddr);
-   break;
-   default:
-   pr_debug("Error: Cannot write %u bit width to PCC for 
ss: %d\n",
-reg->bit_width, pcc_ss_id);
-   ret_val = -EFAULT;
-   break;
+   case 8:
+   writeb_relaxed(val, vaddr);
+   break;
+   case 16:
+   writew_relaxed(val, vaddr);
+   break;
+   case 32:
+   writel_relaxed(val, vaddr);
+   break;
+   case 64:
+   writeq_relaxed(val, vaddr);
+   break;
+   default:
+   pr_debug("Error: Cannot write %u bit width to PCC for ss: %d\n",
+reg->bit_width, pcc_ss_id);
+   ret_val = -EFAULT;
+   break;
}
 
return ret_val;
-- 
2.8.1



[PATCH v2 13/15] ACPI: PM: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

WARNING: Missing a blank line after declarations

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/device_pm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 0961537..16c0fe8 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -966,6 +966,7 @@ EXPORT_SYMBOL_GPL(acpi_dev_resume);
 int acpi_subsys_runtime_suspend(struct device *dev)
 {
int ret = pm_generic_runtime_suspend(dev);
+
return ret ? ret : acpi_dev_suspend(dev, true);
 }
 EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend);
@@ -980,6 +981,7 @@ EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend);
 int acpi_subsys_runtime_resume(struct device *dev)
 {
int ret = acpi_dev_resume(dev);
+
return ret ? ret : pm_generic_runtime_resume(dev);
 }
 EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume);
@@ -1171,6 +1173,7 @@ EXPORT_SYMBOL_GPL(acpi_subsys_freeze);
 int acpi_subsys_restore_early(struct device *dev)
 {
int ret = acpi_dev_resume(dev);
+
return ret ? ret : pm_generic_restore_early(dev);
 }
 EXPORT_SYMBOL_GPL(acpi_subsys_restore_early);
-- 
2.8.1



[PATCH v2 09/15] ACPI: battery: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Block comments use * on subsequent lines
WARNING: Block comments use a trailing */ on a separate line
ERROR: code indent should use tabs where possible
WARNING: Missing a blank line after declarations
ERROR: spaces required around that '?' (ctx:WxV)
WARNING: Block comments should align the * on each line

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/battery.c | 64 ++
 1 file changed, 38 insertions(+), 26 deletions(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index b822f77..a0d8ead 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -74,16 +74,17 @@ enum {
ACPI_BATTERY_XINFO_PRESENT,
ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY,
/* On Lenovo Thinkpad models from 2010 and 2011, the power unit
-  switches between mWh and mAh depending on whether the system
-  is running on battery or not.  When mAh is the unit, most
-  reported values are incorrect and need to be adjusted by
-  1/design_voltage.  Verified on x201, t410, t410s, and x220.
-  Pre-2010 and 2012 models appear to always report in mWh and
-  are thus unaffected (tested with t42, t61, t500, x200, x300,
-  and x230).  Also, in mid-2012 Lenovo issued a BIOS update for
-  the 2011 models that fixes the issue (tested on x220 with a
-  post-1.29 BIOS), but as of Nov. 2012, no such update is
-  available for the 2010 models.  */
+* switches between mWh and mAh depending on whether the system
+* is running on battery or not.  When mAh is the unit, most
+* reported values are incorrect and need to be adjusted by
+* 1/design_voltage.  Verified on x201, t410, t410s, and x220.
+* Pre-2010 and 2012 models appear to always report in mWh and
+* are thus unaffected (tested with t42, t61, t500, x200, x300,
+* and x230).  Also, in mid-2012 Lenovo issued a BIOS update for
+*  the 2011 models that fixes the issue (tested on x220 with a
+* post-1.29 BIOS), but as of Nov. 2012, no such update is
+* available for the 2010 models.
+*/
ACPI_BATTERY_QUIRK_THINKPAD_MAH,
/* for batteries reporting current capacity with design capacity
 * on a full charge, but showing degradation in full charge cap.
@@ -372,8 +373,9 @@ static enum power_supply_property 
energy_battery_full_cap_broken_props[] = {
 };
 
 /* --
-   Battery Management
-   -- 
*/
+ * Battery Management
+ * --
+ */
 struct acpi_offsets {
size_t offset;  /* offset inside struct acpi_sbs_battery */
u8 mode;/* int or string? */
@@ -431,6 +433,7 @@ static int extract_package(struct acpi_battery *battery,
 {
int i;
union acpi_object *element;
+
if (package->type != ACPI_TYPE_PACKAGE)
return -EFAULT;
for (i = 0; i < num; ++i) {
@@ -439,6 +442,7 @@ static int extract_package(struct acpi_battery *battery,
element = >package.elements[i];
if (offsets[i].mode) {
u8 *ptr = (u8 *)battery + offsets[i].offset;
+
if (element->type == ACPI_TYPE_STRING ||
element->type == ACPI_TYPE_BUFFER)
strncpy(ptr, element->string.pointer, 32);
@@ -497,10 +501,12 @@ static int extract_battery_info(const int use_bix,
battery->design_capacity_warning *
1 / battery->design_voltage;
/* Curiously, design_capacity_low, unlike the rest of them,
-  is correct.  */
+*  is correct.
+*/
/* capacity_granularity_* equal 1 on the systems tested, so
-  it's impossible to tell if they would need an adjustment
-  or not if their values were higher.  */
+* it's impossible to tell if they would need an adjustment
+* or not if their values were higher.
+*/
}
if (test_bit(ACPI_BATTERY_QUIRK_DEGRADED_FULL_CHARGE, >flags) 
&&
battery->capacity_now > battery->full_charge_capacity)
@@ -532,8 +538,8 @@ static int acpi_battery_get_info(struct acpi_battery 
*battery)
if (ACPI_FAILURE(status)) {
acpi_handle_info(battery->device->handle,
 "%s evaluation failed: %s\n",
- 

[PATCH v2 06/15] ACPI: LPSS: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: simple_strtol is obsolete, use kstrtol instead
WARNING: Missing a blank line after declarations

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_lpss.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index be73974..2df231e 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -187,7 +187,7 @@ static void byt_i2c_setup(struct lpss_private_data *pdata)
 
/* Expected to always be true, but better safe then sorry */
if (uid_str)
-   uid = simple_strtol(uid_str, NULL, 10);
+   uid = kstrtol(uid_str, NULL, 10);
 
/* Detect I2C bus shared with PUNIT and ignore its d3 status */
status = acpi_evaluate_integer(handle, "_SEM", NULL, _host);
@@ -377,6 +377,7 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = 
{
 static int is_memory(struct acpi_resource *res, void *not_used)
 {
struct resource r;
+
return !acpi_dev_resource_memory(res, );
 }
 
@@ -1200,6 +1201,7 @@ static int acpi_lpss_poweroff_noirq(struct device *dev)
if (pdata->dev_desc->resume_from_noirq) {
/* This is analogous to the acpi_lpss_suspend_noirq() case. */
int ret = acpi_lpss_do_poweroff_late(dev);
+
if (ret)
return ret;
}
-- 
2.8.1



[PATCH v2 12/15] ACPI: custom_method: fix a coding style issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

ERROR: "foo * bar" should be "foo *bar"
FILE: drivers/acpi/custom_method.c:22:
+static ssize_t cm_write(struct file *file, const char __user * user_buf,

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/custom_method.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
index 7b54dc9..443fdf62 100644
--- a/drivers/acpi/custom_method.c
+++ b/drivers/acpi/custom_method.c
@@ -19,7 +19,7 @@ static struct dentry *cm_dentry;
 
 /* /sys/kernel/debug/acpi/custom_method */
 
-static ssize_t cm_write(struct file *file, const char __user * user_buf,
+static ssize_t cm_write(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos)
 {
static char *buf;
-- 
2.8.1



[PATCH v2 07/15] ACPI: memhotplug: fix a coding style issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

WARNING: __initdata should be placed after acpi_no_memhotplug
FILE: drivers/acpi/acpi_memhotplug.c:326:
+static bool __initdata acpi_no_memhotplug;

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_memhotplug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 8cc195c..5c5ed22 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -323,7 +323,7 @@ static void acpi_memory_device_remove(struct acpi_device 
*device)
acpi_memory_device_free(mem_device);
 }
 
-static bool __initdata acpi_no_memhotplug;
+static bool acpi_no_memhotplug __initdata;
 
 void __init acpi_memory_hotplug_init(void)
 {
-- 
2.8.1



[PATCH v2 08/15] ACPI: acpi_pad: fix a coding style issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

WARNING: Missing a blank line after declarations

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_pad.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index b84ab72..df4adeb 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -128,6 +128,7 @@ static void round_robin_cpu(unsigned int tsk_index)
 static void exit_round_robin(unsigned int tsk_index)
 {
struct cpumask *pad_busy_cpus = to_cpumask(pad_busy_cpus_bits);
+
cpumask_clear_cpu(tsk_in_cpu[tsk_index], pad_busy_cpus);
tsk_in_cpu[tsk_index] = -1;
 }
@@ -265,6 +266,7 @@ static ssize_t rrtime_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
unsigned long num;
+
if (kstrtoul(buf, 0, ))
return -EINVAL;
if (num < 1 || num >= 100)
@@ -286,6 +288,7 @@ static ssize_t idlepct_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
unsigned long num;
+
if (kstrtoul(buf, 0, ))
return -EINVAL;
if (num < 1 || num >= 100)
@@ -307,6 +310,7 @@ static ssize_t idlecpus_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
unsigned long num;
+
if (kstrtoul(buf, 0, ))
return -EINVAL;
mutex_lock(_cpus_lock);
-- 
2.8.1



[PATCH v2 15/15] ACPI: dock: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Missing a blank line after declarations
ERROR: spaces required around that ':'
WARNING: Statements should start on a tabstop

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/dock.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 0937cea..7cf9215 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -271,6 +271,7 @@ static void hotplug_dock_devices(struct dock_station *ds, 
u32 event)
 
if (!acpi_device_enumerated(adev)) {
int ret = acpi_bus_scan(adev->handle);
+
if (ret)
dev_dbg(>dev, "scan error %d\n", -ret);
}
@@ -502,6 +503,7 @@ static ssize_t flags_show(struct device *dev,
  struct device_attribute *attr, char *buf)
 {
struct dock_station *dock_station = dev->platform_data;
+
return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
 
 }
@@ -523,7 +525,7 @@ static ssize_t undock_store(struct device *dev, struct 
device_attribute *attr,
begin_undock(dock_station);
ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST);
acpi_scan_lock_release();
-   return ret ? ret: count;
+   return ret ? ret : count;
 }
 static DEVICE_ATTR_WO(undock);
 
@@ -535,10 +537,11 @@ static ssize_t uid_show(struct device *dev,
 {
unsigned long long lbuf;
struct dock_station *dock_station = dev->platform_data;
+
acpi_status status = acpi_evaluate_integer(dock_station->handle,
"_UID", NULL, );
if (ACPI_FAILURE(status))
-   return 0;
+   return 0;
 
return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
 }
-- 
2.8.1



[PATCH v2 14/15] ACPI: sysfs: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Missing a blank line after declarations
WARNING: Block comments should align the * on each line
ERROR: open brace '{' following function definitions go on the next line

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/device_sysfs.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index da4ff2a..a07d4ad 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -73,6 +73,7 @@ static const struct sysfs_ops acpi_data_node_sysfs_ops = {
 static void acpi_data_node_release(struct kobject *kobj)
 {
struct acpi_data_node *dn = to_data_node(kobj);
+
complete(>kobj_done);
 }
 
@@ -130,7 +131,7 @@ static void acpi_hide_nondev_subnodes(struct 
acpi_device_data *data)
  * Return: 0: no _HID and no _CID
  * -EINVAL: output error
  * -ENOMEM: output is truncated
-*/
+ */
 static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias,
   int size)
 {
@@ -431,7 +432,8 @@ static DEVICE_ATTR_RO(path);
 /* sysfs file that shows description text from the ACPI _STR method */
 static ssize_t description_show(struct device *dev,
struct device_attribute *attr,
-   char *buf) {
+   char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
int result;
 
@@ -456,7 +458,8 @@ static DEVICE_ATTR_RO(description);
 
 static ssize_t
 sun_show(struct device *dev, struct device_attribute *attr,
-char *buf) {
+char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
acpi_status status;
unsigned long long sun;
@@ -471,7 +474,8 @@ static DEVICE_ATTR_RO(sun);
 
 static ssize_t
 hrv_show(struct device *dev, struct device_attribute *attr,
-char *buf) {
+char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
acpi_status status;
unsigned long long hrv;
@@ -485,7 +489,8 @@ hrv_show(struct device *dev, struct device_attribute *attr,
 static DEVICE_ATTR_RO(hrv);
 
 static ssize_t status_show(struct device *dev, struct device_attribute *attr,
-   char *buf) {
+   char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
acpi_status status;
unsigned long long sta;
-- 
2.8.1



[PATCH v2 01/15] ACPI: APD: fix a block comment align issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl.
WARNING: Block comments should align the * on each line
+/**
+* Create platform device during acpi scan attach handle.

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_apd.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
index 39359ce..0ec5b3f 100644
--- a/drivers/acpi/acpi_apd.c
+++ b/drivers/acpi/acpi_apd.c
@@ -176,10 +176,10 @@ static const struct apd_device_desc hip08_spi_desc = {
 
 #endif
 
-/**
-* Create platform device during acpi scan attach handle.
-* Return value > 0 on success of creating device.
-*/
+/*
+ * Create platform device during acpi scan attach handle.
+ * Return value > 0 on success of creating device.
+ */
 static int acpi_apd_create_device(struct acpi_device *adev,
   const struct acpi_device_id *id)
 {
-- 
2.8.1



[PATCH v2 04/15] ACPI: table: replace __attribute__((packed)) by __packed

2021-03-27 Thread Xiaofei Tan
Replace __attribute__((packed)) by __packed following the
advice of checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_fpdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/acpi_fpdt.c b/drivers/acpi/acpi_fpdt.c
index a89a806..690a88a 100644
--- a/drivers/acpi/acpi_fpdt.c
+++ b/drivers/acpi/acpi_fpdt.c
@@ -53,7 +53,7 @@ struct resume_performance_record {
u32 resume_count;
u64 resume_prev;
u64 resume_avg;
-} __attribute__((packed));
+} __packed;
 
 struct boot_performance_record {
struct fpdt_record_header header;
@@ -63,13 +63,13 @@ struct boot_performance_record {
u64 bootloader_launch;
u64 exitbootservice_start;
u64 exitbootservice_end;
-} __attribute__((packed));
+} __packed;
 
 struct suspend_performance_record {
struct fpdt_record_header header;
u64 suspend_start;
u64 suspend_end;
-} __attribute__((packed));
+} __packed;
 
 
 static struct resume_performance_record *record_resume;
-- 
2.8.1



[PATCH v2 03/15] ACPI: debug: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: space prohibited between function name and open parenthesis
WARNING: else is not generally useful after a break or return

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_dbg.c | 40 +++-
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
index d50261d..e641bc1 100644
--- a/drivers/acpi/acpi_dbg.c
+++ b/drivers/acpi/acpi_dbg.c
@@ -21,7 +21,7 @@
 #include 
 #include "internal.h"
 
-#define ACPI_AML_BUF_ALIGN (sizeof (acpi_size))
+#define ACPI_AML_BUF_ALIGN (sizeof(acpi_size))
 #define ACPI_AML_BUF_SIZE  PAGE_SIZE
 
 #define circ_count(circ) \
@@ -613,16 +613,15 @@ static ssize_t acpi_aml_read(struct file *file, char 
__user *buf,
if (ret == -EAGAIN) {
if (file->f_flags & O_NONBLOCK)
break;
-   else {
-   ret = wait_event_interruptible(acpi_aml_io.wait,
-   acpi_aml_user_readable());
-   /*
-* We need to retry when the condition
-* becomes true.
-*/
-   if (ret == 0)
-   goto again;
-   }
+
+   ret = wait_event_interruptible(acpi_aml_io.wait,
+   acpi_aml_user_readable());
+   /*
+* We need to retry when the condition
+* becomes true.
+*/
+   if (ret == 0)
+   goto again;
}
if (ret < 0) {
if (!acpi_aml_running())
@@ -683,16 +682,15 @@ static ssize_t acpi_aml_write(struct file *file, const 
char __user *buf,
if (ret == -EAGAIN) {
if (file->f_flags & O_NONBLOCK)
break;
-   else {
-   ret = wait_event_interruptible(acpi_aml_io.wait,
-   acpi_aml_user_writable());
-   /*
-* We need to retry when the condition
-* becomes true.
-*/
-   if (ret == 0)
-   goto again;
-   }
+
+   ret = wait_event_interruptible(acpi_aml_io.wait,
+   acpi_aml_user_writable());
+   /*
+* We need to retry when the condition
+* becomes true.
+*/
+   if (ret == 0)
+   goto again;
}
if (ret < 0) {
if (!acpi_aml_running())
-- 
2.8.1



[PATCH v2 05/15] ACPI: ipmi: remove useless return statement for void function

2021-03-27 Thread Xiaofei Tan
Remove useless return statement for void function, reported by
checkpatch.pl.

WARNING: void function return statements are not generally useful
FILE: drivers/acpi/acpi_ipmi.c:482:
+   return;
+}

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_ipmi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/acpi/acpi_ipmi.c b/drivers/acpi/acpi_ipmi.c
index 9d6c0fc..bbd00d9 100644
--- a/drivers/acpi/acpi_ipmi.c
+++ b/drivers/acpi/acpi_ipmi.c
@@ -478,7 +478,6 @@ static void ipmi_register_bmc(int iface, struct device *dev)
ipmi_dev_release(ipmi_device);
 err_ref:
put_device(smi_data.dev);
-   return;
 }
 
 static void ipmi_bmc_gone(int iface)
-- 
2.8.1



[PATCH v2 00/15] acpi: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl.

Differences from v1 to v2:
- Add subsystem and module name in the name of patch 05/15.
- Change to use more proper module name for some patch names.

Xiaofei Tan (15):
  ACPI: APD: fix a block comment align issue
  ACPI: processor: fix some coding style issues
  ACPI: debug: fix some coding style issues
  ACPI: table: replace __attribute__((packed)) by __packed
  ACPI: ipmi: remove useless return statement for void function
  ACPI: LPSS: fix some coding style issues
  ACPI: memhotplug: fix a coding style issue
  ACPI: acpi_pad: fix a coding style issue
  ACPI: battery: fix some coding style issues
  ACPI: button: fix some coding style issues
  ACPI: CPPC: fix some coding style issues
  ACPI: custom_method: fix a coding style issue
  ACPI: PM: fix some coding style issues
  ACPI: sysfs: fix some coding style issues
  ACPI: dock: fix some coding style issues

 drivers/acpi/acpi_apd.c|  8 ++---
 drivers/acpi/acpi_dbg.c| 40 +++-
 drivers/acpi/acpi_fpdt.c   |  6 ++--
 drivers/acpi/acpi_ipmi.c   |  1 -
 drivers/acpi/acpi_lpss.c   |  4 ++-
 drivers/acpi/acpi_memhotplug.c |  2 +-
 drivers/acpi/acpi_pad.c|  4 +++
 drivers/acpi/acpi_processor.c  | 18 +++
 drivers/acpi/battery.c | 64 +
 drivers/acpi/button.c  | 10 +++---
 drivers/acpi/cppc_acpi.c   | 71 +-
 drivers/acpi/custom_method.c   |  2 +-
 drivers/acpi/device_pm.c   |  3 ++
 drivers/acpi/device_sysfs.c| 15 ++---
 drivers/acpi/dock.c|  7 +++--
 15 files changed, 138 insertions(+), 117 deletions(-)

-- 
2.8.1



Re: [PATCH 00/15] acpi: fix some coding style issues

2021-03-27 Thread Xiaofei Tan

Please ignore this patch set. thanks.

On 2021/3/27 14:40, Xiaofei Tan wrote:

Fix some coding style issues reported by checkpatch.pl.

Xiaofei Tan (15):
  ACPI: APD: fix a block comment align issue
  ACPI: processor: fix some coding style issues
  ACPI: acpi_dbg: fix some coding style issues
  ACPI: acpi_fpdt: replace __attribute__((packed)) by __packed
  remove useless return statement for void function
  ACPI: acpi_lpss: fix some coding style issues
  ACPI: acpi_memhotplug: fix a coding style issue
  ACPI: acpi_pad: fix a coding style issue
  ACPI: battery: fix some coding style issues
  ACPI: button: fix some coding style issues
  ACPI: cppc_acpi: fix some coding style issues
  ACPI: custom_method: fix a coding style issue
  ACPI: device_pm: fix some coding style issues
  ACPI: device_sysfs: fix some coding style issues
  ACPI: dock: fix some coding style issues

 drivers/acpi/acpi_apd.c|  8 ++---
 drivers/acpi/acpi_dbg.c| 40 +++-
 drivers/acpi/acpi_fpdt.c   |  6 ++--
 drivers/acpi/acpi_ipmi.c   |  1 -
 drivers/acpi/acpi_lpss.c   |  4 ++-
 drivers/acpi/acpi_memhotplug.c |  2 +-
 drivers/acpi/acpi_pad.c|  4 +++
 drivers/acpi/acpi_processor.c  | 18 +++
 drivers/acpi/battery.c | 64 +
 drivers/acpi/button.c  | 10 +++---
 drivers/acpi/cppc_acpi.c   | 71 +-
 drivers/acpi/custom_method.c   |  2 +-
 drivers/acpi/device_pm.c   |  3 ++
 drivers/acpi/device_sysfs.c| 15 ++---
 drivers/acpi/dock.c|  7 +++--
 15 files changed, 138 insertions(+), 117 deletions(-)





Re: [PATCH 05/15] remove useless return statement for void function

2021-03-27 Thread Xiaofei Tan
Oh, sorry, the title doesn't contain subsystem and module name. I'll 
send v2 later. Please ignore this one. thanks.


On 2021/3/27 14:40, Xiaofei Tan wrote:

Remove useless return statement for void function, reported by
checkpatch.pl.

WARNING: void function return statements are not generally useful
FILE: drivers/acpi/acpi_ipmi.c:482:
+   return;
+}

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_ipmi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/acpi/acpi_ipmi.c b/drivers/acpi/acpi_ipmi.c
index 9d6c0fc..bbd00d9 100644
--- a/drivers/acpi/acpi_ipmi.c
+++ b/drivers/acpi/acpi_ipmi.c
@@ -478,7 +478,6 @@ static void ipmi_register_bmc(int iface, struct device *dev)
ipmi_dev_release(ipmi_device);
 err_ref:
put_device(smi_data.dev);
-   return;
 }

 static void ipmi_bmc_gone(int iface)





[PATCH 07/15] ACPI: acpi_memhotplug: fix a coding style issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

WARNING: __initdata should be placed after acpi_no_memhotplug
FILE: drivers/acpi/acpi_memhotplug.c:326:
+static bool __initdata acpi_no_memhotplug;

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_memhotplug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 8cc195c..5c5ed22 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -323,7 +323,7 @@ static void acpi_memory_device_remove(struct acpi_device 
*device)
acpi_memory_device_free(mem_device);
 }
 
-static bool __initdata acpi_no_memhotplug;
+static bool acpi_no_memhotplug __initdata;
 
 void __init acpi_memory_hotplug_init(void)
 {
-- 
2.8.1



[PATCH 09/15] ACPI: battery: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Block comments use * on subsequent lines
WARNING: Block comments use a trailing */ on a separate line
ERROR: code indent should use tabs where possible
WARNING: Missing a blank line after declarations
ERROR: spaces required around that '?' (ctx:WxV)
WARNING: Block comments should align the * on each line

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/battery.c | 64 ++
 1 file changed, 38 insertions(+), 26 deletions(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index b822f77..a0d8ead 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -74,16 +74,17 @@ enum {
ACPI_BATTERY_XINFO_PRESENT,
ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY,
/* On Lenovo Thinkpad models from 2010 and 2011, the power unit
-  switches between mWh and mAh depending on whether the system
-  is running on battery or not.  When mAh is the unit, most
-  reported values are incorrect and need to be adjusted by
-  1/design_voltage.  Verified on x201, t410, t410s, and x220.
-  Pre-2010 and 2012 models appear to always report in mWh and
-  are thus unaffected (tested with t42, t61, t500, x200, x300,
-  and x230).  Also, in mid-2012 Lenovo issued a BIOS update for
-  the 2011 models that fixes the issue (tested on x220 with a
-  post-1.29 BIOS), but as of Nov. 2012, no such update is
-  available for the 2010 models.  */
+* switches between mWh and mAh depending on whether the system
+* is running on battery or not.  When mAh is the unit, most
+* reported values are incorrect and need to be adjusted by
+* 1/design_voltage.  Verified on x201, t410, t410s, and x220.
+* Pre-2010 and 2012 models appear to always report in mWh and
+* are thus unaffected (tested with t42, t61, t500, x200, x300,
+* and x230).  Also, in mid-2012 Lenovo issued a BIOS update for
+*  the 2011 models that fixes the issue (tested on x220 with a
+* post-1.29 BIOS), but as of Nov. 2012, no such update is
+* available for the 2010 models.
+*/
ACPI_BATTERY_QUIRK_THINKPAD_MAH,
/* for batteries reporting current capacity with design capacity
 * on a full charge, but showing degradation in full charge cap.
@@ -372,8 +373,9 @@ static enum power_supply_property 
energy_battery_full_cap_broken_props[] = {
 };
 
 /* --
-   Battery Management
-   -- 
*/
+ * Battery Management
+ * --
+ */
 struct acpi_offsets {
size_t offset;  /* offset inside struct acpi_sbs_battery */
u8 mode;/* int or string? */
@@ -431,6 +433,7 @@ static int extract_package(struct acpi_battery *battery,
 {
int i;
union acpi_object *element;
+
if (package->type != ACPI_TYPE_PACKAGE)
return -EFAULT;
for (i = 0; i < num; ++i) {
@@ -439,6 +442,7 @@ static int extract_package(struct acpi_battery *battery,
element = >package.elements[i];
if (offsets[i].mode) {
u8 *ptr = (u8 *)battery + offsets[i].offset;
+
if (element->type == ACPI_TYPE_STRING ||
element->type == ACPI_TYPE_BUFFER)
strncpy(ptr, element->string.pointer, 32);
@@ -497,10 +501,12 @@ static int extract_battery_info(const int use_bix,
battery->design_capacity_warning *
1 / battery->design_voltage;
/* Curiously, design_capacity_low, unlike the rest of them,
-  is correct.  */
+*  is correct.
+*/
/* capacity_granularity_* equal 1 on the systems tested, so
-  it's impossible to tell if they would need an adjustment
-  or not if their values were higher.  */
+* it's impossible to tell if they would need an adjustment
+* or not if their values were higher.
+*/
}
if (test_bit(ACPI_BATTERY_QUIRK_DEGRADED_FULL_CHARGE, >flags) 
&&
battery->capacity_now > battery->full_charge_capacity)
@@ -532,8 +538,8 @@ static int acpi_battery_get_info(struct acpi_battery 
*battery)
if (ACPI_FAILURE(status)) {
acpi_handle_info(battery->device->handle,
 "%s evaluation failed: %s\n",
- 

[PATCH 03/15] ACPI: acpi_dbg: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: space prohibited between function name and open parenthesis
WARNING: else is not generally useful after a break or return

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_dbg.c | 40 +++-
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
index d50261d..e641bc1 100644
--- a/drivers/acpi/acpi_dbg.c
+++ b/drivers/acpi/acpi_dbg.c
@@ -21,7 +21,7 @@
 #include 
 #include "internal.h"
 
-#define ACPI_AML_BUF_ALIGN (sizeof (acpi_size))
+#define ACPI_AML_BUF_ALIGN (sizeof(acpi_size))
 #define ACPI_AML_BUF_SIZE  PAGE_SIZE
 
 #define circ_count(circ) \
@@ -613,16 +613,15 @@ static ssize_t acpi_aml_read(struct file *file, char 
__user *buf,
if (ret == -EAGAIN) {
if (file->f_flags & O_NONBLOCK)
break;
-   else {
-   ret = wait_event_interruptible(acpi_aml_io.wait,
-   acpi_aml_user_readable());
-   /*
-* We need to retry when the condition
-* becomes true.
-*/
-   if (ret == 0)
-   goto again;
-   }
+
+   ret = wait_event_interruptible(acpi_aml_io.wait,
+   acpi_aml_user_readable());
+   /*
+* We need to retry when the condition
+* becomes true.
+*/
+   if (ret == 0)
+   goto again;
}
if (ret < 0) {
if (!acpi_aml_running())
@@ -683,16 +682,15 @@ static ssize_t acpi_aml_write(struct file *file, const 
char __user *buf,
if (ret == -EAGAIN) {
if (file->f_flags & O_NONBLOCK)
break;
-   else {
-   ret = wait_event_interruptible(acpi_aml_io.wait,
-   acpi_aml_user_writable());
-   /*
-* We need to retry when the condition
-* becomes true.
-*/
-   if (ret == 0)
-   goto again;
-   }
+
+   ret = wait_event_interruptible(acpi_aml_io.wait,
+   acpi_aml_user_writable());
+   /*
+* We need to retry when the condition
+* becomes true.
+*/
+   if (ret == 0)
+   goto again;
}
if (ret < 0) {
if (!acpi_aml_running())
-- 
2.8.1



[PATCH 11/15] ACPI: cppc_acpi: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Missing a blank line after declarations
WARNING: unnecessary whitespace before a quoted newline
ERROR: spaces required around that '>='
ERROR: switch and case should be at the same indent

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/cppc_acpi.c | 71 
 1 file changed, 36 insertions(+), 35 deletions(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index ae53740..3dbaf47 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -326,6 +326,7 @@ static int send_pcc_cmd(int pcc_ss_id, u16 cmd)
if (unlikely(ret)) {
for_each_possible_cpu(i) {
struct cpc_desc *desc = per_cpu(cpc_desc_ptr, 
i);
+
if (!desc)
continue;
 
@@ -777,7 +778,7 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
cpc_ptr->cpc_regs[i-2].type = ACPI_TYPE_BUFFER;
memcpy(_ptr->cpc_regs[i-2].cpc_entry.reg, gas_t, 
sizeof(*gas_t));
} else {
-   pr_debug("Err in entry:%d in CPC table of CPU:%d \n", 
i, pr->id);
+   pr_debug("Err in entry:%d in CPC table of CPU:%d\n", i, 
pr->id);
goto out_free;
}
}
@@ -867,7 +868,7 @@ void acpi_cppc_processor_exit(struct acpi_processor *pr)
void __iomem *addr;
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, pr->id);
 
-   if (pcc_ss_id >=0 && pcc_data[pcc_ss_id]) {
+   if (pcc_ss_id >= 0 && pcc_data[pcc_ss_id]) {
if (pcc_data[pcc_ss_id]->pcc_channel_acquired) {
pcc_data[pcc_ss_id]->refcount--;
if (!pcc_data[pcc_ss_id]->refcount) {
@@ -954,22 +955,22 @@ static int cpc_read(int cpu, struct cpc_register_resource 
*reg_res, u64 *val)
val, reg->bit_width);
 
switch (reg->bit_width) {
-   case 8:
-   *val = readb_relaxed(vaddr);
-   break;
-   case 16:
-   *val = readw_relaxed(vaddr);
-   break;
-   case 32:
-   *val = readl_relaxed(vaddr);
-   break;
-   case 64:
-   *val = readq_relaxed(vaddr);
-   break;
-   default:
-   pr_debug("Error: Cannot read %u bit width from PCC for 
ss: %d\n",
-reg->bit_width, pcc_ss_id);
-   ret_val = -EFAULT;
+   case 8:
+   *val = readb_relaxed(vaddr);
+   break;
+   case 16:
+   *val = readw_relaxed(vaddr);
+   break;
+   case 32:
+   *val = readl_relaxed(vaddr);
+   break;
+   case 64:
+   *val = readq_relaxed(vaddr);
+   break;
+   default:
+   pr_debug("Error: Cannot read %u bit width from PCC for ss: 
%d\n",
+reg->bit_width, pcc_ss_id);
+   ret_val = -EFAULT;
}
 
return ret_val;
@@ -993,23 +994,23 @@ static int cpc_write(int cpu, struct 
cpc_register_resource *reg_res, u64 val)
val, reg->bit_width);
 
switch (reg->bit_width) {
-   case 8:
-   writeb_relaxed(val, vaddr);
-   break;
-   case 16:
-   writew_relaxed(val, vaddr);
-   break;
-   case 32:
-   writel_relaxed(val, vaddr);
-   break;
-   case 64:
-   writeq_relaxed(val, vaddr);
-   break;
-   default:
-   pr_debug("Error: Cannot write %u bit width to PCC for 
ss: %d\n",
-reg->bit_width, pcc_ss_id);
-   ret_val = -EFAULT;
-   break;
+   case 8:
+   writeb_relaxed(val, vaddr);
+   break;
+   case 16:
+   writew_relaxed(val, vaddr);
+   break;
+   case 32:
+   writel_relaxed(val, vaddr);
+   break;
+   case 64:
+   writeq_relaxed(val, vaddr);
+   break;
+   default:
+   pr_debug("Error: Cannot write %u bit width to PCC for ss: %d\n",
+reg->bit_width, pcc_ss_id);
+   ret_val = -EFAULT;
+   break;
}
 
return ret_val;
-- 
2.8.1



[PATCH 02/15] ACPI: processor: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

ERROR: code indent should use tabs where possible
WARNING: Block comments use a trailing */ on a separate line
WARNING: Missing a blank line after declarations
WARNING: labels should not be indented

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_processor.c | 18 +-
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index fc89f3a..2d5bd2a 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -25,10 +25,7 @@
 DEFINE_PER_CPU(struct acpi_processor *, processors);
 EXPORT_PER_CPU_SYMBOL(processors);
 
-/* --
-Errata Handling
-   -- 
*/
-
+/* Errata Handling */
 struct acpi_processor_errata errata __read_mostly;
 EXPORT_SYMBOL_GPL(errata);
 
@@ -151,10 +148,7 @@ static int acpi_processor_errata(void)
return result;
 }
 
-/* --
-Initialization
-   -- 
*/
-
+/* Initialization */
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
 int __weak acpi_map_cpu(acpi_handle handle,
phys_cpuid_t physid, u32 acpi_id, int *pcpu)
@@ -306,6 +300,7 @@ static int acpi_processor_get_info(struct acpi_device 
*device)
 */
if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) {
int ret = acpi_processor_hotadd_init(pr);
+
if (ret)
return ret;
}
@@ -431,10 +426,7 @@ static int acpi_processor_add(struct acpi_device *device,
 }
 
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
-/* --
-Removal
-   -- 
*/
-
+/* Removal */
 static void acpi_processor_remove(struct acpi_device *device)
 {
struct acpi_processor *pr;
@@ -892,7 +884,7 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
 
info->count = last_index;
 
-  end:
+end:
kfree(buffer.pointer);
 
return ret;
-- 
2.8.1



[PATCH 08/15] ACPI: acpi_pad: fix a coding style issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

WARNING: Missing a blank line after declarations

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_pad.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index b84ab72..df4adeb 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -128,6 +128,7 @@ static void round_robin_cpu(unsigned int tsk_index)
 static void exit_round_robin(unsigned int tsk_index)
 {
struct cpumask *pad_busy_cpus = to_cpumask(pad_busy_cpus_bits);
+
cpumask_clear_cpu(tsk_in_cpu[tsk_index], pad_busy_cpus);
tsk_in_cpu[tsk_index] = -1;
 }
@@ -265,6 +266,7 @@ static ssize_t rrtime_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
unsigned long num;
+
if (kstrtoul(buf, 0, ))
return -EINVAL;
if (num < 1 || num >= 100)
@@ -286,6 +288,7 @@ static ssize_t idlepct_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
unsigned long num;
+
if (kstrtoul(buf, 0, ))
return -EINVAL;
if (num < 1 || num >= 100)
@@ -307,6 +310,7 @@ static ssize_t idlecpus_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
unsigned long num;
+
if (kstrtoul(buf, 0, ))
return -EINVAL;
mutex_lock(_cpus_lock);
-- 
2.8.1



[PATCH 13/15] ACPI: device_pm: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

WARNING: Missing a blank line after declarations

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/device_pm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 0961537..16c0fe8 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -966,6 +966,7 @@ EXPORT_SYMBOL_GPL(acpi_dev_resume);
 int acpi_subsys_runtime_suspend(struct device *dev)
 {
int ret = pm_generic_runtime_suspend(dev);
+
return ret ? ret : acpi_dev_suspend(dev, true);
 }
 EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend);
@@ -980,6 +981,7 @@ EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend);
 int acpi_subsys_runtime_resume(struct device *dev)
 {
int ret = acpi_dev_resume(dev);
+
return ret ? ret : pm_generic_runtime_resume(dev);
 }
 EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume);
@@ -1171,6 +1173,7 @@ EXPORT_SYMBOL_GPL(acpi_subsys_freeze);
 int acpi_subsys_restore_early(struct device *dev)
 {
int ret = acpi_dev_resume(dev);
+
return ret ? ret : pm_generic_restore_early(dev);
 }
 EXPORT_SYMBOL_GPL(acpi_subsys_restore_early);
-- 
2.8.1



[PATCH 15/15] ACPI: dock: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Missing a blank line after declarations
ERROR: spaces required around that ':'
WARNING: Statements should start on a tabstop

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/dock.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 0937cea..7cf9215 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -271,6 +271,7 @@ static void hotplug_dock_devices(struct dock_station *ds, 
u32 event)
 
if (!acpi_device_enumerated(adev)) {
int ret = acpi_bus_scan(adev->handle);
+
if (ret)
dev_dbg(>dev, "scan error %d\n", -ret);
}
@@ -502,6 +503,7 @@ static ssize_t flags_show(struct device *dev,
  struct device_attribute *attr, char *buf)
 {
struct dock_station *dock_station = dev->platform_data;
+
return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
 
 }
@@ -523,7 +525,7 @@ static ssize_t undock_store(struct device *dev, struct 
device_attribute *attr,
begin_undock(dock_station);
ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST);
acpi_scan_lock_release();
-   return ret ? ret: count;
+   return ret ? ret : count;
 }
 static DEVICE_ATTR_WO(undock);
 
@@ -535,10 +537,11 @@ static ssize_t uid_show(struct device *dev,
 {
unsigned long long lbuf;
struct dock_station *dock_station = dev->platform_data;
+
acpi_status status = acpi_evaluate_integer(dock_station->handle,
"_UID", NULL, );
if (ACPI_FAILURE(status))
-   return 0;
+   return 0;
 
return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
 }
-- 
2.8.1



[PATCH 05/15] remove useless return statement for void function

2021-03-27 Thread Xiaofei Tan
Remove useless return statement for void function, reported by
checkpatch.pl.

WARNING: void function return statements are not generally useful
FILE: drivers/acpi/acpi_ipmi.c:482:
+   return;
+}

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_ipmi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/acpi/acpi_ipmi.c b/drivers/acpi/acpi_ipmi.c
index 9d6c0fc..bbd00d9 100644
--- a/drivers/acpi/acpi_ipmi.c
+++ b/drivers/acpi/acpi_ipmi.c
@@ -478,7 +478,6 @@ static void ipmi_register_bmc(int iface, struct device *dev)
ipmi_dev_release(ipmi_device);
 err_ref:
put_device(smi_data.dev);
-   return;
 }
 
 static void ipmi_bmc_gone(int iface)
-- 
2.8.1



[PATCH 10/15] ACPI: button: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Block comments use * on subsequent lines
WARNING: Block comments use a trailing */ on a separate line
ERROR: code indent should use tabs where possible

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/button.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 85e5e03..c66db72 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -157,8 +157,9 @@ module_param(lid_report_interval, ulong, 0644);
 MODULE_PARM_DESC(lid_report_interval, "Interval (ms) between lid key events");
 
 /* --
-  FS Interface (/proc)
-   -- 
*/
+ * FS Interface (/proc)
+ * --
+ */
 
 static struct proc_dir_entry *acpi_button_dir;
 static struct proc_dir_entry *acpi_lid_dir;
@@ -349,8 +350,9 @@ static int acpi_button_remove_fs(struct acpi_device *device)
 }
 
 /* --
-Driver Interface
-   -- 
*/
+ * Driver Interface
+ * --
+ */
 int acpi_lid_open(void)
 {
if (!lid_device)
-- 
2.8.1



[PATCH 12/15] ACPI: custom_method: fix a coding style issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl

ERROR: "foo * bar" should be "foo *bar"
FILE: drivers/acpi/custom_method.c:22:
+static ssize_t cm_write(struct file *file, const char __user * user_buf,

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/custom_method.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
index 7b54dc9..443fdf62 100644
--- a/drivers/acpi/custom_method.c
+++ b/drivers/acpi/custom_method.c
@@ -19,7 +19,7 @@ static struct dentry *cm_dentry;
 
 /* /sys/kernel/debug/acpi/custom_method */
 
-static ssize_t cm_write(struct file *file, const char __user * user_buf,
+static ssize_t cm_write(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos)
 {
static char *buf;
-- 
2.8.1



[PATCH 04/15] ACPI: acpi_fpdt: replace __attribute__((packed)) by __packed

2021-03-27 Thread Xiaofei Tan
Replace __attribute__((packed)) by __packed following the
advice of checkpatch.pl.

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_fpdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/acpi_fpdt.c b/drivers/acpi/acpi_fpdt.c
index a89a806..690a88a 100644
--- a/drivers/acpi/acpi_fpdt.c
+++ b/drivers/acpi/acpi_fpdt.c
@@ -53,7 +53,7 @@ struct resume_performance_record {
u32 resume_count;
u64 resume_prev;
u64 resume_avg;
-} __attribute__((packed));
+} __packed;
 
 struct boot_performance_record {
struct fpdt_record_header header;
@@ -63,13 +63,13 @@ struct boot_performance_record {
u64 bootloader_launch;
u64 exitbootservice_start;
u64 exitbootservice_end;
-} __attribute__((packed));
+} __packed;
 
 struct suspend_performance_record {
struct fpdt_record_header header;
u64 suspend_start;
u64 suspend_end;
-} __attribute__((packed));
+} __packed;
 
 
 static struct resume_performance_record *record_resume;
-- 
2.8.1



[PATCH 06/15] ACPI: acpi_lpss: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: simple_strtol is obsolete, use kstrtol instead
WARNING: Missing a blank line after declarations

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_lpss.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index be73974..2df231e 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -187,7 +187,7 @@ static void byt_i2c_setup(struct lpss_private_data *pdata)
 
/* Expected to always be true, but better safe then sorry */
if (uid_str)
-   uid = simple_strtol(uid_str, NULL, 10);
+   uid = kstrtol(uid_str, NULL, 10);
 
/* Detect I2C bus shared with PUNIT and ignore its d3 status */
status = acpi_evaluate_integer(handle, "_SEM", NULL, _host);
@@ -377,6 +377,7 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = 
{
 static int is_memory(struct acpi_resource *res, void *not_used)
 {
struct resource r;
+
return !acpi_dev_resource_memory(res, );
 }
 
@@ -1200,6 +1201,7 @@ static int acpi_lpss_poweroff_noirq(struct device *dev)
if (pdata->dev_desc->resume_from_noirq) {
/* This is analogous to the acpi_lpss_suspend_noirq() case. */
int ret = acpi_lpss_do_poweroff_late(dev);
+
if (ret)
return ret;
}
-- 
2.8.1



[PATCH 14/15] ACPI: device_sysfs: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

WARNING: Missing a blank line after declarations
WARNING: Block comments should align the * on each line
ERROR: open brace '{' following function definitions go on the next line

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/device_sysfs.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index da4ff2a..a07d4ad 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -73,6 +73,7 @@ static const struct sysfs_ops acpi_data_node_sysfs_ops = {
 static void acpi_data_node_release(struct kobject *kobj)
 {
struct acpi_data_node *dn = to_data_node(kobj);
+
complete(>kobj_done);
 }
 
@@ -130,7 +131,7 @@ static void acpi_hide_nondev_subnodes(struct 
acpi_device_data *data)
  * Return: 0: no _HID and no _CID
  * -EINVAL: output error
  * -ENOMEM: output is truncated
-*/
+ */
 static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias,
   int size)
 {
@@ -431,7 +432,8 @@ static DEVICE_ATTR_RO(path);
 /* sysfs file that shows description text from the ACPI _STR method */
 static ssize_t description_show(struct device *dev,
struct device_attribute *attr,
-   char *buf) {
+   char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
int result;
 
@@ -456,7 +458,8 @@ static DEVICE_ATTR_RO(description);
 
 static ssize_t
 sun_show(struct device *dev, struct device_attribute *attr,
-char *buf) {
+char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
acpi_status status;
unsigned long long sun;
@@ -471,7 +474,8 @@ static DEVICE_ATTR_RO(sun);
 
 static ssize_t
 hrv_show(struct device *dev, struct device_attribute *attr,
-char *buf) {
+char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
acpi_status status;
unsigned long long hrv;
@@ -485,7 +489,8 @@ hrv_show(struct device *dev, struct device_attribute *attr,
 static DEVICE_ATTR_RO(hrv);
 
 static ssize_t status_show(struct device *dev, struct device_attribute *attr,
-   char *buf) {
+   char *buf)
+{
struct acpi_device *acpi_dev = to_acpi_device(dev);
acpi_status status;
unsigned long long sta;
-- 
2.8.1



[PATCH 00/15] acpi: fix some coding style issues

2021-03-27 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl.

Xiaofei Tan (15):
  ACPI: APD: fix a block comment align issue
  ACPI: processor: fix some coding style issues
  ACPI: acpi_dbg: fix some coding style issues
  ACPI: acpi_fpdt: replace __attribute__((packed)) by __packed
  remove useless return statement for void function
  ACPI: acpi_lpss: fix some coding style issues
  ACPI: acpi_memhotplug: fix a coding style issue
  ACPI: acpi_pad: fix a coding style issue
  ACPI: battery: fix some coding style issues
  ACPI: button: fix some coding style issues
  ACPI: cppc_acpi: fix some coding style issues
  ACPI: custom_method: fix a coding style issue
  ACPI: device_pm: fix some coding style issues
  ACPI: device_sysfs: fix some coding style issues
  ACPI: dock: fix some coding style issues

 drivers/acpi/acpi_apd.c|  8 ++---
 drivers/acpi/acpi_dbg.c| 40 +++-
 drivers/acpi/acpi_fpdt.c   |  6 ++--
 drivers/acpi/acpi_ipmi.c   |  1 -
 drivers/acpi/acpi_lpss.c   |  4 ++-
 drivers/acpi/acpi_memhotplug.c |  2 +-
 drivers/acpi/acpi_pad.c|  4 +++
 drivers/acpi/acpi_processor.c  | 18 +++
 drivers/acpi/battery.c | 64 +
 drivers/acpi/button.c  | 10 +++---
 drivers/acpi/cppc_acpi.c   | 71 +-
 drivers/acpi/custom_method.c   |  2 +-
 drivers/acpi/device_pm.c   |  3 ++
 drivers/acpi/device_sysfs.c| 15 ++---
 drivers/acpi/dock.c|  7 +++--
 15 files changed, 138 insertions(+), 117 deletions(-)

-- 
2.8.1



[PATCH 01/15] ACPI: APD: fix a block comment align issue

2021-03-27 Thread Xiaofei Tan
Fix the following coding style issue reported by checkpatch.pl.
WARNING: Block comments should align the * on each line
+/**
+* Create platform device during acpi scan attach handle.

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/acpi_apd.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
index 39359ce..0ec5b3f 100644
--- a/drivers/acpi/acpi_apd.c
+++ b/drivers/acpi/acpi_apd.c
@@ -176,10 +176,10 @@ static const struct apd_device_desc hip08_spi_desc = {
 
 #endif
 
-/**
-* Create platform device during acpi scan attach handle.
-* Return value > 0 on success of creating device.
-*/
+/*
+ * Create platform device during acpi scan attach handle.
+ * Return value > 0 on success of creating device.
+ */
 static int acpi_apd_create_device(struct acpi_device *adev,
   const struct acpi_device_id *id)
 {
-- 
2.8.1



[PATCH v2] ACPI: AC: fix some coding style issues

2021-03-26 Thread Xiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including
following types:

ERROR: "foo * bar" should be "foo *bar"
ERROR: code indent should use tabs where possible
WARNING: Block comments use a trailing */ on a separate line
WARNING: braces {} are not necessary for single statement blocks
WARNING: void function return statements are not generally useful
WARNING: CVS style keyword markers, these will _not_ be updated

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/ac.c | 28 
 1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index b86ee6e..b0cb662 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
- *  acpi_ac.c - ACPI AC Adapter Driver ($Revision: 27 $)
+ *  acpi_ac.c - ACPI AC Adapter Driver (Revision: 27)
  *
  *  Copyright (C) 2001, 2002 Andy Grover 
  *  Copyright (C) 2001, 2002 Paul Diefenbaugh 
@@ -78,17 +78,14 @@ static struct acpi_driver acpi_ac_driver = {
 struct acpi_ac {
struct power_supply *charger;
struct power_supply_desc charger_desc;
-   struct acpi_device * device;
+   struct acpi_device *device;
unsigned long long state;
struct notifier_block battery_nb;
 };
 
 #define to_acpi_ac(x) power_supply_get_drvdata(x)
 
-/* --
-   AC Adapter Management
-   -- 
*/
-
+/* AC Adapter Management */
 static int acpi_ac_get_state(struct acpi_ac *ac)
 {
acpi_status status = AE_OK;
@@ -109,9 +106,7 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
return 0;
 }
 
-/* --
-sysfs I/F
-   -- 
*/
+/* sysfs I/F */
 static int get_ac_property(struct power_supply *psy,
   enum power_supply_property psp,
   union power_supply_propval *val)
@@ -138,10 +133,7 @@ static enum power_supply_property ac_props[] = {
POWER_SUPPLY_PROP_ONLINE,
 };
 
-/* --
-   Driver Model
-   -- 
*/
-
+/* Driver Model */
 static void acpi_ac_notify(struct acpi_device *device, u32 event)
 {
struct acpi_ac *ac = acpi_driver_data(device);
@@ -174,8 +166,6 @@ static void acpi_ac_notify(struct acpi_device *device, u32 
event)
acpi_notifier_call_chain(device, event, (u32) ac->state);
kobject_uevent(>charger->dev.kobj, KOBJ_CHANGE);
}
-
-   return;
 }
 
 static int acpi_ac_battery_notify(struct notifier_block *nb,
@@ -282,9 +272,8 @@ static int acpi_ac_add(struct acpi_device *device)
ac->battery_nb.notifier_call = acpi_ac_battery_notify;
register_acpi_notifier(>battery_nb);
 end:
-   if (result) {
+   if (result)
kfree(ac);
-   }
 
return result;
 }
@@ -293,7 +282,7 @@ static int acpi_ac_add(struct acpi_device *device)
 static int acpi_ac_resume(struct device *dev)
 {
struct acpi_ac *ac;
-   unsigned old_state;
+   unsigned int old_state;
 
if (!dev)
return -EINVAL;
@@ -352,9 +341,8 @@ static int __init acpi_ac_init(void)
}
 
result = acpi_bus_register_driver(_ac_driver);
-   if (result < 0) {
+   if (result < 0)
return -ENODEV;
-   }
 
return 0;
 }
-- 
2.8.1



Re: [PATCH] ACPI: AC: fix some errors and warnings reported by checkpatch.pl

2021-03-24 Thread Xiaofei Tan

Hi Rafael,
BTW, there is still one warning left reported by checkpatch.pl in this 
file. The cause of the warning is that it contains an special character 
'$'. Does it have any special purpose? If no, i can fix it in the new 
version, too. thanks.


WARNING: CVS style keyword markers, these will _not_ be updated
#3: FILE: drivers/acpi/ac.c:3:
+ *  acpi_ac.c - ACPI AC Adapter Driver ($Revision: 27 $)

On 2021/3/25 9:26, Xiaofei Tan wrote:

Hi Rafael,

On 2021/3/24 23:57, Rafael J. Wysocki wrote:

On Tue, Mar 23, 2021 at 2:01 PM Xiaofei Tan 
wrote:


Fix some errors and warnings reported by checkpatch.pl, including
following five types:


Well, they are coding style issues rather than errors.



Right, i could change the description.


ERROR: "foo * bar" should be "foo *bar"
ERROR: code indent should use tabs where possible
WARNING: Block comments use a trailing */ on a separate line
WARNING: braces {} are not necessary for single statement blocks
WARNING: void function return statements are not generally useful

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/ac.c | 32 +---
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index b86ee6e..07987854 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -78,17 +78,16 @@ static struct acpi_driver acpi_ac_driver = {
 struct acpi_ac {
struct power_supply *charger;
struct power_supply_desc charger_desc;
-   struct acpi_device * device;
+   struct acpi_device *device;
unsigned long long state;
struct notifier_block battery_nb;
 };

 #define to_acpi_ac(x) power_supply_get_drvdata(x)

-/*
--

-   AC Adapter Management
-
--
*/
-
+/*
+ * AC Adapter Management
+ */


Please use the /* ... */ (one-line) comment format here and below for
comments that aren't longer than one line.



Sure.


 static int acpi_ac_get_state(struct acpi_ac *ac)
 {
acpi_status status = AE_OK;
@@ -109,9 +108,9 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
return 0;
 }

-/*
--

-sysfs I/F
-
--
*/
+/*
+ * sysfs I/F
+ */
 static int get_ac_property(struct power_supply *psy,
   enum power_supply_property psp,
   union power_supply_propval *val)
@@ -138,10 +137,9 @@ static enum power_supply_property ac_props[] = {
POWER_SUPPLY_PROP_ONLINE,
 };

-/*
--

-   Driver Model
-
--
*/
-
+/*
+ * Driver Model
+ */
 static void acpi_ac_notify(struct acpi_device *device, u32 event)
 {
struct acpi_ac *ac = acpi_driver_data(device);
@@ -174,8 +172,6 @@ static void acpi_ac_notify(struct acpi_device
*device, u32 event)
acpi_notifier_call_chain(device, event, (u32)
ac->state);
kobject_uevent(>charger->dev.kobj, KOBJ_CHANGE);
}
-
-   return;
 }

 static int acpi_ac_battery_notify(struct notifier_block *nb,
@@ -282,9 +278,8 @@ static int acpi_ac_add(struct acpi_device *device)
ac->battery_nb.notifier_call = acpi_ac_battery_notify;
register_acpi_notifier(>battery_nb);
 end:
-   if (result) {
+   if (result)
kfree(ac);
-   }

return result;
 }
@@ -293,7 +288,7 @@ static int acpi_ac_add(struct acpi_device *device)
 static int acpi_ac_resume(struct device *dev)
 {
struct acpi_ac *ac;
-   unsigned old_state;
+   unsigned int old_state;

if (!dev)
return -EINVAL;
@@ -352,9 +347,8 @@ static int __init acpi_ac_init(void)
}

result = acpi_bus_register_driver(_ac_driver);
-   if (result < 0) {
+   if (result < 0)
return -ENODEV;
-   }

return 0;
 }
--


.





Re: [PATCH] ACPI: AC: fix some errors and warnings reported by checkpatch.pl

2021-03-24 Thread Xiaofei Tan

Hi Rafael,

On 2021/3/24 23:57, Rafael J. Wysocki wrote:

On Tue, Mar 23, 2021 at 2:01 PM Xiaofei Tan  wrote:


Fix some errors and warnings reported by checkpatch.pl, including
following five types:


Well, they are coding style issues rather than errors.



Right, i could change the description.


ERROR: "foo * bar" should be "foo *bar"
ERROR: code indent should use tabs where possible
WARNING: Block comments use a trailing */ on a separate line
WARNING: braces {} are not necessary for single statement blocks
WARNING: void function return statements are not generally useful

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/ac.c | 32 +---
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index b86ee6e..07987854 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -78,17 +78,16 @@ static struct acpi_driver acpi_ac_driver = {
 struct acpi_ac {
struct power_supply *charger;
struct power_supply_desc charger_desc;
-   struct acpi_device * device;
+   struct acpi_device *device;
unsigned long long state;
struct notifier_block battery_nb;
 };

 #define to_acpi_ac(x) power_supply_get_drvdata(x)

-/* --
-   AC Adapter Management
-   -- 
*/
-
+/*
+ * AC Adapter Management
+ */


Please use the /* ... */ (one-line) comment format here and below for
comments that aren't longer than one line.



Sure.


 static int acpi_ac_get_state(struct acpi_ac *ac)
 {
acpi_status status = AE_OK;
@@ -109,9 +108,9 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
return 0;
 }

-/* --
-sysfs I/F
-   -- 
*/
+/*
+ * sysfs I/F
+ */
 static int get_ac_property(struct power_supply *psy,
   enum power_supply_property psp,
   union power_supply_propval *val)
@@ -138,10 +137,9 @@ static enum power_supply_property ac_props[] = {
POWER_SUPPLY_PROP_ONLINE,
 };

-/* --
-   Driver Model
-   -- 
*/
-
+/*
+ * Driver Model
+ */
 static void acpi_ac_notify(struct acpi_device *device, u32 event)
 {
struct acpi_ac *ac = acpi_driver_data(device);
@@ -174,8 +172,6 @@ static void acpi_ac_notify(struct acpi_device *device, u32 
event)
acpi_notifier_call_chain(device, event, (u32) ac->state);
kobject_uevent(>charger->dev.kobj, KOBJ_CHANGE);
}
-
-   return;
 }

 static int acpi_ac_battery_notify(struct notifier_block *nb,
@@ -282,9 +278,8 @@ static int acpi_ac_add(struct acpi_device *device)
ac->battery_nb.notifier_call = acpi_ac_battery_notify;
register_acpi_notifier(>battery_nb);
 end:
-   if (result) {
+   if (result)
kfree(ac);
-   }

return result;
 }
@@ -293,7 +288,7 @@ static int acpi_ac_add(struct acpi_device *device)
 static int acpi_ac_resume(struct device *dev)
 {
struct acpi_ac *ac;
-   unsigned old_state;
+   unsigned int old_state;

if (!dev)
return -EINVAL;
@@ -352,9 +347,8 @@ static int __init acpi_ac_init(void)
}

result = acpi_bus_register_driver(_ac_driver);
-   if (result < 0) {
+   if (result < 0)
return -ENODEV;
-   }

return 0;
 }
--


.





[PATCH] ACPI: AC: fix some errors and warnings reported by checkpatch.pl

2021-03-23 Thread Xiaofei Tan
Fix some errors and warnings reported by checkpatch.pl, including
following five types:
ERROR: "foo * bar" should be "foo *bar"
ERROR: code indent should use tabs where possible
WARNING: Block comments use a trailing */ on a separate line
WARNING: braces {} are not necessary for single statement blocks
WARNING: void function return statements are not generally useful

Signed-off-by: Xiaofei Tan 
---
 drivers/acpi/ac.c | 32 +---
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index b86ee6e..07987854 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -78,17 +78,16 @@ static struct acpi_driver acpi_ac_driver = {
 struct acpi_ac {
struct power_supply *charger;
struct power_supply_desc charger_desc;
-   struct acpi_device * device;
+   struct acpi_device *device;
unsigned long long state;
struct notifier_block battery_nb;
 };
 
 #define to_acpi_ac(x) power_supply_get_drvdata(x)
 
-/* --
-   AC Adapter Management
-   -- 
*/
-
+/*
+ * AC Adapter Management
+ */
 static int acpi_ac_get_state(struct acpi_ac *ac)
 {
acpi_status status = AE_OK;
@@ -109,9 +108,9 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
return 0;
 }
 
-/* --
-sysfs I/F
-   -- 
*/
+/*
+ * sysfs I/F
+ */
 static int get_ac_property(struct power_supply *psy,
   enum power_supply_property psp,
   union power_supply_propval *val)
@@ -138,10 +137,9 @@ static enum power_supply_property ac_props[] = {
POWER_SUPPLY_PROP_ONLINE,
 };
 
-/* --
-   Driver Model
-   -- 
*/
-
+/*
+ * Driver Model
+ */
 static void acpi_ac_notify(struct acpi_device *device, u32 event)
 {
struct acpi_ac *ac = acpi_driver_data(device);
@@ -174,8 +172,6 @@ static void acpi_ac_notify(struct acpi_device *device, u32 
event)
acpi_notifier_call_chain(device, event, (u32) ac->state);
kobject_uevent(>charger->dev.kobj, KOBJ_CHANGE);
}
-
-   return;
 }
 
 static int acpi_ac_battery_notify(struct notifier_block *nb,
@@ -282,9 +278,8 @@ static int acpi_ac_add(struct acpi_device *device)
ac->battery_nb.notifier_call = acpi_ac_battery_notify;
register_acpi_notifier(>battery_nb);
 end:
-   if (result) {
+   if (result)
kfree(ac);
-   }
 
return result;
 }
@@ -293,7 +288,7 @@ static int acpi_ac_add(struct acpi_device *device)
 static int acpi_ac_resume(struct device *dev)
 {
struct acpi_ac *ac;
-   unsigned old_state;
+   unsigned int old_state;
 
if (!dev)
return -EINVAL;
@@ -352,9 +347,8 @@ static int __init acpi_ac_init(void)
}
 
result = acpi_bus_register_driver(_ac_driver);
-   if (result < 0) {
+   if (result < 0)
return -ENODEV;
-   }
 
return 0;
 }
-- 
2.8.1



Re: [Linuxarm] Re: [PATCH for-next 00/32] spin lock usage optimization for SCSI drivers

2021-02-24 Thread Xiaofei Tan

Hi Geert,

On 2021/2/24 17:41, Geert Uytterhoeven wrote:

Hi Xiaofei,

On Sun, Feb 7, 2021 at 12:46 PM Xiaofei Tan  wrote:

Replace spin_lock_irqsave with spin_lock in hard IRQ of SCSI drivers.
There are no function changes, but may speed up if interrupt happen
too often.


I'll bite: how much does this speed up interrupt processing?
What's the typical cost of saving/disabling, and restoring interrupt
state?


It could only take a few CPU cycles. So there is little benefit for 
speeding up interrupt processing.You could take them as cleanup.


Is removing this cost worth the risk of introducing subtle

regressions on platforms you cannot test yourself?



Currently, only found M68K platform support that high-priority interrupt 
preempts low-priority. No other platform has such services. Therefore, 
these changes do not affect non-M68K platforms.


For M68K platform, no one report such interrupt preemption case in these 
SCSI drivers.



BTW, how many of these legacy SCSI controllers do you have access to?



Actually, no.


Thanks for your answers!

Gr{oetje,eeting}s,

Geert





Re: [Linuxarm] Re: [PATCH for-next 00/32] spin lock usage optimization for SCSI drivers

2021-02-18 Thread Xiaofei Tan

Hi Finn,

On 2021/2/9 13:06, Finn Thain wrote:

On Tue, 9 Feb 2021, Song Bao Hua (Barry Song) wrote:


-Original Message-
From: Finn Thain [mailto:fth...@telegraphics.com.au]
Sent: Monday, February 8, 2021 8:57 PM
To: tanxiaofei 
Cc: j...@linux.ibm.com; martin.peter...@oracle.com;
linux-s...@vger.kernel.org; linux-kernel@vger.kernel.org;
linux...@openeuler.org
Subject: [Linuxarm] Re: [PATCH for-next 00/32] spin lock usage optimization
for SCSI drivers

On Sun, 7 Feb 2021, Xiaofei Tan wrote:


Replace spin_lock_irqsave with spin_lock in hard IRQ of SCSI drivers.
There are no function changes, but may speed up if interrupt happen too
often.


This change doesn't necessarily work on platforms that support nested
interrupts.

Were you able to measure any benefit from this change on some other
platform?


I think the code disabling irq in hardIRQ is simply wrong.
Since this commit
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e58aa3d2d0cc
genirq: Run irq handlers with interrupts disabled

interrupt handlers are definitely running in a irq-disabled context
unless irq handlers enable them explicitly in the handler to permit
other interrupts.



Repeating the same claim does not somehow make it true. If you put your
claim to the test, you'll see that that interrupts are not disabled on
m68k when interrupt handlers execute.

The Interrupt Priority Level (IPL) can prevent any given irq handler from
being re-entered, but an irq with a higher priority level may be handled
during execution of a lower priority irq handler.

sonic_interrupt() uses an irq lock within an interrupt handler to avoid
issues relating to this. This kind of locking may be needed in the drivers
you are trying to patch. Or it might not. Apparently, no-one has looked.



According to your discussion with Barry, it seems that m68k is a little 
different from other architecture, and this kind of modification of this 
patch cannot be applied to m68k. So, could help to point out which 
driver belong to m68k architecture in this patch set of SCSI?

I can remove them.

BTW, sonic_interrupt() is from net driver natsemi, right?  It would be 
appreciative if only discuss SCSI drivers in this patch set. thanks.



.





[PATCH for-next 19/32] scsi: mvumi: Replace spin_lock_irqsave with spin_lock in hard IRQ

2021-02-07 Thread Xiaofei Tan
It is redundant to do irqsave and irqrestore in hardIRQ context, where
it has been in a irq-disabled context.

Signed-off-by: Xiaofei Tan 
---
 drivers/scsi/mvumi.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
index 71b6a1f..b36164c 100644
--- a/drivers/scsi/mvumi.c
+++ b/drivers/scsi/mvumi.c
@@ -1790,11 +1790,10 @@ static void mvumi_handle_clob(struct mvumi_hba *mhba)
 static irqreturn_t mvumi_isr_handler(int irq, void *devp)
 {
struct mvumi_hba *mhba = (struct mvumi_hba *) devp;
-   unsigned long flags;
 
-   spin_lock_irqsave(mhba->shost->host_lock, flags);
+   spin_lock(mhba->shost->host_lock);
if (unlikely(mhba->instancet->clear_intr(mhba) || !mhba->global_isr)) {
-   spin_unlock_irqrestore(mhba->shost->host_lock, flags);
+   spin_unlock(mhba->shost->host_lock);
return IRQ_NONE;
}
 
@@ -1815,7 +1814,7 @@ static irqreturn_t mvumi_isr_handler(int irq, void *devp)
mhba->isr_status = 0;
if (mhba->fw_state == FW_STATE_STARTED)
mvumi_handle_clob(mhba);
-   spin_unlock_irqrestore(mhba->shost->host_lock, flags);
+   spin_unlock(mhba->shost->host_lock);
return IRQ_HANDLED;
 }
 
-- 
2.8.1



[PATCH for-next 27/32] scsi: qlogicpti: Replace spin_lock_irqsave with spin_lock in hard IRQ

2021-02-07 Thread Xiaofei Tan
It is redundant to do irqsave and irqrestore in hardIRQ context, where
it has been in a irq-disabled context.

Signed-off-by: Xiaofei Tan 
---
 drivers/scsi/qlogicpti.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index d84e218..078555e 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -1203,10 +1203,9 @@ static struct scsi_cmnd *qlogicpti_intr_handler(struct 
qlogicpti *qpti)
 static irqreturn_t qpti_intr(int irq, void *dev_id)
 {
struct qlogicpti *qpti = dev_id;
-   unsigned long flags;
struct scsi_cmnd *dq;
 
-   spin_lock_irqsave(qpti->qhost->host_lock, flags);
+   spin_lock(qpti->qhost->host_lock);
dq = qlogicpti_intr_handler(qpti);
 
if (dq != NULL) {
@@ -1218,7 +1217,7 @@ static irqreturn_t qpti_intr(int irq, void *dev_id)
dq = next;
} while (dq != NULL);
}
-   spin_unlock_irqrestore(qpti->qhost->host_lock, flags);
+   spin_unlock(qpti->qhost->host_lock);
 
return IRQ_HANDLED;
 }
-- 
2.8.1



[PATCH for-next 21/32] scsi: myrs: Replace spin_lock_irqsave with spin_lock in hard IRQ

2021-02-07 Thread Xiaofei Tan
It is redundant to do irqsave and irqrestore in hardIRQ context, where
it has been in a irq-disabled context.

Signed-off-by: Xiaofei Tan 
---
 drivers/scsi/myrs.c | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
index 4adf9de..59379fc 100644
--- a/drivers/scsi/myrs.c
+++ b/drivers/scsi/myrs.c
@@ -2615,9 +2615,8 @@ static irqreturn_t DAC960_GEM_intr_handler(int irq, void 
*arg)
struct myrs_hba *cs = arg;
void __iomem *base = cs->io_base;
struct myrs_stat_mbox *next_stat_mbox;
-   unsigned long flags;
 
-   spin_lock_irqsave(>queue_lock, flags);
+   spin_lock(>queue_lock);
DAC960_GEM_ack_intr(base);
next_stat_mbox = cs->next_stat_mbox;
while (next_stat_mbox->id > 0) {
@@ -2654,7 +2653,7 @@ static irqreturn_t DAC960_GEM_intr_handler(int irq, void 
*arg)
}
}
cs->next_stat_mbox = next_stat_mbox;
-   spin_unlock_irqrestore(>queue_lock, flags);
+   spin_unlock(>queue_lock);
return IRQ_HANDLED;
 }
 
@@ -2865,9 +2864,8 @@ static irqreturn_t DAC960_BA_intr_handler(int irq, void 
*arg)
struct myrs_hba *cs = arg;
void __iomem *base = cs->io_base;
struct myrs_stat_mbox *next_stat_mbox;
-   unsigned long flags;
 
-   spin_lock_irqsave(>queue_lock, flags);
+   spin_lock(>queue_lock);
DAC960_BA_ack_intr(base);
next_stat_mbox = cs->next_stat_mbox;
while (next_stat_mbox->id > 0) {
@@ -2904,7 +2902,7 @@ static irqreturn_t DAC960_BA_intr_handler(int irq, void 
*arg)
}
}
cs->next_stat_mbox = next_stat_mbox;
-   spin_unlock_irqrestore(>queue_lock, flags);
+   spin_unlock(>queue_lock);
return IRQ_HANDLED;
 }
 
@@ -3115,9 +3113,8 @@ static irqreturn_t DAC960_LP_intr_handler(int irq, void 
*arg)
struct myrs_hba *cs = arg;
void __iomem *base = cs->io_base;
struct myrs_stat_mbox *next_stat_mbox;
-   unsigned long flags;
 
-   spin_lock_irqsave(>queue_lock, flags);
+   spin_lock(>queue_lock);
DAC960_LP_ack_intr(base);
next_stat_mbox = cs->next_stat_mbox;
while (next_stat_mbox->id > 0) {
@@ -3154,7 +3151,7 @@ static irqreturn_t DAC960_LP_intr_handler(int irq, void 
*arg)
}
}
cs->next_stat_mbox = next_stat_mbox;
-   spin_unlock_irqrestore(>queue_lock, flags);
+   spin_unlock(>queue_lock);
return IRQ_HANDLED;
 }
 
-- 
2.8.1



  1   2   >