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


Groups > linux.kernel > #1374289

[QUEUED v20160408 04/18] stm class: stm_heartbeat: Make nr_devs parameter read-only

From Alexander Shishkin <alexander.shishkin@linux.intel.com>
Newsgroups linux.kernel
Subject [QUEUED v20160408 04/18] stm class: stm_heartbeat: Make nr_devs parameter read-only
Date 2016-04-08 17:10 +0200
Message-ID <rlGcP-5Mb-31@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_devs 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/heartbeat.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/hwtracing/stm/heartbeat.c b/drivers/hwtracing/stm/heartbeat.c
index 0133571b50..3da7b673aa 100644
--- a/drivers/hwtracing/stm/heartbeat.c
+++ b/drivers/hwtracing/stm/heartbeat.c
@@ -26,7 +26,7 @@
 static int nr_devs = 4;
 static int interval_ms = 10;
 
-module_param(nr_devs, int, 0600);
+module_param(nr_devs, int, 0400);
 module_param(interval_ms, int, 0600);
 
 static struct stm_heartbeat {
@@ -35,8 +35,6 @@ static struct stm_heartbeat {
 	unsigned int		active;
 } stm_heartbeat[STM_HEARTBEAT_MAX];
 
-static unsigned int nr_instances;
-
 static const char str[] = "heartbeat stm source driver is here to serve you";
 
 static enum hrtimer_restart stm_heartbeat_hrtimer_handler(struct hrtimer *hr)
@@ -74,12 +72,12 @@ static void stm_heartbeat_unlink(struct stm_source_data *data)
 
 static int stm_heartbeat_init(void)
 {
-	int i, ret = -ENOMEM, __nr_instances = ACCESS_ONCE(nr_devs);
+	int i, ret = -ENOMEM;
 
-	if (__nr_instances < 0 || __nr_instances > STM_HEARTBEAT_MAX)
+	if (nr_devs < 0 || nr_devs > STM_HEARTBEAT_MAX)
 		return -EINVAL;
 
-	for (i = 0; i < __nr_instances; i++) {
+	for (i = 0; i < nr_devs; i++) {
 		stm_heartbeat[i].data.name =
 			kasprintf(GFP_KERNEL, "heartbeat.%d", i);
 		if (!stm_heartbeat[i].data.name)
@@ -98,8 +96,6 @@ static int stm_heartbeat_init(void)
 			goto fail_free;
 	}
 
-	nr_instances = __nr_instances;
-
 	return 0;
 
 fail_unregister:
@@ -116,7 +112,7 @@ static void stm_heartbeat_exit(void)
 {
 	int i;
 
-	for (i = 0; i < nr_instances; i++) {
+	for (i = 0; i < nr_devs; i++) {
 		stm_source_unregister_device(&stm_heartbeat[i].data);
 		kfree(stm_heartbeat[i].data.name);
 	}
-- 
2.8.0.rc3

Back to linux.kernel | Previous | NextPrevious in thread | Next 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