blob: 6aa120cd0574d89ba63db30bc0e473255fe7c161 [file] [log] [blame]
Bill Richardsone7c256f2015-02-02 12:26:25 +01001/*
2 * cros_ec_dev - expose the Chrome OS Embedded Controller to user-space
3 *
4 * Copyright (C) 2014 Google, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <linux/fs.h>
Enric Balletbo i Serra5668bfd2016-08-01 11:54:38 +020021#include <linux/mfd/core.h>
Bill Richardsone7c256f2015-02-02 12:26:25 +010022#include <linux/module.h>
23#include <linux/platform_device.h>
Javier Martinez Canillasa8411782015-06-09 13:04:42 +020024#include <linux/slab.h>
Bill Richardsone7c256f2015-02-02 12:26:25 +010025#include <linux/uaccess.h>
26
27#include "cros_ec_dev.h"
28
29/* Device variables */
30#define CROS_MAX_DEV 128
Bill Richardsone7c256f2015-02-02 12:26:25 +010031static int ec_major;
32
Gwendal Grignou57b33ff2015-06-09 13:04:47 +020033static const struct attribute_group *cros_ec_groups[] = {
34 &cros_ec_attr_group,
35 &cros_ec_lightbar_attr_group,
Emilio López18800fc2015-09-21 10:38:22 -030036 &cros_ec_vbc_attr_group,
Gwendal Grignou57b33ff2015-06-09 13:04:47 +020037 NULL,
38};
39
40static struct class cros_class = {
41 .owner = THIS_MODULE,
42 .name = "chromeos",
43 .dev_groups = cros_ec_groups,
44};
45
Bill Richardsone7c256f2015-02-02 12:26:25 +010046/* Basic communication */
Gwendal Grignou57b33ff2015-06-09 13:04:47 +020047static int ec_get_version(struct cros_ec_dev *ec, char *str, int maxlen)
Bill Richardsone7c256f2015-02-02 12:26:25 +010048{
49 struct ec_response_get_version *resp;
50 static const char * const current_image_name[] = {
51 "unknown", "read-only", "read-write", "invalid",
52 };
Javier Martinez Canillasa8411782015-06-09 13:04:42 +020053 struct cros_ec_command *msg;
Bill Richardsone7c256f2015-02-02 12:26:25 +010054 int ret;
55
Javier Martinez Canillasa8411782015-06-09 13:04:42 +020056 msg = kmalloc(sizeof(*msg) + sizeof(*resp), GFP_KERNEL);
57 if (!msg)
58 return -ENOMEM;
Bill Richardsone7c256f2015-02-02 12:26:25 +010059
Javier Martinez Canillasa8411782015-06-09 13:04:42 +020060 msg->version = 0;
Gwendal Grignou57b33ff2015-06-09 13:04:47 +020061 msg->command = EC_CMD_GET_VERSION + ec->cmd_offset;
Javier Martinez Canillasa8411782015-06-09 13:04:42 +020062 msg->insize = sizeof(*resp);
63 msg->outsize = 0;
64
Gwendal Grignou57b33ff2015-06-09 13:04:47 +020065 ret = cros_ec_cmd_xfer(ec->ec_dev, msg);
Javier Martinez Canillasa8411782015-06-09 13:04:42 +020066 if (ret < 0)
67 goto exit;
68
69 if (msg->result != EC_RES_SUCCESS) {
Bill Richardsone7c256f2015-02-02 12:26:25 +010070 snprintf(str, maxlen,
71 "%s\nUnknown EC version: EC returned %d\n",
Javier Martinez Canillasa8411782015-06-09 13:04:42 +020072 CROS_EC_DEV_VERSION, msg->result);
73 ret = -EINVAL;
74 goto exit;
Bill Richardsone7c256f2015-02-02 12:26:25 +010075 }
76
Javier Martinez Canillasa8411782015-06-09 13:04:42 +020077 resp = (struct ec_response_get_version *)msg->data;
Bill Richardsone7c256f2015-02-02 12:26:25 +010078 if (resp->current_image >= ARRAY_SIZE(current_image_name))
79 resp->current_image = 3; /* invalid */
80
Olof Johanssonef59c252015-03-03 13:22:32 +010081 snprintf(str, maxlen, "%s\n%s\n%s\n%s\n", CROS_EC_DEV_VERSION,
Bill Richardsone7c256f2015-02-02 12:26:25 +010082 resp->version_string_ro, resp->version_string_rw,
83 current_image_name[resp->current_image]);
84
Javier Martinez Canillasa8411782015-06-09 13:04:42 +020085 ret = 0;
86exit:
87 kfree(msg);
88 return ret;
Bill Richardsone7c256f2015-02-02 12:26:25 +010089}
90
Vincent Palatine4244eb2016-08-01 11:54:37 +020091static int cros_ec_check_features(struct cros_ec_dev *ec, int feature)
92{
93 struct cros_ec_command *msg;
94 int ret;
95
96 if (ec->features[0] == -1U && ec->features[1] == -1U) {
97 /* features bitmap not read yet */
98
99 msg = kmalloc(sizeof(*msg) + sizeof(ec->features), GFP_KERNEL);
100 if (!msg)
101 return -ENOMEM;
102
103 msg->version = 0;
104 msg->command = EC_CMD_GET_FEATURES + ec->cmd_offset;
105 msg->insize = sizeof(ec->features);
106 msg->outsize = 0;
107
108 ret = cros_ec_cmd_xfer(ec->ec_dev, msg);
109 if (ret < 0 || msg->result != EC_RES_SUCCESS) {
110 dev_warn(ec->dev, "cannot get EC features: %d/%d\n",
111 ret, msg->result);
112 memset(ec->features, 0, sizeof(ec->features));
113 }
114
115 memcpy(ec->features, msg->data, sizeof(ec->features));
116
117 dev_dbg(ec->dev, "EC features %08x %08x\n",
118 ec->features[0], ec->features[1]);
119
120 kfree(msg);
121 }
122
123 return ec->features[feature / 32] & EC_FEATURE_MASK_0(feature);
124}
125
Bill Richardsone7c256f2015-02-02 12:26:25 +0100126/* Device file ops */
127static int ec_device_open(struct inode *inode, struct file *filp)
128{
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200129 struct cros_ec_dev *ec = container_of(inode->i_cdev,
130 struct cros_ec_dev, cdev);
131 filp->private_data = ec;
132 nonseekable_open(inode, filp);
Bill Richardsone7c256f2015-02-02 12:26:25 +0100133 return 0;
134}
135
136static int ec_device_release(struct inode *inode, struct file *filp)
137{
138 return 0;
139}
140
141static ssize_t ec_device_read(struct file *filp, char __user *buffer,
142 size_t length, loff_t *offset)
143{
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200144 struct cros_ec_dev *ec = filp->private_data;
Bill Richardsone7c256f2015-02-02 12:26:25 +0100145 char msg[sizeof(struct ec_response_get_version) +
146 sizeof(CROS_EC_DEV_VERSION)];
147 size_t count;
148 int ret;
149
150 if (*offset != 0)
151 return 0;
152
153 ret = ec_get_version(ec, msg, sizeof(msg));
154 if (ret)
155 return ret;
156
157 count = min(length, strlen(msg));
158
159 if (copy_to_user(buffer, msg, count))
160 return -EFAULT;
161
162 *offset = count;
163 return count;
164}
165
166/* Ioctls */
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200167static long ec_device_ioctl_xcmd(struct cros_ec_dev *ec, void __user *arg)
Bill Richardsone7c256f2015-02-02 12:26:25 +0100168{
169 long ret;
Javier Martinez Canillasa8411782015-06-09 13:04:42 +0200170 struct cros_ec_command u_cmd;
171 struct cros_ec_command *s_cmd;
Bill Richardsone7c256f2015-02-02 12:26:25 +0100172
Javier Martinez Canillasa8411782015-06-09 13:04:42 +0200173 if (copy_from_user(&u_cmd, arg, sizeof(u_cmd)))
Bill Richardsone7c256f2015-02-02 12:26:25 +0100174 return -EFAULT;
175
Gwendal Grignou5d749d02016-03-08 09:13:52 -0800176 if ((u_cmd.outsize > EC_MAX_MSG_BYTES) ||
177 (u_cmd.insize > EC_MAX_MSG_BYTES))
178 return -EINVAL;
179
Javier Martinez Canillasa8411782015-06-09 13:04:42 +0200180 s_cmd = kmalloc(sizeof(*s_cmd) + max(u_cmd.outsize, u_cmd.insize),
181 GFP_KERNEL);
182 if (!s_cmd)
183 return -ENOMEM;
184
185 if (copy_from_user(s_cmd, arg, sizeof(*s_cmd) + u_cmd.outsize)) {
186 ret = -EFAULT;
187 goto exit;
188 }
189
Dan Carpenter096cdc62016-06-21 16:58:46 +0300190 if (u_cmd.outsize != s_cmd->outsize ||
191 u_cmd.insize != s_cmd->insize) {
192 ret = -EINVAL;
193 goto exit;
194 }
195
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200196 s_cmd->command += ec->cmd_offset;
197 ret = cros_ec_cmd_xfer(ec->ec_dev, s_cmd);
Bill Richardsone7c256f2015-02-02 12:26:25 +0100198 /* Only copy data to userland if data was received. */
199 if (ret < 0)
Javier Martinez Canillasa8411782015-06-09 13:04:42 +0200200 goto exit;
Bill Richardsone7c256f2015-02-02 12:26:25 +0100201
Dan Carpenter096cdc62016-06-21 16:58:46 +0300202 if (copy_to_user(arg, s_cmd, sizeof(*s_cmd) + s_cmd->insize))
Javier Martinez Canillasa8411782015-06-09 13:04:42 +0200203 ret = -EFAULT;
204exit:
205 kfree(s_cmd);
206 return ret;
Bill Richardsone7c256f2015-02-02 12:26:25 +0100207}
208
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200209static long ec_device_ioctl_readmem(struct cros_ec_dev *ec, void __user *arg)
Bill Richardsone7c256f2015-02-02 12:26:25 +0100210{
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200211 struct cros_ec_device *ec_dev = ec->ec_dev;
Bill Richardsone7c256f2015-02-02 12:26:25 +0100212 struct cros_ec_readmem s_mem = { };
213 long num;
214
215 /* Not every platform supports direct reads */
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200216 if (!ec_dev->cmd_readmem)
Bill Richardsone7c256f2015-02-02 12:26:25 +0100217 return -ENOTTY;
218
219 if (copy_from_user(&s_mem, arg, sizeof(s_mem)))
220 return -EFAULT;
221
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200222 num = ec_dev->cmd_readmem(ec_dev, s_mem.offset, s_mem.bytes,
223 s_mem.buffer);
Bill Richardsone7c256f2015-02-02 12:26:25 +0100224 if (num <= 0)
225 return num;
226
227 if (copy_to_user((void __user *)arg, &s_mem, sizeof(s_mem)))
228 return -EFAULT;
229
230 return 0;
231}
232
233static long ec_device_ioctl(struct file *filp, unsigned int cmd,
234 unsigned long arg)
235{
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200236 struct cros_ec_dev *ec = filp->private_data;
Bill Richardsone7c256f2015-02-02 12:26:25 +0100237
238 if (_IOC_TYPE(cmd) != CROS_EC_DEV_IOC)
239 return -ENOTTY;
240
241 switch (cmd) {
242 case CROS_EC_DEV_IOCXCMD:
243 return ec_device_ioctl_xcmd(ec, (void __user *)arg);
244 case CROS_EC_DEV_IOCRDMEM:
245 return ec_device_ioctl_readmem(ec, (void __user *)arg);
246 }
247
248 return -ENOTTY;
249}
250
251/* Module initialization */
252static const struct file_operations fops = {
253 .open = ec_device_open,
254 .release = ec_device_release,
255 .read = ec_device_read,
256 .unlocked_ioctl = ec_device_ioctl,
Guenter Roeck2521ea32016-04-14 19:35:29 -0700257#ifdef CONFIG_COMPAT
258 .compat_ioctl = ec_device_ioctl,
259#endif
Bill Richardsone7c256f2015-02-02 12:26:25 +0100260};
261
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200262static void __remove(struct device *dev)
263{
264 struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev,
265 class_dev);
266 kfree(ec);
267}
268
Enric Balletbo i Serra5668bfd2016-08-01 11:54:38 +0200269static void cros_ec_sensors_register(struct cros_ec_dev *ec)
270{
271 /*
272 * Issue a command to get the number of sensor reported.
273 * Build an array of sensors driver and register them all.
274 */
275 int ret, i, id, sensor_num;
276 struct mfd_cell *sensor_cells;
277 struct cros_ec_sensor_platform *sensor_platforms;
278 int sensor_type[MOTIONSENSE_TYPE_MAX];
279 struct ec_params_motion_sense *params;
280 struct ec_response_motion_sense *resp;
281 struct cros_ec_command *msg;
282
283 msg = kzalloc(sizeof(struct cros_ec_command) +
284 max(sizeof(*params), sizeof(*resp)), GFP_KERNEL);
285 if (msg == NULL)
286 return;
287
288 msg->version = 2;
289 msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset;
290 msg->outsize = sizeof(*params);
291 msg->insize = sizeof(*resp);
292
293 params = (struct ec_params_motion_sense *)msg->data;
294 params->cmd = MOTIONSENSE_CMD_DUMP;
295
296 ret = cros_ec_cmd_xfer(ec->ec_dev, msg);
297 if (ret < 0 || msg->result != EC_RES_SUCCESS) {
298 dev_warn(ec->dev, "cannot get EC sensor information: %d/%d\n",
299 ret, msg->result);
300 goto error;
301 }
302
303 resp = (struct ec_response_motion_sense *)msg->data;
304 sensor_num = resp->dump.sensor_count;
305 /* Allocate 2 extra sensors in case lid angle or FIFO are needed */
306 sensor_cells = kzalloc(sizeof(struct mfd_cell) * (sensor_num + 2),
307 GFP_KERNEL);
308 if (sensor_cells == NULL)
309 goto error;
310
311 sensor_platforms = kzalloc(sizeof(struct cros_ec_sensor_platform) *
312 (sensor_num + 1), GFP_KERNEL);
313 if (sensor_platforms == NULL)
314 goto error_platforms;
315
316 memset(sensor_type, 0, sizeof(sensor_type));
317 id = 0;
318 for (i = 0; i < sensor_num; i++) {
319 params->cmd = MOTIONSENSE_CMD_INFO;
320 params->info.sensor_num = i;
321 ret = cros_ec_cmd_xfer(ec->ec_dev, msg);
322 if (ret < 0 || msg->result != EC_RES_SUCCESS) {
323 dev_warn(ec->dev, "no info for EC sensor %d : %d/%d\n",
324 i, ret, msg->result);
325 continue;
326 }
327 switch (resp->info.type) {
328 case MOTIONSENSE_TYPE_ACCEL:
329 sensor_cells[id].name = "cros-ec-accel";
330 break;
Gwendal Grignoud7322482017-01-24 14:41:41 +0100331 case MOTIONSENSE_TYPE_BARO:
332 sensor_cells[id].name = "cros-ec-baro";
333 break;
Enric Balletbo i Serra5668bfd2016-08-01 11:54:38 +0200334 case MOTIONSENSE_TYPE_GYRO:
335 sensor_cells[id].name = "cros-ec-gyro";
336 break;
337 case MOTIONSENSE_TYPE_MAG:
338 sensor_cells[id].name = "cros-ec-mag";
339 break;
340 case MOTIONSENSE_TYPE_PROX:
341 sensor_cells[id].name = "cros-ec-prox";
342 break;
343 case MOTIONSENSE_TYPE_LIGHT:
344 sensor_cells[id].name = "cros-ec-light";
345 break;
346 case MOTIONSENSE_TYPE_ACTIVITY:
347 sensor_cells[id].name = "cros-ec-activity";
348 break;
349 default:
350 dev_warn(ec->dev, "unknown type %d\n", resp->info.type);
351 continue;
352 }
353 sensor_platforms[id].sensor_num = i;
354 sensor_cells[id].id = sensor_type[resp->info.type];
355 sensor_cells[id].platform_data = &sensor_platforms[id];
356 sensor_cells[id].pdata_size =
357 sizeof(struct cros_ec_sensor_platform);
358
359 sensor_type[resp->info.type]++;
360 id++;
361 }
362 if (sensor_type[MOTIONSENSE_TYPE_ACCEL] >= 2) {
363 sensor_platforms[id].sensor_num = sensor_num;
364
365 sensor_cells[id].name = "cros-ec-angle";
366 sensor_cells[id].id = 0;
367 sensor_cells[id].platform_data = &sensor_platforms[id];
368 sensor_cells[id].pdata_size =
369 sizeof(struct cros_ec_sensor_platform);
370 id++;
371 }
372 if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE_FIFO)) {
373 sensor_cells[id].name = "cros-ec-ring";
374 id++;
375 }
376
377 ret = mfd_add_devices(ec->dev, 0, sensor_cells, id,
378 NULL, 0, NULL);
379 if (ret)
380 dev_err(ec->dev, "failed to add EC sensors\n");
381
382 kfree(sensor_platforms);
383error_platforms:
384 kfree(sensor_cells);
385error:
386 kfree(msg);
387}
388
Bill Richardsone7c256f2015-02-02 12:26:25 +0100389static int ec_device_probe(struct platform_device *pdev)
390{
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200391 int retval = -ENOMEM;
392 struct device *dev = &pdev->dev;
393 struct cros_ec_platform *ec_platform = dev_get_platdata(dev);
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200394 struct cros_ec_dev *ec = kzalloc(sizeof(*ec), GFP_KERNEL);
Bill Richardsone7c256f2015-02-02 12:26:25 +0100395
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200396 if (!ec)
397 return retval;
398
399 dev_set_drvdata(dev, ec);
400 ec->ec_dev = dev_get_drvdata(dev->parent);
401 ec->dev = dev;
402 ec->cmd_offset = ec_platform->cmd_offset;
Vincent Palatine4244eb2016-08-01 11:54:37 +0200403 ec->features[0] = -1U; /* Not cached yet */
404 ec->features[1] = -1U; /* Not cached yet */
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200405 device_initialize(&ec->class_dev);
Bill Richardsone7c256f2015-02-02 12:26:25 +0100406 cdev_init(&ec->cdev, &fops);
407
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200408 /*
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200409 * Add the class device
410 * Link to the character device for creating the /dev entry
411 * in devtmpfs.
412 */
Logan Gunthorpe1c1d1522017-03-17 12:48:14 -0600413 ec->class_dev.devt = MKDEV(ec_major, pdev->id);
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200414 ec->class_dev.class = &cros_class;
415 ec->class_dev.parent = dev;
416 ec->class_dev.release = __remove;
417
418 retval = dev_set_name(&ec->class_dev, "%s", ec_platform->ec_name);
419 if (retval) {
420 dev_err(dev, "dev_set_name failed => %d\n", retval);
Logan Gunthorpe1c1d1522017-03-17 12:48:14 -0600421 goto failed;
Bill Richardsone7c256f2015-02-02 12:26:25 +0100422 }
423
Logan Gunthorpe1c1d1522017-03-17 12:48:14 -0600424 retval = cdev_device_add(&ec->cdev, &ec->class_dev);
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200425 if (retval) {
Logan Gunthorpe1c1d1522017-03-17 12:48:14 -0600426 dev_err(dev, "cdev_device_add failed => %d\n", retval);
427 goto failed;
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200428 }
Bill Richardson71af4b52015-02-02 12:26:27 +0100429
Enric Balletbo i Serra5668bfd2016-08-01 11:54:38 +0200430 /* check whether this EC is a sensor hub. */
431 if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE))
432 cros_ec_sensors_register(ec);
433
Bill Richardsone7c256f2015-02-02 12:26:25 +0100434 return 0;
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200435
Logan Gunthorpe1c1d1522017-03-17 12:48:14 -0600436failed:
437 put_device(&ec->class_dev);
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200438 return retval;
Bill Richardsone7c256f2015-02-02 12:26:25 +0100439}
440
441static int ec_device_remove(struct platform_device *pdev)
442{
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200443 struct cros_ec_dev *ec = dev_get_drvdata(&pdev->dev);
Bill Richardsone7c256f2015-02-02 12:26:25 +0100444 cdev_del(&ec->cdev);
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200445 device_unregister(&ec->class_dev);
Bill Richardsone7c256f2015-02-02 12:26:25 +0100446 return 0;
447}
448
Javier Martinez Canillasafbf8ec2015-06-22 08:27:20 +0200449static const struct platform_device_id cros_ec_id[] = {
450 { "cros-ec-ctl", 0 },
451 { /* sentinel */ },
452};
453MODULE_DEVICE_TABLE(platform, cros_ec_id);
454
Bill Richardsone7c256f2015-02-02 12:26:25 +0100455static struct platform_driver cros_ec_dev_driver = {
456 .driver = {
457 .name = "cros-ec-ctl",
458 },
459 .probe = ec_device_probe,
460 .remove = ec_device_remove,
461};
462
463static int __init cros_ec_dev_init(void)
464{
465 int ret;
466 dev_t dev = 0;
467
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200468 ret = class_register(&cros_class);
469 if (ret) {
Bill Richardsone7c256f2015-02-02 12:26:25 +0100470 pr_err(CROS_EC_DEV_NAME ": failed to register device class\n");
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200471 return ret;
Bill Richardsone7c256f2015-02-02 12:26:25 +0100472 }
473
474 /* Get a range of minor numbers (starting with 0) to work with */
475 ret = alloc_chrdev_region(&dev, 0, CROS_MAX_DEV, CROS_EC_DEV_NAME);
476 if (ret < 0) {
477 pr_err(CROS_EC_DEV_NAME ": alloc_chrdev_region() failed\n");
478 goto failed_chrdevreg;
479 }
480 ec_major = MAJOR(dev);
481
482 /* Register the driver */
483 ret = platform_driver_register(&cros_ec_dev_driver);
484 if (ret < 0) {
485 pr_warn(CROS_EC_DEV_NAME ": can't register driver: %d\n", ret);
486 goto failed_devreg;
487 }
488 return 0;
489
490failed_devreg:
491 unregister_chrdev_region(MKDEV(ec_major, 0), CROS_MAX_DEV);
492failed_chrdevreg:
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200493 class_unregister(&cros_class);
Bill Richardsone7c256f2015-02-02 12:26:25 +0100494 return ret;
495}
496
497static void __exit cros_ec_dev_exit(void)
498{
499 platform_driver_unregister(&cros_ec_dev_driver);
500 unregister_chrdev(ec_major, CROS_EC_DEV_NAME);
Gwendal Grignou57b33ff2015-06-09 13:04:47 +0200501 class_unregister(&cros_class);
Bill Richardsone7c256f2015-02-02 12:26:25 +0100502}
503
504module_init(cros_ec_dev_init);
505module_exit(cros_ec_dev_exit);
506
507MODULE_AUTHOR("Bill Richardson <wfrichar@chromium.org>");
508MODULE_DESCRIPTION("Userspace interface to the Chrome OS Embedded Controller");
509MODULE_VERSION("1.0");
510MODULE_LICENSE("GPL");