Skip to content

Commit 034dbec

Browse files
author
Enric Balletbo i Serra
committed
platform/chrome: cros_ec: Match implementation with headers
The 'cros_ec' core driver is the common interface for the cros_ec transport drivers to do the shared operations to register, unregister, suspend, resume and handle_event. The interface is provided by including the header 'include/linux/platform_data/cros_ec_proto.h', however, instead of have the implementation of these functions in cros_ec_proto.c, it is in 'cros_ec.c', which is a different kernel module. Apart from being a bad practice, this can induce confusions allowing the users of the cros_ec protocol to call these functions. The register, unregister, suspend, resume and handle_event functions *should* only be called by the different transport drivers (i2c, spi, lpc, etc.), so make this a bit less confusing by moving these functions from the public in-kernel space to a private include in platform/chrome, and then, the interface for cros_ec module and for the cros_ec_proto module is clean. Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Signed-off-by: Benson Leung <bleung@chromium.org>
1 parent 943063b commit 034dbec

8 files changed

Lines changed: 30 additions & 10 deletions

File tree

‎drivers/platform/chrome/cros_ec.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <linux/platform_data/cros_ec_proto.h>
1818
#include <linux/suspend.h>
1919

20+
#include "cros_ec.h"
21+
2022
#define CROS_EC_DEV_EC_INDEX 0
2123
#define CROS_EC_DEV_PD_INDEX 1
2224

‎drivers/platform/chrome/cros_ec.h‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* ChromeOS Embedded Controller core interface.
4+
*
5+
* Copyright (C) 2020 Google LLC
6+
*/
7+
8+
#ifndef __CROS_EC_H
9+
#define __CROS_EC_H
10+
11+
int cros_ec_register(struct cros_ec_device *ec_dev);
12+
int cros_ec_unregister(struct cros_ec_device *ec_dev);
13+
14+
int cros_ec_suspend(struct cros_ec_device *ec_dev);
15+
int cros_ec_resume(struct cros_ec_device *ec_dev);
16+
17+
bool cros_ec_handle_event(struct cros_ec_device *ec_dev);
18+
19+
#endif /* __CROS_EC_H */

‎drivers/platform/chrome/cros_ec_i2c.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <linux/platform_device.h>
1515
#include <linux/slab.h>
1616

17+
#include "cros_ec.h"
18+
1719
/**
1820
* Request format for protocol v3
1921
* byte 0 0xda (EC_COMMAND_PROTOCOL_3)

‎drivers/platform/chrome/cros_ec_ishtp.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <linux/platform_data/cros_ec_proto.h>
1515
#include <linux/intel-ish-client-if.h>
1616

17+
#include "cros_ec.h"
18+
1719
/*
1820
* ISH TX/RX ring buffer pool size
1921
*

‎drivers/platform/chrome/cros_ec_lpc.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/printk.h>
2424
#include <linux/suspend.h>
2525

26+
#include "cros_ec.h"
2627
#include "cros_ec_lpc_mec.h"
2728

2829
#define DRV_NAME "cros_ec_lpcs"

‎drivers/platform/chrome/cros_ec_rpmsg.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <linux/rpmsg.h>
1414
#include <linux/slab.h>
1515

16+
#include "cros_ec.h"
17+
1618
#define EC_MSG_TIMEOUT_MS 200
1719
#define HOST_COMMAND_MARK 1
1820
#define HOST_EVENT_MARK 2

‎drivers/platform/chrome/cros_ec_spi.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <linux/spi/spi.h>
1515
#include <uapi/linux/sched/types.h>
1616

17+
#include "cros_ec.h"
18+
1719
/* The header byte, which follows the preamble */
1820
#define EC_MSG_HEADER 0xec
1921

‎include/linux/platform_data/cros_ec_proto.h‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,6 @@ struct cros_ec_dev {
206206

207207
#define to_cros_ec_dev(dev) container_of(dev, struct cros_ec_dev, class_dev)
208208

209-
int cros_ec_suspend(struct cros_ec_device *ec_dev);
210-
211-
int cros_ec_resume(struct cros_ec_device *ec_dev);
212-
213209
int cros_ec_prepare_tx(struct cros_ec_device *ec_dev,
214210
struct cros_ec_command *msg);
215211

@@ -222,10 +218,6 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
222218
int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
223219
struct cros_ec_command *msg);
224220

225-
int cros_ec_register(struct cros_ec_device *ec_dev);
226-
227-
int cros_ec_unregister(struct cros_ec_device *ec_dev);
228-
229221
int cros_ec_query_all(struct cros_ec_device *ec_dev);
230222

231223
int cros_ec_get_next_event(struct cros_ec_device *ec_dev,
@@ -238,8 +230,6 @@ int cros_ec_check_features(struct cros_ec_dev *ec, int feature);
238230

239231
int cros_ec_get_sensor_count(struct cros_ec_dev *ec);
240232

241-
bool cros_ec_handle_event(struct cros_ec_device *ec_dev);
242-
243233
/**
244234
* cros_ec_get_time_ns() - Return time in ns.
245235
*

0 commit comments

Comments
 (0)