aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>2018-02-23 06:19:43 -0500
committerAlexander Shishkin <alexander.shishkin@linux.intel.com>2018-03-28 11:47:18 -0400
commit4f0c7c6a12906e3571abb3c2b93eca8f727f4c9c (patch)
treec1059d2697ba34ee36bb5247a5e0908e3a289031
parent9ea393d8d8377b6da8ee25c6a114ec24c0687c7c (diff)
stm class: Make dummy's master/channel ranges configurable
To allow for more flexible testing of the stm class, make it possible to specify the ranges of masters and channels that the dummy_stm devices cover. This is done via module parameters. Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
-rw-r--r--drivers/hwtracing/stm/dummy_stm.c24
-rw-r--r--include/uapi/linux/stm.h4
2 files changed, 25 insertions, 3 deletions
diff --git a/drivers/hwtracing/stm/dummy_stm.c b/drivers/hwtracing/stm/dummy_stm.c
index 63288020ea5b..38528ffdc0b3 100644
--- a/drivers/hwtracing/stm/dummy_stm.c
+++ b/drivers/hwtracing/stm/dummy_stm.c
@@ -12,6 +12,7 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/stm.h> 14#include <linux/stm.h>
15#include <uapi/linux/stm.h>
15 16
16static ssize_t notrace 17static ssize_t notrace
17dummy_stm_packet(struct stm_data *stm_data, unsigned int master, 18dummy_stm_packet(struct stm_data *stm_data, unsigned int master,
@@ -44,6 +45,18 @@ static unsigned int fail_mode;
44 45
45module_param(fail_mode, int, 0600); 46module_param(fail_mode, int, 0600);
46 47
48static unsigned int master_min;
49
50module_param(master_min, int, 0400);
51
52static unsigned int master_max = STP_MASTER_MAX;
53
54module_param(master_max, int, 0400);
55
56static unsigned int nr_channels = STP_CHANNEL_MAX;
57
58module_param(nr_channels, int, 0400);
59
47static int dummy_stm_link(struct stm_data *data, unsigned int master, 60static int dummy_stm_link(struct stm_data *data, unsigned int master,
48 unsigned int channel) 61 unsigned int channel)
49{ 62{
@@ -60,14 +73,19 @@ static int dummy_stm_init(void)
60 if (nr_dummies < 0 || nr_dummies > DUMMY_STM_MAX) 73 if (nr_dummies < 0 || nr_dummies > DUMMY_STM_MAX)
61 return -EINVAL; 74 return -EINVAL;
62 75
76 if (master_min > master_max ||
77 master_max > STP_MASTER_MAX ||
78 nr_channels > STP_CHANNEL_MAX)
79 return -EINVAL;
80
63 for (i = 0; i < nr_dummies; i++) { 81 for (i = 0; i < nr_dummies; i++) {
64 dummy_stm[i].name = kasprintf(GFP_KERNEL, "dummy_stm.%d", i); 82 dummy_stm[i].name = kasprintf(GFP_KERNEL, "dummy_stm.%d", i);
65 if (!dummy_stm[i].name) 83 if (!dummy_stm[i].name)
66 goto fail_unregister; 84 goto fail_unregister;
67 85
68 dummy_stm[i].sw_start = 0x0000; 86 dummy_stm[i].sw_start = master_min;
69 dummy_stm[i].sw_end = 0xffff; 87 dummy_stm[i].sw_end = master_max;
70 dummy_stm[i].sw_nchannels = 0xffff; 88 dummy_stm[i].sw_nchannels = nr_channels;
71 dummy_stm[i].packet = dummy_stm_packet; 89 dummy_stm[i].packet = dummy_stm_packet;
72 dummy_stm[i].link = dummy_stm_link; 90 dummy_stm[i].link = dummy_stm_link;
73 91
diff --git a/include/uapi/linux/stm.h b/include/uapi/linux/stm.h
index 29c89be72275..7bac318b4440 100644
--- a/include/uapi/linux/stm.h
+++ b/include/uapi/linux/stm.h
@@ -12,6 +12,10 @@
12 12
13#include <linux/types.h> 13#include <linux/types.h>
14 14
15/* Maximum allowed master and channel values */
16#define STP_MASTER_MAX 0xffff
17#define STP_CHANNEL_MAX 0xffff
18
15/** 19/**
16 * struct stp_policy_id - identification for the STP policy 20 * struct stp_policy_id - identification for the STP policy
17 * @size: size of the structure including real id[] length 21 * @size: size of the structure including real id[] length