Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1374291

[QUEUED v20160408 03/18] stm class: dummy_stm: Make nr_dummies parameter read-only

From Alexander Shishkin <alexander.shishkin@linux.intel.com>
Newsgroups linux.kernel
Subject [QUEUED v20160408 03/18] stm class: dummy_stm: Make nr_dummies parameter read-only
Date 2016-04-08 17:10 +0200
Message-ID <rlGcP-5Mb-41@gated-at.bofh.it> (permalink)
References <rlG37-5o2-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Changing nr_dummies after the module has been loaded doesn't actually
change anything, so just make it read-only.

Reported-by: Alan Cox <alan.cox@intel.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
---
 drivers/hwtracing/stm/dummy_stm.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/hwtracing/stm/dummy_stm.c b/drivers/hwtracing/stm/dummy_stm.c
index 310adf57e7..a86612d989 100644
--- a/drivers/hwtracing/stm/dummy_stm.c
+++ b/drivers/hwtracing/stm/dummy_stm.c
@@ -46,9 +46,7 @@ static struct stm_data dummy_stm[DUMMY_STM_MAX];
 
 static int nr_dummies = 4;
 
-module_param(nr_dummies, int, 0600);
-
-static unsigned int dummy_stm_nr;
+module_param(nr_dummies, int, 0400);
 
 static unsigned int fail_mode;
 
@@ -65,12 +63,12 @@ static int dummy_stm_link(struct stm_data *data, unsigned int master,
 
 static int dummy_stm_init(void)
 {
-	int i, ret = -ENOMEM, __nr_dummies = ACCESS_ONCE(nr_dummies);
+	int i, ret = -ENOMEM;
 
-	if (__nr_dummies < 0 || __nr_dummies > DUMMY_STM_MAX)
+	if (nr_dummies < 0 || nr_dummies > DUMMY_STM_MAX)
 		return -EINVAL;
 
-	for (i = 0; i < __nr_dummies; i++) {
+	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;
@@ -86,8 +84,6 @@ static int dummy_stm_init(void)
 			goto fail_free;
 	}
 
-	dummy_stm_nr = __nr_dummies;
-
 	return 0;
 
 fail_unregister:
@@ -105,7 +101,7 @@ static void dummy_stm_exit(void)
 {
 	int i;
 
-	for (i = 0; i < dummy_stm_nr; i++) {
+	for (i = 0; i < nr_dummies; i++) {
 		stm_unregister_device(&dummy_stm[i]);
 		kfree(dummy_stm[i].name);
 	}
-- 
2.8.0.rc3

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[QUEUED v20160408 00/18] stm class/intel_th: Patches in my queue Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-08 17:00 +0200
  [QUEUED v20160408 09/18] intel_th: pti: Do remove sysfs group on device removal Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-08 17:00 +0200
  [QUEUED v20160408 15/18] intel_th: msu: Serialize enabling/disabling Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-08 17:00 +0200
  [QUEUED v20160408 10/18] intel_th: msu: Handle kstrndup() failure Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-08 17:10 +0200
  [QUEUED v20160408 07/18] stm class: Fix stm device initialization order Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-08 17:10 +0200
  [QUEUED v20160408 08/18] stm class: Remove unnecessary pointer increment Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-08 17:10 +0200
  [QUEUED v20160408 04/18] stm class: stm_heartbeat: Make nr_devs parameter read-only Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-08 17:10 +0200
  [QUEUED v20160408 03/18] stm class: dummy_stm: Make nr_dummies parameter read-only Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-04-08 17:10 +0200

csiph-web