Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Intel Management Engine Interface (Intel MEI) Linux driver |
| 3 | * Copyright (c) 2012-2013, Intel Corporation. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms and conditions of the GNU General Public License, |
| 7 | * version 2, as published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | */ |
| 15 | |
| 16 | #include <linux/module.h> |
| 17 | #include <linux/device.h> |
| 18 | #include <linux/kernel.h> |
Samuel Ortiz | 3e83329 | 2013-03-27 17:29:55 +0200 | [diff] [blame] | 19 | #include <linux/sched.h> |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 20 | #include <linux/init.h> |
| 21 | #include <linux/errno.h> |
| 22 | #include <linux/slab.h> |
| 23 | #include <linux/mutex.h> |
| 24 | #include <linux/interrupt.h> |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 25 | #include <linux/mei_cl_bus.h> |
| 26 | |
| 27 | #include "mei_dev.h" |
Samuel Ortiz | 3e83329 | 2013-03-27 17:29:55 +0200 | [diff] [blame] | 28 | #include "client.h" |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 29 | |
| 30 | #define to_mei_cl_driver(d) container_of(d, struct mei_cl_driver, driver) |
| 31 | #define to_mei_cl_device(d) container_of(d, struct mei_cl_device, dev) |
| 32 | |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 33 | /** |
| 34 | * __mei_cl_send - internal client send (write) |
| 35 | * |
| 36 | * @cl: host client |
| 37 | * @buf: buffer to send |
| 38 | * @length: buffer length |
| 39 | * @blocking: wait for write completion |
| 40 | * |
| 41 | * Return: written size bytes or < 0 on error |
| 42 | */ |
| 43 | ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, |
| 44 | bool blocking) |
| 45 | { |
| 46 | struct mei_device *bus; |
Alexander Usyskin | 6cbb097 | 2016-02-10 23:57:26 +0200 | [diff] [blame^] | 47 | struct mei_cl_cb *cb; |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 48 | ssize_t rets; |
| 49 | |
| 50 | if (WARN_ON(!cl || !cl->dev)) |
| 51 | return -ENODEV; |
| 52 | |
| 53 | bus = cl->dev; |
| 54 | |
| 55 | mutex_lock(&bus->device_lock); |
Alexander Usyskin | 15c13df | 2016-02-07 23:35:32 +0200 | [diff] [blame] | 56 | if (bus->dev_state != MEI_DEV_ENABLED) { |
| 57 | rets = -ENODEV; |
| 58 | goto out; |
| 59 | } |
| 60 | |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 61 | if (!mei_cl_is_connected(cl)) { |
| 62 | rets = -ENODEV; |
| 63 | goto out; |
| 64 | } |
| 65 | |
| 66 | /* Check if we have an ME client device */ |
| 67 | if (!mei_me_cl_is_active(cl->me_cl)) { |
| 68 | rets = -ENOTTY; |
| 69 | goto out; |
| 70 | } |
| 71 | |
| 72 | if (length > mei_cl_mtu(cl)) { |
| 73 | rets = -EFBIG; |
| 74 | goto out; |
| 75 | } |
| 76 | |
| 77 | cb = mei_cl_alloc_cb(cl, length, MEI_FOP_WRITE, NULL); |
| 78 | if (!cb) { |
| 79 | rets = -ENOMEM; |
| 80 | goto out; |
| 81 | } |
| 82 | |
| 83 | memcpy(cb->buf.data, buf, length); |
| 84 | |
| 85 | rets = mei_cl_write(cl, cb, blocking); |
| 86 | |
| 87 | out: |
| 88 | mutex_unlock(&bus->device_lock); |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 89 | |
| 90 | return rets; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * __mei_cl_recv - internal client receive (read) |
| 95 | * |
| 96 | * @cl: host client |
Tomas Winkler | df7f544 | 2015-10-13 15:02:40 +0300 | [diff] [blame] | 97 | * @buf: buffer to receive |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 98 | * @length: buffer length |
| 99 | * |
| 100 | * Return: read size in bytes of < 0 on error |
| 101 | */ |
| 102 | ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length) |
| 103 | { |
| 104 | struct mei_device *bus; |
| 105 | struct mei_cl_cb *cb; |
| 106 | size_t r_length; |
| 107 | ssize_t rets; |
| 108 | |
| 109 | if (WARN_ON(!cl || !cl->dev)) |
| 110 | return -ENODEV; |
| 111 | |
| 112 | bus = cl->dev; |
| 113 | |
| 114 | mutex_lock(&bus->device_lock); |
Alexander Usyskin | 15c13df | 2016-02-07 23:35:32 +0200 | [diff] [blame] | 115 | if (bus->dev_state != MEI_DEV_ENABLED) { |
| 116 | rets = -ENODEV; |
| 117 | goto out; |
| 118 | } |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 119 | |
| 120 | cb = mei_cl_read_cb(cl, NULL); |
| 121 | if (cb) |
| 122 | goto copy; |
| 123 | |
| 124 | rets = mei_cl_read_start(cl, length, NULL); |
| 125 | if (rets && rets != -EBUSY) |
| 126 | goto out; |
| 127 | |
| 128 | /* wait on event only if there is no other waiter */ |
| 129 | if (list_empty(&cl->rd_completed) && !waitqueue_active(&cl->rx_wait)) { |
| 130 | |
| 131 | mutex_unlock(&bus->device_lock); |
| 132 | |
| 133 | if (wait_event_interruptible(cl->rx_wait, |
| 134 | (!list_empty(&cl->rd_completed)) || |
| 135 | (!mei_cl_is_connected(cl)))) { |
| 136 | |
| 137 | if (signal_pending(current)) |
| 138 | return -EINTR; |
| 139 | return -ERESTARTSYS; |
| 140 | } |
| 141 | |
| 142 | mutex_lock(&bus->device_lock); |
| 143 | |
| 144 | if (!mei_cl_is_connected(cl)) { |
| 145 | rets = -EBUSY; |
| 146 | goto out; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | cb = mei_cl_read_cb(cl, NULL); |
| 151 | if (!cb) { |
| 152 | rets = 0; |
| 153 | goto out; |
| 154 | } |
| 155 | |
| 156 | copy: |
| 157 | if (cb->status) { |
| 158 | rets = cb->status; |
| 159 | goto free; |
| 160 | } |
| 161 | |
| 162 | r_length = min_t(size_t, length, cb->buf_idx); |
| 163 | memcpy(buf, cb->buf.data, r_length); |
| 164 | rets = r_length; |
| 165 | |
| 166 | free: |
| 167 | mei_io_cb_free(cb); |
| 168 | out: |
| 169 | mutex_unlock(&bus->device_lock); |
| 170 | |
| 171 | return rets; |
| 172 | } |
| 173 | |
| 174 | /** |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 175 | * mei_cldev_send - me device send (write) |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 176 | * |
| 177 | * @cldev: me client device |
| 178 | * @buf: buffer to send |
| 179 | * @length: buffer length |
| 180 | * |
| 181 | * Return: written size in bytes or < 0 on error |
| 182 | */ |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 183 | ssize_t mei_cldev_send(struct mei_cl_device *cldev, u8 *buf, size_t length) |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 184 | { |
| 185 | struct mei_cl *cl = cldev->cl; |
| 186 | |
| 187 | if (cl == NULL) |
| 188 | return -ENODEV; |
| 189 | |
| 190 | return __mei_cl_send(cl, buf, length, 1); |
| 191 | } |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 192 | EXPORT_SYMBOL_GPL(mei_cldev_send); |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 193 | |
| 194 | /** |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 195 | * mei_cldev_recv - client receive (read) |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 196 | * |
| 197 | * @cldev: me client device |
Tomas Winkler | df7f544 | 2015-10-13 15:02:40 +0300 | [diff] [blame] | 198 | * @buf: buffer to receive |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 199 | * @length: buffer length |
| 200 | * |
| 201 | * Return: read size in bytes of < 0 on error |
| 202 | */ |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 203 | ssize_t mei_cldev_recv(struct mei_cl_device *cldev, u8 *buf, size_t length) |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 204 | { |
| 205 | struct mei_cl *cl = cldev->cl; |
| 206 | |
| 207 | if (cl == NULL) |
| 208 | return -ENODEV; |
| 209 | |
| 210 | return __mei_cl_recv(cl, buf, length); |
| 211 | } |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 212 | EXPORT_SYMBOL_GPL(mei_cldev_recv); |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 213 | |
| 214 | /** |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 215 | * mei_cl_bus_event_work - dispatch rx event for a bus device |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 216 | * and schedule new work |
| 217 | * |
| 218 | * @work: work |
| 219 | */ |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 220 | static void mei_cl_bus_event_work(struct work_struct *work) |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 221 | { |
| 222 | struct mei_cl_device *cldev; |
| 223 | |
| 224 | cldev = container_of(work, struct mei_cl_device, event_work); |
| 225 | |
| 226 | if (cldev->event_cb) |
| 227 | cldev->event_cb(cldev, cldev->events, cldev->event_context); |
| 228 | |
| 229 | cldev->events = 0; |
| 230 | |
| 231 | /* Prepare for the next read */ |
Alexander Usyskin | bb2ef9c | 2015-07-26 09:54:23 +0300 | [diff] [blame] | 232 | if (cldev->events_mask & BIT(MEI_CL_EVENT_RX)) |
| 233 | mei_cl_read_start(cldev->cl, 0, NULL); |
| 234 | } |
| 235 | |
| 236 | /** |
| 237 | * mei_cl_bus_notify_event - schedule notify cb on bus client |
| 238 | * |
| 239 | * @cl: host client |
Tomas Winkler | 850f894 | 2016-02-07 23:35:31 +0200 | [diff] [blame] | 240 | * |
| 241 | * Return: true if event was scheduled |
| 242 | * false if the client is not waiting for event |
Alexander Usyskin | bb2ef9c | 2015-07-26 09:54:23 +0300 | [diff] [blame] | 243 | */ |
Tomas Winkler | 850f894 | 2016-02-07 23:35:31 +0200 | [diff] [blame] | 244 | bool mei_cl_bus_notify_event(struct mei_cl *cl) |
Alexander Usyskin | bb2ef9c | 2015-07-26 09:54:23 +0300 | [diff] [blame] | 245 | { |
| 246 | struct mei_cl_device *cldev = cl->cldev; |
| 247 | |
| 248 | if (!cldev || !cldev->event_cb) |
Tomas Winkler | 850f894 | 2016-02-07 23:35:31 +0200 | [diff] [blame] | 249 | return false; |
Alexander Usyskin | bb2ef9c | 2015-07-26 09:54:23 +0300 | [diff] [blame] | 250 | |
| 251 | if (!(cldev->events_mask & BIT(MEI_CL_EVENT_NOTIF))) |
Tomas Winkler | 850f894 | 2016-02-07 23:35:31 +0200 | [diff] [blame] | 252 | return false; |
Alexander Usyskin | bb2ef9c | 2015-07-26 09:54:23 +0300 | [diff] [blame] | 253 | |
| 254 | if (!cl->notify_ev) |
Tomas Winkler | 850f894 | 2016-02-07 23:35:31 +0200 | [diff] [blame] | 255 | return false; |
Alexander Usyskin | bb2ef9c | 2015-07-26 09:54:23 +0300 | [diff] [blame] | 256 | |
| 257 | set_bit(MEI_CL_EVENT_NOTIF, &cldev->events); |
| 258 | |
| 259 | schedule_work(&cldev->event_work); |
| 260 | |
| 261 | cl->notify_ev = false; |
Tomas Winkler | 850f894 | 2016-02-07 23:35:31 +0200 | [diff] [blame] | 262 | |
| 263 | return true; |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | /** |
Tomas Winkler | a1f9ae2 | 2016-02-07 23:35:30 +0200 | [diff] [blame] | 267 | * mei_cl_bus_rx_event - schedule rx event |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 268 | * |
| 269 | * @cl: host client |
Tomas Winkler | a1f9ae2 | 2016-02-07 23:35:30 +0200 | [diff] [blame] | 270 | * |
| 271 | * Return: true if event was scheduled |
| 272 | * false if the client is not waiting for event |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 273 | */ |
Tomas Winkler | a1f9ae2 | 2016-02-07 23:35:30 +0200 | [diff] [blame] | 274 | bool mei_cl_bus_rx_event(struct mei_cl *cl) |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 275 | { |
| 276 | struct mei_cl_device *cldev = cl->cldev; |
| 277 | |
| 278 | if (!cldev || !cldev->event_cb) |
Tomas Winkler | a1f9ae2 | 2016-02-07 23:35:30 +0200 | [diff] [blame] | 279 | return false; |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 280 | |
Alexander Usyskin | bb2ef9c | 2015-07-26 09:54:23 +0300 | [diff] [blame] | 281 | if (!(cldev->events_mask & BIT(MEI_CL_EVENT_RX))) |
Tomas Winkler | a1f9ae2 | 2016-02-07 23:35:30 +0200 | [diff] [blame] | 282 | return false; |
Alexander Usyskin | bb2ef9c | 2015-07-26 09:54:23 +0300 | [diff] [blame] | 283 | |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 284 | set_bit(MEI_CL_EVENT_RX, &cldev->events); |
| 285 | |
| 286 | schedule_work(&cldev->event_work); |
Tomas Winkler | a1f9ae2 | 2016-02-07 23:35:30 +0200 | [diff] [blame] | 287 | |
| 288 | return true; |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | /** |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 292 | * mei_cldev_register_event_cb - register event callback |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 293 | * |
| 294 | * @cldev: me client devices |
| 295 | * @event_cb: callback function |
Alexander Usyskin | bb2ef9c | 2015-07-26 09:54:23 +0300 | [diff] [blame] | 296 | * @events_mask: requested events bitmask |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 297 | * @context: driver context data |
| 298 | * |
| 299 | * Return: 0 on success |
| 300 | * -EALREADY if an callback is already registered |
| 301 | * <0 on other errors |
| 302 | */ |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 303 | int mei_cldev_register_event_cb(struct mei_cl_device *cldev, |
| 304 | unsigned long events_mask, |
| 305 | mei_cldev_event_cb_t event_cb, void *context) |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 306 | { |
Tomas Winkler | 48168f4 | 2015-07-23 15:08:38 +0300 | [diff] [blame] | 307 | int ret; |
| 308 | |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 309 | if (cldev->event_cb) |
| 310 | return -EALREADY; |
| 311 | |
| 312 | cldev->events = 0; |
Alexander Usyskin | bb2ef9c | 2015-07-26 09:54:23 +0300 | [diff] [blame] | 313 | cldev->events_mask = events_mask; |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 314 | cldev->event_cb = event_cb; |
| 315 | cldev->event_context = context; |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 316 | INIT_WORK(&cldev->event_work, mei_cl_bus_event_work); |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 317 | |
Alexander Usyskin | bb2ef9c | 2015-07-26 09:54:23 +0300 | [diff] [blame] | 318 | if (cldev->events_mask & BIT(MEI_CL_EVENT_RX)) { |
| 319 | ret = mei_cl_read_start(cldev->cl, 0, NULL); |
| 320 | if (ret && ret != -EBUSY) |
| 321 | return ret; |
| 322 | } |
| 323 | |
| 324 | if (cldev->events_mask & BIT(MEI_CL_EVENT_NOTIF)) { |
| 325 | mutex_lock(&cldev->cl->dev->device_lock); |
| 326 | ret = mei_cl_notify_request(cldev->cl, NULL, event_cb ? 1 : 0); |
| 327 | mutex_unlock(&cldev->cl->dev->device_lock); |
| 328 | if (ret) |
| 329 | return ret; |
| 330 | } |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 331 | |
| 332 | return 0; |
| 333 | } |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 334 | EXPORT_SYMBOL_GPL(mei_cldev_register_event_cb); |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 335 | |
| 336 | /** |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 337 | * mei_cldev_get_drvdata - driver data getter |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 338 | * |
| 339 | * @cldev: mei client device |
| 340 | * |
| 341 | * Return: driver private data |
| 342 | */ |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 343 | void *mei_cldev_get_drvdata(const struct mei_cl_device *cldev) |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 344 | { |
| 345 | return dev_get_drvdata(&cldev->dev); |
| 346 | } |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 347 | EXPORT_SYMBOL_GPL(mei_cldev_get_drvdata); |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 348 | |
| 349 | /** |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 350 | * mei_cldev_set_drvdata - driver data setter |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 351 | * |
| 352 | * @cldev: mei client device |
| 353 | * @data: data to store |
| 354 | */ |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 355 | void mei_cldev_set_drvdata(struct mei_cl_device *cldev, void *data) |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 356 | { |
| 357 | dev_set_drvdata(&cldev->dev, data); |
| 358 | } |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 359 | EXPORT_SYMBOL_GPL(mei_cldev_set_drvdata); |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 360 | |
| 361 | /** |
Tomas Winkler | baeacd0 | 2015-09-10 10:18:02 +0300 | [diff] [blame] | 362 | * mei_cldev_uuid - return uuid of the underlying me client |
| 363 | * |
| 364 | * @cldev: mei client device |
| 365 | * |
| 366 | * Return: me client uuid |
| 367 | */ |
| 368 | const uuid_le *mei_cldev_uuid(const struct mei_cl_device *cldev) |
| 369 | { |
| 370 | return mei_me_cl_uuid(cldev->me_cl); |
| 371 | } |
| 372 | EXPORT_SYMBOL_GPL(mei_cldev_uuid); |
| 373 | |
| 374 | /** |
| 375 | * mei_cldev_ver - return protocol version of the underlying me client |
| 376 | * |
| 377 | * @cldev: mei client device |
| 378 | * |
| 379 | * Return: me client protocol version |
| 380 | */ |
| 381 | u8 mei_cldev_ver(const struct mei_cl_device *cldev) |
| 382 | { |
| 383 | return mei_me_cl_ver(cldev->me_cl); |
| 384 | } |
| 385 | EXPORT_SYMBOL_GPL(mei_cldev_ver); |
| 386 | |
| 387 | /** |
Tomas Winkler | 01a14ed | 2015-09-10 10:18:03 +0300 | [diff] [blame] | 388 | * mei_cldev_enabled - check whether the device is enabled |
| 389 | * |
| 390 | * @cldev: mei client device |
| 391 | * |
| 392 | * Return: true if me client is initialized and connected |
| 393 | */ |
| 394 | bool mei_cldev_enabled(struct mei_cl_device *cldev) |
| 395 | { |
| 396 | return cldev->cl && mei_cl_is_connected(cldev->cl); |
| 397 | } |
| 398 | EXPORT_SYMBOL_GPL(mei_cldev_enabled); |
| 399 | |
| 400 | /** |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 401 | * mei_cldev_enable_device - enable me client device |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 402 | * create connection with me client |
| 403 | * |
| 404 | * @cldev: me client device |
| 405 | * |
| 406 | * Return: 0 on success and < 0 on error |
| 407 | */ |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 408 | int mei_cldev_enable(struct mei_cl_device *cldev) |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 409 | { |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 410 | struct mei_device *bus = cldev->bus; |
| 411 | struct mei_cl *cl; |
| 412 | int ret; |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 413 | |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 414 | cl = cldev->cl; |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 415 | |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 416 | if (!cl) { |
| 417 | mutex_lock(&bus->device_lock); |
Alexander Usyskin | 7851e00 | 2016-02-07 23:35:40 +0200 | [diff] [blame] | 418 | cl = mei_cl_alloc_linked(bus); |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 419 | mutex_unlock(&bus->device_lock); |
| 420 | if (IS_ERR(cl)) |
| 421 | return PTR_ERR(cl); |
| 422 | /* update pointers */ |
| 423 | cldev->cl = cl; |
| 424 | cl->cldev = cldev; |
| 425 | } |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 426 | |
| 427 | mutex_lock(&bus->device_lock); |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 428 | if (mei_cl_is_connected(cl)) { |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 429 | ret = 0; |
| 430 | goto out; |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 431 | } |
| 432 | |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 433 | if (!mei_me_cl_is_active(cldev->me_cl)) { |
| 434 | dev_err(&cldev->dev, "me client is not active\n"); |
| 435 | ret = -ENOTTY; |
| 436 | goto out; |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 437 | } |
| 438 | |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 439 | ret = mei_cl_connect(cl, cldev->me_cl, NULL); |
| 440 | if (ret < 0) |
| 441 | dev_err(&cldev->dev, "cannot connect\n"); |
| 442 | |
| 443 | out: |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 444 | mutex_unlock(&bus->device_lock); |
| 445 | |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 446 | return ret; |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 447 | } |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 448 | EXPORT_SYMBOL_GPL(mei_cldev_enable); |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 449 | |
| 450 | /** |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 451 | * mei_cldev_disable - disable me client device |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 452 | * disconnect form the me client |
| 453 | * |
| 454 | * @cldev: me client device |
| 455 | * |
| 456 | * Return: 0 on success and < 0 on error |
| 457 | */ |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 458 | int mei_cldev_disable(struct mei_cl_device *cldev) |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 459 | { |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 460 | struct mei_device *bus; |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 461 | struct mei_cl *cl; |
| 462 | int err; |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 463 | |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 464 | if (!cldev || !cldev->cl) |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 465 | return -ENODEV; |
| 466 | |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 467 | cl = cldev->cl; |
| 468 | |
| 469 | bus = cldev->bus; |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 470 | |
| 471 | cldev->event_cb = NULL; |
| 472 | |
| 473 | mutex_lock(&bus->device_lock); |
| 474 | |
| 475 | if (!mei_cl_is_connected(cl)) { |
| 476 | dev_err(bus->dev, "Already disconnected"); |
| 477 | err = 0; |
| 478 | goto out; |
| 479 | } |
| 480 | |
| 481 | err = mei_cl_disconnect(cl); |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 482 | if (err < 0) |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 483 | dev_err(bus->dev, "Could not disconnect from the ME client"); |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 484 | |
| 485 | out: |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 486 | /* Flush queues and remove any pending read */ |
| 487 | mei_cl_flush_queues(cl, NULL); |
| 488 | mei_cl_unlink(cl); |
| 489 | |
| 490 | kfree(cl); |
| 491 | cldev->cl = NULL; |
| 492 | |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 493 | mutex_unlock(&bus->device_lock); |
| 494 | return err; |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 495 | } |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 496 | EXPORT_SYMBOL_GPL(mei_cldev_disable); |
Tomas Winkler | 6238299 | 2015-07-23 15:08:35 +0300 | [diff] [blame] | 497 | |
Tomas Winkler | 688a9cc | 2015-07-23 15:08:39 +0300 | [diff] [blame] | 498 | /** |
| 499 | * mei_cl_device_find - find matching entry in the driver id table |
| 500 | * |
| 501 | * @cldev: me client device |
| 502 | * @cldrv: me client driver |
| 503 | * |
| 504 | * Return: id on success; NULL if no id is matching |
| 505 | */ |
| 506 | static const |
| 507 | struct mei_cl_device_id *mei_cl_device_find(struct mei_cl_device *cldev, |
| 508 | struct mei_cl_driver *cldrv) |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 509 | { |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 510 | const struct mei_cl_device_id *id; |
Tomas Winkler | c93b76b | 2015-05-07 15:54:02 +0300 | [diff] [blame] | 511 | const uuid_le *uuid; |
Tomas Winkler | b26864c | 2015-09-10 10:18:01 +0300 | [diff] [blame] | 512 | u8 version; |
| 513 | bool match; |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 514 | |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 515 | uuid = mei_me_cl_uuid(cldev->me_cl); |
Tomas Winkler | b26864c | 2015-09-10 10:18:01 +0300 | [diff] [blame] | 516 | version = mei_me_cl_ver(cldev->me_cl); |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 517 | |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 518 | id = cldrv->id_table; |
Greg Kroah-Hartman | b144ce2 | 2015-05-27 17:17:27 -0700 | [diff] [blame] | 519 | while (uuid_le_cmp(NULL_UUID_LE, id->uuid)) { |
Greg Kroah-Hartman | b144ce2 | 2015-05-27 17:17:27 -0700 | [diff] [blame] | 520 | if (!uuid_le_cmp(*uuid, id->uuid)) { |
Tomas Winkler | b26864c | 2015-09-10 10:18:01 +0300 | [diff] [blame] | 521 | match = true; |
Tomas Winkler | 688a9cc | 2015-07-23 15:08:39 +0300 | [diff] [blame] | 522 | |
Tomas Winkler | b26864c | 2015-09-10 10:18:01 +0300 | [diff] [blame] | 523 | if (cldev->name[0]) |
| 524 | if (strncmp(cldev->name, id->name, |
| 525 | sizeof(id->name))) |
| 526 | match = false; |
Tomas Winkler | 688a9cc | 2015-07-23 15:08:39 +0300 | [diff] [blame] | 527 | |
Tomas Winkler | b26864c | 2015-09-10 10:18:01 +0300 | [diff] [blame] | 528 | if (id->version != MEI_CL_VERSION_ANY) |
| 529 | if (id->version != version) |
| 530 | match = false; |
| 531 | if (match) |
Tomas Winkler | 688a9cc | 2015-07-23 15:08:39 +0300 | [diff] [blame] | 532 | return id; |
Tomas Winkler | c93b76b | 2015-05-07 15:54:02 +0300 | [diff] [blame] | 533 | } |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 534 | |
| 535 | id++; |
| 536 | } |
| 537 | |
Tomas Winkler | 688a9cc | 2015-07-23 15:08:39 +0300 | [diff] [blame] | 538 | return NULL; |
| 539 | } |
| 540 | |
| 541 | /** |
| 542 | * mei_cl_device_match - device match function |
| 543 | * |
| 544 | * @dev: device |
| 545 | * @drv: driver |
| 546 | * |
| 547 | * Return: 1 if matching device was found 0 otherwise |
| 548 | */ |
| 549 | static int mei_cl_device_match(struct device *dev, struct device_driver *drv) |
| 550 | { |
| 551 | struct mei_cl_device *cldev = to_mei_cl_device(dev); |
| 552 | struct mei_cl_driver *cldrv = to_mei_cl_driver(drv); |
| 553 | const struct mei_cl_device_id *found_id; |
| 554 | |
| 555 | if (!cldev) |
| 556 | return 0; |
| 557 | |
Tomas Winkler | 71ce789 | 2015-07-23 15:08:43 +0300 | [diff] [blame] | 558 | if (!cldev->do_match) |
| 559 | return 0; |
| 560 | |
Tomas Winkler | 688a9cc | 2015-07-23 15:08:39 +0300 | [diff] [blame] | 561 | if (!cldrv || !cldrv->id_table) |
| 562 | return 0; |
| 563 | |
| 564 | found_id = mei_cl_device_find(cldev, cldrv); |
| 565 | if (found_id) |
| 566 | return 1; |
| 567 | |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 568 | return 0; |
| 569 | } |
| 570 | |
Tomas Winkler | feb8cd0 | 2015-07-23 15:08:40 +0300 | [diff] [blame] | 571 | /** |
| 572 | * mei_cl_device_probe - bus probe function |
| 573 | * |
| 574 | * @dev: device |
| 575 | * |
| 576 | * Return: 0 on success; < 0 otherwise |
| 577 | */ |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 578 | static int mei_cl_device_probe(struct device *dev) |
| 579 | { |
Tomas Winkler | feb8cd0 | 2015-07-23 15:08:40 +0300 | [diff] [blame] | 580 | struct mei_cl_device *cldev; |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 581 | struct mei_cl_driver *cldrv; |
Tomas Winkler | feb8cd0 | 2015-07-23 15:08:40 +0300 | [diff] [blame] | 582 | const struct mei_cl_device_id *id; |
| 583 | |
| 584 | cldev = to_mei_cl_device(dev); |
| 585 | cldrv = to_mei_cl_driver(dev->driver); |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 586 | |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 587 | if (!cldev) |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 588 | return 0; |
| 589 | |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 590 | if (!cldrv || !cldrv->probe) |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 591 | return -ENODEV; |
| 592 | |
Tomas Winkler | feb8cd0 | 2015-07-23 15:08:40 +0300 | [diff] [blame] | 593 | id = mei_cl_device_find(cldev, cldrv); |
| 594 | if (!id) |
| 595 | return -ENODEV; |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 596 | |
Tomas Winkler | feb8cd0 | 2015-07-23 15:08:40 +0300 | [diff] [blame] | 597 | __module_get(THIS_MODULE); |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 598 | |
Tomas Winkler | feb8cd0 | 2015-07-23 15:08:40 +0300 | [diff] [blame] | 599 | return cldrv->probe(cldev, id); |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 600 | } |
| 601 | |
Tomas Winkler | feb8cd0 | 2015-07-23 15:08:40 +0300 | [diff] [blame] | 602 | /** |
| 603 | * mei_cl_device_remove - remove device from the bus |
| 604 | * |
| 605 | * @dev: device |
| 606 | * |
| 607 | * Return: 0 on success; < 0 otherwise |
| 608 | */ |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 609 | static int mei_cl_device_remove(struct device *dev) |
| 610 | { |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 611 | struct mei_cl_device *cldev = to_mei_cl_device(dev); |
| 612 | struct mei_cl_driver *cldrv; |
Tomas Winkler | feb8cd0 | 2015-07-23 15:08:40 +0300 | [diff] [blame] | 613 | int ret = 0; |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 614 | |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 615 | if (!cldev || !dev->driver) |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 616 | return 0; |
| 617 | |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 618 | if (cldev->event_cb) { |
| 619 | cldev->event_cb = NULL; |
| 620 | cancel_work_sync(&cldev->event_work); |
Samuel Ortiz | 3e83329 | 2013-03-27 17:29:55 +0200 | [diff] [blame] | 621 | } |
| 622 | |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 623 | cldrv = to_mei_cl_driver(dev->driver); |
Tomas Winkler | feb8cd0 | 2015-07-23 15:08:40 +0300 | [diff] [blame] | 624 | if (cldrv->remove) |
| 625 | ret = cldrv->remove(cldev); |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 626 | |
Tomas Winkler | feb8cd0 | 2015-07-23 15:08:40 +0300 | [diff] [blame] | 627 | module_put(THIS_MODULE); |
| 628 | dev->driver = NULL; |
| 629 | return ret; |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 630 | |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 631 | } |
| 632 | |
Tomas Winkler | 007d64e | 2015-05-07 15:54:03 +0300 | [diff] [blame] | 633 | static ssize_t name_show(struct device *dev, struct device_attribute *a, |
| 634 | char *buf) |
| 635 | { |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 636 | struct mei_cl_device *cldev = to_mei_cl_device(dev); |
Tomas Winkler | 007d64e | 2015-05-07 15:54:03 +0300 | [diff] [blame] | 637 | size_t len; |
| 638 | |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 639 | len = snprintf(buf, PAGE_SIZE, "%s", cldev->name); |
Tomas Winkler | 007d64e | 2015-05-07 15:54:03 +0300 | [diff] [blame] | 640 | |
| 641 | return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; |
| 642 | } |
| 643 | static DEVICE_ATTR_RO(name); |
| 644 | |
| 645 | static ssize_t uuid_show(struct device *dev, struct device_attribute *a, |
| 646 | char *buf) |
| 647 | { |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 648 | struct mei_cl_device *cldev = to_mei_cl_device(dev); |
| 649 | const uuid_le *uuid = mei_me_cl_uuid(cldev->me_cl); |
Tomas Winkler | 007d64e | 2015-05-07 15:54:03 +0300 | [diff] [blame] | 650 | size_t len; |
| 651 | |
| 652 | len = snprintf(buf, PAGE_SIZE, "%pUl", uuid); |
| 653 | |
| 654 | return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; |
| 655 | } |
| 656 | static DEVICE_ATTR_RO(uuid); |
| 657 | |
Tomas Winkler | 40b7320 | 2015-09-10 10:18:00 +0300 | [diff] [blame] | 658 | static ssize_t version_show(struct device *dev, struct device_attribute *a, |
| 659 | char *buf) |
| 660 | { |
| 661 | struct mei_cl_device *cldev = to_mei_cl_device(dev); |
| 662 | u8 version = mei_me_cl_ver(cldev->me_cl); |
| 663 | size_t len; |
| 664 | |
| 665 | len = snprintf(buf, PAGE_SIZE, "%02X", version); |
| 666 | |
| 667 | return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; |
| 668 | } |
| 669 | static DEVICE_ATTR_RO(version); |
| 670 | |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 671 | static ssize_t modalias_show(struct device *dev, struct device_attribute *a, |
| 672 | char *buf) |
| 673 | { |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 674 | struct mei_cl_device *cldev = to_mei_cl_device(dev); |
| 675 | const uuid_le *uuid = mei_me_cl_uuid(cldev->me_cl); |
Tomas Winkler | c93b76b | 2015-05-07 15:54:02 +0300 | [diff] [blame] | 676 | size_t len; |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 677 | |
Prarit Bhargava | 59796ed | 2015-09-10 10:17:59 +0300 | [diff] [blame] | 678 | len = snprintf(buf, PAGE_SIZE, "mei:%s:%pUl:", cldev->name, uuid); |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 679 | return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; |
| 680 | } |
Greg Kroah-Hartman | 32f389ec | 2013-08-23 14:24:39 -0700 | [diff] [blame] | 681 | static DEVICE_ATTR_RO(modalias); |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 682 | |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 683 | static struct attribute *mei_cldev_attrs[] = { |
Tomas Winkler | 007d64e | 2015-05-07 15:54:03 +0300 | [diff] [blame] | 684 | &dev_attr_name.attr, |
| 685 | &dev_attr_uuid.attr, |
Tomas Winkler | 40b7320 | 2015-09-10 10:18:00 +0300 | [diff] [blame] | 686 | &dev_attr_version.attr, |
Greg Kroah-Hartman | 32f389ec | 2013-08-23 14:24:39 -0700 | [diff] [blame] | 687 | &dev_attr_modalias.attr, |
| 688 | NULL, |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 689 | }; |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 690 | ATTRIBUTE_GROUPS(mei_cldev); |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 691 | |
Tomas Winkler | 38d3c00 | 2015-07-23 15:08:36 +0300 | [diff] [blame] | 692 | /** |
| 693 | * mei_cl_device_uevent - me client bus uevent handler |
| 694 | * |
| 695 | * @dev: device |
| 696 | * @env: uevent kobject |
| 697 | * |
| 698 | * Return: 0 on success -ENOMEM on when add_uevent_var fails |
| 699 | */ |
| 700 | static int mei_cl_device_uevent(struct device *dev, struct kobj_uevent_env *env) |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 701 | { |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 702 | struct mei_cl_device *cldev = to_mei_cl_device(dev); |
| 703 | const uuid_le *uuid = mei_me_cl_uuid(cldev->me_cl); |
Tomas Winkler | 40b7320 | 2015-09-10 10:18:00 +0300 | [diff] [blame] | 704 | u8 version = mei_me_cl_ver(cldev->me_cl); |
| 705 | |
| 706 | if (add_uevent_var(env, "MEI_CL_VERSION=%d", version)) |
| 707 | return -ENOMEM; |
Tomas Winkler | c93b76b | 2015-05-07 15:54:02 +0300 | [diff] [blame] | 708 | |
Tomas Winkler | 007d64e | 2015-05-07 15:54:03 +0300 | [diff] [blame] | 709 | if (add_uevent_var(env, "MEI_CL_UUID=%pUl", uuid)) |
| 710 | return -ENOMEM; |
| 711 | |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 712 | if (add_uevent_var(env, "MEI_CL_NAME=%s", cldev->name)) |
Tomas Winkler | 007d64e | 2015-05-07 15:54:03 +0300 | [diff] [blame] | 713 | return -ENOMEM; |
| 714 | |
Tomas Winkler | b26864c | 2015-09-10 10:18:01 +0300 | [diff] [blame] | 715 | if (add_uevent_var(env, "MODALIAS=mei:%s:%pUl:%02X:", |
| 716 | cldev->name, uuid, version)) |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 717 | return -ENOMEM; |
| 718 | |
| 719 | return 0; |
| 720 | } |
| 721 | |
| 722 | static struct bus_type mei_cl_bus_type = { |
| 723 | .name = "mei", |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 724 | .dev_groups = mei_cldev_groups, |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 725 | .match = mei_cl_device_match, |
| 726 | .probe = mei_cl_device_probe, |
| 727 | .remove = mei_cl_device_remove, |
Tomas Winkler | 38d3c00 | 2015-07-23 15:08:36 +0300 | [diff] [blame] | 728 | .uevent = mei_cl_device_uevent, |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 729 | }; |
| 730 | |
Tomas Winkler | 512f64d | 2015-07-23 15:08:41 +0300 | [diff] [blame] | 731 | static struct mei_device *mei_dev_bus_get(struct mei_device *bus) |
| 732 | { |
| 733 | if (bus) |
| 734 | get_device(bus->dev); |
| 735 | |
| 736 | return bus; |
| 737 | } |
| 738 | |
| 739 | static void mei_dev_bus_put(struct mei_device *bus) |
| 740 | { |
| 741 | if (bus) |
| 742 | put_device(bus->dev); |
| 743 | } |
| 744 | |
Tomas Winkler | ae48d74 | 2015-09-10 10:18:06 +0300 | [diff] [blame] | 745 | static void mei_cl_bus_dev_release(struct device *dev) |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 746 | { |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 747 | struct mei_cl_device *cldev = to_mei_cl_device(dev); |
Alexander Usyskin | d49ed64 | 2015-05-04 09:43:54 +0300 | [diff] [blame] | 748 | |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 749 | if (!cldev) |
Alexander Usyskin | d49ed64 | 2015-05-04 09:43:54 +0300 | [diff] [blame] | 750 | return; |
| 751 | |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 752 | mei_me_cl_put(cldev->me_cl); |
Tomas Winkler | 512f64d | 2015-07-23 15:08:41 +0300 | [diff] [blame] | 753 | mei_dev_bus_put(cldev->bus); |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 754 | kfree(cldev); |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 755 | } |
| 756 | |
| 757 | static struct device_type mei_cl_device_type = { |
Tomas Winkler | ae48d74 | 2015-09-10 10:18:06 +0300 | [diff] [blame] | 758 | .release = mei_cl_bus_dev_release, |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 759 | }; |
| 760 | |
Tomas Winkler | 71ce789 | 2015-07-23 15:08:43 +0300 | [diff] [blame] | 761 | /** |
Tomas Winkler | 213dd19 | 2015-10-28 14:34:35 +0200 | [diff] [blame] | 762 | * mei_cl_bus_set_name - set device name for me client device |
| 763 | * |
| 764 | * @cldev: me client device |
| 765 | */ |
| 766 | static inline void mei_cl_bus_set_name(struct mei_cl_device *cldev) |
| 767 | { |
| 768 | dev_set_name(&cldev->dev, "mei:%s:%pUl:%02X", |
| 769 | cldev->name, |
| 770 | mei_me_cl_uuid(cldev->me_cl), |
| 771 | mei_me_cl_ver(cldev->me_cl)); |
| 772 | } |
| 773 | |
| 774 | /** |
Tomas Winkler | ae48d74 | 2015-09-10 10:18:06 +0300 | [diff] [blame] | 775 | * mei_cl_bus_dev_alloc - initialize and allocate mei client device |
Tomas Winkler | 71ce789 | 2015-07-23 15:08:43 +0300 | [diff] [blame] | 776 | * |
| 777 | * @bus: mei device |
| 778 | * @me_cl: me client |
| 779 | * |
| 780 | * Return: allocated device structur or NULL on allocation failure |
| 781 | */ |
Tomas Winkler | ae48d74 | 2015-09-10 10:18:06 +0300 | [diff] [blame] | 782 | static struct mei_cl_device *mei_cl_bus_dev_alloc(struct mei_device *bus, |
| 783 | struct mei_me_client *me_cl) |
Tomas Winkler | 71ce789 | 2015-07-23 15:08:43 +0300 | [diff] [blame] | 784 | { |
| 785 | struct mei_cl_device *cldev; |
| 786 | |
| 787 | cldev = kzalloc(sizeof(struct mei_cl_device), GFP_KERNEL); |
| 788 | if (!cldev) |
| 789 | return NULL; |
| 790 | |
| 791 | device_initialize(&cldev->dev); |
| 792 | cldev->dev.parent = bus->dev; |
| 793 | cldev->dev.bus = &mei_cl_bus_type; |
| 794 | cldev->dev.type = &mei_cl_device_type; |
| 795 | cldev->bus = mei_dev_bus_get(bus); |
| 796 | cldev->me_cl = mei_me_cl_get(me_cl); |
Tomas Winkler | 213dd19 | 2015-10-28 14:34:35 +0200 | [diff] [blame] | 797 | mei_cl_bus_set_name(cldev); |
Tomas Winkler | 71ce789 | 2015-07-23 15:08:43 +0300 | [diff] [blame] | 798 | cldev->is_added = 0; |
| 799 | INIT_LIST_HEAD(&cldev->bus_list); |
| 800 | |
| 801 | return cldev; |
| 802 | } |
| 803 | |
| 804 | /** |
| 805 | * mei_cl_dev_setup - setup me client device |
| 806 | * run fix up routines and set the device name |
| 807 | * |
| 808 | * @bus: mei device |
| 809 | * @cldev: me client device |
| 810 | * |
| 811 | * Return: true if the device is eligible for enumeration |
| 812 | */ |
Tomas Winkler | ae48d74 | 2015-09-10 10:18:06 +0300 | [diff] [blame] | 813 | static bool mei_cl_bus_dev_setup(struct mei_device *bus, |
| 814 | struct mei_cl_device *cldev) |
Tomas Winkler | 71ce789 | 2015-07-23 15:08:43 +0300 | [diff] [blame] | 815 | { |
| 816 | cldev->do_match = 1; |
Tomas Winkler | ae48d74 | 2015-09-10 10:18:06 +0300 | [diff] [blame] | 817 | mei_cl_bus_dev_fixup(cldev); |
Tomas Winkler | 71ce789 | 2015-07-23 15:08:43 +0300 | [diff] [blame] | 818 | |
Tomas Winkler | 213dd19 | 2015-10-28 14:34:35 +0200 | [diff] [blame] | 819 | /* the device name can change during fix up */ |
Tomas Winkler | 71ce789 | 2015-07-23 15:08:43 +0300 | [diff] [blame] | 820 | if (cldev->do_match) |
Tomas Winkler | 213dd19 | 2015-10-28 14:34:35 +0200 | [diff] [blame] | 821 | mei_cl_bus_set_name(cldev); |
Tomas Winkler | 71ce789 | 2015-07-23 15:08:43 +0300 | [diff] [blame] | 822 | |
| 823 | return cldev->do_match == 1; |
| 824 | } |
| 825 | |
| 826 | /** |
| 827 | * mei_cl_bus_dev_add - add me client devices |
| 828 | * |
| 829 | * @cldev: me client device |
| 830 | * |
| 831 | * Return: 0 on success; < 0 on failre |
| 832 | */ |
| 833 | static int mei_cl_bus_dev_add(struct mei_cl_device *cldev) |
| 834 | { |
| 835 | int ret; |
| 836 | |
Tomas Winkler | b26864c | 2015-09-10 10:18:01 +0300 | [diff] [blame] | 837 | dev_dbg(cldev->bus->dev, "adding %pUL:%02X\n", |
| 838 | mei_me_cl_uuid(cldev->me_cl), |
| 839 | mei_me_cl_ver(cldev->me_cl)); |
Tomas Winkler | 71ce789 | 2015-07-23 15:08:43 +0300 | [diff] [blame] | 840 | ret = device_add(&cldev->dev); |
| 841 | if (!ret) |
| 842 | cldev->is_added = 1; |
| 843 | |
| 844 | return ret; |
| 845 | } |
| 846 | |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 847 | /** |
| 848 | * mei_cl_bus_dev_stop - stop the driver |
| 849 | * |
| 850 | * @cldev: me client device |
| 851 | */ |
| 852 | static void mei_cl_bus_dev_stop(struct mei_cl_device *cldev) |
| 853 | { |
| 854 | if (cldev->is_added) |
| 855 | device_release_driver(&cldev->dev); |
| 856 | } |
| 857 | |
| 858 | /** |
| 859 | * mei_cl_bus_dev_destroy - destroy me client devices object |
| 860 | * |
| 861 | * @cldev: me client device |
Tomas Winkler | 2da55cf | 2015-10-28 14:34:34 +0200 | [diff] [blame] | 862 | * |
| 863 | * Locking: called under "dev->cl_bus_lock" lock |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 864 | */ |
| 865 | static void mei_cl_bus_dev_destroy(struct mei_cl_device *cldev) |
| 866 | { |
Tomas Winkler | 2da55cf | 2015-10-28 14:34:34 +0200 | [diff] [blame] | 867 | |
| 868 | WARN_ON(!mutex_is_locked(&cldev->bus->cl_bus_lock)); |
| 869 | |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 870 | if (!cldev->is_added) |
| 871 | return; |
| 872 | |
| 873 | device_del(&cldev->dev); |
| 874 | |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 875 | list_del_init(&cldev->bus_list); |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 876 | |
| 877 | cldev->is_added = 0; |
| 878 | put_device(&cldev->dev); |
| 879 | } |
| 880 | |
| 881 | /** |
| 882 | * mei_cl_bus_remove_device - remove a devices form the bus |
| 883 | * |
| 884 | * @cldev: me client device |
| 885 | */ |
| 886 | static void mei_cl_bus_remove_device(struct mei_cl_device *cldev) |
| 887 | { |
| 888 | mei_cl_bus_dev_stop(cldev); |
| 889 | mei_cl_bus_dev_destroy(cldev); |
| 890 | } |
| 891 | |
| 892 | /** |
| 893 | * mei_cl_bus_remove_devices - remove all devices form the bus |
| 894 | * |
| 895 | * @bus: mei device |
| 896 | */ |
| 897 | void mei_cl_bus_remove_devices(struct mei_device *bus) |
| 898 | { |
| 899 | struct mei_cl_device *cldev, *next; |
| 900 | |
Tomas Winkler | 2da55cf | 2015-10-28 14:34:34 +0200 | [diff] [blame] | 901 | mutex_lock(&bus->cl_bus_lock); |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 902 | list_for_each_entry_safe(cldev, next, &bus->device_list, bus_list) |
| 903 | mei_cl_bus_remove_device(cldev); |
Tomas Winkler | 2da55cf | 2015-10-28 14:34:34 +0200 | [diff] [blame] | 904 | mutex_unlock(&bus->cl_bus_lock); |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 905 | } |
| 906 | |
| 907 | |
| 908 | /** |
Tomas Winkler | ae48d74 | 2015-09-10 10:18:06 +0300 | [diff] [blame] | 909 | * mei_cl_bus_dev_init - allocate and initializes an mei client devices |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 910 | * based on me client |
| 911 | * |
| 912 | * @bus: mei device |
| 913 | * @me_cl: me client |
Tomas Winkler | 2da55cf | 2015-10-28 14:34:34 +0200 | [diff] [blame] | 914 | * |
| 915 | * Locking: called under "dev->cl_bus_lock" lock |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 916 | */ |
Tomas Winkler | ae48d74 | 2015-09-10 10:18:06 +0300 | [diff] [blame] | 917 | static void mei_cl_bus_dev_init(struct mei_device *bus, |
| 918 | struct mei_me_client *me_cl) |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 919 | { |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 920 | struct mei_cl_device *cldev; |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 921 | |
Tomas Winkler | 2da55cf | 2015-10-28 14:34:34 +0200 | [diff] [blame] | 922 | WARN_ON(!mutex_is_locked(&bus->cl_bus_lock)); |
| 923 | |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 924 | dev_dbg(bus->dev, "initializing %pUl", mei_me_cl_uuid(me_cl)); |
| 925 | |
| 926 | if (me_cl->bus_added) |
| 927 | return; |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 928 | |
Tomas Winkler | ae48d74 | 2015-09-10 10:18:06 +0300 | [diff] [blame] | 929 | cldev = mei_cl_bus_dev_alloc(bus, me_cl); |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 930 | if (!cldev) |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 931 | return; |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 932 | |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 933 | me_cl->bus_added = true; |
| 934 | list_add_tail(&cldev->bus_list, &bus->device_list); |
Tomas Winkler | c93b76b | 2015-05-07 15:54:02 +0300 | [diff] [blame] | 935 | |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 936 | } |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 937 | |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 938 | /** |
| 939 | * mei_cl_bus_rescan - scan me clients list and add create |
| 940 | * devices for eligible clients |
| 941 | * |
| 942 | * @bus: mei device |
| 943 | */ |
| 944 | void mei_cl_bus_rescan(struct mei_device *bus) |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 945 | { |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 946 | struct mei_cl_device *cldev, *n; |
| 947 | struct mei_me_client *me_cl; |
| 948 | |
Tomas Winkler | 2da55cf | 2015-10-28 14:34:34 +0200 | [diff] [blame] | 949 | mutex_lock(&bus->cl_bus_lock); |
| 950 | |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 951 | down_read(&bus->me_clients_rwsem); |
| 952 | list_for_each_entry(me_cl, &bus->me_clients, list) |
Tomas Winkler | ae48d74 | 2015-09-10 10:18:06 +0300 | [diff] [blame] | 953 | mei_cl_bus_dev_init(bus, me_cl); |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 954 | up_read(&bus->me_clients_rwsem); |
| 955 | |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 956 | list_for_each_entry_safe(cldev, n, &bus->device_list, bus_list) { |
| 957 | |
| 958 | if (!mei_me_cl_is_active(cldev->me_cl)) { |
| 959 | mei_cl_bus_remove_device(cldev); |
| 960 | continue; |
| 961 | } |
| 962 | |
| 963 | if (cldev->is_added) |
| 964 | continue; |
| 965 | |
Tomas Winkler | ae48d74 | 2015-09-10 10:18:06 +0300 | [diff] [blame] | 966 | if (mei_cl_bus_dev_setup(bus, cldev)) |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 967 | mei_cl_bus_dev_add(cldev); |
| 968 | else { |
| 969 | list_del_init(&cldev->bus_list); |
| 970 | put_device(&cldev->dev); |
| 971 | } |
| 972 | } |
| 973 | mutex_unlock(&bus->cl_bus_lock); |
| 974 | |
| 975 | dev_dbg(bus->dev, "rescan end"); |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 976 | } |
Samuel Ortiz | 333e4ee | 2013-03-27 17:29:54 +0200 | [diff] [blame] | 977 | |
Alexander Usyskin | a816a00 | 2016-02-07 23:35:41 +0200 | [diff] [blame] | 978 | void mei_cl_bus_rescan_work(struct work_struct *work) |
| 979 | { |
| 980 | struct mei_device *bus = |
| 981 | container_of(work, struct mei_device, bus_rescan_work); |
Alexander Usyskin | 025fb79 | 2016-02-07 23:35:43 +0200 | [diff] [blame] | 982 | struct mei_me_client *me_cl; |
| 983 | |
| 984 | mutex_lock(&bus->device_lock); |
| 985 | me_cl = mei_me_cl_by_uuid(bus, &mei_amthif_guid); |
| 986 | if (me_cl) |
| 987 | mei_amthif_host_init(bus, me_cl); |
| 988 | mei_me_cl_put(me_cl); |
| 989 | mutex_unlock(&bus->device_lock); |
Alexander Usyskin | a816a00 | 2016-02-07 23:35:41 +0200 | [diff] [blame] | 990 | |
| 991 | mei_cl_bus_rescan(bus); |
| 992 | } |
| 993 | |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 994 | int __mei_cldev_driver_register(struct mei_cl_driver *cldrv, |
| 995 | struct module *owner) |
Samuel Ortiz | 333e4ee | 2013-03-27 17:29:54 +0200 | [diff] [blame] | 996 | { |
| 997 | int err; |
| 998 | |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 999 | cldrv->driver.name = cldrv->name; |
| 1000 | cldrv->driver.owner = owner; |
| 1001 | cldrv->driver.bus = &mei_cl_bus_type; |
Samuel Ortiz | 333e4ee | 2013-03-27 17:29:54 +0200 | [diff] [blame] | 1002 | |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 1003 | err = driver_register(&cldrv->driver); |
Samuel Ortiz | 333e4ee | 2013-03-27 17:29:54 +0200 | [diff] [blame] | 1004 | if (err) |
| 1005 | return err; |
| 1006 | |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 1007 | pr_debug("mei: driver [%s] registered\n", cldrv->driver.name); |
Samuel Ortiz | 333e4ee | 2013-03-27 17:29:54 +0200 | [diff] [blame] | 1008 | |
| 1009 | return 0; |
| 1010 | } |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 1011 | EXPORT_SYMBOL_GPL(__mei_cldev_driver_register); |
Samuel Ortiz | 333e4ee | 2013-03-27 17:29:54 +0200 | [diff] [blame] | 1012 | |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 1013 | void mei_cldev_driver_unregister(struct mei_cl_driver *cldrv) |
Samuel Ortiz | 333e4ee | 2013-03-27 17:29:54 +0200 | [diff] [blame] | 1014 | { |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 1015 | driver_unregister(&cldrv->driver); |
Samuel Ortiz | 333e4ee | 2013-03-27 17:29:54 +0200 | [diff] [blame] | 1016 | |
Tomas Winkler | b37719c3 | 2015-07-23 15:08:33 +0300 | [diff] [blame] | 1017 | pr_debug("mei: driver [%s] unregistered\n", cldrv->driver.name); |
Samuel Ortiz | 333e4ee | 2013-03-27 17:29:54 +0200 | [diff] [blame] | 1018 | } |
Tomas Winkler | d49dc5e | 2015-09-10 10:18:05 +0300 | [diff] [blame] | 1019 | EXPORT_SYMBOL_GPL(mei_cldev_driver_unregister); |
Samuel Ortiz | 3e83329 | 2013-03-27 17:29:55 +0200 | [diff] [blame] | 1020 | |
Tomas Winkler | 6009595 | 2015-07-23 15:08:47 +0300 | [diff] [blame] | 1021 | |
Samuel Ortiz | cf3baef | 2013-03-27 17:29:57 +0200 | [diff] [blame] | 1022 | int __init mei_cl_bus_init(void) |
| 1023 | { |
| 1024 | return bus_register(&mei_cl_bus_type); |
| 1025 | } |
| 1026 | |
| 1027 | void __exit mei_cl_bus_exit(void) |
| 1028 | { |
| 1029 | bus_unregister(&mei_cl_bus_type); |
| 1030 | } |