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