cros_ec_lightbar.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. // SPDX-License-Identifier: GPL-2.0+
  2. // Expose the Chromebook Pixel lightbar to userspace
  3. //
  4. // Copyright (C) 2014 Google, Inc.
  5. #include <linux/ctype.h>
  6. #include <linux/delay.h>
  7. #include <linux/device.h>
  8. #include <linux/fs.h>
  9. #include <linux/kobject.h>
  10. #include <linux/kstrtox.h>
  11. #include <linux/mod_devicetable.h>
  12. #include <linux/module.h>
  13. #include <linux/platform_data/cros_ec_commands.h>
  14. #include <linux/platform_data/cros_ec_proto.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/sched.h>
  17. #include <linux/types.h>
  18. #include <linux/uaccess.h>
  19. #include <linux/slab.h>
  20. #define DRV_NAME "cros-ec-lightbar"
  21. /* Rate-limit the lightbar interface to prevent DoS. */
  22. static unsigned long lb_interval_jiffies = 50 * HZ / 1000;
  23. /*
  24. * Whether or not we have given userspace control of the lightbar.
  25. * If this is true, we won't do anything during suspend/resume.
  26. */
  27. static bool userspace_control;
  28. /*
  29. * Whether or not the lightbar supports the manual suspend commands.
  30. * The Pixel 2013 (Link) does not while all other devices with a
  31. * lightbar do.
  32. */
  33. static bool has_manual_suspend;
  34. /*
  35. * Lightbar version
  36. */
  37. static int lb_version;
  38. static ssize_t interval_msec_show(struct device *dev,
  39. struct device_attribute *attr, char *buf)
  40. {
  41. unsigned long msec = lb_interval_jiffies * 1000 / HZ;
  42. return sysfs_emit(buf, "%lu\n", msec);
  43. }
  44. static ssize_t interval_msec_store(struct device *dev,
  45. struct device_attribute *attr,
  46. const char *buf, size_t count)
  47. {
  48. unsigned long msec;
  49. if (kstrtoul(buf, 0, &msec))
  50. return -EINVAL;
  51. lb_interval_jiffies = msec * HZ / 1000;
  52. return count;
  53. }
  54. static DEFINE_MUTEX(lb_mutex);
  55. /* Return 0 if able to throttle correctly, error otherwise */
  56. static int lb_throttle(void)
  57. {
  58. static unsigned long last_access;
  59. unsigned long now, next_timeslot;
  60. long delay;
  61. int ret = 0;
  62. mutex_lock(&lb_mutex);
  63. now = jiffies;
  64. next_timeslot = last_access + lb_interval_jiffies;
  65. if (time_before(now, next_timeslot)) {
  66. delay = (long)(next_timeslot) - (long)now;
  67. set_current_state(TASK_INTERRUPTIBLE);
  68. if (schedule_timeout(delay) > 0) {
  69. /* interrupted - just abort */
  70. ret = -EINTR;
  71. goto out;
  72. }
  73. now = jiffies;
  74. }
  75. last_access = now;
  76. out:
  77. mutex_unlock(&lb_mutex);
  78. return ret;
  79. }
  80. static struct cros_ec_command *alloc_lightbar_cmd_msg(struct cros_ec_dev *ec)
  81. {
  82. int len = max(ec->ec_dev->max_response, ec->ec_dev->max_request);
  83. struct cros_ec_command *msg;
  84. msg = kmalloc(sizeof(*msg) + len, GFP_KERNEL);
  85. if (!msg)
  86. return NULL;
  87. msg->version = 0;
  88. msg->command = EC_CMD_LIGHTBAR_CMD + ec->cmd_offset;
  89. /*
  90. * Default sizes for regular commands.
  91. * Can be set smaller to optimize transfer,
  92. * larger when sending large light sequences.
  93. */
  94. msg->outsize = sizeof(struct ec_params_lightbar);
  95. msg->insize = sizeof(struct ec_response_lightbar);
  96. return msg;
  97. }
  98. static int get_lightbar_version(struct cros_ec_dev *ec,
  99. uint32_t *ver_ptr, uint32_t *flg_ptr)
  100. {
  101. struct ec_params_lightbar *param;
  102. struct ec_response_lightbar *resp;
  103. struct cros_ec_command *msg;
  104. int ret;
  105. msg = alloc_lightbar_cmd_msg(ec);
  106. if (!msg)
  107. return 0;
  108. param = (struct ec_params_lightbar *)msg->data;
  109. param->cmd = LIGHTBAR_CMD_VERSION;
  110. msg->outsize = sizeof(param->cmd);
  111. msg->insize = sizeof(resp->version);
  112. ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
  113. if (ret < 0 && ret != -EINVAL) {
  114. ret = 0;
  115. goto exit;
  116. }
  117. switch (msg->result) {
  118. case EC_RES_INVALID_PARAM:
  119. /* Pixel had no version command. */
  120. if (ver_ptr)
  121. *ver_ptr = 0;
  122. if (flg_ptr)
  123. *flg_ptr = 0;
  124. ret = 1;
  125. goto exit;
  126. case EC_RES_SUCCESS:
  127. resp = (struct ec_response_lightbar *)msg->data;
  128. /* Future devices w/lightbars should implement this command */
  129. if (ver_ptr)
  130. *ver_ptr = resp->version.num;
  131. if (flg_ptr)
  132. *flg_ptr = resp->version.flags;
  133. ret = 1;
  134. goto exit;
  135. }
  136. /* Anything else (ie, EC_RES_INVALID_COMMAND) - no lightbar */
  137. ret = 0;
  138. exit:
  139. kfree(msg);
  140. return ret;
  141. }
  142. static ssize_t version_show(struct device *dev,
  143. struct device_attribute *attr, char *buf)
  144. {
  145. uint32_t version = 0, flags = 0;
  146. struct cros_ec_dev *ec = to_cros_ec_dev(dev);
  147. int ret;
  148. ret = lb_throttle();
  149. if (ret)
  150. return ret;
  151. /* This should always succeed, because we check during init. */
  152. if (!get_lightbar_version(ec, &version, &flags))
  153. return -EIO;
  154. return sysfs_emit(buf, "%d %d\n", version, flags);
  155. }
  156. static ssize_t num_segments_show(struct device *dev,
  157. struct device_attribute *attr, char *buf)
  158. {
  159. struct ec_params_lightbar *param;
  160. struct ec_response_lightbar *resp;
  161. struct cros_ec_command *msg;
  162. struct cros_ec_dev *ec = to_cros_ec_dev(dev);
  163. uint32_t num = 0;
  164. int ret;
  165. ret = lb_throttle();
  166. if (ret)
  167. return ret;
  168. msg = alloc_lightbar_cmd_msg(ec);
  169. if (!msg)
  170. return -ENOMEM;
  171. param = (struct ec_params_lightbar *)msg->data;
  172. param->cmd = LIGHTBAR_CMD_GET_PARAMS_V3;
  173. msg->outsize = sizeof(param->cmd);
  174. msg->insize = sizeof(resp->get_params_v3);
  175. ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
  176. if (ret < 0 && ret != -EINVAL)
  177. goto exit;
  178. if (msg->result == EC_RES_SUCCESS) {
  179. resp = (struct ec_response_lightbar *)msg->data;
  180. num = resp->get_params_v3.reported_led_num;
  181. }
  182. /*
  183. * Anything else (ie, EC_RES_INVALID_COMMAND) - no direct control over
  184. * LEDs, return that no leds are supported.
  185. */
  186. ret = sysfs_emit(buf, "%u\n", num);
  187. exit:
  188. kfree(msg);
  189. return ret;
  190. }
  191. static ssize_t brightness_store(struct device *dev,
  192. struct device_attribute *attr,
  193. const char *buf, size_t count)
  194. {
  195. struct ec_params_lightbar *param;
  196. struct cros_ec_command *msg;
  197. int ret;
  198. unsigned int val;
  199. struct cros_ec_dev *ec = to_cros_ec_dev(dev);
  200. if (kstrtouint(buf, 0, &val))
  201. return -EINVAL;
  202. msg = alloc_lightbar_cmd_msg(ec);
  203. if (!msg)
  204. return -ENOMEM;
  205. param = (struct ec_params_lightbar *)msg->data;
  206. param->cmd = LIGHTBAR_CMD_SET_BRIGHTNESS;
  207. param->set_brightness.num = val;
  208. ret = lb_throttle();
  209. if (ret)
  210. goto exit;
  211. ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
  212. if (ret < 0)
  213. goto exit;
  214. ret = count;
  215. exit:
  216. kfree(msg);
  217. return ret;
  218. }
  219. /*
  220. * We expect numbers, and we'll keep reading until we find them, skipping over
  221. * any whitespace (sysfs guarantees that the input is null-terminated). Every
  222. * four numbers are sent to the lightbar as <LED,R,G,B>. We fail at the first
  223. * parsing error, if we don't parse any numbers, or if we have numbers left
  224. * over.
  225. */
  226. static ssize_t led_rgb_store(struct device *dev, struct device_attribute *attr,
  227. const char *buf, size_t count)
  228. {
  229. struct ec_params_lightbar *param;
  230. struct cros_ec_command *msg;
  231. struct cros_ec_dev *ec = to_cros_ec_dev(dev);
  232. unsigned int val[4];
  233. int ret, i = 0, j = 0, ok = 0;
  234. msg = alloc_lightbar_cmd_msg(ec);
  235. if (!msg)
  236. return -ENOMEM;
  237. do {
  238. /* Skip any whitespace */
  239. while (*buf && isspace(*buf))
  240. buf++;
  241. if (!*buf)
  242. break;
  243. ret = sscanf(buf, "%i", &val[i++]);
  244. if (ret == 0)
  245. goto exit;
  246. if (i == 4) {
  247. param = (struct ec_params_lightbar *)msg->data;
  248. param->cmd = LIGHTBAR_CMD_SET_RGB;
  249. param->set_rgb.led = val[0];
  250. param->set_rgb.red = val[1];
  251. param->set_rgb.green = val[2];
  252. param->set_rgb.blue = val[3];
  253. /*
  254. * Throttle only the first of every four transactions,
  255. * so that the user can update all four LEDs at once.
  256. */
  257. if ((j++ % 4) == 0) {
  258. ret = lb_throttle();
  259. if (ret)
  260. goto exit;
  261. }
  262. ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
  263. if (ret < 0)
  264. goto exit;
  265. i = 0;
  266. ok = 1;
  267. }
  268. /* Skip over the number we just read */
  269. while (*buf && !isspace(*buf))
  270. buf++;
  271. } while (*buf);
  272. exit:
  273. kfree(msg);
  274. return (ok && i == 0) ? count : -EINVAL;
  275. }
  276. static char const *seqname[] = {
  277. "ERROR", "S5", "S3", "S0", "S5S3", "S3S0",
  278. "S0S3", "S3S5", "STOP", "RUN", "KONAMI",
  279. "TAP", "PROGRAM",
  280. };
  281. static ssize_t sequence_show(struct device *dev,
  282. struct device_attribute *attr, char *buf)
  283. {
  284. struct ec_params_lightbar *param;
  285. struct ec_response_lightbar *resp;
  286. struct cros_ec_command *msg;
  287. int ret;
  288. struct cros_ec_dev *ec = to_cros_ec_dev(dev);
  289. msg = alloc_lightbar_cmd_msg(ec);
  290. if (!msg)
  291. return -ENOMEM;
  292. param = (struct ec_params_lightbar *)msg->data;
  293. param->cmd = LIGHTBAR_CMD_GET_SEQ;
  294. ret = lb_throttle();
  295. if (ret)
  296. goto exit;
  297. ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
  298. if (ret < 0) {
  299. ret = sysfs_emit(buf, "XFER / EC ERROR %d / %d\n", ret, msg->result);
  300. goto exit;
  301. }
  302. resp = (struct ec_response_lightbar *)msg->data;
  303. if (resp->get_seq.num >= ARRAY_SIZE(seqname))
  304. ret = sysfs_emit(buf, "%d\n", resp->get_seq.num);
  305. else
  306. ret = sysfs_emit(buf, "%s\n", seqname[resp->get_seq.num]);
  307. exit:
  308. kfree(msg);
  309. return ret;
  310. }
  311. static int lb_send_empty_cmd(struct cros_ec_dev *ec, uint8_t cmd)
  312. {
  313. struct ec_params_lightbar *param;
  314. struct cros_ec_command *msg;
  315. int ret;
  316. msg = alloc_lightbar_cmd_msg(ec);
  317. if (!msg)
  318. return -ENOMEM;
  319. param = (struct ec_params_lightbar *)msg->data;
  320. param->cmd = cmd;
  321. ret = lb_throttle();
  322. if (ret)
  323. goto error;
  324. ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
  325. if (ret < 0)
  326. goto error;
  327. ret = 0;
  328. error:
  329. kfree(msg);
  330. return ret;
  331. }
  332. static int lb_manual_suspend_ctrl(struct cros_ec_dev *ec, uint8_t enable)
  333. {
  334. struct ec_params_lightbar *param;
  335. struct cros_ec_command *msg;
  336. int ret;
  337. msg = alloc_lightbar_cmd_msg(ec);
  338. if (!msg)
  339. return -ENOMEM;
  340. param = (struct ec_params_lightbar *)msg->data;
  341. param->cmd = LIGHTBAR_CMD_MANUAL_SUSPEND_CTRL;
  342. param->manual_suspend_ctrl.enable = enable;
  343. ret = lb_throttle();
  344. if (ret)
  345. goto error;
  346. ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
  347. if (ret < 0)
  348. goto error;
  349. ret = 0;
  350. error:
  351. kfree(msg);
  352. return ret;
  353. }
  354. static ssize_t sequence_store(struct device *dev, struct device_attribute *attr,
  355. const char *buf, size_t count)
  356. {
  357. struct ec_params_lightbar *param;
  358. struct cros_ec_command *msg;
  359. unsigned int num;
  360. int ret, len;
  361. struct cros_ec_dev *ec = to_cros_ec_dev(dev);
  362. for (len = 0; len < count; len++)
  363. if (!isalnum(buf[len]))
  364. break;
  365. for (num = 0; num < ARRAY_SIZE(seqname); num++)
  366. if (!strncasecmp(seqname[num], buf, len))
  367. break;
  368. if (num >= ARRAY_SIZE(seqname)) {
  369. ret = kstrtouint(buf, 0, &num);
  370. if (ret)
  371. return ret;
  372. }
  373. msg = alloc_lightbar_cmd_msg(ec);
  374. if (!msg)
  375. return -ENOMEM;
  376. param = (struct ec_params_lightbar *)msg->data;
  377. param->cmd = LIGHTBAR_CMD_SEQ;
  378. param->seq.num = num;
  379. ret = lb_throttle();
  380. if (ret)
  381. goto exit;
  382. ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
  383. if (ret < 0)
  384. goto exit;
  385. ret = count;
  386. exit:
  387. kfree(msg);
  388. return ret;
  389. }
  390. static ssize_t program_store(struct device *dev, struct device_attribute *attr,
  391. const char *buf, size_t count)
  392. {
  393. size_t extra_bytes, max_size;
  394. struct ec_params_lightbar *param;
  395. struct cros_ec_command *msg;
  396. struct cros_ec_dev *ec = to_cros_ec_dev(dev);
  397. int ret;
  398. /*
  399. * We might need to reject the program for size reasons. The EC
  400. * enforces a maximum program size, but we also don't want to try
  401. * and send a program that is too big for the protocol. In order
  402. * to ensure the latter, we also need to ensure we have extra bytes
  403. * to represent the rest of the packet.
  404. * With V3, larger program can be sent, limited only by the EC.
  405. * Only the protocol limit the payload size.
  406. */
  407. if (lb_version < 3) {
  408. extra_bytes = sizeof(*param) - sizeof(param->set_program.data);
  409. max_size = min(EC_LB_PROG_LEN, ec->ec_dev->max_request - extra_bytes);
  410. if (count > max_size) {
  411. dev_err(dev, "Program is %zu bytes, too long to send (max: %zu)",
  412. count, max_size);
  413. return -EINVAL;
  414. }
  415. } else {
  416. extra_bytes = offsetof(typeof(*param), set_program_ex) +
  417. sizeof(param->set_program_ex);
  418. max_size = ec->ec_dev->max_request - extra_bytes;
  419. }
  420. msg = alloc_lightbar_cmd_msg(ec);
  421. if (!msg)
  422. return -ENOMEM;
  423. ret = lb_throttle();
  424. if (ret)
  425. goto exit;
  426. param = (struct ec_params_lightbar *)msg->data;
  427. if (lb_version < 3) {
  428. dev_info(dev, "Copying %zu byte program to EC", count);
  429. param->cmd = LIGHTBAR_CMD_SET_PROGRAM;
  430. param->set_program.size = count;
  431. memcpy(param->set_program.data, buf, count);
  432. /*
  433. * We need to set the message size manually or else it will use
  434. * EC_LB_PROG_LEN. This might be too long, and the program
  435. * is unlikely to use all of the space.
  436. */
  437. msg->outsize = count + extra_bytes;
  438. ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
  439. if (ret < 0)
  440. goto exit;
  441. } else {
  442. size_t offset = 0;
  443. size_t payload = 0;
  444. param->cmd = LIGHTBAR_CMD_SET_PROGRAM_EX;
  445. while (offset < count) {
  446. payload = min(max_size, count - offset);
  447. param->set_program_ex.offset = offset;
  448. param->set_program_ex.size = payload;
  449. memcpy(param->set_program_ex.data, &buf[offset], payload);
  450. msg->outsize = payload + extra_bytes;
  451. ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
  452. if (ret < 0)
  453. goto exit;
  454. offset += payload;
  455. }
  456. }
  457. ret = count;
  458. exit:
  459. kfree(msg);
  460. return ret;
  461. }
  462. static ssize_t userspace_control_show(struct device *dev,
  463. struct device_attribute *attr,
  464. char *buf)
  465. {
  466. return sysfs_emit(buf, "%d\n", userspace_control);
  467. }
  468. static ssize_t userspace_control_store(struct device *dev,
  469. struct device_attribute *attr,
  470. const char *buf,
  471. size_t count)
  472. {
  473. bool enable;
  474. int ret;
  475. ret = kstrtobool(buf, &enable);
  476. if (ret < 0)
  477. return ret;
  478. userspace_control = enable;
  479. return count;
  480. }
  481. /* Module initialization */
  482. static DEVICE_ATTR_RW(interval_msec);
  483. static DEVICE_ATTR_RO(num_segments);
  484. static DEVICE_ATTR_RO(version);
  485. static DEVICE_ATTR_WO(brightness);
  486. static DEVICE_ATTR_WO(led_rgb);
  487. static DEVICE_ATTR_RW(sequence);
  488. static DEVICE_ATTR_WO(program);
  489. static DEVICE_ATTR_RW(userspace_control);
  490. static struct attribute *__lb_cmds_attrs[] = {
  491. &dev_attr_interval_msec.attr,
  492. &dev_attr_num_segments.attr,
  493. &dev_attr_version.attr,
  494. &dev_attr_brightness.attr,
  495. &dev_attr_led_rgb.attr,
  496. &dev_attr_sequence.attr,
  497. &dev_attr_program.attr,
  498. &dev_attr_userspace_control.attr,
  499. NULL,
  500. };
  501. static const struct attribute_group cros_ec_lightbar_attr_group = {
  502. .name = "lightbar",
  503. .attrs = __lb_cmds_attrs,
  504. };
  505. static int cros_ec_lightbar_probe(struct platform_device *pd)
  506. {
  507. struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent);
  508. struct cros_ec_platform *pdata = dev_get_platdata(ec_dev->dev);
  509. struct device *dev = &pd->dev;
  510. int ret;
  511. /*
  512. * Only instantiate the lightbar if the EC name is 'cros_ec'. Other EC
  513. * devices like 'cros_pd' doesn't have a lightbar.
  514. */
  515. if (strcmp(pdata->ec_name, CROS_EC_DEV_NAME) != 0)
  516. return -ENODEV;
  517. /*
  518. * Ask then for the lightbar version, if it's 0 then the 'cros_ec'
  519. * doesn't have a lightbar.
  520. */
  521. if (!get_lightbar_version(ec_dev, &lb_version, NULL))
  522. return -ENODEV;
  523. /* Take control of the lightbar from the EC. */
  524. has_manual_suspend = (lb_manual_suspend_ctrl(ec_dev, 1) != -EINVAL);
  525. ret = sysfs_create_group(&ec_dev->class_dev.kobj,
  526. &cros_ec_lightbar_attr_group);
  527. if (ret < 0)
  528. dev_err(dev, "failed to create %s attributes. err=%d\n",
  529. cros_ec_lightbar_attr_group.name, ret);
  530. return ret;
  531. }
  532. static void cros_ec_lightbar_remove(struct platform_device *pd)
  533. {
  534. struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent);
  535. sysfs_remove_group(&ec_dev->class_dev.kobj,
  536. &cros_ec_lightbar_attr_group);
  537. /* Let the EC take over the lightbar again. */
  538. if (has_manual_suspend)
  539. lb_manual_suspend_ctrl(ec_dev, 0);
  540. }
  541. static int __maybe_unused cros_ec_lightbar_resume(struct device *dev)
  542. {
  543. struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent);
  544. if (userspace_control || !has_manual_suspend)
  545. return 0;
  546. return lb_send_empty_cmd(ec_dev, LIGHTBAR_CMD_RESUME);
  547. }
  548. static int __maybe_unused cros_ec_lightbar_suspend(struct device *dev)
  549. {
  550. struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent);
  551. if (userspace_control || !has_manual_suspend)
  552. return 0;
  553. return lb_send_empty_cmd(ec_dev, LIGHTBAR_CMD_SUSPEND);
  554. }
  555. static SIMPLE_DEV_PM_OPS(cros_ec_lightbar_pm_ops,
  556. cros_ec_lightbar_suspend, cros_ec_lightbar_resume);
  557. static const struct platform_device_id cros_ec_lightbar_id[] = {
  558. { DRV_NAME, 0 },
  559. {}
  560. };
  561. MODULE_DEVICE_TABLE(platform, cros_ec_lightbar_id);
  562. static struct platform_driver cros_ec_lightbar_driver = {
  563. .driver = {
  564. .name = DRV_NAME,
  565. .pm = &cros_ec_lightbar_pm_ops,
  566. .probe_type = PROBE_PREFER_ASYNCHRONOUS,
  567. },
  568. .probe = cros_ec_lightbar_probe,
  569. .remove = cros_ec_lightbar_remove,
  570. .id_table = cros_ec_lightbar_id,
  571. };
  572. module_platform_driver(cros_ec_lightbar_driver);
  573. MODULE_LICENSE("GPL");
  574. MODULE_DESCRIPTION("Expose the Chromebook Pixel's lightbar to userspace");