From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Linux PM <linux-pm@vger.kernel.org>
Subject: [PATCH 03/10] ACPI: EC: Pass one argument to acpi_ec_query()
Date: Tue, 23 Nov 2021 19:38:21 +0100 [thread overview]
Message-ID: <4686424.GXAFRqVoOG@kreacher> (raw)
In-Reply-To: <11887969.O9o76ZdvQC@kreacher>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Notice that the second argument to acpi_ec_query() is redundant,
because in the only case when it is not NULL, the value passed
through it is only checked against 0 and it can only be 0 when
acpi_ec_query() returns an error code, but its return value
is checked along with the value passed through its second
argument.
Accordingly, modify acpi_ec_query() to take only one argument
and while at it, change its handling of the case when
acpi_ec_transaction() returns an error so as to return that
error value to the caller right away.
No expected functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/ec.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
Index: linux-pm/drivers/acpi/ec.c
===================================================================
--- linux-pm.orig/drivers/acpi/ec.c
+++ linux-pm/drivers/acpi/ec.c
@@ -169,7 +169,7 @@ struct acpi_ec_query {
struct acpi_ec *ec;
};
-static int acpi_ec_query(struct acpi_ec *ec, u8 *data);
+static int acpi_ec_query(struct acpi_ec *ec);
static bool advance_transaction(struct acpi_ec *ec, bool interrupt);
static void acpi_ec_event_handler(struct work_struct *work);
static void acpi_ec_event_processor(struct work_struct *work);
@@ -496,12 +496,10 @@ static inline void __acpi_ec_disable_eve
*/
static void acpi_ec_clear(struct acpi_ec *ec)
{
- int i, status;
- u8 value = 0;
+ int i;
for (i = 0; i < ACPI_EC_CLEAR_MAX; i++) {
- status = acpi_ec_query(ec, &value);
- if (status || !value)
+ if (acpi_ec_query(ec))
break;
}
if (unlikely(i == ACPI_EC_CLEAR_MAX))
@@ -1164,11 +1162,11 @@ static void acpi_ec_event_processor(stru
acpi_ec_delete_query(q);
}
-static int acpi_ec_query(struct acpi_ec *ec, u8 *data)
+static int acpi_ec_query(struct acpi_ec *ec)
{
+ struct acpi_ec_query *q;
u8 value = 0;
int result;
- struct acpi_ec_query *q;
q = acpi_ec_create_query(ec, &value);
if (!q)
@@ -1180,11 +1178,14 @@ static int acpi_ec_query(struct acpi_ec
* bit to be cleared (and thus clearing the interrupt source).
*/
result = acpi_ec_transaction(ec, &q->transaction);
- if (!value)
- result = -ENODATA;
if (result)
goto err_exit;
+ if (!value) {
+ result = -ENODATA;
+ goto err_exit;
+ }
+
q->handler = acpi_ec_get_query_handler_by_value(ec, value);
if (!q->handler) {
result = -ENODATA;
@@ -1210,8 +1211,7 @@ static int acpi_ec_query(struct acpi_ec
err_exit:
if (result)
acpi_ec_delete_query(q);
- if (data)
- *data = value;
+
return result;
}
@@ -1243,7 +1243,9 @@ static void acpi_ec_event_handler(struct
spin_lock_irqsave(&ec->lock, flags);
while (ec->nr_pending_queries) {
spin_unlock_irqrestore(&ec->lock, flags);
- (void)acpi_ec_query(ec, NULL);
+
+ acpi_ec_query(ec);
+
spin_lock_irqsave(&ec->lock, flags);
ec->nr_pending_queries--;
/*
next prev parent reply other threads:[~2021-11-23 18:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-23 18:35 [PATCH 00/10] ACPI: EC: Two fixes and cleanups Rafael J. Wysocki
2021-11-23 18:36 ` [PATCH 01/10] ACPI: EC: Rework flushing of EC work while suspended to idle Rafael J. Wysocki
2021-11-23 18:37 ` [PATCH 02/10] ACPI: EC: Call advance_transaction() from acpi_ec_dispatch_gpe() Rafael J. Wysocki
2021-11-23 18:38 ` Rafael J. Wysocki [this message]
2021-11-23 18:39 ` [PATCH 04/10] ACPI: EC: Fold acpi_ec_check_event() into acpi_ec_event_handler() Rafael J. Wysocki
2021-11-23 18:40 ` [PATCH 05/10] ACPI: EC: Rearrange the loop in acpi_ec_event_handler() Rafael J. Wysocki
2021-11-23 18:40 ` [PATCH 06/10] ACPI: EC: Simplify locking " Rafael J. Wysocki
2021-11-23 18:42 ` [PATCH 07/10] ACPI: EC: Rename three functions Rafael J. Wysocki
2021-11-23 18:43 ` [PATCH 08/10] ACPI: EC: Avoid queuing unnecessary work in acpi_ec_submit_event() Rafael J. Wysocki
2021-11-23 18:44 ` [PATCH 09/10] ACPI: EC: Make the event work state machine visible Rafael J. Wysocki
2021-11-23 18:46 ` [PATCH 10/10] ACPI: EC: Relocate acpi_ec_create_query() and drop acpi_ec_delete_query() Rafael J. Wysocki
2021-12-01 19:22 ` [PATCH 00/10] ACPI: EC: Two fixes and cleanups Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4686424.GXAFRqVoOG@kreacher \
--to=rjw@rjwysocki.net \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).