Skip to content

Commit 3475b91

Browse files
committed
Merge tag 'tag-chrome-platform-for-v6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux
Pull chrome platform updates from Tzung-Bi Shih: "Improvements: - Annotate flexible array members with __counted_by - Convert platform drivers' .remove callbacks to return void Fixes: - Avoid MKBP event timeouts by disabling/enabling IRQ later/earlier Misc: - Minor cleanups and fixes" * tag 'tag-chrome-platform-for-v6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux: (21 commits) platform/chrome: cros_ec_lpc: Separate host command and irq disable platform/chrome: kunit: make EC protocol tests independent platform/chrome: kunit: initialize lock for fake ec_dev platform/chrome: cros_ec: fix compilation warning platform/chrome: cros_ec_proto: Mark outdata as const platform/chrome: cros_typec_vdm: Mark port_amode_ops const platform/chrome: cros_ec_typec: Use dev_err_probe() more platform/chrome: cros_ec_typec: Use semi-colons instead of commas platform/chrome/wilco_ec: telemetry: Convert to platform remove callback returning void platform/chrome/wilco_ec: debugfs: Convert to platform remove callback returning void platform/chrome/wilco_ec: core: Convert to platform remove callback returning void platform/chrome: cros_usbpd_notify: Convert to platform remove callback returning void platform/chrome: cros_usbpd_logger: Convert to platform remove callback returning void platform/chrome: cros_typec_switch: Convert to platform remove callback returning void platform/chrome: cros_ec_vbc: Convert to platform remove callback returning void platform/chrome: cros_ec_sysfs: Convert to platform remove callback returning void platform/chrome: cros_ec_lpc: Convert to platform remove callback returning void platform/chrome: cros_ec_lightbar: Convert to platform remove callback returning void platform/chrome: cros_ec_debugfs: Convert to platform remove callback returning void platform/chrome: cros_ec_chardev: Convert to platform remove callback returning void ...
2 parents f9a7eda + 47ea0dd commit 3475b91

25 files changed

+166
-100
lines changed

drivers/platform/chrome/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,12 @@ config CROS_TYPEC_SWITCH
299299
source "drivers/platform/chrome/wilco_ec/Kconfig"
300300

301301
# Kunit test cases
302-
config CROS_KUNIT
303-
tristate "Kunit tests for ChromeOS" if !KUNIT_ALL_TESTS
302+
config CROS_KUNIT_EC_PROTO_TEST
303+
tristate "Kunit tests for ChromeOS EC protocol" if !KUNIT_ALL_TESTS
304304
depends on KUNIT && CROS_EC
305305
default KUNIT_ALL_TESTS
306306
select CROS_EC_PROTO
307307
help
308-
ChromeOS Kunit tests.
308+
Kunit tests for ChromeOS EC protocol.
309309

310310
endif # CHROMEOS_PLATFORMS

drivers/platform/chrome/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,5 @@ obj-$(CONFIG_CROS_USBPD_NOTIFY) += cros_usbpd_notify.o
3636
obj-$(CONFIG_WILCO_EC) += wilco_ec/
3737

3838
# Kunit test cases
39-
obj-$(CONFIG_CROS_KUNIT) += cros_kunit.o
40-
cros_kunit-objs := cros_kunit_util.o
41-
cros_kunit-objs += cros_ec_proto_test.o
39+
obj-$(CONFIG_CROS_KUNIT_EC_PROTO_TEST) += cros_kunit_proto_test.o
40+
cros_kunit_proto_test-objs := cros_ec_proto_test_util.o cros_ec_proto_test.o

drivers/platform/chrome/cros_ec.c

Lines changed: 94 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -321,17 +321,8 @@ void cros_ec_unregister(struct cros_ec_device *ec_dev)
321321
EXPORT_SYMBOL(cros_ec_unregister);
322322

323323
#ifdef CONFIG_PM_SLEEP
324-
/**
325-
* cros_ec_suspend() - Handle a suspend operation for the ChromeOS EC device.
326-
* @ec_dev: Device to suspend.
327-
*
328-
* This can be called by drivers to handle a suspend event.
329-
*
330-
* Return: 0 on success or negative error code.
331-
*/
332-
int cros_ec_suspend(struct cros_ec_device *ec_dev)
324+
static void cros_ec_send_suspend_event(struct cros_ec_device *ec_dev)
333325
{
334-
struct device *dev = ec_dev->dev;
335326
int ret;
336327
u8 sleep_event;
337328

@@ -343,15 +334,62 @@ int cros_ec_suspend(struct cros_ec_device *ec_dev)
343334
if (ret < 0)
344335
dev_dbg(ec_dev->dev, "Error %d sending suspend event to ec\n",
345336
ret);
337+
}
346338

339+
/**
340+
* cros_ec_suspend_prepare() - Handle a suspend prepare operation for the ChromeOS EC device.
341+
* @ec_dev: Device to suspend.
342+
*
343+
* This can be called by drivers to handle a suspend prepare stage of suspend.
344+
*
345+
* Return: 0 always.
346+
*/
347+
int cros_ec_suspend_prepare(struct cros_ec_device *ec_dev)
348+
{
349+
cros_ec_send_suspend_event(ec_dev);
350+
return 0;
351+
}
352+
EXPORT_SYMBOL(cros_ec_suspend_prepare);
353+
354+
static void cros_ec_disable_irq(struct cros_ec_device *ec_dev)
355+
{
356+
struct device *dev = ec_dev->dev;
347357
if (device_may_wakeup(dev))
348358
ec_dev->wake_enabled = !enable_irq_wake(ec_dev->irq);
349359
else
350360
ec_dev->wake_enabled = false;
351361

352362
disable_irq(ec_dev->irq);
353363
ec_dev->suspended = true;
364+
}
354365

366+
/**
367+
* cros_ec_suspend_late() - Handle a suspend late operation for the ChromeOS EC device.
368+
* @ec_dev: Device to suspend.
369+
*
370+
* This can be called by drivers to handle a suspend late stage of suspend.
371+
*
372+
* Return: 0 always.
373+
*/
374+
int cros_ec_suspend_late(struct cros_ec_device *ec_dev)
375+
{
376+
cros_ec_disable_irq(ec_dev);
377+
return 0;
378+
}
379+
EXPORT_SYMBOL(cros_ec_suspend_late);
380+
381+
/**
382+
* cros_ec_suspend() - Handle a suspend operation for the ChromeOS EC device.
383+
* @ec_dev: Device to suspend.
384+
*
385+
* This can be called by drivers to handle a suspend event.
386+
*
387+
* Return: 0 always.
388+
*/
389+
int cros_ec_suspend(struct cros_ec_device *ec_dev)
390+
{
391+
cros_ec_send_suspend_event(ec_dev);
392+
cros_ec_disable_irq(ec_dev);
355393
return 0;
356394
}
357395
EXPORT_SYMBOL(cros_ec_suspend);
@@ -370,22 +408,11 @@ static void cros_ec_report_events_during_suspend(struct cros_ec_device *ec_dev)
370408
}
371409
}
372410

373-
/**
374-
* cros_ec_resume() - Handle a resume operation for the ChromeOS EC device.
375-
* @ec_dev: Device to resume.
376-
*
377-
* This can be called by drivers to handle a resume event.
378-
*
379-
* Return: 0 on success or negative error code.
380-
*/
381-
int cros_ec_resume(struct cros_ec_device *ec_dev)
411+
static void cros_ec_send_resume_event(struct cros_ec_device *ec_dev)
382412
{
383413
int ret;
384414
u8 sleep_event;
385415

386-
ec_dev->suspended = false;
387-
enable_irq(ec_dev->irq);
388-
389416
sleep_event = (!IS_ENABLED(CONFIG_ACPI) || pm_suspend_via_firmware()) ?
390417
HOST_SLEEP_EVENT_S3_RESUME :
391418
HOST_SLEEP_EVENT_S0IX_RESUME;
@@ -394,6 +421,24 @@ int cros_ec_resume(struct cros_ec_device *ec_dev)
394421
if (ret < 0)
395422
dev_dbg(ec_dev->dev, "Error %d sending resume event to ec\n",
396423
ret);
424+
}
425+
426+
/**
427+
* cros_ec_resume_complete() - Handle a resume complete operation for the ChromeOS EC device.
428+
* @ec_dev: Device to resume.
429+
*
430+
* This can be called by drivers to handle a resume complete stage of resume.
431+
*/
432+
void cros_ec_resume_complete(struct cros_ec_device *ec_dev)
433+
{
434+
cros_ec_send_resume_event(ec_dev);
435+
}
436+
EXPORT_SYMBOL(cros_ec_resume_complete);
437+
438+
static void cros_ec_enable_irq(struct cros_ec_device *ec_dev)
439+
{
440+
ec_dev->suspended = false;
441+
enable_irq(ec_dev->irq);
397442

398443
if (ec_dev->wake_enabled)
399444
disable_irq_wake(ec_dev->irq);
@@ -403,8 +448,35 @@ int cros_ec_resume(struct cros_ec_device *ec_dev)
403448
* suspend. This way the clients know what to do with them.
404449
*/
405450
cros_ec_report_events_during_suspend(ec_dev);
451+
}
406452

453+
/**
454+
* cros_ec_resume_early() - Handle a resume early operation for the ChromeOS EC device.
455+
* @ec_dev: Device to resume.
456+
*
457+
* This can be called by drivers to handle a resume early stage of resume.
458+
*
459+
* Return: 0 always.
460+
*/
461+
int cros_ec_resume_early(struct cros_ec_device *ec_dev)
462+
{
463+
cros_ec_enable_irq(ec_dev);
464+
return 0;
465+
}
466+
EXPORT_SYMBOL(cros_ec_resume_early);
407467

468+
/**
469+
* cros_ec_resume() - Handle a resume operation for the ChromeOS EC device.
470+
* @ec_dev: Device to resume.
471+
*
472+
* This can be called by drivers to handle a resume event.
473+
*
474+
* Return: 0 always.
475+
*/
476+
int cros_ec_resume(struct cros_ec_device *ec_dev)
477+
{
478+
cros_ec_enable_irq(ec_dev);
479+
cros_ec_send_resume_event(ec_dev);
408480
return 0;
409481
}
410482
EXPORT_SYMBOL(cros_ec_resume);

drivers/platform/chrome/cros_ec.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@
1010

1111
#include <linux/interrupt.h>
1212

13+
struct cros_ec_device;
14+
1315
int cros_ec_register(struct cros_ec_device *ec_dev);
1416
void cros_ec_unregister(struct cros_ec_device *ec_dev);
1517

1618
int cros_ec_suspend(struct cros_ec_device *ec_dev);
19+
int cros_ec_suspend_late(struct cros_ec_device *ec_dev);
20+
int cros_ec_suspend_prepare(struct cros_ec_device *ec_dev);
1721
int cros_ec_resume(struct cros_ec_device *ec_dev);
22+
int cros_ec_resume_early(struct cros_ec_device *ec_dev);
23+
void cros_ec_resume_complete(struct cros_ec_device *ec_dev);
1824

1925
irqreturn_t cros_ec_irq_thread(int irq, void *data);
2026

drivers/platform/chrome/cros_ec_chardev.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,21 +396,19 @@ static int cros_ec_chardev_probe(struct platform_device *pdev)
396396
return misc_register(&data->misc);
397397
}
398398

399-
static int cros_ec_chardev_remove(struct platform_device *pdev)
399+
static void cros_ec_chardev_remove(struct platform_device *pdev)
400400
{
401401
struct chardev_data *data = dev_get_drvdata(&pdev->dev);
402402

403403
misc_deregister(&data->misc);
404-
405-
return 0;
406404
}
407405

408406
static struct platform_driver cros_ec_chardev_driver = {
409407
.driver = {
410408
.name = DRV_NAME,
411409
},
412410
.probe = cros_ec_chardev_probe,
413-
.remove = cros_ec_chardev_remove,
411+
.remove_new = cros_ec_chardev_remove,
414412
};
415413

416414
module_platform_driver(cros_ec_chardev_driver);

drivers/platform/chrome/cros_ec_debugfs.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,14 +533,12 @@ static int cros_ec_debugfs_probe(struct platform_device *pd)
533533
return ret;
534534
}
535535

536-
static int cros_ec_debugfs_remove(struct platform_device *pd)
536+
static void cros_ec_debugfs_remove(struct platform_device *pd)
537537
{
538538
struct cros_ec_dev *ec = dev_get_drvdata(pd->dev.parent);
539539

540540
debugfs_remove_recursive(ec->debug_info->dir);
541541
cros_ec_cleanup_console_log(ec->debug_info);
542-
543-
return 0;
544542
}
545543

546544
static int __maybe_unused cros_ec_debugfs_suspend(struct device *dev)
@@ -573,7 +571,7 @@ static struct platform_driver cros_ec_debugfs_driver = {
573571
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
574572
},
575573
.probe = cros_ec_debugfs_probe,
576-
.remove = cros_ec_debugfs_remove,
574+
.remove_new = cros_ec_debugfs_remove,
577575
};
578576

579577
module_platform_driver(cros_ec_debugfs_driver);

drivers/platform/chrome/cros_ec_lightbar.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ static int cros_ec_lightbar_probe(struct platform_device *pd)
560560
return ret;
561561
}
562562

563-
static int cros_ec_lightbar_remove(struct platform_device *pd)
563+
static void cros_ec_lightbar_remove(struct platform_device *pd)
564564
{
565565
struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent);
566566

@@ -569,8 +569,6 @@ static int cros_ec_lightbar_remove(struct platform_device *pd)
569569

570570
/* Let the EC take over the lightbar again. */
571571
lb_manual_suspend_ctrl(ec_dev, 0);
572-
573-
return 0;
574572
}
575573

576574
static int __maybe_unused cros_ec_lightbar_resume(struct device *dev)
@@ -603,7 +601,7 @@ static struct platform_driver cros_ec_lightbar_driver = {
603601
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
604602
},
605603
.probe = cros_ec_lightbar_probe,
606-
.remove = cros_ec_lightbar_remove,
604+
.remove_new = cros_ec_lightbar_remove,
607605
};
608606

609607
module_platform_driver(cros_ec_lightbar_driver);

drivers/platform/chrome/cros_ec_lpc.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
460460
return 0;
461461
}
462462

463-
static int cros_ec_lpc_remove(struct platform_device *pdev)
463+
static void cros_ec_lpc_remove(struct platform_device *pdev)
464464
{
465465
struct cros_ec_device *ec_dev = platform_get_drvdata(pdev);
466466
struct acpi_device *adev;
@@ -471,8 +471,6 @@ static int cros_ec_lpc_remove(struct platform_device *pdev)
471471
cros_ec_lpc_acpi_notify);
472472

473473
cros_ec_unregister(ec_dev);
474-
475-
return 0;
476474
}
477475

478476
static const struct acpi_device_id cros_ec_lpc_acpi_device_ids[] = {
@@ -549,22 +547,36 @@ MODULE_DEVICE_TABLE(dmi, cros_ec_lpc_dmi_table);
549547
static int cros_ec_lpc_prepare(struct device *dev)
550548
{
551549
struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
552-
553-
return cros_ec_suspend(ec_dev);
550+
return cros_ec_suspend_prepare(ec_dev);
554551
}
555552

556553
static void cros_ec_lpc_complete(struct device *dev)
557554
{
558555
struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
559-
cros_ec_resume(ec_dev);
556+
cros_ec_resume_complete(ec_dev);
557+
}
558+
559+
static int cros_ec_lpc_suspend_late(struct device *dev)
560+
{
561+
struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
562+
563+
return cros_ec_suspend_late(ec_dev);
564+
}
565+
566+
static int cros_ec_lpc_resume_early(struct device *dev)
567+
{
568+
struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
569+
570+
return cros_ec_resume_early(ec_dev);
560571
}
561572
#endif
562573

563574
static const struct dev_pm_ops cros_ec_lpc_pm_ops = {
564575
#ifdef CONFIG_PM_SLEEP
565576
.prepare = cros_ec_lpc_prepare,
566-
.complete = cros_ec_lpc_complete
577+
.complete = cros_ec_lpc_complete,
567578
#endif
579+
SET_LATE_SYSTEM_SLEEP_PM_OPS(cros_ec_lpc_suspend_late, cros_ec_lpc_resume_early)
568580
};
569581

570582
static struct platform_driver cros_ec_lpc_driver = {
@@ -580,7 +592,7 @@ static struct platform_driver cros_ec_lpc_driver = {
580592
.probe_type = PROBE_FORCE_SYNCHRONOUS,
581593
},
582594
.probe = cros_ec_lpc_probe,
583-
.remove = cros_ec_lpc_remove,
595+
.remove_new = cros_ec_lpc_remove,
584596
};
585597

586598
static struct platform_device cros_ec_lpc_device = {

drivers/platform/chrome/cros_ec_proto.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ EXPORT_SYMBOL_GPL(cros_ec_get_sensor_count);
10041004
int cros_ec_cmd(struct cros_ec_device *ec_dev,
10051005
unsigned int version,
10061006
int command,
1007-
void *outdata,
1007+
const void *outdata,
10081008
size_t outsize,
10091009
void *indata,
10101010
size_t insize)

drivers/platform/chrome/cros_ec_proto_test.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <linux/platform_data/cros_ec_proto.h>
1212

1313
#include "cros_ec.h"
14-
#include "cros_kunit_util.h"
14+
#include "cros_ec_proto_test_util.h"
1515

1616
#define BUFSIZE 512
1717

@@ -2668,6 +2668,7 @@ static int cros_ec_proto_test_init(struct kunit *test)
26682668
ec_dev->dev->release = cros_ec_proto_test_release;
26692669
ec_dev->cmd_xfer = cros_kunit_ec_xfer_mock;
26702670
ec_dev->pkt_xfer = cros_kunit_ec_xfer_mock;
2671+
mutex_init(&ec_dev->lock);
26712672

26722673
priv->msg = (struct cros_ec_command *)priv->_msg;
26732674

0 commit comments

Comments
 (0)