Skip to content

Commit

Permalink
platform/chrome: cros_ec: Match implementation with headers
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Enric Balletbo i Serra committed Feb 3, 2020
1 parent 943063b commit 034dbec
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 10 deletions.
2 changes: 2 additions & 0 deletions drivers/platform/chrome/cros_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <linux/platform_data/cros_ec_proto.h>
#include <linux/suspend.h>

#include "cros_ec.h"

#define CROS_EC_DEV_EC_INDEX 0
#define CROS_EC_DEV_PD_INDEX 1

Expand Down
19 changes: 19 additions & 0 deletions drivers/platform/chrome/cros_ec.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* ChromeOS Embedded Controller core interface.
*
* Copyright (C) 2020 Google LLC
*/

#ifndef __CROS_EC_H
#define __CROS_EC_H

int cros_ec_register(struct cros_ec_device *ec_dev);
int cros_ec_unregister(struct cros_ec_device *ec_dev);

int cros_ec_suspend(struct cros_ec_device *ec_dev);
int cros_ec_resume(struct cros_ec_device *ec_dev);

bool cros_ec_handle_event(struct cros_ec_device *ec_dev);

#endif /* __CROS_EC_H */
2 changes: 2 additions & 0 deletions drivers/platform/chrome/cros_ec_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <linux/platform_device.h>
#include <linux/slab.h>

#include "cros_ec.h"

/**
* Request format for protocol v3
* byte 0 0xda (EC_COMMAND_PROTOCOL_3)
Expand Down
2 changes: 2 additions & 0 deletions drivers/platform/chrome/cros_ec_ishtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <linux/platform_data/cros_ec_proto.h>
#include <linux/intel-ish-client-if.h>

#include "cros_ec.h"

/*
* ISH TX/RX ring buffer pool size
*
Expand Down
1 change: 1 addition & 0 deletions drivers/platform/chrome/cros_ec_lpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/printk.h>
#include <linux/suspend.h>

#include "cros_ec.h"
#include "cros_ec_lpc_mec.h"

#define DRV_NAME "cros_ec_lpcs"
Expand Down
2 changes: 2 additions & 0 deletions drivers/platform/chrome/cros_ec_rpmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <linux/rpmsg.h>
#include <linux/slab.h>

#include "cros_ec.h"

#define EC_MSG_TIMEOUT_MS 200
#define HOST_COMMAND_MARK 1
#define HOST_EVENT_MARK 2
Expand Down
2 changes: 2 additions & 0 deletions drivers/platform/chrome/cros_ec_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <linux/spi/spi.h>
#include <uapi/linux/sched/types.h>

#include "cros_ec.h"

/* The header byte, which follows the preamble */
#define EC_MSG_HEADER 0xec

Expand Down
10 changes: 0 additions & 10 deletions include/linux/platform_data/cros_ec_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ struct cros_ec_dev {

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

int cros_ec_suspend(struct cros_ec_device *ec_dev);

int cros_ec_resume(struct cros_ec_device *ec_dev);

int cros_ec_prepare_tx(struct cros_ec_device *ec_dev,
struct cros_ec_command *msg);

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

int cros_ec_register(struct cros_ec_device *ec_dev);

int cros_ec_unregister(struct cros_ec_device *ec_dev);

int cros_ec_query_all(struct cros_ec_device *ec_dev);

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

int cros_ec_get_sensor_count(struct cros_ec_dev *ec);

bool cros_ec_handle_event(struct cros_ec_device *ec_dev);

/**
* cros_ec_get_time_ns() - Return time in ns.
*
Expand Down

0 comments on commit 034dbec

Please sign in to comment.