Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Intel Management Engine Interface (Intel MEI) Linux driver |
Tomas Winkler | 733ba91 | 2012-02-09 19:25:53 +0200 | [diff] [blame] | 4 | * Copyright (c) 2003-2012, Intel Corporation. |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms and conditions of the GNU General Public License, |
| 8 | * version 2, as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
| 15 | */ |
| 16 | |
Tomas Winkler | 2f3d2b4 | 2012-03-19 22:38:13 +0200 | [diff] [blame] | 17 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 18 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 19 | #include <linux/module.h> |
| 20 | #include <linux/moduleparam.h> |
| 21 | #include <linux/kernel.h> |
| 22 | #include <linux/device.h> |
| 23 | #include <linux/fs.h> |
| 24 | #include <linux/errno.h> |
| 25 | #include <linux/types.h> |
| 26 | #include <linux/fcntl.h> |
| 27 | #include <linux/aio.h> |
| 28 | #include <linux/pci.h> |
| 29 | #include <linux/poll.h> |
| 30 | #include <linux/init.h> |
| 31 | #include <linux/ioctl.h> |
| 32 | #include <linux/cdev.h> |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 33 | #include <linux/sched.h> |
| 34 | #include <linux/uuid.h> |
| 35 | #include <linux/compat.h> |
| 36 | #include <linux/jiffies.h> |
| 37 | #include <linux/interrupt.h> |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 38 | #include <linux/miscdevice.h> |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 39 | |
Tomas Winkler | 4f3afe1 | 2012-05-09 16:38:59 +0300 | [diff] [blame] | 40 | #include <linux/mei.h> |
Tomas Winkler | 47a7380 | 2012-12-25 19:06:03 +0200 | [diff] [blame] | 41 | |
| 42 | #include "mei_dev.h" |
Tomas Winkler | 9dc64d6 | 2013-01-08 23:07:17 +0200 | [diff] [blame] | 43 | #include "hw-me.h" |
Tomas Winkler | 90e0b5f | 2013-01-08 23:07:14 +0200 | [diff] [blame] | 44 | #include "client.h" |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 45 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 46 | /** |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 47 | * mei_open - the open function |
| 48 | * |
| 49 | * @inode: pointer to inode structure |
| 50 | * @file: pointer to file structure |
Tomas Winkler | 9b0d5ef | 2013-04-18 23:03:48 +0300 | [diff] [blame] | 51 | e |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 52 | * returns 0 on success, <0 on error |
| 53 | */ |
| 54 | static int mei_open(struct inode *inode, struct file *file) |
| 55 | { |
Tomas Winkler | 2703d4b | 2013-02-06 14:06:39 +0200 | [diff] [blame] | 56 | struct miscdevice *misc = file->private_data; |
| 57 | struct pci_dev *pdev; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 58 | struct mei_cl *cl; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 59 | struct mei_device *dev; |
Tomas Winkler | 2703d4b | 2013-02-06 14:06:39 +0200 | [diff] [blame] | 60 | |
Tomas Winkler | 6f37aca | 2011-11-13 09:41:15 +0200 | [diff] [blame] | 61 | int err; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 62 | |
| 63 | err = -ENODEV; |
Tomas Winkler | 2703d4b | 2013-02-06 14:06:39 +0200 | [diff] [blame] | 64 | if (!misc->parent) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 65 | goto out; |
| 66 | |
Tomas Winkler | 2703d4b | 2013-02-06 14:06:39 +0200 | [diff] [blame] | 67 | pdev = container_of(misc->parent, struct pci_dev, dev); |
| 68 | |
| 69 | dev = pci_get_drvdata(pdev); |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 70 | if (!dev) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 71 | goto out; |
| 72 | |
| 73 | mutex_lock(&dev->device_lock); |
| 74 | err = -ENOMEM; |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 75 | cl = mei_cl_allocate(dev); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 76 | if (!cl) |
Alexey Khoroshilov | 303dfbf | 2011-08-31 00:41:14 +0400 | [diff] [blame] | 77 | goto out_unlock; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 78 | |
| 79 | err = -ENODEV; |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 80 | if (dev->dev_state != MEI_DEV_ENABLED) { |
| 81 | dev_dbg(&dev->pdev->dev, "dev_state != MEI_ENABLED dev_state = %s\n", |
| 82 | mei_dev_state_str(dev->dev_state)); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 83 | goto out_unlock; |
| 84 | } |
| 85 | err = -EMFILE; |
Tomas Winkler | 1b81294 | 2012-09-11 00:43:20 +0300 | [diff] [blame] | 86 | if (dev->open_handle_count >= MEI_MAX_OPEN_HANDLE_COUNT) { |
| 87 | dev_err(&dev->pdev->dev, "open_handle_count exceded %d", |
| 88 | MEI_MAX_OPEN_HANDLE_COUNT); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 89 | goto out_unlock; |
Tomas Winkler | 1b81294 | 2012-09-11 00:43:20 +0300 | [diff] [blame] | 90 | } |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 91 | |
Tomas Winkler | 781d0d8 | 2013-01-08 23:07:22 +0200 | [diff] [blame] | 92 | err = mei_cl_link(cl, MEI_HOST_CLIENT_ID_ANY); |
| 93 | if (err) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 94 | goto out_unlock; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 95 | |
| 96 | file->private_data = cl; |
| 97 | mutex_unlock(&dev->device_lock); |
| 98 | |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 99 | return nonseekable_open(inode, file); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 100 | |
| 101 | out_unlock: |
| 102 | mutex_unlock(&dev->device_lock); |
| 103 | kfree(cl); |
| 104 | out: |
| 105 | return err; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * mei_release - the release function |
| 110 | * |
| 111 | * @inode: pointer to inode structure |
| 112 | * @file: pointer to file structure |
| 113 | * |
| 114 | * returns 0 on success, <0 on error |
| 115 | */ |
| 116 | static int mei_release(struct inode *inode, struct file *file) |
| 117 | { |
| 118 | struct mei_cl *cl = file->private_data; |
| 119 | struct mei_cl_cb *cb; |
| 120 | struct mei_device *dev; |
| 121 | int rets = 0; |
| 122 | |
| 123 | if (WARN_ON(!cl || !cl->dev)) |
| 124 | return -ENODEV; |
| 125 | |
| 126 | dev = cl->dev; |
| 127 | |
| 128 | mutex_lock(&dev->device_lock); |
Tomas Winkler | a562d5c | 2012-11-11 17:38:01 +0200 | [diff] [blame] | 129 | if (cl == &dev->iamthif_cl) { |
| 130 | rets = mei_amthif_release(dev, file); |
| 131 | goto out; |
| 132 | } |
| 133 | if (cl->state == MEI_FILE_CONNECTED) { |
| 134 | cl->state = MEI_FILE_DISCONNECTING; |
| 135 | dev_dbg(&dev->pdev->dev, |
| 136 | "disconnecting client host client = %d, " |
| 137 | "ME client = %d\n", |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 138 | cl->host_client_id, |
| 139 | cl->me_client_id); |
Tomas Winkler | 90e0b5f | 2013-01-08 23:07:14 +0200 | [diff] [blame] | 140 | rets = mei_cl_disconnect(cl); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 141 | } |
Tomas Winkler | a562d5c | 2012-11-11 17:38:01 +0200 | [diff] [blame] | 142 | mei_cl_flush_queues(cl); |
| 143 | dev_dbg(&dev->pdev->dev, "remove client host client = %d, ME client = %d\n", |
| 144 | cl->host_client_id, |
| 145 | cl->me_client_id); |
| 146 | |
| 147 | if (dev->open_handle_count > 0) { |
| 148 | clear_bit(cl->host_client_id, dev->host_clients_map); |
| 149 | dev->open_handle_count--; |
| 150 | } |
Tomas Winkler | 90e0b5f | 2013-01-08 23:07:14 +0200 | [diff] [blame] | 151 | mei_cl_unlink(cl); |
Tomas Winkler | a562d5c | 2012-11-11 17:38:01 +0200 | [diff] [blame] | 152 | |
Tomas Winkler | 781d0d8 | 2013-01-08 23:07:22 +0200 | [diff] [blame] | 153 | |
Tomas Winkler | a562d5c | 2012-11-11 17:38:01 +0200 | [diff] [blame] | 154 | /* free read cb */ |
| 155 | cb = NULL; |
| 156 | if (cl->read_cb) { |
Tomas Winkler | 90e0b5f | 2013-01-08 23:07:14 +0200 | [diff] [blame] | 157 | cb = mei_cl_find_read_cb(cl); |
Tomas Winkler | a562d5c | 2012-11-11 17:38:01 +0200 | [diff] [blame] | 158 | /* Remove entry from read list */ |
| 159 | if (cb) |
| 160 | list_del(&cb->list); |
| 161 | |
| 162 | cb = cl->read_cb; |
| 163 | cl->read_cb = NULL; |
| 164 | } |
| 165 | |
| 166 | file->private_data = NULL; |
| 167 | |
| 168 | if (cb) { |
| 169 | mei_io_cb_free(cb); |
| 170 | cb = NULL; |
| 171 | } |
| 172 | |
| 173 | kfree(cl); |
| 174 | out: |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 175 | mutex_unlock(&dev->device_lock); |
| 176 | return rets; |
| 177 | } |
| 178 | |
| 179 | |
| 180 | /** |
| 181 | * mei_read - the read function. |
| 182 | * |
| 183 | * @file: pointer to file structure |
| 184 | * @ubuf: pointer to user buffer |
| 185 | * @length: buffer length |
| 186 | * @offset: data offset in buffer |
| 187 | * |
| 188 | * returns >=0 data length on success , <0 on error |
| 189 | */ |
| 190 | static ssize_t mei_read(struct file *file, char __user *ubuf, |
Tomas Winkler | 441ab50 | 2011-12-13 23:39:34 +0200 | [diff] [blame] | 191 | size_t length, loff_t *offset) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 192 | { |
| 193 | struct mei_cl *cl = file->private_data; |
| 194 | struct mei_cl_cb *cb_pos = NULL; |
| 195 | struct mei_cl_cb *cb = NULL; |
| 196 | struct mei_device *dev; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 197 | int rets; |
| 198 | int err; |
| 199 | |
| 200 | |
| 201 | if (WARN_ON(!cl || !cl->dev)) |
| 202 | return -ENODEV; |
| 203 | |
| 204 | dev = cl->dev; |
| 205 | |
| 206 | mutex_lock(&dev->device_lock); |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 207 | if (dev->dev_state != MEI_DEV_ENABLED) { |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 208 | rets = -ENODEV; |
| 209 | goto out; |
| 210 | } |
| 211 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 212 | if (cl == &dev->iamthif_cl) { |
Tomas Winkler | 19838fb | 2012-11-01 21:17:15 +0200 | [diff] [blame] | 213 | rets = mei_amthif_read(dev, file, ubuf, length, offset); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 214 | goto out; |
| 215 | } |
| 216 | |
Tomas Winkler | 139aacf | 2013-05-29 20:09:30 +0300 | [diff] [blame] | 217 | if (cl->read_cb) { |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 218 | cb = cl->read_cb; |
Tomas Winkler | 139aacf | 2013-05-29 20:09:30 +0300 | [diff] [blame] | 219 | /* read what left */ |
| 220 | if (cb->buf_idx > *offset) |
| 221 | goto copy_buffer; |
| 222 | /* offset is beyond buf_idx we have no more data return 0 */ |
| 223 | if (cb->buf_idx > 0 && cb->buf_idx <= *offset) { |
| 224 | rets = 0; |
| 225 | goto free; |
| 226 | } |
| 227 | /* Offset needs to be cleaned for contiguous reads*/ |
| 228 | if (cb->buf_idx == 0 && *offset > 0) |
| 229 | *offset = 0; |
| 230 | } else if (*offset > 0) { |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 231 | *offset = 0; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 232 | } |
| 233 | |
Tomas Winkler | fcb136e | 2013-04-19 22:01:35 +0300 | [diff] [blame] | 234 | err = mei_cl_read_start(cl, length); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 235 | if (err && err != -EBUSY) { |
| 236 | dev_dbg(&dev->pdev->dev, |
| 237 | "mei start read failure with status = %d\n", err); |
| 238 | rets = err; |
| 239 | goto out; |
| 240 | } |
| 241 | |
| 242 | if (MEI_READ_COMPLETE != cl->reading_state && |
| 243 | !waitqueue_active(&cl->rx_wait)) { |
| 244 | if (file->f_flags & O_NONBLOCK) { |
| 245 | rets = -EAGAIN; |
| 246 | goto out; |
| 247 | } |
| 248 | |
| 249 | mutex_unlock(&dev->device_lock); |
| 250 | |
| 251 | if (wait_event_interruptible(cl->rx_wait, |
| 252 | (MEI_READ_COMPLETE == cl->reading_state || |
| 253 | MEI_FILE_INITIALIZING == cl->state || |
| 254 | MEI_FILE_DISCONNECTED == cl->state || |
| 255 | MEI_FILE_DISCONNECTING == cl->state))) { |
| 256 | if (signal_pending(current)) |
| 257 | return -EINTR; |
| 258 | return -ERESTARTSYS; |
| 259 | } |
| 260 | |
| 261 | mutex_lock(&dev->device_lock); |
| 262 | if (MEI_FILE_INITIALIZING == cl->state || |
| 263 | MEI_FILE_DISCONNECTED == cl->state || |
| 264 | MEI_FILE_DISCONNECTING == cl->state) { |
| 265 | rets = -EBUSY; |
| 266 | goto out; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | cb = cl->read_cb; |
| 271 | |
| 272 | if (!cb) { |
| 273 | rets = -ENODEV; |
| 274 | goto out; |
| 275 | } |
| 276 | if (cl->reading_state != MEI_READ_COMPLETE) { |
| 277 | rets = 0; |
| 278 | goto out; |
| 279 | } |
| 280 | /* now copy the data to user space */ |
| 281 | copy_buffer: |
Tomas Winkler | fcb136e | 2013-04-19 22:01:35 +0300 | [diff] [blame] | 282 | dev_dbg(&dev->pdev->dev, "buf.size = %d buf.idx= %ld\n", |
| 283 | cb->response_buffer.size, cb->buf_idx); |
Tomas Winkler | ebb108ef | 2012-10-09 16:50:16 +0200 | [diff] [blame] | 284 | if (length == 0 || ubuf == NULL || *offset > cb->buf_idx) { |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 285 | rets = -EMSGSIZE; |
| 286 | goto free; |
| 287 | } |
| 288 | |
Tomas Winkler | ebb108ef | 2012-10-09 16:50:16 +0200 | [diff] [blame] | 289 | /* length is being truncated to PAGE_SIZE, |
| 290 | * however buf_idx may point beyond that */ |
| 291 | length = min_t(size_t, length, cb->buf_idx - *offset); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 292 | |
Tomas Winkler | 441ab50 | 2011-12-13 23:39:34 +0200 | [diff] [blame] | 293 | if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length)) { |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 294 | rets = -EFAULT; |
| 295 | goto free; |
| 296 | } |
| 297 | |
| 298 | rets = length; |
| 299 | *offset += length; |
Tomas Winkler | ebb108ef | 2012-10-09 16:50:16 +0200 | [diff] [blame] | 300 | if ((unsigned long)*offset < cb->buf_idx) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 301 | goto out; |
| 302 | |
| 303 | free: |
Tomas Winkler | 90e0b5f | 2013-01-08 23:07:14 +0200 | [diff] [blame] | 304 | cb_pos = mei_cl_find_read_cb(cl); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 305 | /* Remove entry from read list */ |
| 306 | if (cb_pos) |
Tomas Winkler | fb601ad | 2012-10-15 12:06:48 +0200 | [diff] [blame] | 307 | list_del(&cb_pos->list); |
Tomas Winkler | 601a1ef | 2012-10-09 16:50:20 +0200 | [diff] [blame] | 308 | mei_io_cb_free(cb); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 309 | cl->reading_state = MEI_IDLE; |
| 310 | cl->read_cb = NULL; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 311 | out: |
| 312 | dev_dbg(&dev->pdev->dev, "end mei read rets= %d\n", rets); |
| 313 | mutex_unlock(&dev->device_lock); |
| 314 | return rets; |
| 315 | } |
Tomas Winkler | 33d28c9 | 2012-10-09 16:50:17 +0200 | [diff] [blame] | 316 | /** |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 317 | * mei_write - the write function. |
| 318 | * |
| 319 | * @file: pointer to file structure |
| 320 | * @ubuf: pointer to user buffer |
| 321 | * @length: buffer length |
| 322 | * @offset: data offset in buffer |
| 323 | * |
| 324 | * returns >=0 data length on success , <0 on error |
| 325 | */ |
| 326 | static ssize_t mei_write(struct file *file, const char __user *ubuf, |
Tomas Winkler | 441ab50 | 2011-12-13 23:39:34 +0200 | [diff] [blame] | 327 | size_t length, loff_t *offset) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 328 | { |
| 329 | struct mei_cl *cl = file->private_data; |
| 330 | struct mei_cl_cb *write_cb = NULL; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 331 | struct mei_device *dev; |
| 332 | unsigned long timeout = 0; |
| 333 | int rets; |
Tomas Winkler | 4234a6d | 2013-04-08 21:56:37 +0300 | [diff] [blame] | 334 | int id; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 335 | |
| 336 | if (WARN_ON(!cl || !cl->dev)) |
| 337 | return -ENODEV; |
| 338 | |
| 339 | dev = cl->dev; |
| 340 | |
| 341 | mutex_lock(&dev->device_lock); |
| 342 | |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 343 | if (dev->dev_state != MEI_DEV_ENABLED) { |
Tomas Winkler | 75f0ee1 | 2012-10-09 16:50:18 +0200 | [diff] [blame] | 344 | rets = -ENODEV; |
Tomas Winkler | 4234a6d | 2013-04-08 21:56:37 +0300 | [diff] [blame] | 345 | goto out; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 346 | } |
| 347 | |
Tomas Winkler | 4234a6d | 2013-04-08 21:56:37 +0300 | [diff] [blame] | 348 | id = mei_me_cl_by_id(dev, cl->me_client_id); |
| 349 | if (id < 0) { |
Tomas Winkler | 75f0ee1 | 2012-10-09 16:50:18 +0200 | [diff] [blame] | 350 | rets = -ENODEV; |
Tomas Winkler | 4234a6d | 2013-04-08 21:56:37 +0300 | [diff] [blame] | 351 | goto out; |
Tomas Winkler | 75f0ee1 | 2012-10-09 16:50:18 +0200 | [diff] [blame] | 352 | } |
Tomas Winkler | 4234a6d | 2013-04-08 21:56:37 +0300 | [diff] [blame] | 353 | if (length > dev->me_clients[id].props.max_msg_length || length <= 0) { |
Tomas Winkler | 75f0ee1 | 2012-10-09 16:50:18 +0200 | [diff] [blame] | 354 | rets = -EMSGSIZE; |
Tomas Winkler | 4234a6d | 2013-04-08 21:56:37 +0300 | [diff] [blame] | 355 | goto out; |
Tomas Winkler | 75f0ee1 | 2012-10-09 16:50:18 +0200 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | if (cl->state != MEI_FILE_CONNECTED) { |
Tomas Winkler | 75f0ee1 | 2012-10-09 16:50:18 +0200 | [diff] [blame] | 359 | dev_err(&dev->pdev->dev, "host client = %d, is not connected to ME client = %d", |
| 360 | cl->host_client_id, cl->me_client_id); |
Tomas Winkler | 4234a6d | 2013-04-08 21:56:37 +0300 | [diff] [blame] | 361 | rets = -ENODEV; |
| 362 | goto out; |
Tomas Winkler | 75f0ee1 | 2012-10-09 16:50:18 +0200 | [diff] [blame] | 363 | } |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 364 | if (cl == &dev->iamthif_cl) { |
Tomas Winkler | 19838fb | 2012-11-01 21:17:15 +0200 | [diff] [blame] | 365 | write_cb = mei_amthif_find_read_list_entry(dev, file); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 366 | |
| 367 | if (write_cb) { |
| 368 | timeout = write_cb->read_time + |
Tomas Winkler | 3870c32 | 2012-11-01 21:17:14 +0200 | [diff] [blame] | 369 | mei_secs_to_jiffies(MEI_IAMTHIF_READ_TIMER); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 370 | |
| 371 | if (time_after(jiffies, timeout) || |
Tomas Winkler | 75f0ee1 | 2012-10-09 16:50:18 +0200 | [diff] [blame] | 372 | cl->reading_state == MEI_READ_COMPLETE) { |
| 373 | *offset = 0; |
Tomas Winkler | fb601ad | 2012-10-15 12:06:48 +0200 | [diff] [blame] | 374 | list_del(&write_cb->list); |
Tomas Winkler | 601a1ef | 2012-10-09 16:50:20 +0200 | [diff] [blame] | 375 | mei_io_cb_free(write_cb); |
Tomas Winkler | 75f0ee1 | 2012-10-09 16:50:18 +0200 | [diff] [blame] | 376 | write_cb = NULL; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 377 | } |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | /* free entry used in read */ |
| 382 | if (cl->reading_state == MEI_READ_COMPLETE) { |
| 383 | *offset = 0; |
Tomas Winkler | 90e0b5f | 2013-01-08 23:07:14 +0200 | [diff] [blame] | 384 | write_cb = mei_cl_find_read_cb(cl); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 385 | if (write_cb) { |
Tomas Winkler | fb601ad | 2012-10-15 12:06:48 +0200 | [diff] [blame] | 386 | list_del(&write_cb->list); |
Tomas Winkler | 601a1ef | 2012-10-09 16:50:20 +0200 | [diff] [blame] | 387 | mei_io_cb_free(write_cb); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 388 | write_cb = NULL; |
| 389 | cl->reading_state = MEI_IDLE; |
| 390 | cl->read_cb = NULL; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 391 | } |
Tomas Winkler | d91aaed | 2013-01-08 23:07:18 +0200 | [diff] [blame] | 392 | } else if (cl->reading_state == MEI_IDLE) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 393 | *offset = 0; |
| 394 | |
| 395 | |
Tomas Winkler | 33d28c9 | 2012-10-09 16:50:17 +0200 | [diff] [blame] | 396 | write_cb = mei_io_cb_init(cl, file); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 397 | if (!write_cb) { |
Tomas Winkler | 33d28c9 | 2012-10-09 16:50:17 +0200 | [diff] [blame] | 398 | dev_err(&dev->pdev->dev, "write cb allocation failed\n"); |
| 399 | rets = -ENOMEM; |
Tomas Winkler | 4234a6d | 2013-04-08 21:56:37 +0300 | [diff] [blame] | 400 | goto out; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 401 | } |
Tomas Winkler | 33d28c9 | 2012-10-09 16:50:17 +0200 | [diff] [blame] | 402 | rets = mei_io_cb_alloc_req_buf(write_cb, length); |
| 403 | if (rets) |
Tomas Winkler | 4234a6d | 2013-04-08 21:56:37 +0300 | [diff] [blame] | 404 | goto out; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 405 | |
Tomas Winkler | 75f0ee1 | 2012-10-09 16:50:18 +0200 | [diff] [blame] | 406 | rets = copy_from_user(write_cb->request_buffer.data, ubuf, length); |
Alexander Usyskin | d8b29ef | 2013-09-02 03:11:02 +0300 | [diff] [blame^] | 407 | if (rets) { |
| 408 | dev_err(&dev->pdev->dev, "failed to copy data from userland\n"); |
| 409 | rets = -EFAULT; |
Tomas Winkler | 4234a6d | 2013-04-08 21:56:37 +0300 | [diff] [blame] | 410 | goto out; |
Alexander Usyskin | d8b29ef | 2013-09-02 03:11:02 +0300 | [diff] [blame^] | 411 | } |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 412 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 413 | if (cl == &dev->iamthif_cl) { |
Tomas Winkler | ab5c4a5 | 2012-11-01 21:17:18 +0200 | [diff] [blame] | 414 | rets = mei_amthif_write(dev, write_cb); |
| 415 | |
| 416 | if (rets) { |
| 417 | dev_err(&dev->pdev->dev, |
Tomas Winkler | 1a1aca4 | 2013-01-08 23:07:21 +0200 | [diff] [blame] | 418 | "amthif write failed with status = %d\n", rets); |
Tomas Winkler | 4234a6d | 2013-04-08 21:56:37 +0300 | [diff] [blame] | 419 | goto out; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 420 | } |
| 421 | mutex_unlock(&dev->device_lock); |
Tomas Winkler | 75f0ee1 | 2012-10-09 16:50:18 +0200 | [diff] [blame] | 422 | return length; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 423 | } |
| 424 | |
Tomas Winkler | 4234a6d | 2013-04-08 21:56:37 +0300 | [diff] [blame] | 425 | rets = mei_cl_write(cl, write_cb, false); |
Tomas Winkler | b0d0cf7 | 2012-11-01 21:17:13 +0200 | [diff] [blame] | 426 | out: |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 427 | mutex_unlock(&dev->device_lock); |
Tomas Winkler | 4234a6d | 2013-04-08 21:56:37 +0300 | [diff] [blame] | 428 | if (rets < 0) |
| 429 | mei_io_cb_free(write_cb); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 430 | return rets; |
| 431 | } |
| 432 | |
Tomas Winkler | 9f81abda | 2013-01-08 23:07:15 +0200 | [diff] [blame] | 433 | /** |
| 434 | * mei_ioctl_connect_client - the connect to fw client IOCTL function |
| 435 | * |
| 436 | * @dev: the device structure |
| 437 | * @data: IOCTL connect data, input and output parameters |
| 438 | * @file: private data of the file object |
| 439 | * |
| 440 | * Locking: called under "dev->device_lock" lock |
| 441 | * |
| 442 | * returns 0 on success, <0 on failure. |
| 443 | */ |
| 444 | static int mei_ioctl_connect_client(struct file *file, |
| 445 | struct mei_connect_client_data *data) |
| 446 | { |
| 447 | struct mei_device *dev; |
| 448 | struct mei_client *client; |
| 449 | struct mei_cl *cl; |
| 450 | int i; |
| 451 | int rets; |
| 452 | |
| 453 | cl = file->private_data; |
| 454 | if (WARN_ON(!cl || !cl->dev)) |
| 455 | return -ENODEV; |
| 456 | |
| 457 | dev = cl->dev; |
| 458 | |
| 459 | if (dev->dev_state != MEI_DEV_ENABLED) { |
| 460 | rets = -ENODEV; |
| 461 | goto end; |
| 462 | } |
| 463 | |
| 464 | if (cl->state != MEI_FILE_INITIALIZING && |
| 465 | cl->state != MEI_FILE_DISCONNECTED) { |
| 466 | rets = -EBUSY; |
| 467 | goto end; |
| 468 | } |
| 469 | |
| 470 | /* find ME client we're trying to connect to */ |
| 471 | i = mei_me_cl_by_uuid(dev, &data->in_client_uuid); |
Tomas Winkler | 80fe636 | 2013-05-07 21:12:31 +0300 | [diff] [blame] | 472 | if (i < 0 || dev->me_clients[i].props.fixed_address) { |
| 473 | dev_dbg(&dev->pdev->dev, "Cannot connect to FW Client UUID = %pUl\n", |
| 474 | &data->in_client_uuid); |
| 475 | rets = -ENODEV; |
| 476 | goto end; |
Tomas Winkler | 9f81abda | 2013-01-08 23:07:15 +0200 | [diff] [blame] | 477 | } |
| 478 | |
Tomas Winkler | 80fe636 | 2013-05-07 21:12:31 +0300 | [diff] [blame] | 479 | cl->me_client_id = dev->me_clients[i].client_id; |
| 480 | cl->state = MEI_FILE_CONNECTING; |
| 481 | |
Tomas Winkler | 9f81abda | 2013-01-08 23:07:15 +0200 | [diff] [blame] | 482 | dev_dbg(&dev->pdev->dev, "Connect to FW Client ID = %d\n", |
| 483 | cl->me_client_id); |
| 484 | dev_dbg(&dev->pdev->dev, "FW Client - Protocol Version = %d\n", |
| 485 | dev->me_clients[i].props.protocol_version); |
| 486 | dev_dbg(&dev->pdev->dev, "FW Client - Max Msg Len = %d\n", |
| 487 | dev->me_clients[i].props.max_msg_length); |
| 488 | |
Tomas Winkler | 1a1aca4 | 2013-01-08 23:07:21 +0200 | [diff] [blame] | 489 | /* if we're connecting to amthif client then we will use the |
Tomas Winkler | 9f81abda | 2013-01-08 23:07:15 +0200 | [diff] [blame] | 490 | * existing connection |
| 491 | */ |
Tomas Winkler | 1a1aca4 | 2013-01-08 23:07:21 +0200 | [diff] [blame] | 492 | if (uuid_le_cmp(data->in_client_uuid, mei_amthif_guid) == 0) { |
Tomas Winkler | 9f81abda | 2013-01-08 23:07:15 +0200 | [diff] [blame] | 493 | dev_dbg(&dev->pdev->dev, "FW Client is amthi\n"); |
| 494 | if (dev->iamthif_cl.state != MEI_FILE_CONNECTED) { |
| 495 | rets = -ENODEV; |
| 496 | goto end; |
| 497 | } |
| 498 | clear_bit(cl->host_client_id, dev->host_clients_map); |
| 499 | mei_cl_unlink(cl); |
| 500 | |
| 501 | kfree(cl); |
| 502 | cl = NULL; |
| 503 | file->private_data = &dev->iamthif_cl; |
| 504 | |
| 505 | client = &data->out_client_properties; |
| 506 | client->max_msg_length = |
| 507 | dev->me_clients[i].props.max_msg_length; |
| 508 | client->protocol_version = |
| 509 | dev->me_clients[i].props.protocol_version; |
| 510 | rets = dev->iamthif_cl.status; |
| 511 | |
| 512 | goto end; |
| 513 | } |
| 514 | |
Tomas Winkler | 9f81abda | 2013-01-08 23:07:15 +0200 | [diff] [blame] | 515 | |
| 516 | /* prepare the output buffer */ |
| 517 | client = &data->out_client_properties; |
| 518 | client->max_msg_length = dev->me_clients[i].props.max_msg_length; |
| 519 | client->protocol_version = dev->me_clients[i].props.protocol_version; |
| 520 | dev_dbg(&dev->pdev->dev, "Can connect?\n"); |
| 521 | |
| 522 | |
| 523 | rets = mei_cl_connect(cl, file); |
| 524 | |
| 525 | end: |
Tomas Winkler | 9f81abda | 2013-01-08 23:07:15 +0200 | [diff] [blame] | 526 | return rets; |
| 527 | } |
| 528 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 529 | |
| 530 | /** |
| 531 | * mei_ioctl - the IOCTL function |
| 532 | * |
| 533 | * @file: pointer to file structure |
| 534 | * @cmd: ioctl command |
| 535 | * @data: pointer to mei message structure |
| 536 | * |
| 537 | * returns 0 on success , <0 on error |
| 538 | */ |
| 539 | static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data) |
| 540 | { |
| 541 | struct mei_device *dev; |
| 542 | struct mei_cl *cl = file->private_data; |
| 543 | struct mei_connect_client_data *connect_data = NULL; |
| 544 | int rets; |
| 545 | |
| 546 | if (cmd != IOCTL_MEI_CONNECT_CLIENT) |
| 547 | return -EINVAL; |
| 548 | |
| 549 | if (WARN_ON(!cl || !cl->dev)) |
| 550 | return -ENODEV; |
| 551 | |
| 552 | dev = cl->dev; |
| 553 | |
| 554 | dev_dbg(&dev->pdev->dev, "IOCTL cmd = 0x%x", cmd); |
| 555 | |
| 556 | mutex_lock(&dev->device_lock); |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 557 | if (dev->dev_state != MEI_DEV_ENABLED) { |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 558 | rets = -ENODEV; |
| 559 | goto out; |
| 560 | } |
| 561 | |
| 562 | dev_dbg(&dev->pdev->dev, ": IOCTL_MEI_CONNECT_CLIENT.\n"); |
| 563 | |
| 564 | connect_data = kzalloc(sizeof(struct mei_connect_client_data), |
| 565 | GFP_KERNEL); |
| 566 | if (!connect_data) { |
| 567 | rets = -ENOMEM; |
| 568 | goto out; |
| 569 | } |
| 570 | dev_dbg(&dev->pdev->dev, "copy connect data from user\n"); |
| 571 | if (copy_from_user(connect_data, (char __user *)data, |
| 572 | sizeof(struct mei_connect_client_data))) { |
Alexander Usyskin | d8b29ef | 2013-09-02 03:11:02 +0300 | [diff] [blame^] | 573 | dev_err(&dev->pdev->dev, "failed to copy data from userland\n"); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 574 | rets = -EFAULT; |
| 575 | goto out; |
| 576 | } |
Tomas Winkler | 9f81abda | 2013-01-08 23:07:15 +0200 | [diff] [blame] | 577 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 578 | rets = mei_ioctl_connect_client(file, connect_data); |
| 579 | |
| 580 | /* if all is ok, copying the data back to user. */ |
| 581 | if (rets) |
| 582 | goto out; |
| 583 | |
| 584 | dev_dbg(&dev->pdev->dev, "copy connect data to user\n"); |
| 585 | if (copy_to_user((char __user *)data, connect_data, |
| 586 | sizeof(struct mei_connect_client_data))) { |
| 587 | dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n"); |
| 588 | rets = -EFAULT; |
| 589 | goto out; |
| 590 | } |
| 591 | |
| 592 | out: |
| 593 | kfree(connect_data); |
| 594 | mutex_unlock(&dev->device_lock); |
| 595 | return rets; |
| 596 | } |
| 597 | |
| 598 | /** |
| 599 | * mei_compat_ioctl - the compat IOCTL function |
| 600 | * |
| 601 | * @file: pointer to file structure |
| 602 | * @cmd: ioctl command |
| 603 | * @data: pointer to mei message structure |
| 604 | * |
| 605 | * returns 0 on success , <0 on error |
| 606 | */ |
| 607 | #ifdef CONFIG_COMPAT |
| 608 | static long mei_compat_ioctl(struct file *file, |
Tomas Winkler | 441ab50 | 2011-12-13 23:39:34 +0200 | [diff] [blame] | 609 | unsigned int cmd, unsigned long data) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 610 | { |
| 611 | return mei_ioctl(file, cmd, (unsigned long)compat_ptr(data)); |
| 612 | } |
| 613 | #endif |
| 614 | |
| 615 | |
| 616 | /** |
| 617 | * mei_poll - the poll function |
| 618 | * |
| 619 | * @file: pointer to file structure |
| 620 | * @wait: pointer to poll_table structure |
| 621 | * |
| 622 | * returns poll mask |
| 623 | */ |
| 624 | static unsigned int mei_poll(struct file *file, poll_table *wait) |
| 625 | { |
| 626 | struct mei_cl *cl = file->private_data; |
| 627 | struct mei_device *dev; |
| 628 | unsigned int mask = 0; |
| 629 | |
| 630 | if (WARN_ON(!cl || !cl->dev)) |
Tomas Winkler | b950ac1 | 2013-07-25 20:15:53 +0300 | [diff] [blame] | 631 | return POLLERR; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 632 | |
| 633 | dev = cl->dev; |
| 634 | |
| 635 | mutex_lock(&dev->device_lock); |
| 636 | |
Tomas Winkler | b950ac1 | 2013-07-25 20:15:53 +0300 | [diff] [blame] | 637 | if (!mei_cl_is_connected(cl)) { |
| 638 | mask = POLLERR; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 639 | goto out; |
| 640 | } |
| 641 | |
| 642 | mutex_unlock(&dev->device_lock); |
Tomas Winkler | b950ac1 | 2013-07-25 20:15:53 +0300 | [diff] [blame] | 643 | |
| 644 | |
| 645 | if (cl == &dev->iamthif_cl) |
| 646 | return mei_amthif_poll(dev, file, wait); |
| 647 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 648 | poll_wait(file, &cl->tx_wait, wait); |
Tomas Winkler | b950ac1 | 2013-07-25 20:15:53 +0300 | [diff] [blame] | 649 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 650 | mutex_lock(&dev->device_lock); |
Tomas Winkler | b950ac1 | 2013-07-25 20:15:53 +0300 | [diff] [blame] | 651 | |
| 652 | if (!mei_cl_is_connected(cl)) { |
| 653 | mask = POLLERR; |
| 654 | goto out; |
| 655 | } |
| 656 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 657 | if (MEI_WRITE_COMPLETE == cl->writing_state) |
| 658 | mask |= (POLLIN | POLLRDNORM); |
| 659 | |
| 660 | out: |
| 661 | mutex_unlock(&dev->device_lock); |
| 662 | return mask; |
| 663 | } |
| 664 | |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 665 | /* |
| 666 | * file operations structure will be used for mei char device. |
| 667 | */ |
| 668 | static const struct file_operations mei_fops = { |
| 669 | .owner = THIS_MODULE, |
| 670 | .read = mei_read, |
| 671 | .unlocked_ioctl = mei_ioctl, |
| 672 | #ifdef CONFIG_COMPAT |
| 673 | .compat_ioctl = mei_compat_ioctl, |
| 674 | #endif |
| 675 | .open = mei_open, |
| 676 | .release = mei_release, |
| 677 | .write = mei_write, |
| 678 | .poll = mei_poll, |
| 679 | .llseek = no_llseek |
| 680 | }; |
| 681 | |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 682 | /* |
| 683 | * Misc Device Struct |
| 684 | */ |
| 685 | static struct miscdevice mei_misc_device = { |
Tomas Winkler | c38ea24 | 2012-04-02 20:32:39 +0300 | [diff] [blame] | 686 | .name = "mei", |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 687 | .fops = &mei_fops, |
| 688 | .minor = MISC_DYNAMIC_MINOR, |
| 689 | }; |
| 690 | |
Tomas Winkler | 30e53bb | 2013-04-05 22:10:34 +0300 | [diff] [blame] | 691 | |
| 692 | int mei_register(struct mei_device *dev) |
Tomas Winkler | 9a123f1 | 2012-08-06 15:23:55 +0300 | [diff] [blame] | 693 | { |
Tomas Winkler | 30e53bb | 2013-04-05 22:10:34 +0300 | [diff] [blame] | 694 | int ret; |
| 695 | mei_misc_device.parent = &dev->pdev->dev; |
| 696 | ret = misc_register(&mei_misc_device); |
| 697 | if (ret) |
| 698 | return ret; |
| 699 | |
| 700 | if (mei_dbgfs_register(dev, mei_misc_device.name)) |
| 701 | dev_err(&dev->pdev->dev, "cannot register debugfs\n"); |
| 702 | |
| 703 | return 0; |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 704 | } |
Tomas Winkler | 40e0b67 | 2013-03-27 16:58:30 +0200 | [diff] [blame] | 705 | EXPORT_SYMBOL_GPL(mei_register); |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 706 | |
Tomas Winkler | 30e53bb | 2013-04-05 22:10:34 +0300 | [diff] [blame] | 707 | void mei_deregister(struct mei_device *dev) |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 708 | { |
Tomas Winkler | 30e53bb | 2013-04-05 22:10:34 +0300 | [diff] [blame] | 709 | mei_dbgfs_deregister(dev); |
Tomas Winkler | a44cab4 | 2012-05-29 16:39:11 +0300 | [diff] [blame] | 710 | misc_deregister(&mei_misc_device); |
Tomas Winkler | 2703d4b | 2013-02-06 14:06:39 +0200 | [diff] [blame] | 711 | mei_misc_device.parent = NULL; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 712 | } |
Tomas Winkler | 40e0b67 | 2013-03-27 16:58:30 +0200 | [diff] [blame] | 713 | EXPORT_SYMBOL_GPL(mei_deregister); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 714 | |
Samuel Ortiz | cf3baef | 2013-03-27 17:29:57 +0200 | [diff] [blame] | 715 | static int __init mei_init(void) |
| 716 | { |
| 717 | return mei_cl_bus_init(); |
| 718 | } |
| 719 | |
| 720 | static void __exit mei_exit(void) |
| 721 | { |
| 722 | mei_cl_bus_exit(); |
| 723 | } |
| 724 | |
| 725 | module_init(mei_init); |
| 726 | module_exit(mei_exit); |
| 727 | |
Tomas Winkler | 40e0b67 | 2013-03-27 16:58:30 +0200 | [diff] [blame] | 728 | MODULE_AUTHOR("Intel Corporation"); |
| 729 | MODULE_DESCRIPTION("Intel(R) Management Engine Interface"); |
Tomas Winkler | 827eef5 | 2013-02-06 14:06:41 +0200 | [diff] [blame] | 730 | MODULE_LICENSE("GPL v2"); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 731 | |