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 | |
| 40 | #include "mei_dev.h" |
Tomas Winkler | 4f3afe1 | 2012-05-09 16:38:59 +0300 | [diff] [blame] | 41 | #include <linux/mei.h> |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 42 | #include "interface.h" |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 43 | |
Tomas Winkler | daed6b5 | 2012-08-17 09:54:23 +0300 | [diff] [blame] | 44 | /* AMT device is a singleton on the platform */ |
| 45 | static struct pci_dev *mei_pdev; |
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_pci_tbl - PCI Device ID Table */ |
| 48 | static DEFINE_PCI_DEVICE_TABLE(mei_pci_tbl) = { |
| 49 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82946GZ)}, |
| 50 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82G35)}, |
| 51 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82Q965)}, |
| 52 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82G965)}, |
| 53 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82GM965)}, |
| 54 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82GME965)}, |
| 55 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_82Q35)}, |
| 56 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_82G33)}, |
| 57 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_82Q33)}, |
| 58 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_82X38)}, |
| 59 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_3200)}, |
| 60 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_6)}, |
| 61 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_7)}, |
| 62 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_8)}, |
| 63 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_9)}, |
| 64 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_10)}, |
| 65 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9M_1)}, |
| 66 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9M_2)}, |
| 67 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9M_3)}, |
| 68 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9M_4)}, |
| 69 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH10_1)}, |
| 70 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH10_2)}, |
| 71 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH10_3)}, |
| 72 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH10_4)}, |
| 73 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_IBXPK_1)}, |
| 74 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_IBXPK_2)}, |
| 75 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_CPT_1)}, |
| 76 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PBG_1)}, |
| 77 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_1)}, |
| 78 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_2)}, |
| 79 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_3)}, |
Tomas Winkler | 9af5142 | 2012-08-29 01:15:50 +0300 | [diff] [blame] | 80 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT)}, |
| 81 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT_LP)}, |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 82 | |
| 83 | /* required last entry */ |
| 84 | {0, } |
| 85 | }; |
| 86 | |
| 87 | MODULE_DEVICE_TABLE(pci, mei_pci_tbl); |
| 88 | |
| 89 | static DEFINE_MUTEX(mei_mutex); |
| 90 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 91 | |
| 92 | /** |
| 93 | * mei_clear_list - removes all callbacks associated with file |
| 94 | * from mei_cb_list |
| 95 | * |
| 96 | * @dev: device structure. |
| 97 | * @file: file structure |
| 98 | * @mei_cb_list: callbacks list |
| 99 | * |
| 100 | * mei_clear_list is called to clear resources associated with file |
| 101 | * when application calls close function or Ctrl-C was pressed |
| 102 | * |
| 103 | * returns true if callback removed from the list, false otherwise |
| 104 | */ |
| 105 | static bool mei_clear_list(struct mei_device *dev, |
| 106 | struct file *file, struct list_head *mei_cb_list) |
| 107 | { |
| 108 | struct mei_cl_cb *cb_pos = NULL; |
| 109 | struct mei_cl_cb *cb_next = NULL; |
| 110 | struct file *file_temp; |
| 111 | bool removed = false; |
| 112 | |
| 113 | /* list all list member */ |
| 114 | list_for_each_entry_safe(cb_pos, cb_next, mei_cb_list, cb_list) { |
| 115 | file_temp = (struct file *)cb_pos->file_object; |
| 116 | /* check if list member associated with a file */ |
| 117 | if (file_temp == file) { |
| 118 | /* remove member from the list */ |
| 119 | list_del(&cb_pos->cb_list); |
| 120 | /* check if cb equal to current iamthif cb */ |
| 121 | if (dev->iamthif_current_cb == cb_pos) { |
| 122 | dev->iamthif_current_cb = NULL; |
| 123 | /* send flow control to iamthif client */ |
| 124 | mei_send_flow_control(dev, &dev->iamthif_cl); |
| 125 | } |
| 126 | /* free all allocated buffers */ |
| 127 | mei_free_cb_private(cb_pos); |
| 128 | cb_pos = NULL; |
| 129 | removed = true; |
| 130 | } |
| 131 | } |
| 132 | return removed; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * mei_clear_lists - removes all callbacks associated with file |
| 137 | * |
| 138 | * @dev: device structure |
| 139 | * @file: file structure |
| 140 | * |
| 141 | * mei_clear_lists is called to clear resources associated with file |
| 142 | * when application calls close function or Ctrl-C was pressed |
| 143 | * |
| 144 | * returns true if callback removed from the list, false otherwise |
| 145 | */ |
| 146 | static bool mei_clear_lists(struct mei_device *dev, struct file *file) |
| 147 | { |
| 148 | bool removed = false; |
| 149 | |
| 150 | /* remove callbacks associated with a file */ |
| 151 | mei_clear_list(dev, file, &dev->amthi_cmd_list.mei_cb.cb_list); |
| 152 | if (mei_clear_list(dev, file, |
| 153 | &dev->amthi_read_complete_list.mei_cb.cb_list)) |
| 154 | removed = true; |
| 155 | |
| 156 | mei_clear_list(dev, file, &dev->ctrl_rd_list.mei_cb.cb_list); |
| 157 | |
| 158 | if (mei_clear_list(dev, file, &dev->ctrl_wr_list.mei_cb.cb_list)) |
| 159 | removed = true; |
| 160 | |
| 161 | if (mei_clear_list(dev, file, &dev->write_waiting_list.mei_cb.cb_list)) |
| 162 | removed = true; |
| 163 | |
| 164 | if (mei_clear_list(dev, file, &dev->write_list.mei_cb.cb_list)) |
| 165 | removed = true; |
| 166 | |
| 167 | /* check if iamthif_current_cb not NULL */ |
| 168 | if (dev->iamthif_current_cb && !removed) { |
| 169 | /* check file and iamthif current cb association */ |
| 170 | if (dev->iamthif_current_cb->file_object == file) { |
| 171 | /* remove cb */ |
| 172 | mei_free_cb_private(dev->iamthif_current_cb); |
| 173 | dev->iamthif_current_cb = NULL; |
| 174 | removed = true; |
| 175 | } |
| 176 | } |
| 177 | return removed; |
| 178 | } |
| 179 | /** |
| 180 | * find_read_list_entry - find read list entry |
| 181 | * |
| 182 | * @dev: device structure |
| 183 | * @file: pointer to file structure |
| 184 | * |
| 185 | * returns cb on success, NULL on error |
| 186 | */ |
| 187 | static struct mei_cl_cb *find_read_list_entry( |
| 188 | struct mei_device *dev, |
| 189 | struct mei_cl *cl) |
| 190 | { |
Tomas Winkler | b7cd2d9 | 2011-11-27 21:43:34 +0200 | [diff] [blame] | 191 | struct mei_cl_cb *pos = NULL; |
| 192 | struct mei_cl_cb *next = NULL; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 193 | |
Tomas Winkler | b7cd2d9 | 2011-11-27 21:43:34 +0200 | [diff] [blame] | 194 | dev_dbg(&dev->pdev->dev, "remove read_list CB\n"); |
| 195 | list_for_each_entry_safe(pos, next, |
| 196 | &dev->read_list.mei_cb.cb_list, cb_list) { |
| 197 | struct mei_cl *cl_temp; |
| 198 | cl_temp = (struct mei_cl *)pos->file_private; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 199 | |
Tomas Winkler | b7cd2d9 | 2011-11-27 21:43:34 +0200 | [diff] [blame] | 200 | if (mei_cl_cmp_id(cl, cl_temp)) |
| 201 | return pos; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 202 | } |
| 203 | return NULL; |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * mei_open - the open function |
| 208 | * |
| 209 | * @inode: pointer to inode structure |
| 210 | * @file: pointer to file structure |
| 211 | * |
| 212 | * returns 0 on success, <0 on error |
| 213 | */ |
| 214 | static int mei_open(struct inode *inode, struct file *file) |
| 215 | { |
| 216 | struct mei_cl *cl; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 217 | struct mei_device *dev; |
Tomas Winkler | 6f37aca | 2011-11-13 09:41:15 +0200 | [diff] [blame] | 218 | unsigned long cl_id; |
| 219 | int err; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 220 | |
| 221 | err = -ENODEV; |
Tomas Winkler | daed6b5 | 2012-08-17 09:54:23 +0300 | [diff] [blame] | 222 | if (!mei_pdev) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 223 | goto out; |
| 224 | |
Tomas Winkler | daed6b5 | 2012-08-17 09:54:23 +0300 | [diff] [blame] | 225 | dev = pci_get_drvdata(mei_pdev); |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 226 | if (!dev) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 227 | goto out; |
| 228 | |
| 229 | mutex_lock(&dev->device_lock); |
| 230 | err = -ENOMEM; |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 231 | cl = mei_cl_allocate(dev); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 232 | if (!cl) |
Alexey Khoroshilov | 303dfbf | 2011-08-31 00:41:14 +0400 | [diff] [blame] | 233 | goto out_unlock; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 234 | |
| 235 | err = -ENODEV; |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 236 | if (dev->dev_state != MEI_DEV_ENABLED) { |
| 237 | dev_dbg(&dev->pdev->dev, "dev_state != MEI_ENABLED dev_state = %s\n", |
| 238 | mei_dev_state_str(dev->dev_state)); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 239 | goto out_unlock; |
| 240 | } |
| 241 | err = -EMFILE; |
Tomas Winkler | 1b81294 | 2012-09-11 00:43:20 +0300 | [diff] [blame] | 242 | if (dev->open_handle_count >= MEI_MAX_OPEN_HANDLE_COUNT) { |
| 243 | dev_err(&dev->pdev->dev, "open_handle_count exceded %d", |
| 244 | MEI_MAX_OPEN_HANDLE_COUNT); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 245 | goto out_unlock; |
Tomas Winkler | 1b81294 | 2012-09-11 00:43:20 +0300 | [diff] [blame] | 246 | } |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 247 | |
Tomas Winkler | 6f37aca | 2011-11-13 09:41:15 +0200 | [diff] [blame] | 248 | cl_id = find_first_zero_bit(dev->host_clients_map, MEI_CLIENTS_MAX); |
Tomas Winkler | 1b81294 | 2012-09-11 00:43:20 +0300 | [diff] [blame] | 249 | if (cl_id >= MEI_CLIENTS_MAX) { |
| 250 | dev_err(&dev->pdev->dev, "client_id exceded %d", |
| 251 | MEI_CLIENTS_MAX) ; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 252 | goto out_unlock; |
Tomas Winkler | 1b81294 | 2012-09-11 00:43:20 +0300 | [diff] [blame] | 253 | } |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 254 | |
Tomas Winkler | 6f37aca | 2011-11-13 09:41:15 +0200 | [diff] [blame] | 255 | cl->host_client_id = cl_id; |
| 256 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 257 | dev_dbg(&dev->pdev->dev, "client_id = %d\n", cl->host_client_id); |
| 258 | |
| 259 | dev->open_handle_count++; |
Tomas Winkler | 6f37aca | 2011-11-13 09:41:15 +0200 | [diff] [blame] | 260 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 261 | list_add_tail(&cl->link, &dev->file_list); |
| 262 | |
| 263 | set_bit(cl->host_client_id, dev->host_clients_map); |
| 264 | cl->state = MEI_FILE_INITIALIZING; |
| 265 | cl->sm_state = 0; |
| 266 | |
| 267 | file->private_data = cl; |
| 268 | mutex_unlock(&dev->device_lock); |
| 269 | |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 270 | return nonseekable_open(inode, file); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 271 | |
| 272 | out_unlock: |
| 273 | mutex_unlock(&dev->device_lock); |
| 274 | kfree(cl); |
| 275 | out: |
| 276 | return err; |
| 277 | } |
| 278 | |
| 279 | /** |
| 280 | * mei_release - the release function |
| 281 | * |
| 282 | * @inode: pointer to inode structure |
| 283 | * @file: pointer to file structure |
| 284 | * |
| 285 | * returns 0 on success, <0 on error |
| 286 | */ |
| 287 | static int mei_release(struct inode *inode, struct file *file) |
| 288 | { |
| 289 | struct mei_cl *cl = file->private_data; |
| 290 | struct mei_cl_cb *cb; |
| 291 | struct mei_device *dev; |
| 292 | int rets = 0; |
| 293 | |
| 294 | if (WARN_ON(!cl || !cl->dev)) |
| 295 | return -ENODEV; |
| 296 | |
| 297 | dev = cl->dev; |
| 298 | |
| 299 | mutex_lock(&dev->device_lock); |
| 300 | if (cl != &dev->iamthif_cl) { |
| 301 | if (cl->state == MEI_FILE_CONNECTED) { |
| 302 | cl->state = MEI_FILE_DISCONNECTING; |
| 303 | dev_dbg(&dev->pdev->dev, |
| 304 | "disconnecting client host client = %d, " |
| 305 | "ME client = %d\n", |
| 306 | cl->host_client_id, |
| 307 | cl->me_client_id); |
| 308 | rets = mei_disconnect_host_client(dev, cl); |
| 309 | } |
Tomas Winkler | 0288c7c | 2011-06-06 10:44:34 +0300 | [diff] [blame] | 310 | mei_cl_flush_queues(cl); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 311 | dev_dbg(&dev->pdev->dev, "remove client host client = %d, ME client = %d\n", |
| 312 | cl->host_client_id, |
| 313 | cl->me_client_id); |
| 314 | |
| 315 | if (dev->open_handle_count > 0) { |
Tomas Winkler | 441ab50 | 2011-12-13 23:39:34 +0200 | [diff] [blame] | 316 | clear_bit(cl->host_client_id, dev->host_clients_map); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 317 | dev->open_handle_count--; |
| 318 | } |
| 319 | mei_remove_client_from_file_list(dev, cl->host_client_id); |
| 320 | |
| 321 | /* free read cb */ |
| 322 | cb = NULL; |
| 323 | if (cl->read_cb) { |
| 324 | cb = find_read_list_entry(dev, cl); |
| 325 | /* Remove entry from read list */ |
| 326 | if (cb) |
| 327 | list_del(&cb->cb_list); |
| 328 | |
| 329 | cb = cl->read_cb; |
| 330 | cl->read_cb = NULL; |
| 331 | } |
| 332 | |
| 333 | file->private_data = NULL; |
| 334 | |
| 335 | if (cb) { |
| 336 | mei_free_cb_private(cb); |
| 337 | cb = NULL; |
| 338 | } |
| 339 | |
| 340 | kfree(cl); |
| 341 | } else { |
| 342 | if (dev->open_handle_count > 0) |
| 343 | dev->open_handle_count--; |
| 344 | |
| 345 | if (dev->iamthif_file_object == file && |
| 346 | dev->iamthif_state != MEI_IAMTHIF_IDLE) { |
| 347 | |
| 348 | dev_dbg(&dev->pdev->dev, "amthi canceled iamthif state %d\n", |
| 349 | dev->iamthif_state); |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 350 | dev->iamthif_canceled = true; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 351 | if (dev->iamthif_state == MEI_IAMTHIF_READ_COMPLETE) { |
| 352 | dev_dbg(&dev->pdev->dev, "run next amthi iamthif cb\n"); |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 353 | mei_run_next_iamthif_cmd(dev); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 354 | } |
| 355 | } |
| 356 | |
| 357 | if (mei_clear_lists(dev, file)) |
| 358 | dev->iamthif_state = MEI_IAMTHIF_IDLE; |
| 359 | |
| 360 | } |
| 361 | mutex_unlock(&dev->device_lock); |
| 362 | return rets; |
| 363 | } |
| 364 | |
| 365 | |
| 366 | /** |
| 367 | * mei_read - the read function. |
| 368 | * |
| 369 | * @file: pointer to file structure |
| 370 | * @ubuf: pointer to user buffer |
| 371 | * @length: buffer length |
| 372 | * @offset: data offset in buffer |
| 373 | * |
| 374 | * returns >=0 data length on success , <0 on error |
| 375 | */ |
| 376 | static ssize_t mei_read(struct file *file, char __user *ubuf, |
Tomas Winkler | 441ab50 | 2011-12-13 23:39:34 +0200 | [diff] [blame] | 377 | size_t length, loff_t *offset) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 378 | { |
| 379 | struct mei_cl *cl = file->private_data; |
| 380 | struct mei_cl_cb *cb_pos = NULL; |
| 381 | struct mei_cl_cb *cb = NULL; |
| 382 | struct mei_device *dev; |
| 383 | int i; |
| 384 | int rets; |
| 385 | int err; |
| 386 | |
| 387 | |
| 388 | if (WARN_ON(!cl || !cl->dev)) |
| 389 | return -ENODEV; |
| 390 | |
| 391 | dev = cl->dev; |
| 392 | |
| 393 | mutex_lock(&dev->device_lock); |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 394 | if (dev->dev_state != MEI_DEV_ENABLED) { |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 395 | rets = -ENODEV; |
| 396 | goto out; |
| 397 | } |
| 398 | |
| 399 | if ((cl->sm_state & MEI_WD_STATE_INDEPENDENCE_MSG_SENT) == 0) { |
| 400 | /* Do not allow to read watchdog client */ |
Tomas Winkler | 07b509b | 2012-07-23 14:05:39 +0300 | [diff] [blame] | 401 | i = mei_me_cl_by_uuid(dev, &mei_wd_guid); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 402 | if (i >= 0) { |
| 403 | struct mei_me_client *me_client = &dev->me_clients[i]; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 404 | if (cl->me_client_id == me_client->client_id) { |
| 405 | rets = -EBADF; |
| 406 | goto out; |
| 407 | } |
| 408 | } |
| 409 | } else { |
| 410 | cl->sm_state &= ~MEI_WD_STATE_INDEPENDENCE_MSG_SENT; |
| 411 | } |
| 412 | |
| 413 | if (cl == &dev->iamthif_cl) { |
| 414 | rets = amthi_read(dev, file, ubuf, length, offset); |
| 415 | goto out; |
| 416 | } |
| 417 | |
Tomas Winkler | ebb108ef | 2012-10-09 16:50:16 +0200 | [diff] [blame^] | 418 | if (cl->read_cb && cl->read_cb->buf_idx > *offset) { |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 419 | cb = cl->read_cb; |
| 420 | goto copy_buffer; |
Tomas Winkler | ebb108ef | 2012-10-09 16:50:16 +0200 | [diff] [blame^] | 421 | } else if (cl->read_cb && cl->read_cb->buf_idx > 0 && |
| 422 | cl->read_cb->buf_idx <= *offset) { |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 423 | cb = cl->read_cb; |
| 424 | rets = 0; |
| 425 | goto free; |
Tomas Winkler | ebb108ef | 2012-10-09 16:50:16 +0200 | [diff] [blame^] | 426 | } else if ((!cl->read_cb || !cl->read_cb->buf_idx) && *offset > 0) { |
Justin P. Mattock | 5f9092f3 | 2012-03-12 07:18:09 -0700 | [diff] [blame] | 427 | /*Offset needs to be cleaned for contiguous reads*/ |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 428 | *offset = 0; |
| 429 | rets = 0; |
| 430 | goto out; |
| 431 | } |
| 432 | |
| 433 | err = mei_start_read(dev, cl); |
| 434 | if (err && err != -EBUSY) { |
| 435 | dev_dbg(&dev->pdev->dev, |
| 436 | "mei start read failure with status = %d\n", err); |
| 437 | rets = err; |
| 438 | goto out; |
| 439 | } |
| 440 | |
| 441 | if (MEI_READ_COMPLETE != cl->reading_state && |
| 442 | !waitqueue_active(&cl->rx_wait)) { |
| 443 | if (file->f_flags & O_NONBLOCK) { |
| 444 | rets = -EAGAIN; |
| 445 | goto out; |
| 446 | } |
| 447 | |
| 448 | mutex_unlock(&dev->device_lock); |
| 449 | |
| 450 | if (wait_event_interruptible(cl->rx_wait, |
| 451 | (MEI_READ_COMPLETE == cl->reading_state || |
| 452 | MEI_FILE_INITIALIZING == cl->state || |
| 453 | MEI_FILE_DISCONNECTED == cl->state || |
| 454 | MEI_FILE_DISCONNECTING == cl->state))) { |
| 455 | if (signal_pending(current)) |
| 456 | return -EINTR; |
| 457 | return -ERESTARTSYS; |
| 458 | } |
| 459 | |
| 460 | mutex_lock(&dev->device_lock); |
| 461 | if (MEI_FILE_INITIALIZING == cl->state || |
| 462 | MEI_FILE_DISCONNECTED == cl->state || |
| 463 | MEI_FILE_DISCONNECTING == cl->state) { |
| 464 | rets = -EBUSY; |
| 465 | goto out; |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | cb = cl->read_cb; |
| 470 | |
| 471 | if (!cb) { |
| 472 | rets = -ENODEV; |
| 473 | goto out; |
| 474 | } |
| 475 | if (cl->reading_state != MEI_READ_COMPLETE) { |
| 476 | rets = 0; |
| 477 | goto out; |
| 478 | } |
| 479 | /* now copy the data to user space */ |
| 480 | copy_buffer: |
| 481 | dev_dbg(&dev->pdev->dev, "cb->response_buffer size - %d\n", |
| 482 | cb->response_buffer.size); |
Tomas Winkler | ebb108ef | 2012-10-09 16:50:16 +0200 | [diff] [blame^] | 483 | dev_dbg(&dev->pdev->dev, "cb->buf_idx - %lu\n", cb->buf_idx); |
| 484 | if (length == 0 || ubuf == NULL || *offset > cb->buf_idx) { |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 485 | rets = -EMSGSIZE; |
| 486 | goto free; |
| 487 | } |
| 488 | |
Tomas Winkler | ebb108ef | 2012-10-09 16:50:16 +0200 | [diff] [blame^] | 489 | /* length is being truncated to PAGE_SIZE, |
| 490 | * however buf_idx may point beyond that */ |
| 491 | length = min_t(size_t, length, cb->buf_idx - *offset); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 492 | |
Tomas Winkler | 441ab50 | 2011-12-13 23:39:34 +0200 | [diff] [blame] | 493 | if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length)) { |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 494 | rets = -EFAULT; |
| 495 | goto free; |
| 496 | } |
| 497 | |
| 498 | rets = length; |
| 499 | *offset += length; |
Tomas Winkler | ebb108ef | 2012-10-09 16:50:16 +0200 | [diff] [blame^] | 500 | if ((unsigned long)*offset < cb->buf_idx) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 501 | goto out; |
| 502 | |
| 503 | free: |
| 504 | cb_pos = find_read_list_entry(dev, cl); |
| 505 | /* Remove entry from read list */ |
| 506 | if (cb_pos) |
| 507 | list_del(&cb_pos->cb_list); |
| 508 | mei_free_cb_private(cb); |
| 509 | cl->reading_state = MEI_IDLE; |
| 510 | cl->read_cb = NULL; |
| 511 | cl->read_pending = 0; |
| 512 | out: |
| 513 | dev_dbg(&dev->pdev->dev, "end mei read rets= %d\n", rets); |
| 514 | mutex_unlock(&dev->device_lock); |
| 515 | return rets; |
| 516 | } |
| 517 | |
| 518 | /** |
| 519 | * mei_write - the write function. |
| 520 | * |
| 521 | * @file: pointer to file structure |
| 522 | * @ubuf: pointer to user buffer |
| 523 | * @length: buffer length |
| 524 | * @offset: data offset in buffer |
| 525 | * |
| 526 | * returns >=0 data length on success , <0 on error |
| 527 | */ |
| 528 | static ssize_t mei_write(struct file *file, const char __user *ubuf, |
Tomas Winkler | 441ab50 | 2011-12-13 23:39:34 +0200 | [diff] [blame] | 529 | size_t length, loff_t *offset) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 530 | { |
| 531 | struct mei_cl *cl = file->private_data; |
| 532 | struct mei_cl_cb *write_cb = NULL; |
| 533 | struct mei_msg_hdr mei_hdr; |
| 534 | struct mei_device *dev; |
| 535 | unsigned long timeout = 0; |
| 536 | int rets; |
| 537 | int i; |
| 538 | |
| 539 | if (WARN_ON(!cl || !cl->dev)) |
| 540 | return -ENODEV; |
| 541 | |
| 542 | dev = cl->dev; |
| 543 | |
| 544 | mutex_lock(&dev->device_lock); |
| 545 | |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 546 | if (dev->dev_state != MEI_DEV_ENABLED) { |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 547 | mutex_unlock(&dev->device_lock); |
| 548 | return -ENODEV; |
| 549 | } |
| 550 | |
| 551 | if (cl == &dev->iamthif_cl) { |
| 552 | write_cb = find_amthi_read_list_entry(dev, file); |
| 553 | |
| 554 | if (write_cb) { |
| 555 | timeout = write_cb->read_time + |
| 556 | msecs_to_jiffies(IAMTHIF_READ_TIMER); |
| 557 | |
| 558 | if (time_after(jiffies, timeout) || |
| 559 | cl->reading_state == MEI_READ_COMPLETE) { |
| 560 | *offset = 0; |
| 561 | list_del(&write_cb->cb_list); |
| 562 | mei_free_cb_private(write_cb); |
| 563 | write_cb = NULL; |
| 564 | } |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | /* free entry used in read */ |
| 569 | if (cl->reading_state == MEI_READ_COMPLETE) { |
| 570 | *offset = 0; |
| 571 | write_cb = find_read_list_entry(dev, cl); |
| 572 | if (write_cb) { |
| 573 | list_del(&write_cb->cb_list); |
| 574 | mei_free_cb_private(write_cb); |
| 575 | write_cb = NULL; |
| 576 | cl->reading_state = MEI_IDLE; |
| 577 | cl->read_cb = NULL; |
| 578 | cl->read_pending = 0; |
| 579 | } |
Tomas Winkler | 441ab50 | 2011-12-13 23:39:34 +0200 | [diff] [blame] | 580 | } else if (cl->reading_state == MEI_IDLE && !cl->read_pending) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 581 | *offset = 0; |
| 582 | |
| 583 | |
| 584 | write_cb = kzalloc(sizeof(struct mei_cl_cb), GFP_KERNEL); |
| 585 | if (!write_cb) { |
| 586 | mutex_unlock(&dev->device_lock); |
| 587 | return -ENOMEM; |
| 588 | } |
| 589 | |
| 590 | write_cb->file_object = file; |
| 591 | write_cb->file_private = cl; |
| 592 | write_cb->request_buffer.data = kmalloc(length, GFP_KERNEL); |
| 593 | rets = -ENOMEM; |
| 594 | if (!write_cb->request_buffer.data) |
| 595 | goto unlock_dev; |
| 596 | |
| 597 | dev_dbg(&dev->pdev->dev, "length =%d\n", (int) length); |
| 598 | |
| 599 | rets = -EFAULT; |
| 600 | if (copy_from_user(write_cb->request_buffer.data, ubuf, length)) |
| 601 | goto unlock_dev; |
| 602 | |
| 603 | cl->sm_state = 0; |
| 604 | if (length == 4 && |
| 605 | ((memcmp(mei_wd_state_independence_msg[0], |
| 606 | write_cb->request_buffer.data, 4) == 0) || |
| 607 | (memcmp(mei_wd_state_independence_msg[1], |
| 608 | write_cb->request_buffer.data, 4) == 0) || |
| 609 | (memcmp(mei_wd_state_independence_msg[2], |
| 610 | write_cb->request_buffer.data, 4) == 0))) |
| 611 | cl->sm_state |= MEI_WD_STATE_INDEPENDENCE_MSG_SENT; |
| 612 | |
| 613 | INIT_LIST_HEAD(&write_cb->cb_list); |
| 614 | if (cl == &dev->iamthif_cl) { |
| 615 | write_cb->response_buffer.data = |
| 616 | kmalloc(dev->iamthif_mtu, GFP_KERNEL); |
| 617 | if (!write_cb->response_buffer.data) { |
| 618 | rets = -ENOMEM; |
| 619 | goto unlock_dev; |
| 620 | } |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 621 | if (dev->dev_state != MEI_DEV_ENABLED) { |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 622 | rets = -ENODEV; |
| 623 | goto unlock_dev; |
| 624 | } |
Tomas Winkler | 07b509b | 2012-07-23 14:05:39 +0300 | [diff] [blame] | 625 | i = mei_me_cl_by_id(dev, dev->iamthif_cl.me_client_id); |
| 626 | if (i < 0) { |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 627 | rets = -ENODEV; |
| 628 | goto unlock_dev; |
| 629 | } |
Tomas Winkler | 07b509b | 2012-07-23 14:05:39 +0300 | [diff] [blame] | 630 | if (length > dev->me_clients[i].props.max_msg_length || |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 631 | length <= 0) { |
| 632 | rets = -EMSGSIZE; |
| 633 | goto unlock_dev; |
| 634 | } |
| 635 | |
| 636 | write_cb->response_buffer.size = dev->iamthif_mtu; |
| 637 | write_cb->major_file_operations = MEI_IOCTL; |
Tomas Winkler | ebb108ef | 2012-10-09 16:50:16 +0200 | [diff] [blame^] | 638 | write_cb->buf_idx = 0; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 639 | write_cb->request_buffer.size = length; |
| 640 | if (dev->iamthif_cl.state != MEI_FILE_CONNECTED) { |
| 641 | rets = -ENODEV; |
| 642 | goto unlock_dev; |
| 643 | } |
| 644 | |
| 645 | if (!list_empty(&dev->amthi_cmd_list.mei_cb.cb_list) || |
| 646 | dev->iamthif_state != MEI_IAMTHIF_IDLE) { |
| 647 | dev_dbg(&dev->pdev->dev, "amthi_state = %d\n", |
| 648 | (int) dev->iamthif_state); |
| 649 | dev_dbg(&dev->pdev->dev, "add amthi cb to amthi cmd waiting list\n"); |
| 650 | list_add_tail(&write_cb->cb_list, |
| 651 | &dev->amthi_cmd_list.mei_cb.cb_list); |
| 652 | rets = length; |
| 653 | } else { |
| 654 | dev_dbg(&dev->pdev->dev, "call amthi write\n"); |
| 655 | rets = amthi_write(dev, write_cb); |
| 656 | |
| 657 | if (rets) { |
| 658 | dev_dbg(&dev->pdev->dev, "amthi write failed with status = %d\n", |
| 659 | rets); |
| 660 | goto unlock_dev; |
| 661 | } |
| 662 | rets = length; |
| 663 | } |
| 664 | mutex_unlock(&dev->device_lock); |
| 665 | return rets; |
| 666 | } |
| 667 | |
| 668 | write_cb->major_file_operations = MEI_WRITE; |
Tomas Winkler | ebb108ef | 2012-10-09 16:50:16 +0200 | [diff] [blame^] | 669 | /* make sure buffer index is zero before we start */ |
| 670 | write_cb->buf_idx = 0; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 671 | write_cb->request_buffer.size = length; |
| 672 | |
| 673 | dev_dbg(&dev->pdev->dev, "host client = %d, ME client = %d\n", |
| 674 | cl->host_client_id, cl->me_client_id); |
| 675 | if (cl->state != MEI_FILE_CONNECTED) { |
| 676 | rets = -ENODEV; |
| 677 | dev_dbg(&dev->pdev->dev, "host client = %d, is not connected to ME client = %d", |
| 678 | cl->host_client_id, |
| 679 | cl->me_client_id); |
| 680 | goto unlock_dev; |
| 681 | } |
Tomas Winkler | 07b509b | 2012-07-23 14:05:39 +0300 | [diff] [blame] | 682 | i = mei_me_cl_by_id(dev, cl->me_client_id); |
| 683 | if (i < 0) { |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 684 | rets = -ENODEV; |
| 685 | goto unlock_dev; |
| 686 | } |
| 687 | if (length > dev->me_clients[i].props.max_msg_length || length <= 0) { |
| 688 | rets = -EINVAL; |
| 689 | goto unlock_dev; |
| 690 | } |
| 691 | write_cb->file_private = cl; |
| 692 | |
| 693 | rets = mei_flow_ctrl_creds(dev, cl); |
| 694 | if (rets < 0) |
| 695 | goto unlock_dev; |
| 696 | |
| 697 | if (rets && dev->mei_host_buffer_is_empty) { |
| 698 | rets = 0; |
Tomas Winkler | eb9af0a | 2011-05-25 17:28:22 +0300 | [diff] [blame] | 699 | dev->mei_host_buffer_is_empty = false; |
Tomas Winkler | 24aadc8 | 2012-06-25 23:46:27 +0300 | [diff] [blame] | 700 | if (length > mei_hbuf_max_data(dev)) { |
| 701 | mei_hdr.length = mei_hbuf_max_data(dev); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 702 | mei_hdr.msg_complete = 0; |
| 703 | } else { |
| 704 | mei_hdr.length = length; |
| 705 | mei_hdr.msg_complete = 1; |
| 706 | } |
| 707 | mei_hdr.host_addr = cl->host_client_id; |
| 708 | mei_hdr.me_addr = cl->me_client_id; |
| 709 | mei_hdr.reserved = 0; |
| 710 | dev_dbg(&dev->pdev->dev, "call mei_write_message header=%08x.\n", |
| 711 | *((u32 *) &mei_hdr)); |
Tomas Winkler | 1ccb7b6 | 2012-03-14 14:39:42 +0200 | [diff] [blame] | 712 | if (mei_write_message(dev, &mei_hdr, |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 713 | (unsigned char *) (write_cb->request_buffer.data), |
| 714 | mei_hdr.length)) { |
| 715 | rets = -ENODEV; |
| 716 | goto unlock_dev; |
| 717 | } |
| 718 | cl->writing_state = MEI_WRITING; |
Tomas Winkler | ebb108ef | 2012-10-09 16:50:16 +0200 | [diff] [blame^] | 719 | write_cb->buf_idx = mei_hdr.length; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 720 | if (mei_hdr.msg_complete) { |
| 721 | if (mei_flow_ctrl_reduce(dev, cl)) { |
| 722 | rets = -ENODEV; |
| 723 | goto unlock_dev; |
| 724 | } |
| 725 | list_add_tail(&write_cb->cb_list, |
| 726 | &dev->write_waiting_list.mei_cb.cb_list); |
| 727 | } else { |
| 728 | list_add_tail(&write_cb->cb_list, |
| 729 | &dev->write_list.mei_cb.cb_list); |
| 730 | } |
| 731 | |
| 732 | } else { |
| 733 | |
Tomas Winkler | ebb108ef | 2012-10-09 16:50:16 +0200 | [diff] [blame^] | 734 | write_cb->buf_idx = 0; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 735 | cl->writing_state = MEI_WRITING; |
| 736 | list_add_tail(&write_cb->cb_list, |
| 737 | &dev->write_list.mei_cb.cb_list); |
| 738 | } |
| 739 | mutex_unlock(&dev->device_lock); |
| 740 | return length; |
| 741 | |
| 742 | unlock_dev: |
| 743 | mutex_unlock(&dev->device_lock); |
| 744 | mei_free_cb_private(write_cb); |
| 745 | return rets; |
| 746 | } |
| 747 | |
| 748 | |
| 749 | /** |
| 750 | * mei_ioctl - the IOCTL function |
| 751 | * |
| 752 | * @file: pointer to file structure |
| 753 | * @cmd: ioctl command |
| 754 | * @data: pointer to mei message structure |
| 755 | * |
| 756 | * returns 0 on success , <0 on error |
| 757 | */ |
| 758 | static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data) |
| 759 | { |
| 760 | struct mei_device *dev; |
| 761 | struct mei_cl *cl = file->private_data; |
| 762 | struct mei_connect_client_data *connect_data = NULL; |
| 763 | int rets; |
| 764 | |
| 765 | if (cmd != IOCTL_MEI_CONNECT_CLIENT) |
| 766 | return -EINVAL; |
| 767 | |
| 768 | if (WARN_ON(!cl || !cl->dev)) |
| 769 | return -ENODEV; |
| 770 | |
| 771 | dev = cl->dev; |
| 772 | |
| 773 | dev_dbg(&dev->pdev->dev, "IOCTL cmd = 0x%x", cmd); |
| 774 | |
| 775 | mutex_lock(&dev->device_lock); |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 776 | if (dev->dev_state != MEI_DEV_ENABLED) { |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 777 | rets = -ENODEV; |
| 778 | goto out; |
| 779 | } |
| 780 | |
| 781 | dev_dbg(&dev->pdev->dev, ": IOCTL_MEI_CONNECT_CLIENT.\n"); |
| 782 | |
| 783 | connect_data = kzalloc(sizeof(struct mei_connect_client_data), |
| 784 | GFP_KERNEL); |
| 785 | if (!connect_data) { |
| 786 | rets = -ENOMEM; |
| 787 | goto out; |
| 788 | } |
| 789 | dev_dbg(&dev->pdev->dev, "copy connect data from user\n"); |
| 790 | if (copy_from_user(connect_data, (char __user *)data, |
| 791 | sizeof(struct mei_connect_client_data))) { |
| 792 | dev_dbg(&dev->pdev->dev, "failed to copy data from userland\n"); |
| 793 | rets = -EFAULT; |
| 794 | goto out; |
| 795 | } |
| 796 | rets = mei_ioctl_connect_client(file, connect_data); |
| 797 | |
| 798 | /* if all is ok, copying the data back to user. */ |
| 799 | if (rets) |
| 800 | goto out; |
| 801 | |
| 802 | dev_dbg(&dev->pdev->dev, "copy connect data to user\n"); |
| 803 | if (copy_to_user((char __user *)data, connect_data, |
| 804 | sizeof(struct mei_connect_client_data))) { |
| 805 | dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n"); |
| 806 | rets = -EFAULT; |
| 807 | goto out; |
| 808 | } |
| 809 | |
| 810 | out: |
| 811 | kfree(connect_data); |
| 812 | mutex_unlock(&dev->device_lock); |
| 813 | return rets; |
| 814 | } |
| 815 | |
| 816 | /** |
| 817 | * mei_compat_ioctl - the compat IOCTL function |
| 818 | * |
| 819 | * @file: pointer to file structure |
| 820 | * @cmd: ioctl command |
| 821 | * @data: pointer to mei message structure |
| 822 | * |
| 823 | * returns 0 on success , <0 on error |
| 824 | */ |
| 825 | #ifdef CONFIG_COMPAT |
| 826 | static long mei_compat_ioctl(struct file *file, |
Tomas Winkler | 441ab50 | 2011-12-13 23:39:34 +0200 | [diff] [blame] | 827 | unsigned int cmd, unsigned long data) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 828 | { |
| 829 | return mei_ioctl(file, cmd, (unsigned long)compat_ptr(data)); |
| 830 | } |
| 831 | #endif |
| 832 | |
| 833 | |
| 834 | /** |
| 835 | * mei_poll - the poll function |
| 836 | * |
| 837 | * @file: pointer to file structure |
| 838 | * @wait: pointer to poll_table structure |
| 839 | * |
| 840 | * returns poll mask |
| 841 | */ |
| 842 | static unsigned int mei_poll(struct file *file, poll_table *wait) |
| 843 | { |
| 844 | struct mei_cl *cl = file->private_data; |
| 845 | struct mei_device *dev; |
| 846 | unsigned int mask = 0; |
| 847 | |
| 848 | if (WARN_ON(!cl || !cl->dev)) |
| 849 | return mask; |
| 850 | |
| 851 | dev = cl->dev; |
| 852 | |
| 853 | mutex_lock(&dev->device_lock); |
| 854 | |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 855 | if (dev->dev_state != MEI_DEV_ENABLED) |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 856 | goto out; |
| 857 | |
| 858 | |
| 859 | if (cl == &dev->iamthif_cl) { |
| 860 | mutex_unlock(&dev->device_lock); |
| 861 | poll_wait(file, &dev->iamthif_cl.wait, wait); |
| 862 | mutex_lock(&dev->device_lock); |
| 863 | if (dev->iamthif_state == MEI_IAMTHIF_READ_COMPLETE && |
| 864 | dev->iamthif_file_object == file) { |
| 865 | mask |= (POLLIN | POLLRDNORM); |
| 866 | dev_dbg(&dev->pdev->dev, "run next amthi cb\n"); |
Tomas Winkler | c95efb7 | 2011-05-25 17:28:21 +0300 | [diff] [blame] | 867 | mei_run_next_iamthif_cmd(dev); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 868 | } |
| 869 | goto out; |
| 870 | } |
| 871 | |
| 872 | mutex_unlock(&dev->device_lock); |
| 873 | poll_wait(file, &cl->tx_wait, wait); |
| 874 | mutex_lock(&dev->device_lock); |
| 875 | if (MEI_WRITE_COMPLETE == cl->writing_state) |
| 876 | mask |= (POLLIN | POLLRDNORM); |
| 877 | |
| 878 | out: |
| 879 | mutex_unlock(&dev->device_lock); |
| 880 | return mask; |
| 881 | } |
| 882 | |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 883 | /* |
| 884 | * file operations structure will be used for mei char device. |
| 885 | */ |
| 886 | static const struct file_operations mei_fops = { |
| 887 | .owner = THIS_MODULE, |
| 888 | .read = mei_read, |
| 889 | .unlocked_ioctl = mei_ioctl, |
| 890 | #ifdef CONFIG_COMPAT |
| 891 | .compat_ioctl = mei_compat_ioctl, |
| 892 | #endif |
| 893 | .open = mei_open, |
| 894 | .release = mei_release, |
| 895 | .write = mei_write, |
| 896 | .poll = mei_poll, |
| 897 | .llseek = no_llseek |
| 898 | }; |
| 899 | |
| 900 | |
| 901 | /* |
| 902 | * Misc Device Struct |
| 903 | */ |
| 904 | static struct miscdevice mei_misc_device = { |
Tomas Winkler | c38ea24 | 2012-04-02 20:32:39 +0300 | [diff] [blame] | 905 | .name = "mei", |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 906 | .fops = &mei_fops, |
| 907 | .minor = MISC_DYNAMIC_MINOR, |
| 908 | }; |
| 909 | |
| 910 | /** |
Tomas Winkler | 9a123f1 | 2012-08-06 15:23:55 +0300 | [diff] [blame] | 911 | * mei_quirk_probe - probe for devices that doesn't valid ME interface |
| 912 | * @pdev: PCI device structure |
| 913 | * @ent: entry into pci_device_table |
| 914 | * |
| 915 | * returns true if ME Interface is valid, false otherwise |
| 916 | */ |
| 917 | static bool __devinit mei_quirk_probe(struct pci_dev *pdev, |
| 918 | const struct pci_device_id *ent) |
| 919 | { |
| 920 | u32 reg; |
| 921 | if (ent->device == MEI_DEV_ID_PBG_1) { |
| 922 | pci_read_config_dword(pdev, 0x48, ®); |
| 923 | /* make sure that bit 9 is up and bit 10 is down */ |
| 924 | if ((reg & 0x600) == 0x200) { |
| 925 | dev_info(&pdev->dev, "Device doesn't have valid ME Interface\n"); |
| 926 | return false; |
| 927 | } |
| 928 | } |
| 929 | return true; |
| 930 | } |
| 931 | /** |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 932 | * mei_probe - Device Initialization Routine |
| 933 | * |
| 934 | * @pdev: PCI device structure |
| 935 | * @ent: entry in kcs_pci_tbl |
| 936 | * |
| 937 | * returns 0 on success, <0 on failure. |
| 938 | */ |
| 939 | static int __devinit mei_probe(struct pci_dev *pdev, |
| 940 | const struct pci_device_id *ent) |
| 941 | { |
| 942 | struct mei_device *dev; |
| 943 | int err; |
| 944 | |
| 945 | mutex_lock(&mei_mutex); |
Tomas Winkler | 9a123f1 | 2012-08-06 15:23:55 +0300 | [diff] [blame] | 946 | |
| 947 | if (!mei_quirk_probe(pdev, ent)) { |
| 948 | err = -ENODEV; |
| 949 | goto end; |
| 950 | } |
| 951 | |
Tomas Winkler | daed6b5 | 2012-08-17 09:54:23 +0300 | [diff] [blame] | 952 | if (mei_pdev) { |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 953 | err = -EEXIST; |
| 954 | goto end; |
| 955 | } |
| 956 | /* enable pci dev */ |
| 957 | err = pci_enable_device(pdev); |
| 958 | if (err) { |
Tomas Winkler | 32c826b | 2012-05-08 23:04:56 +0300 | [diff] [blame] | 959 | dev_err(&pdev->dev, "failed to enable pci device.\n"); |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 960 | goto end; |
| 961 | } |
| 962 | /* set PCI host mastering */ |
| 963 | pci_set_master(pdev); |
| 964 | /* pci request regions for mei driver */ |
Tomas Winkler | 068c0ae | 2012-08-07 00:03:54 +0300 | [diff] [blame] | 965 | err = pci_request_regions(pdev, KBUILD_MODNAME); |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 966 | if (err) { |
Tomas Winkler | 32c826b | 2012-05-08 23:04:56 +0300 | [diff] [blame] | 967 | dev_err(&pdev->dev, "failed to get pci regions.\n"); |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 968 | goto disable_device; |
| 969 | } |
| 970 | /* allocates and initializes the mei dev structure */ |
| 971 | dev = mei_device_init(pdev); |
| 972 | if (!dev) { |
| 973 | err = -ENOMEM; |
| 974 | goto release_regions; |
| 975 | } |
| 976 | /* mapping IO device memory */ |
| 977 | dev->mem_addr = pci_iomap(pdev, 0, 0); |
| 978 | if (!dev->mem_addr) { |
Tomas Winkler | 32c826b | 2012-05-08 23:04:56 +0300 | [diff] [blame] | 979 | dev_err(&pdev->dev, "mapping I/O device memory failure.\n"); |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 980 | err = -ENOMEM; |
| 981 | goto free_device; |
| 982 | } |
| 983 | pci_enable_msi(pdev); |
| 984 | |
| 985 | /* request and enable interrupt */ |
| 986 | if (pci_dev_msi_enabled(pdev)) |
| 987 | err = request_threaded_irq(pdev->irq, |
| 988 | NULL, |
| 989 | mei_interrupt_thread_handler, |
Tomas Winkler | 068c0ae | 2012-08-07 00:03:54 +0300 | [diff] [blame] | 990 | IRQF_ONESHOT, KBUILD_MODNAME, dev); |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 991 | else |
| 992 | err = request_threaded_irq(pdev->irq, |
| 993 | mei_interrupt_quick_handler, |
| 994 | mei_interrupt_thread_handler, |
Tomas Winkler | 068c0ae | 2012-08-07 00:03:54 +0300 | [diff] [blame] | 995 | IRQF_SHARED, KBUILD_MODNAME, dev); |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 996 | |
| 997 | if (err) { |
Tomas Winkler | 32c826b | 2012-05-08 23:04:56 +0300 | [diff] [blame] | 998 | dev_err(&pdev->dev, "request_threaded_irq failure. irq = %d\n", |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 999 | pdev->irq); |
Samuel Ortiz | 169dc38 | 2012-06-11 12:18:30 +0300 | [diff] [blame] | 1000 | goto disable_msi; |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 1001 | } |
| 1002 | INIT_DELAYED_WORK(&dev->timer_work, mei_timer); |
| 1003 | if (mei_hw_init(dev)) { |
Tomas Winkler | 32c826b | 2012-05-08 23:04:56 +0300 | [diff] [blame] | 1004 | dev_err(&pdev->dev, "init hw failure.\n"); |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 1005 | err = -ENODEV; |
| 1006 | goto release_irq; |
| 1007 | } |
| 1008 | |
| 1009 | err = misc_register(&mei_misc_device); |
| 1010 | if (err) |
| 1011 | goto release_irq; |
| 1012 | |
Tomas Winkler | daed6b5 | 2012-08-17 09:54:23 +0300 | [diff] [blame] | 1013 | mei_pdev = pdev; |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 1014 | pci_set_drvdata(pdev, dev); |
| 1015 | |
| 1016 | |
| 1017 | schedule_delayed_work(&dev->timer_work, HZ); |
| 1018 | |
| 1019 | mutex_unlock(&mei_mutex); |
| 1020 | |
Tomas Winkler | 2f3d2b4 | 2012-03-19 22:38:13 +0200 | [diff] [blame] | 1021 | pr_debug("initialization successful.\n"); |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 1022 | |
| 1023 | return 0; |
| 1024 | |
| 1025 | release_irq: |
| 1026 | /* disable interrupts */ |
| 1027 | dev->host_hw_state = mei_hcsr_read(dev); |
| 1028 | mei_disable_interrupts(dev); |
| 1029 | flush_scheduled_work(); |
| 1030 | free_irq(pdev->irq, dev); |
Samuel Ortiz | 169dc38 | 2012-06-11 12:18:30 +0300 | [diff] [blame] | 1031 | disable_msi: |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 1032 | pci_disable_msi(pdev); |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 1033 | pci_iounmap(pdev, dev->mem_addr); |
| 1034 | free_device: |
| 1035 | kfree(dev); |
| 1036 | release_regions: |
| 1037 | pci_release_regions(pdev); |
| 1038 | disable_device: |
| 1039 | pci_disable_device(pdev); |
| 1040 | end: |
| 1041 | mutex_unlock(&mei_mutex); |
Tomas Winkler | 32c826b | 2012-05-08 23:04:56 +0300 | [diff] [blame] | 1042 | dev_err(&pdev->dev, "initialization failed.\n"); |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 1043 | return err; |
| 1044 | } |
| 1045 | |
| 1046 | /** |
| 1047 | * mei_remove - Device Removal Routine |
| 1048 | * |
| 1049 | * @pdev: PCI device structure |
| 1050 | * |
| 1051 | * mei_remove is called by the PCI subsystem to alert the driver |
| 1052 | * that it should release a PCI device. |
| 1053 | */ |
| 1054 | static void __devexit mei_remove(struct pci_dev *pdev) |
| 1055 | { |
| 1056 | struct mei_device *dev; |
| 1057 | |
Tomas Winkler | daed6b5 | 2012-08-17 09:54:23 +0300 | [diff] [blame] | 1058 | if (mei_pdev != pdev) |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 1059 | return; |
| 1060 | |
| 1061 | dev = pci_get_drvdata(pdev); |
| 1062 | if (!dev) |
| 1063 | return; |
| 1064 | |
| 1065 | mutex_lock(&dev->device_lock); |
| 1066 | |
Tomas Winkler | c216fde | 2012-08-16 19:39:43 +0300 | [diff] [blame] | 1067 | cancel_delayed_work(&dev->timer_work); |
| 1068 | |
| 1069 | mei_wd_stop(dev); |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 1070 | |
Tomas Winkler | daed6b5 | 2012-08-17 09:54:23 +0300 | [diff] [blame] | 1071 | mei_pdev = NULL; |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 1072 | |
| 1073 | if (dev->iamthif_cl.state == MEI_FILE_CONNECTED) { |
| 1074 | dev->iamthif_cl.state = MEI_FILE_DISCONNECTING; |
| 1075 | mei_disconnect_host_client(dev, &dev->iamthif_cl); |
| 1076 | } |
| 1077 | if (dev->wd_cl.state == MEI_FILE_CONNECTED) { |
| 1078 | dev->wd_cl.state = MEI_FILE_DISCONNECTING; |
| 1079 | mei_disconnect_host_client(dev, &dev->wd_cl); |
| 1080 | } |
| 1081 | |
| 1082 | /* Unregistering watchdog device */ |
Tomas Winkler | 70cd533 | 2011-12-22 18:50:50 +0200 | [diff] [blame] | 1083 | mei_watchdog_unregister(dev); |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 1084 | |
| 1085 | /* remove entry if already in list */ |
| 1086 | dev_dbg(&pdev->dev, "list del iamthif and wd file list.\n"); |
| 1087 | mei_remove_client_from_file_list(dev, dev->wd_cl.host_client_id); |
| 1088 | mei_remove_client_from_file_list(dev, dev->iamthif_cl.host_client_id); |
| 1089 | |
| 1090 | dev->iamthif_current_cb = NULL; |
| 1091 | dev->me_clients_num = 0; |
| 1092 | |
| 1093 | mutex_unlock(&dev->device_lock); |
| 1094 | |
| 1095 | flush_scheduled_work(); |
| 1096 | |
| 1097 | /* disable interrupts */ |
| 1098 | mei_disable_interrupts(dev); |
| 1099 | |
| 1100 | free_irq(pdev->irq, dev); |
| 1101 | pci_disable_msi(pdev); |
| 1102 | pci_set_drvdata(pdev, NULL); |
| 1103 | |
| 1104 | if (dev->mem_addr) |
| 1105 | pci_iounmap(pdev, dev->mem_addr); |
| 1106 | |
| 1107 | kfree(dev); |
| 1108 | |
| 1109 | pci_release_regions(pdev); |
| 1110 | pci_disable_device(pdev); |
Tomas Winkler | a44cab4 | 2012-05-29 16:39:11 +0300 | [diff] [blame] | 1111 | |
| 1112 | misc_deregister(&mei_misc_device); |
Oren Weil | 5b881e3 | 2011-11-13 09:41:14 +0200 | [diff] [blame] | 1113 | } |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 1114 | #ifdef CONFIG_PM |
| 1115 | static int mei_pci_suspend(struct device *device) |
| 1116 | { |
| 1117 | struct pci_dev *pdev = to_pci_dev(device); |
| 1118 | struct mei_device *dev = pci_get_drvdata(pdev); |
| 1119 | int err; |
| 1120 | |
| 1121 | if (!dev) |
| 1122 | return -ENODEV; |
| 1123 | mutex_lock(&dev->device_lock); |
Tomas Winkler | c216fde | 2012-08-16 19:39:43 +0300 | [diff] [blame] | 1124 | |
| 1125 | cancel_delayed_work(&dev->timer_work); |
| 1126 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 1127 | /* Stop watchdog if exists */ |
Tomas Winkler | c216fde | 2012-08-16 19:39:43 +0300 | [diff] [blame] | 1128 | err = mei_wd_stop(dev); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 1129 | /* Set new mei state */ |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 1130 | if (dev->dev_state == MEI_DEV_ENABLED || |
| 1131 | dev->dev_state == MEI_DEV_RECOVERING_FROM_RESET) { |
| 1132 | dev->dev_state = MEI_DEV_POWER_DOWN; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 1133 | mei_reset(dev, 0); |
| 1134 | } |
| 1135 | mutex_unlock(&dev->device_lock); |
| 1136 | |
| 1137 | free_irq(pdev->irq, dev); |
Tomas Winkler | 4f61a7a | 2011-07-14 20:11:25 +0300 | [diff] [blame] | 1138 | pci_disable_msi(pdev); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 1139 | |
| 1140 | return err; |
| 1141 | } |
| 1142 | |
| 1143 | static int mei_pci_resume(struct device *device) |
| 1144 | { |
| 1145 | struct pci_dev *pdev = to_pci_dev(device); |
| 1146 | struct mei_device *dev; |
| 1147 | int err; |
| 1148 | |
| 1149 | dev = pci_get_drvdata(pdev); |
| 1150 | if (!dev) |
| 1151 | return -ENODEV; |
| 1152 | |
Tomas Winkler | 4f61a7a | 2011-07-14 20:11:25 +0300 | [diff] [blame] | 1153 | pci_enable_msi(pdev); |
| 1154 | |
| 1155 | /* request and enable interrupt */ |
| 1156 | if (pci_dev_msi_enabled(pdev)) |
| 1157 | err = request_threaded_irq(pdev->irq, |
| 1158 | NULL, |
| 1159 | mei_interrupt_thread_handler, |
Tomas Winkler | 068c0ae | 2012-08-07 00:03:54 +0300 | [diff] [blame] | 1160 | IRQF_ONESHOT, KBUILD_MODNAME, dev); |
Tomas Winkler | 4f61a7a | 2011-07-14 20:11:25 +0300 | [diff] [blame] | 1161 | else |
| 1162 | err = request_threaded_irq(pdev->irq, |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 1163 | mei_interrupt_quick_handler, |
| 1164 | mei_interrupt_thread_handler, |
Tomas Winkler | 068c0ae | 2012-08-07 00:03:54 +0300 | [diff] [blame] | 1165 | IRQF_SHARED, KBUILD_MODNAME, dev); |
Tomas Winkler | 4f61a7a | 2011-07-14 20:11:25 +0300 | [diff] [blame] | 1166 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 1167 | if (err) { |
Tomas Winkler | 32c826b | 2012-05-08 23:04:56 +0300 | [diff] [blame] | 1168 | dev_err(&pdev->dev, "request_threaded_irq failed: irq = %d.\n", |
| 1169 | pdev->irq); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 1170 | return err; |
| 1171 | } |
| 1172 | |
| 1173 | mutex_lock(&dev->device_lock); |
Tomas Winkler | b210d75 | 2012-08-07 00:03:56 +0300 | [diff] [blame] | 1174 | dev->dev_state = MEI_DEV_POWER_UP; |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 1175 | mei_reset(dev, 1); |
| 1176 | mutex_unlock(&dev->device_lock); |
| 1177 | |
Oren Weil | 6d70e93 | 2011-09-07 09:03:14 +0300 | [diff] [blame] | 1178 | /* Start timer if stopped in suspend */ |
| 1179 | schedule_delayed_work(&dev->timer_work, HZ); |
| 1180 | |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 1181 | return err; |
| 1182 | } |
| 1183 | static SIMPLE_DEV_PM_OPS(mei_pm_ops, mei_pci_suspend, mei_pci_resume); |
| 1184 | #define MEI_PM_OPS (&mei_pm_ops) |
| 1185 | #else |
Randy Dunlap | 2d99036 | 2011-05-19 08:52:34 -0700 | [diff] [blame] | 1186 | #define MEI_PM_OPS NULL |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 1187 | #endif /* CONFIG_PM */ |
| 1188 | /* |
| 1189 | * PCI driver structure |
| 1190 | */ |
| 1191 | static struct pci_driver mei_driver = { |
Tomas Winkler | 068c0ae | 2012-08-07 00:03:54 +0300 | [diff] [blame] | 1192 | .name = KBUILD_MODNAME, |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 1193 | .id_table = mei_pci_tbl, |
| 1194 | .probe = mei_probe, |
| 1195 | .remove = __devexit_p(mei_remove), |
| 1196 | .shutdown = __devexit_p(mei_remove), |
| 1197 | .driver.pm = MEI_PM_OPS, |
| 1198 | }; |
| 1199 | |
Tomas Winkler | 6078188 | 2012-07-19 09:45:32 +0300 | [diff] [blame] | 1200 | module_pci_driver(mei_driver); |
Oren Weil | ab84116 | 2011-05-15 13:43:41 +0300 | [diff] [blame] | 1201 | |
| 1202 | MODULE_AUTHOR("Intel Corporation"); |
| 1203 | MODULE_DESCRIPTION("Intel(R) Management Engine Interface"); |
| 1204 | MODULE_LICENSE("GPL v2"); |