lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Date:   Tue,  2 Nov 2021 16:41:13 -0700
From:   Stephen Boyd <swboyd@...omium.org>
To:     Benson Leung <bleung@...omium.org>,
        Enric Balletbo i Serra <enric.balletbo@...labora.com>
Cc:     linux-kernel@...r.kernel.org, Guenter Roeck <groeck@...omium.org>
Subject: [PATCH] platform/chrome: cros_ec_chardev: Export chardev ioctls to UAPI

These ioctls and structures are part of the UAPI, export them as such by
moving the header to include/uapi/. We leave the version define out of
the header as it isn't part of the UAPI. Similarly, EC_MEMMAP_SIZE is
from the copy/pasted cros ec header so we just hardcode the array size
instead of exporting that define.

Cc: Guenter Roeck <groeck@...omium.org>
Signed-off-by: Stephen Boyd <swboyd@...omium.org>
---
 drivers/mfd/cros_ec_dev.c                     |  1 -
 drivers/platform/chrome/cros_ec_chardev.c     |  5 ++-
 include/linux/platform_data/cros_ec_proto.h   | 19 +-----------
 .../linux}/cros_ec_chardev.h                  | 31 +++++++++++++------
 4 files changed, 27 insertions(+), 29 deletions(-)
 rename include/{linux/platform_data => uapi/linux}/cros_ec_chardev.h (55%)

diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index 8c08d1c55726..8c54381bbf45 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -12,7 +12,6 @@
 #include <linux/mod_devicetable.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
-#include <linux/platform_data/cros_ec_chardev.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_data/cros_ec_proto.h>
 #include <linux/slab.h>
diff --git a/drivers/platform/chrome/cros_ec_chardev.c b/drivers/platform/chrome/cros_ec_chardev.c
index e0bce869c49a..3116c5de9fa2 100644
--- a/drivers/platform/chrome/cros_ec_chardev.c
+++ b/drivers/platform/chrome/cros_ec_chardev.c
@@ -16,7 +16,6 @@
 #include <linux/miscdevice.h>
 #include <linux/module.h>
 #include <linux/notifier.h>
-#include <linux/platform_data/cros_ec_chardev.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_data/cros_ec_proto.h>
 #include <linux/platform_device.h>
@@ -25,6 +24,10 @@
 #include <linux/types.h>
 #include <linux/uaccess.h>
 
+#include <uapi/linux/cros_ec_chardev.h>
+
+#define CROS_EC_DEV_VERSION	"1.0.0"
+
 #define DRV_NAME		"cros-ec-chardev"
 
 /* Arbitrary bounded size for the event queue */
diff --git a/include/linux/platform_data/cros_ec_proto.h b/include/linux/platform_data/cros_ec_proto.h
index 02599687770c..6fa882768239 100644
--- a/include/linux/platform_data/cros_ec_proto.h
+++ b/include/linux/platform_data/cros_ec_proto.h
@@ -13,6 +13,7 @@
 #include <linux/notifier.h>
 
 #include <linux/platform_data/cros_ec_commands.h>
+#include <uapi/linux/cros_ec_chardev.h>
 
 #define CROS_EC_DEV_NAME	"cros_ec"
 #define CROS_EC_DEV_FP_NAME	"cros_fp"
@@ -54,24 +55,6 @@ enum {
 	EC_MAX_MSG_BYTES	= 64 * 1024,
 };
 
-/**
- * struct cros_ec_command - Information about a ChromeOS EC command.
- * @version: Command version number (often 0).
- * @command: Command to send (EC_CMD_...).
- * @outsize: Outgoing length in bytes.
- * @insize: Max number of bytes to accept from the EC.
- * @result: EC's response to the command (separate from communication failure).
- * @data: Where to put the incoming data from EC and outgoing data to EC.
- */
-struct cros_ec_command {
-	uint32_t version;
-	uint32_t command;
-	uint32_t outsize;
-	uint32_t insize;
-	uint32_t result;
-	uint8_t data[];
-};
-
 /**
  * struct cros_ec_device - Information about a ChromeOS EC device.
  * @phys_name: Name of physical comms layer (e.g. 'i2c-4').
diff --git a/include/linux/platform_data/cros_ec_chardev.h b/include/uapi/linux/cros_ec_chardev.h
similarity index 55%
rename from include/linux/platform_data/cros_ec_chardev.h
rename to include/uapi/linux/cros_ec_chardev.h
index 7de8faaf77df..61f8690e86c4 100644
--- a/include/linux/platform_data/cros_ec_chardev.h
+++ b/include/uapi/linux/cros_ec_chardev.h
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: GPL-2.0 */
+/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
 /*
  * ChromeOS EC device interface.
  *
@@ -8,13 +8,26 @@
 #ifndef _UAPI_LINUX_CROS_EC_DEV_H_
 #define _UAPI_LINUX_CROS_EC_DEV_H_
 
-#include <linux/bits.h>
 #include <linux/ioctl.h>
 #include <linux/types.h>
 
-#include <linux/platform_data/cros_ec_commands.h>
-
-#define CROS_EC_DEV_VERSION "1.0.0"
+/**
+ * struct cros_ec_command - Information about a ChromeOS EC command.
+ * @version: Command version number (often 0).
+ * @command: Command to send (EC_CMD_...).
+ * @outsize: Outgoing length in bytes.
+ * @insize: Max number of bytes to accept from the EC.
+ * @result: EC's response to the command (separate from communication failure).
+ * @data: Where to put the incoming data from EC and outgoing data to EC.
+ */
+struct cros_ec_command {
+	__u32 version;
+	__u32 command;
+	__u32 outsize;
+	__u32 insize;
+	__u32 result;
+	__u8 data[];
+};
 
 /**
  * struct cros_ec_readmem - Struct used to read mapped memory.
@@ -25,9 +38,9 @@
  *         read or negative on error.
  */
 struct cros_ec_readmem {
-	uint32_t offset;
-	uint32_t bytes;
-	uint8_t buffer[EC_MEMMAP_SIZE];
+	__u32 offset;
+	__u32 bytes;
+	__u8  buffer[255];
 };
 
 #define CROS_EC_DEV_IOC       0xEC
@@ -35,4 +48,4 @@ struct cros_ec_readmem {
 #define CROS_EC_DEV_IOCRDMEM  _IOWR(CROS_EC_DEV_IOC, 1, struct cros_ec_readmem)
 #define CROS_EC_DEV_IOCEVENTMASK _IO(CROS_EC_DEV_IOC, 2)
 
-#endif /* _CROS_EC_DEV_H_ */
+#endif /* _UAPI_LINUX_CROS_EC_DEV_H_ */

base-commit: 8bb7eca972ad531c9b149c0a51ab43a417385813
-- 
https://chromeos.dev

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ