File: p_basic.c

package info (click to toggle)
linux 6.16.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,724,576 kB
  • sloc: ansic: 26,558,545; asm: 271,315; sh: 143,998; python: 72,469; makefile: 57,126; perl: 36,821; xml: 19,553; cpp: 5,820; yacc: 4,915; lex: 2,955; awk: 1,667; sed: 28; ruby: 25
file content (49 lines) | stat: -rw-r--r-- 1,152 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// SPDX-License-Identifier: GPL-2.0
/*
 * Basic framing protocol for STM devices.
 * Copyright (c) 2018, Intel Corporation.
 */

#include <linux/module.h>
#include <linux/device.h>
#include <linux/stm.h>
#include "stm.h"

static ssize_t basic_write(struct stm_data *data, struct stm_output *output,
			   unsigned int chan, const char *buf, size_t count,
			   struct stm_source_data *source)
{
	unsigned int c = output->channel + chan;
	unsigned int m = output->master;
	const unsigned char nil = 0;
	ssize_t sz;

	sz = stm_data_write(data, m, c, true, buf, count);
	if (sz > 0)
		data->packet(data, m, c, STP_PACKET_FLAG, 0, 0, &nil);

	return sz;
}

static const struct stm_protocol_driver basic_pdrv = {
	.owner	= THIS_MODULE,
	.name	= "p_basic",
	.write	= basic_write,
};

static int basic_stm_init(void)
{
	return stm_register_protocol(&basic_pdrv);
}

static void basic_stm_exit(void)
{
	stm_unregister_protocol(&basic_pdrv);
}

module_init(basic_stm_init);
module_exit(basic_stm_exit);

MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("Basic STM framing protocol driver");
MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@linux.intel.com>");