^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Basic framing protocol for STM devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2018, Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/stm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "stm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) static ssize_t basic_write(struct stm_data *data, struct stm_output *output,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) unsigned int chan, const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) unsigned int c = output->channel + chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) unsigned int m = output->master;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) const unsigned char nil = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) ssize_t sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) sz = stm_data_write(data, m, c, true, buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) if (sz > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) data->packet(data, m, c, STP_PACKET_FLAG, 0, 0, &nil);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) return sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static const struct stm_protocol_driver basic_pdrv = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) .name = "p_basic",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) .write = basic_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static int basic_stm_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) return stm_register_protocol(&basic_pdrv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static void basic_stm_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) stm_unregister_protocol(&basic_pdrv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) module_init(basic_stm_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) module_exit(basic_stm_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) MODULE_LICENSE("GPL v2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) MODULE_DESCRIPTION("Basic STM framing protocol driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@linux.intel.com>");