Skip to content

Commit 24c6904

Browse files
gwendalcrEnric Balletbo i Serra
authored andcommitted
platform/chrome: cros_ec: Call interrupt bottom half in ISH or RPMSG mode
Call the same bottom half for all EC protocols (threaded code). Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Link: https://lore.kernel.org/r/20210122054637.1422289-2-gwendal@chromium.org
1 parent 4c2e9b3 commit 24c6904

4 files changed

Lines changed: 25 additions & 17 deletions

File tree

drivers/platform/chrome/cros_ec.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ static struct cros_ec_platform pd_p = {
3232
.cmd_offset = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX),
3333
};
3434

35-
static irqreturn_t ec_irq_handler(int irq, void *data)
35+
/**
36+
* cros_ec_irq_handler() - top half part of the interrupt handler
37+
* @irq: IRQ id
38+
* @data: (ec_dev) Device with events to process.
39+
*
40+
* Return: Wakeup the bottom half
41+
*/
42+
static irqreturn_t cros_ec_irq_handler(int irq, void *data)
3643
{
3744
struct cros_ec_device *ec_dev = data;
3845

@@ -51,7 +58,7 @@ static irqreturn_t ec_irq_handler(int irq, void *data)
5158
* Return: true if more events are still pending and this function should be
5259
* called again.
5360
*/
54-
bool cros_ec_handle_event(struct cros_ec_device *ec_dev)
61+
static bool cros_ec_handle_event(struct cros_ec_device *ec_dev)
5562
{
5663
bool wake_event;
5764
bool ec_has_more_events;
@@ -73,9 +80,15 @@ bool cros_ec_handle_event(struct cros_ec_device *ec_dev)
7380

7481
return ec_has_more_events;
7582
}
76-
EXPORT_SYMBOL(cros_ec_handle_event);
7783

78-
static irqreturn_t ec_irq_thread(int irq, void *data)
84+
/**
85+
* cros_ec_irq_thread() - bottom half part of the interrupt handler
86+
* @irq: IRQ id
87+
* @data: (ec_dev) Device with events to process.
88+
*
89+
* Return: Interrupt handled.
90+
*/
91+
irqreturn_t cros_ec_irq_thread(int irq, void *data)
7992
{
8093
struct cros_ec_device *ec_dev = data;
8194
bool ec_has_more_events;
@@ -86,6 +99,7 @@ static irqreturn_t ec_irq_thread(int irq, void *data)
8699

87100
return IRQ_HANDLED;
88101
}
102+
EXPORT_SYMBOL(cros_ec_irq_thread);
89103

90104
static int cros_ec_sleep_event(struct cros_ec_device *ec_dev, u8 sleep_event)
91105
{
@@ -194,8 +208,8 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
194208

195209
if (ec_dev->irq > 0) {
196210
err = devm_request_threaded_irq(dev, ec_dev->irq,
197-
ec_irq_handler,
198-
ec_irq_thread,
211+
cros_ec_irq_handler,
212+
cros_ec_irq_thread,
199213
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
200214
"chromeos-ec", ec_dev);
201215
if (err) {

drivers/platform/chrome/cros_ec.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
#ifndef __CROS_EC_H
99
#define __CROS_EC_H
1010

11+
#include <linux/interrupt.h>
12+
1113
int cros_ec_register(struct cros_ec_device *ec_dev);
1214
int cros_ec_unregister(struct cros_ec_device *ec_dev);
1315

1416
int cros_ec_suspend(struct cros_ec_device *ec_dev);
1517
int cros_ec_resume(struct cros_ec_device *ec_dev);
1618

17-
bool cros_ec_handle_event(struct cros_ec_device *ec_dev);
19+
irqreturn_t cros_ec_irq_thread(int irq, void *data);
1820

1921
#endif /* __CROS_EC_H */

drivers/platform/chrome/cros_ec_ishtp.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,8 @@ static void ish_evt_handler(struct work_struct *work)
140140
{
141141
struct ishtp_cl_data *client_data =
142142
container_of(work, struct ishtp_cl_data, work_ec_evt);
143-
struct cros_ec_device *ec_dev = client_data->ec_dev;
144-
bool ec_has_more_events;
145143

146-
do {
147-
ec_has_more_events = cros_ec_handle_event(ec_dev);
148-
} while (ec_has_more_events);
144+
cros_ec_irq_thread(0, client_data->ec_dev);
149145
}
150146

151147
/**

drivers/platform/chrome/cros_ec_rpmsg.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,8 @@ cros_ec_rpmsg_host_event_function(struct work_struct *host_event_work)
149149
struct cros_ec_rpmsg *ec_rpmsg = container_of(host_event_work,
150150
struct cros_ec_rpmsg,
151151
host_event_work);
152-
struct cros_ec_device *ec_dev = dev_get_drvdata(&ec_rpmsg->rpdev->dev);
153-
bool ec_has_more_events;
154152

155-
do {
156-
ec_has_more_events = cros_ec_handle_event(ec_dev);
157-
} while (ec_has_more_events);
153+
cros_ec_irq_thread(0, dev_get_drvdata(&ec_rpmsg->rpdev->dev));
158154
}
159155

160156
static int cros_ec_rpmsg_callback(struct rpmsg_device *rpdev, void *data,

0 commit comments

Comments
 (0)