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