Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'chrome-platform-v6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux

Pull chrome platform updates from Tzung-Bi Shih:
"New:
- Add a new API cros_ec_device_registered() for checking if the
cros_ec_deivce is ready

Improvements:
- Use TRAILING_OVERLAP() to fix -Wflex-array-member-not-at-end
warning
- Defer probe until parent EC device is ready in cros_ec_keyb

Cleanups:
- Remove redundant and simplify code in cros_ec_chardev
- Centralize cros_ec_device allocation and initialization to remove
duplicate code"

* tag 'chrome-platform-v6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux:
Input: cros_ec_keyb - Defer probe until parent EC device is registered
platform/chrome: cros_ec: Add a flag to track registration state
platform/chrome: cros_ec: Separate initialization from cros_ec_register()
platform/chrome: Centralize common cros_ec_device initialization
platform/chrome: Centralize cros_ec_device allocation
platform/chrome: wilco_ec: Remove redundant semicolons
platform/chrome: cros_ec: Avoid -Wflex-array-member-not-at-end warning
platform/chrome: cros_ec_chardev: Decouple fops from struct cros_ec_dev
platform/chrome: cros_ec_chardev: Remove redundant struct field

+139 -107
+6
drivers/input/keyboard/cros_ec_keyb.c
··· 705 705 ec = dev_get_drvdata(pdev->dev.parent); 706 706 if (!ec) 707 707 return -EPROBE_DEFER; 708 + /* 709 + * Even if the cros_ec_device pointer is available, still need to check 710 + * if the device is fully registered before using it. 711 + */ 712 + if (!cros_ec_device_registered(ec)) 713 + return -EPROBE_DEFER; 708 714 709 715 ckdev = devm_kzalloc(dev, sizeof(*ckdev), GFP_KERNEL); 710 716 if (!ckdev)
+60 -30
drivers/platform/chrome/cros_ec.c
··· 9 9 * battery charging and regulator control, firmware update. 10 10 */ 11 11 12 + #include <linux/cleanup.h> 12 13 #include <linux/interrupt.h> 13 14 #include <linux/module.h> 14 15 #include <linux/of_platform.h> ··· 30 29 .ec_name = CROS_EC_DEV_PD_NAME, 31 30 .cmd_offset = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX), 32 31 }; 32 + 33 + static void cros_ec_device_free(void *data) 34 + { 35 + struct cros_ec_device *ec_dev = data; 36 + 37 + mutex_destroy(&ec_dev->lock); 38 + lockdep_unregister_key(&ec_dev->lockdep_key); 39 + } 40 + 41 + struct cros_ec_device *cros_ec_device_alloc(struct device *dev) 42 + { 43 + struct cros_ec_device *ec_dev; 44 + 45 + ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL); 46 + if (!ec_dev) 47 + return NULL; 48 + 49 + ec_dev->din_size = sizeof(struct ec_host_response) + 50 + sizeof(struct ec_response_get_protocol_info) + 51 + EC_MAX_RESPONSE_OVERHEAD; 52 + ec_dev->dout_size = sizeof(struct ec_host_request) + 53 + sizeof(struct ec_params_rwsig_action) + 54 + EC_MAX_REQUEST_OVERHEAD; 55 + 56 + ec_dev->din = devm_kzalloc(dev, ec_dev->din_size, GFP_KERNEL); 57 + if (!ec_dev->din) 58 + return NULL; 59 + 60 + ec_dev->dout = devm_kzalloc(dev, ec_dev->dout_size, GFP_KERNEL); 61 + if (!ec_dev->dout) 62 + return NULL; 63 + 64 + ec_dev->dev = dev; 65 + ec_dev->max_response = sizeof(struct ec_response_get_protocol_info); 66 + ec_dev->max_request = sizeof(struct ec_params_rwsig_action); 67 + ec_dev->suspend_timeout_ms = EC_HOST_SLEEP_TIMEOUT_DEFAULT; 68 + 69 + BLOCKING_INIT_NOTIFIER_HEAD(&ec_dev->event_notifier); 70 + BLOCKING_INIT_NOTIFIER_HEAD(&ec_dev->panic_notifier); 71 + 72 + lockdep_register_key(&ec_dev->lockdep_key); 73 + mutex_init(&ec_dev->lock); 74 + lockdep_set_class(&ec_dev->lock, &ec_dev->lockdep_key); 75 + 76 + if (devm_add_action_or_reset(dev, cros_ec_device_free, ec_dev)) 77 + return NULL; 78 + 79 + return ec_dev; 80 + } 81 + EXPORT_SYMBOL(cros_ec_device_alloc); 33 82 34 83 /** 35 84 * cros_ec_irq_handler() - top half part of the interrupt handler ··· 153 102 static int cros_ec_sleep_event(struct cros_ec_device *ec_dev, u8 sleep_event) 154 103 { 155 104 int ret; 156 - struct { 157 - struct cros_ec_command msg; 105 + TRAILING_OVERLAP(struct cros_ec_command, msg, data, 158 106 union { 159 107 struct ec_params_host_sleep_event req0; 160 108 struct ec_params_host_sleep_event_v1 req1; 161 109 struct ec_response_host_sleep_event_v1 resp1; 162 110 } u; 163 - } __packed buf; 111 + ) __packed buf; 164 112 165 113 memset(&buf, 0, sizeof(buf)); 166 114 ··· 230 180 int cros_ec_register(struct cros_ec_device *ec_dev) 231 181 { 232 182 struct device *dev = ec_dev->dev; 233 - int err = 0; 234 - 235 - BLOCKING_INIT_NOTIFIER_HEAD(&ec_dev->event_notifier); 236 - BLOCKING_INIT_NOTIFIER_HEAD(&ec_dev->panic_notifier); 237 - 238 - ec_dev->max_request = sizeof(struct ec_params_hello); 239 - ec_dev->max_response = sizeof(struct ec_response_get_protocol_info); 240 - ec_dev->max_passthru = 0; 241 - ec_dev->ec = NULL; 242 - ec_dev->pd = NULL; 243 - ec_dev->suspend_timeout_ms = EC_HOST_SLEEP_TIMEOUT_DEFAULT; 244 - 245 - ec_dev->din = devm_kzalloc(dev, ec_dev->din_size, GFP_KERNEL); 246 - if (!ec_dev->din) 247 - return -ENOMEM; 248 - 249 - ec_dev->dout = devm_kzalloc(dev, ec_dev->dout_size, GFP_KERNEL); 250 - if (!ec_dev->dout) 251 - return -ENOMEM; 252 - 253 - lockdep_register_key(&ec_dev->lockdep_key); 254 - mutex_init(&ec_dev->lock); 255 - lockdep_set_class(&ec_dev->lock, &ec_dev->lockdep_key); 183 + int err; 256 184 257 185 /* Send RWSIG continue to jump to RW for devices using RWSIG. */ 258 186 err = cros_ec_rwsig_continue(ec_dev); ··· 317 289 goto exit; 318 290 } 319 291 292 + scoped_guard(mutex, &ec_dev->lock) 293 + ec_dev->registered = true; 294 + 320 295 dev_info(dev, "Chrome EC device registered\n"); 321 296 322 297 /* ··· 333 302 exit: 334 303 platform_device_unregister(ec_dev->ec); 335 304 platform_device_unregister(ec_dev->pd); 336 - mutex_destroy(&ec_dev->lock); 337 - lockdep_unregister_key(&ec_dev->lockdep_key); 338 305 return err; 339 306 } 340 307 EXPORT_SYMBOL(cros_ec_register); ··· 347 318 */ 348 319 void cros_ec_unregister(struct cros_ec_device *ec_dev) 349 320 { 321 + scoped_guard(mutex, &ec_dev->lock) 322 + ec_dev->registered = false; 323 + 350 324 if (ec_dev->mkbp_event_supported) 351 325 blocking_notifier_chain_unregister(&ec_dev->event_notifier, 352 326 &ec_dev->notifier_ready); 353 327 platform_device_unregister(ec_dev->pd); 354 328 platform_device_unregister(ec_dev->ec); 355 - mutex_destroy(&ec_dev->lock); 356 - lockdep_unregister_key(&ec_dev->lockdep_key); 357 329 } 358 330 EXPORT_SYMBOL(cros_ec_unregister); 359 331
+3
drivers/platform/chrome/cros_ec.h
··· 11 11 #include <linux/interrupt.h> 12 12 13 13 struct cros_ec_device; 14 + struct device; 15 + 16 + struct cros_ec_device *cros_ec_device_alloc(struct device *dev); 14 17 15 18 int cros_ec_register(struct cros_ec_device *ec_dev); 16 19 void cros_ec_unregister(struct cros_ec_device *ec_dev);
+33 -39
drivers/platform/chrome/cros_ec_chardev.c
··· 31 31 /* Arbitrary bounded size for the event queue */ 32 32 #define CROS_MAX_EVENT_LEN PAGE_SIZE 33 33 34 - struct chardev_data { 35 - struct cros_ec_dev *ec_dev; 36 - struct miscdevice misc; 37 - }; 38 - 39 34 struct chardev_priv { 40 - struct cros_ec_dev *ec_dev; 35 + struct cros_ec_device *ec_dev; 41 36 struct notifier_block notifier; 42 37 wait_queue_head_t wait_event; 43 38 unsigned long event_mask; 44 39 struct list_head events; 45 40 size_t event_len; 41 + u16 cmd_offset; 46 42 }; 47 43 48 44 struct ec_event { ··· 48 52 u8 data[]; 49 53 }; 50 54 51 - static int ec_get_version(struct cros_ec_dev *ec, char *str, int maxlen) 55 + static int ec_get_version(struct chardev_priv *priv, char *str, int maxlen) 52 56 { 53 57 static const char * const current_image_name[] = { 54 58 "unknown", "read-only", "read-write", "invalid", ··· 61 65 if (!msg) 62 66 return -ENOMEM; 63 67 64 - msg->command = EC_CMD_GET_VERSION + ec->cmd_offset; 68 + msg->command = EC_CMD_GET_VERSION + priv->cmd_offset; 65 69 msg->insize = sizeof(*resp); 66 70 67 - ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); 71 + ret = cros_ec_cmd_xfer_status(priv->ec_dev, msg); 68 72 if (ret < 0) { 69 73 snprintf(str, maxlen, 70 74 "Unknown EC version, returned error: %d\n", ··· 92 96 { 93 97 struct chardev_priv *priv = container_of(nb, struct chardev_priv, 94 98 notifier); 95 - struct cros_ec_device *ec_dev = priv->ec_dev->ec_dev; 99 + struct cros_ec_device *ec_dev = priv->ec_dev; 96 100 struct ec_event *event; 97 101 unsigned long event_bit = 1 << ec_dev->event_data.event_type; 98 102 int total_size = sizeof(*event) + ec_dev->event_size; ··· 157 161 static int cros_ec_chardev_open(struct inode *inode, struct file *filp) 158 162 { 159 163 struct miscdevice *mdev = filp->private_data; 160 - struct cros_ec_dev *ec_dev = dev_get_drvdata(mdev->parent); 164 + struct cros_ec_dev *ec = dev_get_drvdata(mdev->parent); 165 + struct cros_ec_device *ec_dev = ec->ec_dev; 161 166 struct chardev_priv *priv; 162 167 int ret; 163 168 ··· 167 170 return -ENOMEM; 168 171 169 172 priv->ec_dev = ec_dev; 173 + priv->cmd_offset = ec->cmd_offset; 170 174 filp->private_data = priv; 171 175 INIT_LIST_HEAD(&priv->events); 172 176 init_waitqueue_head(&priv->wait_event); 173 177 nonseekable_open(inode, filp); 174 178 175 179 priv->notifier.notifier_call = cros_ec_chardev_mkbp_event; 176 - ret = blocking_notifier_chain_register(&ec_dev->ec_dev->event_notifier, 180 + ret = blocking_notifier_chain_register(&ec_dev->event_notifier, 177 181 &priv->notifier); 178 182 if (ret) { 179 183 dev_err(ec_dev->dev, "failed to register event notifier\n"); ··· 202 204 char msg[sizeof(struct ec_response_get_version) + 203 205 sizeof(CROS_EC_DEV_VERSION)]; 204 206 struct chardev_priv *priv = filp->private_data; 205 - struct cros_ec_dev *ec_dev = priv->ec_dev; 206 207 size_t count; 207 208 int ret; 208 209 ··· 235 238 if (*offset != 0) 236 239 return 0; 237 240 238 - ret = ec_get_version(ec_dev, msg, sizeof(msg)); 241 + ret = ec_get_version(priv, msg, sizeof(msg)); 239 242 if (ret) 240 243 return ret; 241 244 ··· 251 254 static int cros_ec_chardev_release(struct inode *inode, struct file *filp) 252 255 { 253 256 struct chardev_priv *priv = filp->private_data; 254 - struct cros_ec_dev *ec_dev = priv->ec_dev; 257 + struct cros_ec_device *ec_dev = priv->ec_dev; 255 258 struct ec_event *event, *e; 256 259 257 - blocking_notifier_chain_unregister(&ec_dev->ec_dev->event_notifier, 260 + blocking_notifier_chain_unregister(&ec_dev->event_notifier, 258 261 &priv->notifier); 259 262 260 263 list_for_each_entry_safe(event, e, &priv->events, node) { ··· 269 272 /* 270 273 * Ioctls 271 274 */ 272 - static long cros_ec_chardev_ioctl_xcmd(struct cros_ec_dev *ec, void __user *arg) 275 + static long cros_ec_chardev_ioctl_xcmd(struct chardev_priv *priv, void __user *arg) 273 276 { 274 277 struct cros_ec_command *s_cmd; 275 278 struct cros_ec_command u_cmd; ··· 298 301 goto exit; 299 302 } 300 303 301 - s_cmd->command += ec->cmd_offset; 302 - ret = cros_ec_cmd_xfer(ec->ec_dev, s_cmd); 304 + s_cmd->command += priv->cmd_offset; 305 + ret = cros_ec_cmd_xfer(priv->ec_dev, s_cmd); 303 306 /* Only copy data to userland if data was received. */ 304 307 if (ret < 0) 305 308 goto exit; ··· 311 314 return ret; 312 315 } 313 316 314 - static long cros_ec_chardev_ioctl_readmem(struct cros_ec_dev *ec, 315 - void __user *arg) 317 + static long cros_ec_chardev_ioctl_readmem(struct chardev_priv *priv, void __user *arg) 316 318 { 317 - struct cros_ec_device *ec_dev = ec->ec_dev; 319 + struct cros_ec_device *ec_dev = priv->ec_dev; 318 320 struct cros_ec_readmem s_mem = { }; 319 321 long num; 320 322 ··· 342 346 unsigned long arg) 343 347 { 344 348 struct chardev_priv *priv = filp->private_data; 345 - struct cros_ec_dev *ec = priv->ec_dev; 346 349 347 350 if (_IOC_TYPE(cmd) != CROS_EC_DEV_IOC) 348 351 return -ENOTTY; 349 352 350 353 switch (cmd) { 351 354 case CROS_EC_DEV_IOCXCMD: 352 - return cros_ec_chardev_ioctl_xcmd(ec, (void __user *)arg); 355 + return cros_ec_chardev_ioctl_xcmd(priv, (void __user *)arg); 353 356 case CROS_EC_DEV_IOCRDMEM: 354 - return cros_ec_chardev_ioctl_readmem(ec, (void __user *)arg); 357 + return cros_ec_chardev_ioctl_readmem(priv, (void __user *)arg); 355 358 case CROS_EC_DEV_IOCEVENTMASK: 356 359 priv->event_mask = arg; 357 360 return 0; ··· 372 377 373 378 static int cros_ec_chardev_probe(struct platform_device *pdev) 374 379 { 375 - struct cros_ec_dev *ec_dev = dev_get_drvdata(pdev->dev.parent); 376 - struct cros_ec_platform *ec_platform = dev_get_platdata(ec_dev->dev); 377 - struct chardev_data *data; 380 + struct cros_ec_dev *ec = dev_get_drvdata(pdev->dev.parent); 381 + struct cros_ec_platform *ec_platform = dev_get_platdata(ec->dev); 382 + struct miscdevice *misc; 378 383 379 384 /* Create a char device: we want to create it anew */ 380 - data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 381 - if (!data) 385 + misc = devm_kzalloc(&pdev->dev, sizeof(*misc), GFP_KERNEL); 386 + if (!misc) 382 387 return -ENOMEM; 383 388 384 - data->ec_dev = ec_dev; 385 - data->misc.minor = MISC_DYNAMIC_MINOR; 386 - data->misc.fops = &chardev_fops; 387 - data->misc.name = ec_platform->ec_name; 388 - data->misc.parent = pdev->dev.parent; 389 + misc->minor = MISC_DYNAMIC_MINOR; 390 + misc->fops = &chardev_fops; 391 + misc->name = ec_platform->ec_name; 392 + misc->parent = pdev->dev.parent; 389 393 390 - dev_set_drvdata(&pdev->dev, data); 394 + dev_set_drvdata(&pdev->dev, misc); 391 395 392 - return misc_register(&data->misc); 396 + return misc_register(misc); 393 397 } 394 398 395 399 static void cros_ec_chardev_remove(struct platform_device *pdev) 396 400 { 397 - struct chardev_data *data = dev_get_drvdata(&pdev->dev); 401 + struct miscdevice *misc = dev_get_drvdata(&pdev->dev); 398 402 399 - misc_deregister(&data->misc); 403 + misc_deregister(misc); 400 404 } 401 405 402 406 static const struct platform_device_id cros_ec_chardev_id[] = {
+2 -7
drivers/platform/chrome/cros_ec_i2c.c
··· 289 289 static int cros_ec_i2c_probe(struct i2c_client *client) 290 290 { 291 291 struct device *dev = &client->dev; 292 - struct cros_ec_device *ec_dev = NULL; 292 + struct cros_ec_device *ec_dev; 293 293 int err; 294 294 295 - ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL); 295 + ec_dev = cros_ec_device_alloc(dev); 296 296 if (!ec_dev) 297 297 return -ENOMEM; 298 298 299 299 i2c_set_clientdata(client, ec_dev); 300 - ec_dev->dev = dev; 301 300 ec_dev->priv = client; 302 301 ec_dev->irq = client->irq; 303 302 ec_dev->cmd_xfer = cros_ec_cmd_xfer_i2c; 304 303 ec_dev->pkt_xfer = cros_ec_pkt_xfer_i2c; 305 304 ec_dev->phys_name = client->adapter->name; 306 - ec_dev->din_size = sizeof(struct ec_host_response_i2c) + 307 - sizeof(struct ec_response_get_protocol_info); 308 - ec_dev->dout_size = sizeof(struct ec_host_request_i2c) + 309 - sizeof(struct ec_params_rwsig_action); 310 305 311 306 err = cros_ec_register(ec_dev); 312 307 if (err) {
+1 -5
drivers/platform/chrome/cros_ec_ishtp.c
··· 543 543 struct cros_ec_device *ec_dev; 544 544 struct device *dev = cl_data_to_dev(client_data); 545 545 546 - ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL); 546 + ec_dev = cros_ec_device_alloc(dev); 547 547 if (!ec_dev) 548 548 return -ENOMEM; 549 549 550 550 client_data->ec_dev = ec_dev; 551 551 dev->driver_data = ec_dev; 552 552 553 - ec_dev->dev = dev; 554 553 ec_dev->priv = client_data->cros_ish_cl; 555 554 ec_dev->cmd_xfer = NULL; 556 555 ec_dev->pkt_xfer = cros_ec_pkt_xfer_ish; 557 556 ec_dev->phys_name = dev_name(dev); 558 - ec_dev->din_size = sizeof(struct cros_ish_in_msg) + 559 - sizeof(struct ec_response_get_protocol_info); 560 - ec_dev->dout_size = sizeof(struct cros_ish_out_msg) + sizeof(struct ec_params_rwsig_action); 561 557 562 558 return cros_ec_register(ec_dev); 563 559 }
+1 -5
drivers/platform/chrome/cros_ec_lpc.c
··· 637 637 } 638 638 } 639 639 640 - ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL); 640 + ec_dev = cros_ec_device_alloc(dev); 641 641 if (!ec_dev) 642 642 return -ENOMEM; 643 643 644 644 platform_set_drvdata(pdev, ec_dev); 645 - ec_dev->dev = dev; 646 645 ec_dev->phys_name = dev_name(dev); 647 646 ec_dev->cmd_xfer = cros_ec_cmd_xfer_lpc; 648 647 ec_dev->pkt_xfer = cros_ec_pkt_xfer_lpc; 649 648 ec_dev->cmd_readmem = cros_ec_lpc_readmem; 650 - ec_dev->din_size = sizeof(struct ec_host_response) + 651 - sizeof(struct ec_response_get_protocol_info); 652 - ec_dev->dout_size = sizeof(struct ec_host_request) + sizeof(struct ec_params_rwsig_action); 653 649 ec_dev->priv = ec_lpc; 654 650 655 651 /*
+15
drivers/platform/chrome/cros_ec_proto.c
··· 3 3 // 4 4 // Copyright (C) 2015 Google, Inc 5 5 6 + #include <linux/cleanup.h> 6 7 #include <linux/delay.h> 7 8 #include <linux/device.h> 8 9 #include <linux/limits.h> ··· 1153 1152 return resp.version_mask; 1154 1153 } 1155 1154 EXPORT_SYMBOL_GPL(cros_ec_get_cmd_versions); 1155 + 1156 + /** 1157 + * cros_ec_device_registered - Return if the ec_dev is registered. 1158 + * 1159 + * @ec_dev: EC device 1160 + * 1161 + * Return: true if registered. Otherwise, false. 1162 + */ 1163 + bool cros_ec_device_registered(struct cros_ec_device *ec_dev) 1164 + { 1165 + guard(mutex)(&ec_dev->lock); 1166 + return ec_dev->registered; 1167 + } 1168 + EXPORT_SYMBOL_GPL(cros_ec_device_registered); 1156 1169 1157 1170 MODULE_LICENSE("GPL"); 1158 1171 MODULE_DESCRIPTION("ChromeOS EC communication protocol helpers");
+1 -5
drivers/platform/chrome/cros_ec_rpmsg.c
··· 216 216 struct cros_ec_device *ec_dev; 217 217 int ret; 218 218 219 - ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL); 219 + ec_dev = cros_ec_device_alloc(dev); 220 220 if (!ec_dev) 221 221 return -ENOMEM; 222 222 ··· 224 224 if (!ec_rpmsg) 225 225 return -ENOMEM; 226 226 227 - ec_dev->dev = dev; 228 227 ec_dev->priv = ec_rpmsg; 229 228 ec_dev->cmd_xfer = cros_ec_cmd_xfer_rpmsg; 230 229 ec_dev->pkt_xfer = cros_ec_pkt_xfer_rpmsg; 231 230 ec_dev->phys_name = dev_name(&rpdev->dev); 232 - ec_dev->din_size = sizeof(struct ec_host_response) + 233 - sizeof(struct ec_response_get_protocol_info); 234 - ec_dev->dout_size = sizeof(struct ec_host_request) + sizeof(struct ec_params_rwsig_action); 235 231 dev_set_drvdata(dev, ec_dev); 236 232 237 233 ec_rpmsg->rpdev = rpdev;
+1 -6
drivers/platform/chrome/cros_ec_spi.c
··· 749 749 if (ec_spi == NULL) 750 750 return -ENOMEM; 751 751 ec_spi->spi = spi; 752 - ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL); 752 + ec_dev = cros_ec_device_alloc(dev); 753 753 if (!ec_dev) 754 754 return -ENOMEM; 755 755 ··· 757 757 cros_ec_spi_dt_probe(ec_spi, dev); 758 758 759 759 spi_set_drvdata(spi, ec_dev); 760 - ec_dev->dev = dev; 761 760 ec_dev->priv = ec_spi; 762 761 ec_dev->irq = spi->irq; 763 762 ec_dev->cmd_xfer = cros_ec_cmd_xfer_spi; 764 763 ec_dev->pkt_xfer = cros_ec_pkt_xfer_spi; 765 764 ec_dev->phys_name = dev_name(&ec_spi->spi->dev); 766 - ec_dev->din_size = EC_MSG_PREAMBLE_COUNT + 767 - sizeof(struct ec_host_response) + 768 - sizeof(struct ec_response_get_protocol_info); 769 - ec_dev->dout_size = sizeof(struct ec_host_request) + sizeof(struct ec_params_rwsig_action); 770 765 771 766 ec_spi->last_transfer_ns = ktime_get_ns(); 772 767
+1 -5
drivers/platform/chrome/cros_ec_uart.c
··· 259 259 if (!ec_uart) 260 260 return -ENOMEM; 261 261 262 - ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL); 262 + ec_dev = cros_ec_device_alloc(dev); 263 263 if (!ec_dev) 264 264 return -ENOMEM; 265 265 ··· 276 276 277 277 /* Initialize ec_dev for cros_ec */ 278 278 ec_dev->phys_name = dev_name(dev); 279 - ec_dev->dev = dev; 280 279 ec_dev->priv = ec_uart; 281 280 ec_dev->irq = ec_uart->irq; 282 281 ec_dev->cmd_xfer = NULL; 283 282 ec_dev->pkt_xfer = cros_ec_uart_pkt_xfer; 284 - ec_dev->din_size = sizeof(struct ec_host_response) + 285 - sizeof(struct ec_response_get_protocol_info); 286 - ec_dev->dout_size = sizeof(struct ec_host_request) + sizeof(struct ec_params_rwsig_action); 287 283 288 284 serdev_device_set_client_ops(serdev, &cros_ec_uart_client_ops); 289 285
+1 -1
drivers/platform/chrome/wilco_ec/telemetry.c
··· 388 388 dev_set_name(&dev_data->dev, TELEM_DEV_NAME_FMT, minor); 389 389 device_initialize(&dev_data->dev); 390 390 391 - /* Initialize the character device and add it to userspace */; 391 + /* Initialize the character device and add it to userspace */ 392 392 cdev_init(&dev_data->cdev, &telem_fops); 393 393 error = cdev_device_add(&dev_data->cdev, &dev_data->dev); 394 394 if (error) {
+14 -4
include/linux/platform_data/cros_ec_proto.h
··· 33 33 34 34 /* 35 35 * Max bus-specific overhead incurred by request/responses. 36 - * I2C requires 1 additional byte for requests. 37 - * I2C requires 2 additional bytes for responses. 38 - * SPI requires up to 32 additional bytes for responses. 36 + * 37 + * Request: 38 + * - I2C requires 1 byte (see struct ec_host_request_i2c). 39 + * - ISHTP requires 4 bytes (see struct cros_ish_out_msg). 40 + * 41 + * Response: 42 + * - I2C requires 2 bytes (see struct ec_host_response_i2c). 43 + * - ISHTP requires 4 bytes (see struct cros_ish_in_msg). 44 + * - SPI requires 32 bytes (see EC_MSG_PREAMBLE_COUNT). 39 45 */ 40 46 #define EC_PROTO_VERSION_UNKNOWN 0 41 - #define EC_MAX_REQUEST_OVERHEAD 1 47 + #define EC_MAX_REQUEST_OVERHEAD 4 42 48 #define EC_MAX_RESPONSE_OVERHEAD 32 43 49 44 50 /* ··· 128 122 * @dout_size: Size of dout buffer to allocate (zero to use static dout). 129 123 * @wake_enabled: True if this device can wake the system from sleep. 130 124 * @suspended: True if this device had been suspended. 125 + * @registered: True if this device had been registered. 131 126 * @cmd_xfer: Send command to EC and get response. 132 127 * Returns the number of bytes received if the communication 133 128 * succeeded, but that doesn't mean the EC was happy with the ··· 187 180 int dout_size; 188 181 bool wake_enabled; 189 182 bool suspended; 183 + bool registered; 190 184 int (*cmd_xfer)(struct cros_ec_device *ec, 191 185 struct cros_ec_command *msg); 192 186 int (*pkt_xfer)(struct cros_ec_device *ec, ··· 279 271 int cros_ec_cmd_readmem(struct cros_ec_device *ec_dev, u8 offset, u8 size, void *dest); 280 272 281 273 int cros_ec_get_cmd_versions(struct cros_ec_device *ec_dev, u16 cmd); 274 + 275 + bool cros_ec_device_registered(struct cros_ec_device *ec_dev); 282 276 283 277 /** 284 278 * cros_ec_get_time_ns() - Return time in ns.