2024-04-26 14:40:12

by Kalle Valo

[permalink] [raw]
Subject: [PATCH 1/2] wifi: rtl8xxxu: remove some unused includes

I noticed by random that rtl8xxxu includes linux/wireless.h even though it
doesn't need it. While investigating a bit more I found even more unused
include files:

#include <linux/init.h>
#include <linux/sched.h>
#include <linux/ethtool.h>

It looks like that the includes are just copied to every file without checking
if the file really needs the include. So more includes could be removed but
that would need more careful analysis per each file.

No functional changes, compile tested only.

Signed-off-by: Kalle Valo <[email protected]>
---
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 4 ----
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 4 ----
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c | 4 ----
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 4 ----
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192f.c | 4 ----
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8710b.c | 4 ----
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c | 4 ----
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 4 ----
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 4 ----
9 files changed, 36 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
index afe9cc1b49dc..43735ca70b7c 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
@@ -13,9 +13,7 @@
* additional 8xxx chips like the 8192cu, 8188cus, etc.
*/

-#include <linux/init.h>
#include <linux/kernel.h>
-#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/module.h>
@@ -24,8 +22,6 @@
#include <linux/usb.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
-#include <linux/ethtool.h>
-#include <linux/wireless.h>
#include <linux/firmware.h>
#include <linux/moduleparam.h>
#include <net/mac80211.h>
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
index 464216d007ce..9043e548518f 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
@@ -11,9 +11,7 @@
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*/

-#include <linux/init.h>
#include <linux/kernel.h>
-#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/module.h>
@@ -22,8 +20,6 @@
#include <linux/usb.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
-#include <linux/ethtool.h>
-#include <linux/wireless.h>
#include <linux/firmware.h>
#include <linux/moduleparam.h>
#include <net/mac80211.h>
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
index ddf2d9707338..49eb1d0a6019 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
@@ -13,9 +13,7 @@
* additional 8xxx chips like the 8192cu, 8188cus, etc.
*/

-#include <linux/init.h>
#include <linux/kernel.h>
-#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/module.h>
@@ -24,8 +22,6 @@
#include <linux/usb.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
-#include <linux/ethtool.h>
-#include <linux/wireless.h>
#include <linux/firmware.h>
#include <linux/moduleparam.h>
#include <net/mac80211.h>
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
index 63b73ace27ec..26132b6b9331 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
@@ -13,9 +13,7 @@
* additional 8xxx chips like the 8192cu, 8188cus, etc.
*/

-#include <linux/init.h>
#include <linux/kernel.h>
-#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/module.h>
@@ -24,8 +22,6 @@
#include <linux/usb.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
-#include <linux/ethtool.h>
-#include <linux/wireless.h>
#include <linux/firmware.h>
#include <linux/moduleparam.h>
#include <net/mac80211.h>
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192f.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192f.c
index 21e4204769d0..9f1d4a6ee210 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192f.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192f.c
@@ -11,9 +11,7 @@
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*/

-#include <linux/init.h>
#include <linux/kernel.h>
-#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/module.h>
@@ -22,8 +20,6 @@
#include <linux/usb.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
-#include <linux/ethtool.h>
-#include <linux/wireless.h>
#include <linux/firmware.h>
#include <linux/moduleparam.h>
#include <net/mac80211.h>
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8710b.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8710b.c
index 46d57510e9fc..aa27ac4f828b 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8710b.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8710b.c
@@ -11,9 +11,7 @@
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*/

-#include <linux/init.h>
#include <linux/kernel.h>
-#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/module.h>
@@ -22,8 +20,6 @@
#include <linux/usb.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
-#include <linux/ethtool.h>
-#include <linux/wireless.h>
#include <linux/firmware.h>
#include <linux/moduleparam.h>
#include <net/mac80211.h>
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
index bf8c34af781f..965c8c3662a6 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
@@ -13,9 +13,7 @@
* additional 8xxx chips like the 8192cu, 8188cus, etc.
*/

-#include <linux/init.h>
#include <linux/kernel.h>
-#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/module.h>
@@ -24,8 +22,6 @@
#include <linux/usb.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
-#include <linux/ethtool.h>
-#include <linux/wireless.h>
#include <linux/firmware.h>
#include <linux/moduleparam.h>
#include <net/mac80211.h>
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
index 6653f43973cf..3355d8e97870 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
@@ -13,9 +13,7 @@
* additional 8xxx chips like the 8192cu, 8188cus, etc.
*/

-#include <linux/init.h>
#include <linux/kernel.h>
-#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/module.h>
@@ -24,8 +22,6 @@
#include <linux/usb.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
-#include <linux/ethtool.h>
-#include <linux/wireless.h>
#include <linux/firmware.h>
#include <linux/moduleparam.h>
#include <net/mac80211.h>
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index e72f35a40ab3..54f955b01475 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -13,9 +13,7 @@
* additional 8xxx chips like the 8192cu, 8188cus, etc.
*/

-#include <linux/init.h>
#include <linux/kernel.h>
-#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/module.h>
@@ -24,8 +22,6 @@
#include <linux/usb.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
-#include <linux/ethtool.h>
-#include <linux/wireless.h>
#include <linux/firmware.h>
#include <linux/moduleparam.h>
#include <net/mac80211.h>

base-commit: 4ea11e4db3550ee655b411b43498552e8c6ead01
--
2.39.2



2024-04-29 02:08:19

by Ping-Ke Shih

[permalink] [raw]
Subject: RE: [PATCH 1/2] wifi: rtl8xxxu: remove some unused includes

Kalle Valo <[email protected]> wrote:
> I noticed by random that rtl8xxxu includes linux/wireless.h even though it
> doesn't need it. While investigating a bit more I found even more unused
> include files:
>
> #include <linux/init.h>
> #include <linux/sched.h>
> #include <linux/ethtool.h>
>
> It looks like that the includes are just copied to every file without checking
> if the file really needs the include. So more includes could be removed but
> that would need more careful analysis per each file.

I can do that. My ways will be to create an empty (new) C file to examine
every driver's header file can be included individually, and then try-and-error
to remove includes from existing C files.

However, this driver uses #ifdef. I will check if autoconf.h is included.

>
> No functional changes, compile tested only.
>
> Signed-off-by: Kalle Valo <[email protected]>

Reviewed-by: Ping-Ke Shih <[email protected]>



2024-04-29 02:55:10

by Ping-Ke Shih

[permalink] [raw]
Subject: RE: [PATCH 1/2] wifi: rtl8xxxu: remove some unused includes

Ping-Ke Shih wrote:
> Kalle Valo <[email protected]> wrote:
> > I noticed by random that rtl8xxxu includes linux/wireless.h even though it
> > doesn't need it. While investigating a bit more I found even more unused
> > include files:
> >
> > #include <linux/init.h>
> > #include <linux/sched.h>
> > #include <linux/ethtool.h>
> >
> > It looks like that the includes are just copied to every file without checking
> > if the file really needs the include. So more includes could be removed but
> > that would need more careful analysis per each file.
>
> I can do that. My ways will be to create an empty (new) C file to examine
> every driver's header file can be included individually, and then try-and-error
> to remove includes from existing C files.

I made a patch [1] followed above ways based on these two patches.

>
> However, this driver uses #ifdef. I will check if autoconf.h is included.

Make script of kernel will automatically include include/linux/kconfig.h, so
I didn't need extra works for #ifdef.

[1] https://lore.kernel.org/linux-wireless/[email protected]/T/#u


2024-04-29 12:58:06

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 1/2] wifi: rtl8xxxu: remove some unused includes

Ping-Ke Shih <[email protected]> writes:

> Ping-Ke Shih wrote:
>> Kalle Valo <[email protected]> wrote:
>> > I noticed by random that rtl8xxxu includes linux/wireless.h even though it
>> > doesn't need it. While investigating a bit more I found even more unused
>> > include files:
>> >
>> > #include <linux/init.h>
>> > #include <linux/sched.h>
>> > #include <linux/ethtool.h>
>> >
>> > It looks like that the includes are just copied to every file without checking
>> > if the file really needs the include. So more includes could be removed but
>> > that would need more careful analysis per each file.
>>
>> I can do that. My ways will be to create an empty (new) C file to examine
>> every driver's header file can be included individually, and then try-and-error
>> to remove includes from existing C files.
>
> I made a patch [1] followed above ways based on these two patches.

Excellent, thanks Ping.

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2024-05-02 03:07:36

by Ping-Ke Shih

[permalink] [raw]
Subject: Re: [PATCH 1/2] wifi: rtl8xxxu: remove some unused includes

Kalle Valo <[email protected]> wrote:

> I noticed by random that rtl8xxxu includes linux/wireless.h even though it
> doesn't need it. While investigating a bit more I found even more unused
> include files:
>
> #include <linux/init.h>
> #include <linux/sched.h>
> #include <linux/ethtool.h>
>
> It looks like that the includes are just copied to every file without checking
> if the file really needs the include. So more includes could be removed but
> that would need more careful analysis per each file.
>
> No functional changes, compile tested only.
>
> Signed-off-by: Kalle Valo <[email protected]>
> Reviewed-by: Ping-Ke Shih <[email protected]>

2 patch(es) applied to rtw-next branch of rtw.git, thanks.

a890495b297b wifi: rtl8xxxu: remove some unused includes
028fa281712d wifi: rtl8xxxu: remove rtl8xxxu_ prefix from filenames

---
https://github.com/pkshih/rtw.git