Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+25 -3
+21 -3
drivers/hwtracing/stm/dummy_stm.c
··· 12 12 #include <linux/module.h> 13 13 #include <linux/slab.h> 14 14 #include <linux/stm.h> 15 + #include <uapi/linux/stm.h> 15 16 16 17 static ssize_t notrace 17 18 dummy_stm_packet(struct stm_data *stm_data, unsigned int master, ··· 45 44 46 45 module_param(fail_mode, int, 0600); 47 46 47 + static unsigned int master_min; 48 + 49 + module_param(master_min, int, 0400); 50 + 51 + static unsigned int master_max = STP_MASTER_MAX; 52 + 53 + module_param(master_max, int, 0400); 54 + 55 + static unsigned int nr_channels = STP_CHANNEL_MAX; 56 + 57 + module_param(nr_channels, int, 0400); 58 + 48 59 static int dummy_stm_link(struct stm_data *data, unsigned int master, 49 60 unsigned int channel) 50 61 { ··· 73 60 if (nr_dummies < 0 || nr_dummies > DUMMY_STM_MAX) 74 61 return -EINVAL; 75 62 63 + if (master_min > master_max || 64 + master_max > STP_MASTER_MAX || 65 + nr_channels > STP_CHANNEL_MAX) 66 + return -EINVAL; 67 + 76 68 for (i = 0; i < nr_dummies; i++) { 77 69 dummy_stm[i].name = kasprintf(GFP_KERNEL, "dummy_stm.%d", i); 78 70 if (!dummy_stm[i].name) 79 71 goto fail_unregister; 80 72 81 - dummy_stm[i].sw_start = 0x0000; 82 - dummy_stm[i].sw_end = 0xffff; 83 - dummy_stm[i].sw_nchannels = 0xffff; 73 + dummy_stm[i].sw_start = master_min; 74 + dummy_stm[i].sw_end = master_max; 75 + dummy_stm[i].sw_nchannels = nr_channels; 84 76 dummy_stm[i].packet = dummy_stm_packet; 85 77 dummy_stm[i].link = dummy_stm_link; 86 78
+4
include/uapi/linux/stm.h
··· 12 12 13 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 20 * struct stp_policy_id - identification for the STP policy 17 21 * @size: size of the structure including real id[] length