diff options
author | Alexander Shishkin <alexander.shishkin@linux.intel.com> | 2018-02-23 13:19:43 +0200 |
---|---|---|
committer | Alexander Shishkin <alexander.shishkin@linux.intel.com> | 2018-03-28 18:47:18 +0300 |
commit | 4f0c7c6a12906e3571abb3c2b93eca8f727f4c9c (patch) | |
tree | c1059d2697ba34ee36bb5247a5e0908e3a289031 | |
parent | 9ea393d8d8377b6da8ee25c6a114ec24c0687c7c (diff) | |
download | linux-stable-4f0c7c6a12906e3571abb3c2b93eca8f727f4c9c.tar.gz linux-stable-4f0c7c6a12906e3571abb3c2b93eca8f727f4c9c.tar.bz2 linux-stable-4f0c7c6a12906e3571abb3c2b93eca8f727f4c9c.zip |
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.c | 24 | ||||
-rw-r--r-- | include/uapi/linux/stm.h | 4 |
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 @@ #include <linux/module.h> #include <linux/slab.h> #include <linux/stm.h> +#include <uapi/linux/stm.h> static ssize_t notrace dummy_stm_packet(struct stm_data *stm_data, unsigned int master, @@ -44,6 +45,18 @@ static unsigned int fail_mode; module_param(fail_mode, int, 0600); +static unsigned int master_min; + +module_param(master_min, int, 0400); + +static unsigned int master_max = STP_MASTER_MAX; + +module_param(master_max, int, 0400); + +static unsigned int nr_channels = STP_CHANNEL_MAX; + +module_param(nr_channels, int, 0400); + static int dummy_stm_link(struct stm_data *data, unsigned int master, unsigned int channel) { @@ -60,14 +73,19 @@ static int dummy_stm_init(void) if (nr_dummies < 0 || nr_dummies > DUMMY_STM_MAX) return -EINVAL; + if (master_min > master_max || + master_max > STP_MASTER_MAX || + nr_channels > STP_CHANNEL_MAX) + return -EINVAL; + for (i = 0; i < nr_dummies; i++) { dummy_stm[i].name = kasprintf(GFP_KERNEL, "dummy_stm.%d", i); if (!dummy_stm[i].name) goto fail_unregister; - dummy_stm[i].sw_start = 0x0000; - dummy_stm[i].sw_end = 0xffff; - dummy_stm[i].sw_nchannels = 0xffff; + dummy_stm[i].sw_start = master_min; + dummy_stm[i].sw_end = master_max; + dummy_stm[i].sw_nchannels = nr_channels; dummy_stm[i].packet = dummy_stm_packet; dummy_stm[i].link = dummy_stm_link; 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 @@ #include <linux/types.h> +/* Maximum allowed master and channel values */ +#define STP_MASTER_MAX 0xffff +#define STP_CHANNEL_MAX 0xffff + /** * struct stp_policy_id - identification for the STP policy * @size: size of the structure including real id[] length |