[staging 1/3 V2] Staging:easycap: fix sparse warnings for module parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



easycap_main.c:34:5: warning: symbol 'easycap_debug' was not declared. Should it be static?
easycap_main.c:36:5: warning: symbol 'easycap_gain' was not declared. Should it be static?

These two variables actually were declared in several places.
The variables are used in several files.
I've fixed "easycap_debug" so it gets declared in one place only and included properly.
For "easycap_gain" made it static and I created added a
->gain member to the easycap struct.  This seems cleaner than using a
global variable and later on we may make this controlable via sysfs.

Cc:Mike Thomas <rmthomas@xxxxxxxxxxx>
Cc:Dan Carpenter <error27@xxxxxxxxx>
Signed-off-by: Tomas Winkler <tomas.winkler@xxxxxxxxx>
---
Should be applied on top of 'Add ALSA sound'
V2: add Dan Carpenter commit comments
    remove redunant easycap_gain declarations in header files

 drivers/staging/easycap/easycap.h          |    4 ++++
 drivers/staging/easycap/easycap_ioctl.h    |    2 --
 drivers/staging/easycap/easycap_low.c      |    6 +-----
 drivers/staging/easycap/easycap_low.h      |    2 --
 drivers/staging/easycap/easycap_main.c     |    7 ++++++-
 drivers/staging/easycap/easycap_settings.h |    2 --
 drivers/staging/easycap/easycap_sound.h    |    2 --
 drivers/staging/easycap/easycap_testcard.h |    2 --
 8 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/easycap/easycap.h b/drivers/staging/easycap/easycap.h
index 111f53c..1205f5f 100644
--- a/drivers/staging/easycap/easycap.h
+++ b/drivers/staging/easycap/easycap.h
@@ -475,6 +475,7 @@ int audio_idle;
 int audio_eof;
 int volume;
 int mute;
+s8 gain;
 
 struct data_buffer audio_isoc_buffer[AUDIO_ISOC_BUFFER_MANY];
 
@@ -639,6 +640,8 @@ struct signed_div_result {
 long long int quotient;
 unsigned long long int remainder;
 } signed_div(long long int, long long int);
+
+
 /*---------------------------------------------------------------------------*/
 /*
  *  MACROS
@@ -668,6 +671,7 @@ unsigned long long int remainder;
  *  IMMEDIATELY OBVIOUS FROM A CASUAL READING OF THE SOURCE CODE.  BEWARE.
 */
 /*---------------------------------------------------------------------------*/
+extern int easycap_debug;
 #define SAY(format, args...) do { \
 	printk(KERN_DEBUG "easycap:: %s: " \
 			format, __func__, ##args); \
diff --git a/drivers/staging/easycap/easycap_ioctl.h b/drivers/staging/easycap/easycap_ioctl.h
index 938de37..245386f 100644
--- a/drivers/staging/easycap/easycap_ioctl.h
+++ b/drivers/staging/easycap/easycap_ioctl.h
@@ -27,8 +27,6 @@
 #if !defined(EASYCAP_IOCTL_H)
 #define EASYCAP_IOCTL_H
 
-extern int easycap_debug;
-extern int easycap_gain;
 extern struct easycap_dongle easycapdc60_dongle[];
 extern struct easycap_standard easycap_standard[];
 extern struct easycap_format easycap_format[];
diff --git a/drivers/staging/easycap/easycap_low.c b/drivers/staging/easycap/easycap_low.c
index b618d4b..e9f3a36 100644
--- a/drivers/staging/easycap/easycap_low.c
+++ b/drivers/staging/easycap/easycap_low.c
@@ -1091,11 +1091,7 @@ SAM("0x%04X:0x%04X is audio vendor id\n", id1, id2);
  *  SELECT AUDIO SOURCE "LINE IN" AND SET THE AUDIO GAIN.
 */
 /*---------------------------------------------------------------------------*/
-if (31 < easycap_gain)
-	easycap_gain = 31;
-if (0 > easycap_gain)
-	easycap_gain = 0;
-if (0 != audio_gainset(pusb_device, (__s8)easycap_gain))
+if (0 != audio_gainset(pusb_device, peasycap->gain))
 	SAY("ERROR: audio_gainset() failed\n");
 check_vt(pusb_device);
 return 0;
diff --git a/drivers/staging/easycap/easycap_low.h b/drivers/staging/easycap/easycap_low.h
index b998fc8..41e3724 100644
--- a/drivers/staging/easycap/easycap_low.h
+++ b/drivers/staging/easycap/easycap_low.h
@@ -27,8 +27,6 @@
 #if !defined(EASYCAP_LOW_H)
 #define EASYCAP_LOW_H
 
-extern int easycap_debug;
-extern int easycap_gain;
 extern struct easycap_dongle easycapdc60_dongle[];
 
 #endif /*EASYCAP_LOW_H*/
diff --git a/drivers/staging/easycap/easycap_main.c b/drivers/staging/easycap/easycap_main.c
index 84128cf..a0b954c 100644
--- a/drivers/staging/easycap/easycap_main.c
+++ b/drivers/staging/easycap/easycap_main.c
@@ -33,7 +33,7 @@
 
 int easycap_debug;
 static int easycap_bars = 1;
-int easycap_gain = 16;
+static int easycap_gain = 16;
 module_param_named(debug, easycap_debug, int, S_IRUGO | S_IWUSR);
 module_param_named(bars, easycap_bars, int, S_IRUGO | S_IWUSR);
 module_param_named(gain, easycap_gain, int, S_IRUGO | S_IWUSR);
@@ -3412,6 +3412,8 @@ struct v4l2_device *pv4l2_device;
 #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/
 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
 
+/* setup modules params */
+
 if ((struct usb_interface *)NULL == pusb_interface) {
 	SAY("ERROR: pusb_interface is NULL\n");
 	return -EFAULT;
@@ -3547,6 +3549,9 @@ if (0 == bInterfaceNumber) {
 			"%i=peasycap->kref.refcount.counter\n", \
 			bInterfaceNumber, peasycap->kref.refcount.counter);
 
+	/* module params */
+	peasycap->gain = (s8)clamp(easycap_gain, 0, 31);
+
 	init_waitqueue_head(&peasycap->wq_video);
 	init_waitqueue_head(&peasycap->wq_audio);
 	init_waitqueue_head(&peasycap->wq_trigger);
diff --git a/drivers/staging/easycap/easycap_settings.h b/drivers/staging/easycap/easycap_settings.h
index ada8048..11f9e22 100644
--- a/drivers/staging/easycap/easycap_settings.h
+++ b/drivers/staging/easycap/easycap_settings.h
@@ -27,8 +27,6 @@
 #if !defined(EASYCAP_SETTINGS_H)
 #define EASYCAP_SETTINGS_H
 
-extern int easycap_debug;
-extern int easycap_gain;
 extern struct easycap_dongle easycapdc60_dongle[];
 
 #endif /*EASYCAP_SETTINGS_H*/
diff --git a/drivers/staging/easycap/easycap_sound.h b/drivers/staging/easycap/easycap_sound.h
index 82104c8..ffcd6f2 100644
--- a/drivers/staging/easycap/easycap_sound.h
+++ b/drivers/staging/easycap/easycap_sound.h
@@ -27,8 +27,6 @@
 #if !defined(EASYCAP_SOUND_H)
 #define EASYCAP_SOUND_H
 
-extern int easycap_debug;
-extern int easycap_gain;
 extern struct easycap_dongle easycapdc60_dongle[];
 extern struct easycap *peasycap;
 extern struct usb_driver easycap_usb_driver;
diff --git a/drivers/staging/easycap/easycap_testcard.h b/drivers/staging/easycap/easycap_testcard.h
index 3309364..d968096 100644
--- a/drivers/staging/easycap/easycap_testcard.h
+++ b/drivers/staging/easycap/easycap_testcard.h
@@ -27,8 +27,6 @@
 #if !defined(EASYCAP_TESTCARD_H)
 #define EASYCAP_TESTCARD_H
 
-extern int easycap_debug;
-extern int easycap_gain;
 extern struct easycap_dongle easycapdc60_dongle[];
 
 #endif /*EASYCAP_TESTCARD_H*/
-- 
1.7.3.4

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux