platform/chrome: kunit: initialize lock for fake ec_dev
authorTzung-Bi Shih <tzungbi@kernel.org>
Tue, 3 Oct 2023 08:05:04 +0000 (08:05 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Nov 2023 17:19:39 +0000 (17:19 +0000)
[ Upstream commit e410b4ade83d06a046f6e32b5085997502ba0559 ]

cros_ec_cmd_xfer() uses ec_dev->lock.  Initialize it.

Otherwise, dmesg shows the following:
> DEBUG_LOCKS_WARN_ON(lock->magic != lock)
> ...
> Call Trace:
>  ? __mutex_lock
>  ? __warn
>  ? __mutex_lock
>  ...
>  ? cros_ec_cmd_xfer

Reviewed-by: Guenter Roeck <groeck@chromium.org>
Link: https://lore.kernel.org/r/20231003080504.4011337-1-tzungbi@kernel.org
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/platform/chrome/cros_ec_proto_test.c

index 5b9748e..63e3867 100644 (file)
@@ -2668,6 +2668,7 @@ static int cros_ec_proto_test_init(struct kunit *test)
        ec_dev->dev->release = cros_ec_proto_test_release;
        ec_dev->cmd_xfer = cros_kunit_ec_xfer_mock;
        ec_dev->pkt_xfer = cros_kunit_ec_xfer_mock;
+       mutex_init(&ec_dev->lock);
 
        priv->msg = (struct cros_ec_command *)priv->_msg;