net: usb: hso.c: remove unneeded DRIVER_LICENSE #define
Subsystems (5)
PATCH 1/1 net: usb: hso.c: remove unneeded DRIVER_LICENSE #define
There is no need to #define the license of the driver, just put it in the MODULE_LICENSE() line directly as a text string.
This allows tools that check that the module license matches the source code license to work properly, as there is no need to unwind the unneeded dereference.
--- drivers/net/usb/hso.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/usb/hso.c +1 -2
@@ -76,7 +76,6 @@#define MOD_AUTHOR "Option Wireless"#define MOD_DESCRIPTION "USB High Speed Option driver" -#define MOD_LICENSE "GPL"#define HSO_MAX_NET_DEVICES 10#define HSO__MAX_MTU 2048
@@ -3288,7 +3287,7 @@ module_exit(hso_exit);MODULE_AUTHOR (MOD_AUTHOR );MODULE_DESCRIPTION (MOD_DESCRIPTION ); -MODULE_LICENSE (MOD_LICENSE ); +MODULE_LICENSE ("GPL" );/* change the debug level (eg: insmod hso.ko debug=0x04) */ MODULE_PARM_DESC (debug,"debug level mask [0x01 | 0x02 | 0x04 | 0x08 | 0x10]" );
Signature · 1 line
2.15.0
Quoted 7 lines · Greg Kroah-Hartman
There is no need to #define the license of the driver, just put it in the
MODULE_LICENSE()line directly as a text string.This allows tools that check that the module license matches the source code license to work properly, as there is no need to unwind the unneeded dereference.
Quoted 5 lines
Cc "David S. Miller" <davem-fT/PcQaiUtIeIZ0/[email protected]>Cc Andreas Kemnade <[email protected]>Cc Johan Hovold <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Signature · 6 lines
Cordially Philippe Ombredanne -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
David Miller
maintainerFrom: Greg Kroah-Hartman <[email protected]>
Date: Fri, 17 Nov 2017 15:19:39 +0100
Quoted 7 lines
There is no need to #define the license of the driver, just put it in the
MODULE_LICENSE()line directly as a text string.This allows tools that check that the module license matches the source code license to work properly, as there is no need to unwind the unneeded dereference.
Quoted 5 lines
Cc "David S. Miller" <davem-fT/PcQaiUtIeIZ0/[email protected]>Cc Andreas Kemnade <[email protected]>Cc Johan Hovold <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Greg Kroah-Hartman
There is no need to #define the license of the driver, just put it in the
MODULE_LICENSE()line directly as a text string.This allows tools that check that the module license matches the source code license to work properly, as there is no need to unwind the unneeded dereference.
[]
drivers/net/usb/hso.c
Quoted 1 line
drivers/net/usb/hso.c +0
-0
[]
Quoted 9 lines
drivers/net/usb/hso.c +0
-1@@ -76,7 +76,6 @@#define MOD_AUTHOR "Option Wireless"#define MOD_DESCRIPTION "USB High Speed Option driver" -#define MOD_LICENSE "GPL"#define HSO_MAX_NET_DEVICES 10#define HSO__MAX_MTU 2048
drivers/net/usb/hso.c module_exit(hso_exit); · line 3290
Quoted 5 lines
drivers/net/usb/hso.c +1
-1@@ -3288,7 +3287,7 @@ module_exit(hso_exit);MODULE_AUTHOR (MOD_AUTHOR );MODULE_DESCRIPTION (MOD_DESCRIPTION ); -MODULE_LICENSE (MOD_LICENSE ); +MODULE_LICENSE ("GPL" );
Probably all of these MODULE_<FOO>(MOD_<BAR>) uses could be simplified as well.
Perhaps there's utility in a (cocci?) script that looks for used-once
macro #defines in various types of macros.
Quoted 20 lines · Joe Perches
Quoted 6 lines · Greg Kroah-Hartman
There is no need to #define the license of the driver, just put it in the
MODULE_LICENSE()line directly as a text string.This allows tools that check that the module license matches the source code license to work properly, as there is no need to unwind the unneeded dereference.
[]
drivers/net/usb/hso.c
Quoted 1 line
drivers/net/usb/hso.c +0
-0[]
Quoted 10 lines
drivers/net/usb/hso.c +0
-1@@ -76,7 +76,6 @@#define MOD_AUTHOR "Option Wireless"#define MOD_DESCRIPTION "USB High Speed Option driver" -#define MOD_LICENSE "GPL"#define HSO_MAX_NET_DEVICES 10#define HSO__MAX_MTU 2048@@ -3288,7 +3287,7 @@ module_exit(hso_exit);
Quoted 7 lines
drivers/net/usb/hso.c module_exit(hso_exit); · line 3290
Quoted 4 lines
drivers/net/usb/hso.c +1
-1MODULE_AUTHOR (MOD_AUTHOR );MODULE_DESCRIPTION (MOD_DESCRIPTION ); -MODULE_LICENSE (MOD_LICENSE ); +MODULE_LICENSE ("GPL" );Probably all of these MODULE_<FOO>(MOD_<BAR>) uses could be simplified as well.
Agreed, I did that for a bunch of USB drivers, need to do it for others as well.
thanks,
greg k-h
Quoted 31 lines · Greg Kroah-Hartman
Quoted 22 lines · Joe Perches
Quoted 6 lines · Greg Kroah-Hartman
There is no need to #define the license of the driver, just put it in the
MODULE_LICENSE()line directly as a text string.This allows tools that check that the module license matches the source code license to work properly, as there is no need to unwind the unneeded dereference.
[]
drivers/net/usb/hso.c
Quoted 1 line
drivers/net/usb/hso.c +0
-0[]
Quoted 10 lines
drivers/net/usb/hso.c +0
-1@@ -76,7 +76,6 @@#define MOD_AUTHOR "Option Wireless"#define MOD_DESCRIPTION "USB High Speed Option driver" -#define MOD_LICENSE "GPL"#define HSO_MAX_NET_DEVICES 10#define HSO__MAX_MTU 2048@@ -3288,7 +3287,7 @@ module_exit(hso_exit);Quoted 7 lines
drivers/net/usb/hso.c module_exit(hso_exit); · line 3290
Quoted 4 lines
drivers/net/usb/hso.c +1
-1MODULE_AUTHOR (MOD_AUTHOR );MODULE_DESCRIPTION (MOD_DESCRIPTION ); -MODULE_LICENSE (MOD_LICENSE ); +MODULE_LICENSE ("GPL" );Probably all of these MODULE_<FOO>(MOD_<BAR>) uses could be simplified as well.
Quoted 2 lines
Agreed, I did that for a bunch of USB drivers, need to do it for others as well.
Here's a little perl and bash script that seems to do the right thing
---
single_use_module.pl new file +15 -0
@@ -0,0 +1,15 @@ +$/ = undef; +my $var = $ARGV[0]; +my $file = $ARGV[1]; +print("var: <$var> file: <$file>\n"); +open my $fh, "<", $file or die; +my $data = <$fh>; +close $fh; +$data =~ s/\n#[ \t]*define\s+$var\s+(.*)\n/\n/; +my $string = $1; +print("string: <$string>\n"); +$string =~ s/\s+\n//; +$data =~ s~$var~$string~; +open my $fh, ">", $file or die; +print $fh $data; +close $fh;
single_use_module.bash new file +25 -0
@@ -0,0 +1,25 @@ +#!/bin/bash +git grep -P '\bMODULE_[A-Z]+\s*\(\s*[A-Z_]+\s*\)' $@ | + while read line ; do + file=$(echo $line | cut -f1 -d":") + define=$(echo $line | cut -f2- -d":") + var=$(echo $define | sed -r -e 's/^MODULE_[A-Z_]+\s*\(\s*//' -r -e 's/^([A-Z_]+).*$/\1/') + + # see if the define exists in the file + count1=$(git grep -c -P "^\s*#\s*define\s+$var\s+" $file | cut -f2- -d":") + if [[ $count1 != 1 ]] ; then + continue + fi + + # see if the var exists twice (once in the #define, once in the use) + count2=$(git grep -c -P -w $var $file | cut -f2- -d":") + if [[ $count2 != 2 ]] ; then + continue + fi + + if [[ "${defline: -1}" == "\\" ]] ; then + continue + fi + + perl single_use_module.pl $var $file + done
single_use_module.pl
Quoted 3 lines · Joe Perches
single_use_module.pl new file +0
-0@@ -0,0 +1,15 @@
[]
single_use_module.pl line 12
Quoted 1 line
single_use_module.pl new file +1
-0+$data =~ s~$var~$string~;
this needs to be:
$data =~ s~\b$var\b~$string~;
Quoted 28 lines · Joe Perches
Quoted 6 lines · Greg Kroah-Hartman
There is no need to #define the license of the driver, just put it in the
MODULE_LICENSE()line directly as a text string.This allows tools that check that the module license matches the source code license to work properly, as there is no need to unwind the unneeded dereference.
[]
drivers/net/usb/hso.c
Quoted 1 line
drivers/net/usb/hso.c +0
-0[]
Quoted 9 lines
drivers/net/usb/hso.c +0
-1@@ -76,7 +76,6 @@#define MOD_AUTHOR "Option Wireless"#define MOD_DESCRIPTION "USB High Speed Option driver" -#define MOD_LICENSE "GPL"#define HSO_MAX_NET_DEVICES 10#define HSO__MAX_MTU 2048drivers/net/usb/hso.c module_exit(hso_exit); · line 3290
Quoted 5 lines
drivers/net/usb/hso.c +1
-1@@ -3288,7 +3287,7 @@ module_exit(hso_exit);MODULE_AUTHOR (MOD_AUTHOR );MODULE_DESCRIPTION (MOD_DESCRIPTION ); -MODULE_LICENSE (MOD_LICENSE ); +MODULE_LICENSE ("GPL" );Probably all of these MODULE_<FOO>(MOD_<BAR>) uses could be simplified as well.
Quoted 3 lines
Perhaps there's utility in a (cocci?) script that looks for used-once
macro #defines in various types of macros.
It could be possible. It's a bit tricky due to ifdefs that Coccinelle doesn't see and header files, but perhaps in special cases like this there is not much worry.
julia
Quoted 8 lines
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe at googlegroups.com. To post to this group, send email to outreachy-kernel at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1511370336.6989.100.camel%40perches.com.
For more options, visit https://groups.google.com/d/optout.
Quoted 28 lines · Joe Perches
Quoted 6 lines · Greg Kroah-Hartman
There is no need to #define the license of the driver, just put it in the
MODULE_LICENSE()line directly as a text string.This allows tools that check that the module license matches the source code license to work properly, as there is no need to unwind the unneeded dereference.
[]
drivers/net/usb/hso.c
Quoted 1 line
drivers/net/usb/hso.c +0
-0[]
Quoted 9 lines
drivers/net/usb/hso.c +0
-1@@ -76,7 +76,6 @@#define MOD_AUTHOR "Option Wireless"#define MOD_DESCRIPTION "USB High Speed Option driver" -#define MOD_LICENSE "GPL"#define HSO_MAX_NET_DEVICES 10#define HSO__MAX_MTU 2048drivers/net/usb/hso.c module_exit(hso_exit); · line 3290
Quoted 5 lines
drivers/net/usb/hso.c +1
-1@@ -3288,7 +3287,7 @@ module_exit(hso_exit);MODULE_AUTHOR (MOD_AUTHOR );MODULE_DESCRIPTION (MOD_DESCRIPTION ); -MODULE_LICENSE (MOD_LICENSE ); +MODULE_LICENSE ("GPL" );Probably all of these MODULE_<FOO>(MOD_<BAR>) uses could be simplified as well.
Quoted 3 lines
Perhaps there's utility in a (cocci?) script that looks for used-once
macro #defines in various types of macros.
What about module_version, eg:
diff -u -p a/drivers/ata/pata_pdc202xx_old.cb/drivers/ata/pata_pdc202xx_old.c
drivers/ata/pata_pdc202xx_old.c +1 -2
@@ -21,7 +21,6 @@#include <linux/libata.h> #define DRV_NAME "pata_pdc202xx_old" -#define DRV_VERSION "0.4.3"static int pdc2026x_cable_detect (struct ata_port *ap) {
@@ -389,4 +388,4 @@ MODULE_AUTHOR("Alan Cox");MODULE_DESCRIPTION ("low-level driver for Promise 2024x and 20262-20267" );MODULE_LICENSE ("GPL" );MODULE_DEVICE_TABLE (pci, pdc202xx); -MODULE_VERSION (DRV_VERSION ); +MODULE_VERSION ("0.4.3" );
julia
Quoted 51 lines · Julia Lawall
Quoted 28 lines · Joe Perches
Quoted 6 lines · Greg Kroah-Hartman
There is no need to #define the license of the driver, just put it in the
MODULE_LICENSE()line directly as a text string.This allows tools that check that the module license matches the source code license to work properly, as there is no need to unwind the unneeded dereference.
[]
drivers/net/usb/hso.c
Quoted 1 line
drivers/net/usb/hso.c +0
-0[]
Quoted 9 lines
drivers/net/usb/hso.c +0
-1@@ -76,7 +76,6 @@#define MOD_AUTHOR "Option Wireless"#define MOD_DESCRIPTION "USB High Speed Option driver" -#define MOD_LICENSE "GPL"#define HSO_MAX_NET_DEVICES 10#define HSO__MAX_MTU 2048drivers/net/usb/hso.c module_exit(hso_exit); · line 3290
Quoted 5 lines
drivers/net/usb/hso.c +1
-1@@ -3288,7 +3287,7 @@ module_exit(hso_exit);MODULE_AUTHOR (MOD_AUTHOR );MODULE_DESCRIPTION (MOD_DESCRIPTION ); -MODULE_LICENSE (MOD_LICENSE ); +MODULE_LICENSE ("GPL" );Probably all of these MODULE_<FOO>(MOD_<BAR>) uses could be simplified as well.
Quoted 3 lines
Perhaps there's utility in a (cocci?) script that looks for used-once
macro #defines in various types of macros.What about
module_version, eg:diff -u -p
a/drivers/ata/pata_pdc202xx_old.cb/drivers/ata/pata_pdc202xx_old.cdrivers/ata/pata_pdc202xx_old.c +0
-1@@ -21,7 +21,6 @@#include <linux/libata.h> #define DRV_NAME "pata_pdc202xx_old" -#define DRV_VERSION "0.4.3"static int pdc2026x_cable_detect (struct ata_port *ap) {
drivers/ata/pata_pdc202xx_old.c MODULE_AUTHOR("Alan Cox"); · line 391
Quoted 5 lines
drivers/ata/pata_pdc202xx_old.c +1
-1@@ -389,4 +388,4 @@ MODULE_AUTHOR("Alan Cox");MODULE_DESCRIPTION ("low-level driver for Promise 2024x and 20262-20267" );MODULE_LICENSE ("GPL" );MODULE_DEVICE_TABLE (pci, pdc202xx); -MODULE_VERSION (DRV_VERSION ); +MODULE_VERSION ("0.4.3" );
I've just deleted MODULE_VERSION() entirely from some subsystems, as once the driver is in the kernel source tree, the "version" makes almost no sense at all.
But I know some companies love incrementing it (some network and scsi drivers specifically), so those might want to keep it around for some odd reason.
thanks
greg k-h
Quoted 62 lines · Greg Kroah-Hartman
Quoted 51 lines · Julia Lawall
Quoted 28 lines · Joe Perches
Quoted 6 lines · Greg Kroah-Hartman
There is no need to #define the license of the driver, just put it in the
MODULE_LICENSE()line directly as a text string.This allows tools that check that the module license matches the source code license to work properly, as there is no need to unwind the unneeded dereference.
[]
drivers/net/usb/hso.c
Quoted 1 line
drivers/net/usb/hso.c +0
-0[]
Quoted 9 lines
drivers/net/usb/hso.c +0
-1@@ -76,7 +76,6 @@#define MOD_AUTHOR "Option Wireless"#define MOD_DESCRIPTION "USB High Speed Option driver" -#define MOD_LICENSE "GPL"#define HSO_MAX_NET_DEVICES 10#define HSO__MAX_MTU 2048drivers/net/usb/hso.c module_exit(hso_exit); · line 3290
Quoted 5 lines
drivers/net/usb/hso.c +1
-1@@ -3288,7 +3287,7 @@ module_exit(hso_exit);MODULE_AUTHOR (MOD_AUTHOR );MODULE_DESCRIPTION (MOD_DESCRIPTION ); -MODULE_LICENSE (MOD_LICENSE ); +MODULE_LICENSE ("GPL" );Probably all of these MODULE_<FOO>(MOD_<BAR>) uses could be simplified as well.
Quoted 3 lines
Perhaps there's utility in a (cocci?) script that looks for used-once
macro #defines in various types of macros.What about
module_version, eg:diff -u -p
a/drivers/ata/pata_pdc202xx_old.cb/drivers/ata/pata_pdc202xx_old.cdrivers/ata/pata_pdc202xx_old.c +0
-1@@ -21,7 +21,6 @@#include <linux/libata.h> #define DRV_NAME "pata_pdc202xx_old" -#define DRV_VERSION "0.4.3"static int pdc2026x_cable_detect (struct ata_port *ap) {drivers/ata/pata_pdc202xx_old.c MODULE_AUTHOR("Alan Cox"); · line 391
Quoted 5 lines
drivers/ata/pata_pdc202xx_old.c +1
-1@@ -389,4 +388,4 @@ MODULE_AUTHOR("Alan Cox");MODULE_DESCRIPTION ("low-level driver for Promise 2024x and 20262-20267" );MODULE_LICENSE ("GPL" );MODULE_DEVICE_TABLE (pci, pdc202xx); -MODULE_VERSION (DRV_VERSION ); +MODULE_VERSION ("0.4.3" );I've just deleted
MODULE_VERSION()entirely from some subsystems, as once the driver is in the kernel source tree, the "version" makes almost no sense at all.
Quoted 3 lines
But I know some companies love incrementing it (some network and scsi drivers specifically), so those might want to keep it around for some odd reason.
OK, that seems like a simple soluton. Thanks.
julia