platform/chrome: wilco_ec: Add circular buffer as event queue
authorNick Crews <ncrews@chromium.org>
Mon, 24 Jun 2019 19:00:42 +0000 (13:00 -0600)
committerEnric Balletbo i Serra <enric.balletbo@collabora.com>
Tue, 25 Jun 2019 10:33:05 +0000 (12:33 +0200)
commit1d333ef3d599026897fb11b4f89f9f8f30838139
tree40e433dd2ed786ef9e5919c733ede0e625c9ed2c
parent9eecd07b34507de9d6a9c264d13d30e1ee5fabe8
platform/chrome: wilco_ec: Add circular buffer as event queue

The current implementation of the event queue both
wastes space using a doubly linked list and isn't super
obvious in how it behaves. This converts the queue to an
actual circular buffer. The size of the queue is a
tunable module parameter. This also fixes a few other things:

- A memory leak that occurred when the ACPI device was
  removed, but the events were not freed from the queue.
- Now kfree() the oldest event from outside all locks.
- Add newline to logging messages.
- Add helper macros to calculate size of events.
- Remove unneeded lock around a check for dev_data->exist
  in hangup_device().
- Remove an unneeded null event pointer check in enqueue_events().
- Correct some comments.

Signed-off-by: Nick Crews <ncrews@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
drivers/platform/chrome/wilco_ec/event.c