History log of /linux-master/drivers/staging/rtl8712/usb_intf.c
Revision Date Author Comments
# 1422b526 31-Jul-2023 Nam Cao <namcaov@gmail.com>

staging: rtl8712: fix race condition

In probe function, request_firmware_nowait() is called to load firmware
asynchronously. At completion of firmware loading, register_netdev() is
called. However, a mutex needed by netdev is initialized after the call
to request_firmware_nowait(). Consequently, it can happen that
register_netdev() is called before the driver is ready.

Move the mutex initialization into r8712_init_drv_sw(), which is called
before request_firmware_nowait().

Reported-by: syzbot+b08315e8cf5a78eed03c@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-staging/000000000000d9d4560601b8e0d7@google.com/T/#u
Fixes: 8c213fa59199 ("staging: r8712u: Use asynchronous firmware loading")
Cc: stable <stable@kernel.org>
Signed-off-by: Nam Cao <namcaov@gmail.com>
Link: https://lore.kernel.org/r/20230731110620.116562-1-namcaov@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0458e542 16-May-2022 Wang Cheng <wanngchenng@gmail.com>

staging: rtl8712: fix uninit-value in r871xu_drv_init()

When 'tmpU1b' returns from r8712_read8(padapter, EE_9346CR) is 0,
'mac[6]' will not be initialized.

BUG: KMSAN: uninit-value in r871xu_drv_init+0x2d54/0x3070 drivers/staging/rtl8712/usb_intf.c:541
r871xu_drv_init+0x2d54/0x3070 drivers/staging/rtl8712/usb_intf.c:541
usb_probe_interface+0xf19/0x1600 drivers/usb/core/driver.c:396
really_probe+0x653/0x14b0 drivers/base/dd.c:596
__driver_probe_device+0x3e9/0x530 drivers/base/dd.c:752
driver_probe_device drivers/base/dd.c:782 [inline]
__device_attach_driver+0x79f/0x1120 drivers/base/dd.c:899
bus_for_each_drv+0x2d6/0x3f0 drivers/base/bus.c:427
__device_attach+0x593/0x8e0 drivers/base/dd.c:970
device_initial_probe+0x4a/0x60 drivers/base/dd.c:1017
bus_probe_device+0x17b/0x3e0 drivers/base/bus.c:487
device_add+0x1fff/0x26e0 drivers/base/core.c:3405
usb_set_configuration+0x37e9/0x3ed0 drivers/usb/core/message.c:2170
usb_generic_driver_probe+0x13c/0x300 drivers/usb/core/generic.c:238
usb_probe_device+0x309/0x570 drivers/usb/core/driver.c:293
really_probe+0x653/0x14b0 drivers/base/dd.c:596
__driver_probe_device+0x3e9/0x530 drivers/base/dd.c:752
driver_probe_device drivers/base/dd.c:782 [inline]
__device_attach_driver+0x79f/0x1120 drivers/base/dd.c:899
bus_for_each_drv+0x2d6/0x3f0 drivers/base/bus.c:427
__device_attach+0x593/0x8e0 drivers/base/dd.c:970
device_initial_probe+0x4a/0x60 drivers/base/dd.c:1017
bus_probe_device+0x17b/0x3e0 drivers/base/bus.c:487
device_add+0x1fff/0x26e0 drivers/base/core.c:3405
usb_new_device+0x1b8e/0x2950 drivers/usb/core/hub.c:2566
hub_port_connect drivers/usb/core/hub.c:5358 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5502 [inline]
port_event drivers/usb/core/hub.c:5660 [inline]
hub_event+0x58e3/0x89e0 drivers/usb/core/hub.c:5742
process_one_work+0xdb6/0x1820 kernel/workqueue.c:2307
worker_thread+0x10b3/0x21e0 kernel/workqueue.c:2454
kthread+0x3c7/0x500 kernel/kthread.c:377
ret_from_fork+0x1f/0x30

Local variable mac created at:
r871xu_drv_init+0x1771/0x3070 drivers/staging/rtl8712/usb_intf.c:394
usb_probe_interface+0xf19/0x1600 drivers/usb/core/driver.c:396

KMSAN: uninit-value in r871xu_drv_init
https://syzkaller.appspot.com/bug?id=3cd92b1d85428b128503bfa7a250294c9ae00bd8

Reported-by: <syzbot+6f5ecd144854c0d8580b@syzkaller.appspotmail.com>
Tested-by: <syzbot+6f5ecd144854c0d8580b@syzkaller.appspotmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Wang Cheng <wanngchenng@gmail.com>
Link: https://lore.kernel.org/r/14c3886173dfa4597f0704547c414cfdbcd11d16.1652618244.git.wanngchenng@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7288ff56 04-Apr-2022 Xiaoke Wang <xkernel.wang@foxmail.com>

staging: rtl8712: fix a potential memory leak in r871xu_drv_init()

In r871xu_drv_init(), if r8712_init_drv_sw() fails, then the memory
allocated by r8712_alloc_io_queue() in r8712_usb_dvobj_init() is not
properly released as there is no action will be performed by
r8712_usb_dvobj_deinit().
To properly release it, we should call r8712_free_io_queue() in
r8712_usb_dvobj_deinit().

Besides, in r871xu_dev_remove(), r8712_usb_dvobj_deinit() will be called
by r871x_dev_unload() under condition `padapter->bup` and
r8712_free_io_queue() is called by r8712_free_drv_sw().
However, r8712_usb_dvobj_deinit() does not rely on `padapter->bup` and
calling r8712_free_io_queue() in r8712_free_drv_sw() is negative for
better understading the code.
So I move r8712_usb_dvobj_deinit() into r871xu_dev_remove(), and remove
r8712_free_io_queue() from r8712_free_drv_sw().

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
Link: https://lore.kernel.org/r/tencent_B8048C592777830380A23A7C4409F9DF1305@qq.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a3515f20 22-Mar-2022 Sathish Kumar <skumark1902@gmail.com>

staging: rtl8712: Use completions for signaling

r8712_sitesurvey_cmd() uses a variable to notify r8712_SetFilter() that it
has completed operation. There is no sort of assurance that the variable will
actually change and it could cache the value the first time it is read and
then never update it for the whole loop logic.

Use completion variables because they are better suited for the purpose.

This patch fixes the checkpatch.pl warnings like:
CHECK: Avoid CamelCase: <blnEnableRxFF0Filter>
+ u8 blnEnableRxFF0Filter;

Reviewed-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Signed-off-by: Sathish Kumar <skumark1902@gmail.com>
Link: https://lore.kernel.org/r/20220323045515.2513-1-skumark1902@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c052cc1a 19-Oct-2021 Pavel Skripkin <paskripkin@gmail.com>

staging: rtl8712: fix use-after-free in rtl8712_dl_fw

Syzbot reported use-after-free in rtl8712_dl_fw(). The problem was in
race condition between r871xu_dev_remove() ->ndo_open() callback.

It's easy to see from crash log, that driver accesses released firmware
in ->ndo_open() callback. It may happen, since driver was releasing
firmware _before_ unregistering netdev. Fix it by moving
unregister_netdev() before cleaning up resources.

Call Trace:
...
rtl871x_open_fw drivers/staging/rtl8712/hal_init.c:83 [inline]
rtl8712_dl_fw+0xd95/0xe10 drivers/staging/rtl8712/hal_init.c:170
rtl8712_hal_init drivers/staging/rtl8712/hal_init.c:330 [inline]
rtl871x_hal_init+0xae/0x180 drivers/staging/rtl8712/hal_init.c:394
netdev_open+0xe6/0x6c0 drivers/staging/rtl8712/os_intfs.c:380
__dev_open+0x2bc/0x4d0 net/core/dev.c:1484

Freed by task 1306:
...
release_firmware+0x1b/0x30 drivers/base/firmware_loader/main.c:1053
r871xu_dev_remove+0xcc/0x2c0 drivers/staging/rtl8712/usb_intf.c:599
usb_unbind_interface+0x1d8/0x8d0 drivers/usb/core/driver.c:458

Fixes: 8c213fa59199 ("staging: r8712u: Use asynchronous firmware loading")
Cc: stable <stable@vger.kernel.org>
Reported-and-tested-by: syzbot+c55162be492189fb4f51@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Link: https://lore.kernel.org/r/20211019211718.26354-1-paskripkin@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 349f631d 19-Oct-2021 Jakub Kicinski <kuba@kernel.org>

staging: use eth_hw_addr_set() instead of ether_addr_copy()

Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.

Convert staging from ether_addr_copy() to eth_hw_addr_set():

@@
expression dev, np;
@@
- ether_addr_copy(dev->dev_addr, np)
+ eth_hw_addr_set(dev, np)

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/r/20211019171243.1412240-3-kuba@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e9e6aa51 21-Jul-2021 Pavel Skripkin <paskripkin@gmail.com>

staging: rtl8712: error handling refactoring

There was strange error handling logic in case of fw load failure. For
some reason fw loader callback was doing clean up stuff when fw is not
available. I don't see any reason behind doing this. Since this driver
doesn't have EEPROM firmware let's just disconnect it in case of fw load
failure. Doing clean up stuff in 2 different place which can run
concurently is not good idea and syzbot found 2 bugs related to this
strange approach.

So, in this pacth I deleted all clean up code from fw callback and made
a call to device_release_driver() under device_lock(parent) in case of fw
load failure. This approach is more generic and it defend driver from UAF
bugs, since all clean up code is moved to one place.

Fixes: e02a3b945816 ("staging: rtl8712: fix memory leak in rtl871x_load_fw_cb")
Fixes: 8c213fa59199 ("staging: r8712u: Use asynchronous firmware loading")
Cc: stable <stable@vger.kernel.org>
Reported-and-tested-by: syzbot+5872a520e0ce0a7c7230@syzkaller.appspotmail.com
Reported-and-tested-by: syzbot+cc699626e48a6ebaf295@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Link: https://lore.kernel.org/r/d49ecc56e97c4df181d7bd4d240b031f315eacc3.1626895918.git.paskripkin@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9be550ee 21-Jul-2021 Pavel Skripkin <paskripkin@gmail.com>

staging: rtl8712: get rid of flush_scheduled_work

This patch is preparation for following patch for error handling
refactoring.

flush_scheduled_work() takes (wq_completion)events lock and
it can lead to deadlock when r871xu_dev_remove() is called from workqueue.
To avoid deadlock sutiation we can change flush_scheduled_work() call to
flush_work() call for all possibly scheduled works in this driver,
since next patch adds device_release_driver() in case of fw load failure.

Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/6e028b4c457eeb7156c76c6ea3cdb3cb0207c7e1.1626895918.git.paskripkin@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d1d3e3cd 13-Jun-2021 Pavel Skripkin <paskripkin@gmail.com>

staging: rtl8712: fix error handling in r871xu_drv_init

Previous error handling path was unique for all
possible errors and there was unnecessary branching.
Also, one step for freeing drv_sw was missing. All
these problems was fixed by restructuring error
handling path.

Also, moved out free_netdev() from r8712_free_drv_sw() for
correct error handling.

Fixes: 2865d42c78a9 ("staging: r8712u: Add the new driver to the mainline kernel")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Link: https://lore.kernel.org/r/febb00f72354449bb4d305f373d6d2f47e539ab4.1623620630.git.paskripkin@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 69d998f1 13-Jun-2021 Pavel Skripkin <paskripkin@gmail.com>

staging: rtl8712: remove redundant check in r871xu_drv_init

padapter->dvobj_init is initialized rigth before
initialization check. There is no need for any
branching here.

Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Link: https://lore.kernel.org/r/d367e5f39f22af44c545f8710cc18fb00f10e66c.1623620630.git.paskripkin@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 939ef169 21-May-2021 Hriday Hegde <hridayhegde1999@gmail.com>

staging: rtl8712: Removed unnecessary blank lines

Following lines were fixed as dictated by running checkpatch

CHECK: Please don't use multiple blank lines
65: FILE: drivers/staging/rtl8712/xmit_linux.c:65:
+

CHECK: Blank lines aren't necessary after an open brace '{'
39: FILE: drivers/staging/rtl8712/usb_intf.c:39:
+static const struct usb_device_id rtl871x_usb_id_tbl[] = {

CHECK: Blank lines aren't necessary after an open brace '{'
849: FILE: drivers/staging/rtl8712/rtl871x_xmit.c:849:
+{

CHECK: Please don't use multiple blank lines
260: FILE: drivers/staging/rtl8712/rtl871x_sta_mgt.c:260:
+

Signed-off-by: Hriday Hegde <hridayhegde1999@gmail.com>
Link: https://lore.kernel.org/r/20210521153924.22843-1-hridayhegde1999@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0e934ce2 19-Sep-2020 Michael Straube <straube.linux@gmail.com>

staging: rtl8712: clean up comparsions to NULL

Clean up comparsions to NULL Reported by checkpatch.
if (x == NULL) -> if (!x)
if (x != NULL) -> if (x)

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20200919085032.32453-1-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b4383c97 16-Jul-2020 Rustam Kovhaev <rkovhaev@gmail.com>

staging: rtl8712: handle firmware load failure

when firmware fails to load we should not call unregister_netdev()
this patch fixes a race condition between rtl871x_load_fw_cb() and
r871xu_dev_remove() and fixes the bug reported by syzbot

Reported-by: syzbot+80899a8a8efe8968cde7@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=80899a8a8efe8968cde7
Signed-off-by: Rustam Kovhaev <rkovhaev@gmail.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200716151324.1036204-1-rkovhaev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c724f776 09-Dec-2019 Johan Hovold <johan@kernel.org>

staging: rtl8712: fix interface sanity check

Make sure to use the current alternate setting when verifying the
interface descriptors to avoid binding to an invalid interface.

Failing to do so could cause the driver to misbehave or trigger a WARN()
in usb_submit_urb() that kernels with panic_on_warn set would choke on.

Fixes: 2865d42c78a9 ("staging: r8712u: Add the new driver to the mainline kernel")
Cc: stable <stable@vger.kernel.org> # 2.6.37
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20191210114751.5119-3-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 690407fd 07-Aug-2019 Nishka Dasgupta <nishkadg.linux@gmail.com>

staging: rtl8712: init_drv_sw(): Change return values

Change return values of init_drv_sw from _SUCCESS and _FAIL to 0 and
-ENOMEM. Change return type from u8 to int to allow this.
Add a return variable to streamline return of error codes of called
functions.
Modify call site to check for non-zero return value instead of _FAIL.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Link: https://lore.kernel.org/r/20190808064012.12661-7-nishkadg.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6cc6677a 11-Jun-2019 Deepak Mishra <linux.dkm@gmail.com>

staging: rtl8712: Fixed CamelCase lockRxFF0Filter renamed to lock_rx_ff0_filter

In process of cleaning up struct _adapter in drv_types.h, lockRxFF0Filter
is renamed to to lock_rx_ff0_filter to fix a checkpatch reported issue.

Signed-off-by: Deepak Mishra <linux.dkm@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 906ad742 09-Jun-2019 Deepak Mishra <linux.dkm@gmail.com>

staging: rtl8712: Fixed CamelCase for EepromAddressSize

This patch renames CamelCase EepromAddressSizefrom to eeprom_address_size in
struct _adapter and in related files drv_types.h, rtl871x_eeprom.c, usb_intf.c

This was reported by checkpatch.pl

Signed-off-by: Deepak Mishra <linux.dkm@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7e517382 03-Mar-2019 Himadri Pandya <himadri18.07@gmail.com>

staging: rtl8712: rename bSuspended to suspended

- Rename structure field bSuspended to suspended to avoid camelcase.
Suggested by checkpatch.
- Change type to bool as the variable is used as a boolean.

Signed-off-by: Himadri Pandya <himadri18.07@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5b8d98f1 03-Mar-2019 Himadri Pandya <himadri18.07@gmail.com>

staging: rtl8712: rename bSurpriseRemoved to surprise_removed

- Rename structure field bSurprisedRemoved to surprised_removed to avoid
camelcase. Suggested by checkpatch.
- Change type to bool as the variable is used as a boolean.

Signed-off-by: Himadri Pandya <himadri18.07@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0ec6fc6f 03-Mar-2019 Himadri Pandya <himadri18.07@gmail.com>

staging: rtl8712: rename bDriverStopped to driver_stopped

- Rename structure field bDriverStopped to driver_stopped to avoid
camelcase. Suggested by checkpatch.
- Change type to bool as the variable is being used as boolean.

Signed-off-by: Himadri Pandya <himadri18.07@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ac544a45 13-Jan-2019 Kai-Heng Feng <kai.heng.feng@canonical.com>

staging: rtl8712u: Fix suspend and resume callbacks

When system resume and the rtl8712u dongle didn't lose its power, it
doesn't work quite right:
[ 146.844241] r8712u 2-3:1.0 wlp0s4f1u3: Unable to resume
...
[ 154.029573] r8712u 2-3:1.0 wlp0s4f1u3: In r8711_wx_set_scan: bDriverStopped=1

The !netif_running() check in PM callbacks aren't correct because
rtl8712u doesn't support runtime suspend, so the when the PM ops get
called, it's system suspend or system resume, hence we want to "stop
everthing" or "resume everything".

The NULL check on pnetdev is also redundant, the only place pnetdev can
become NULL is the disconnect callback, which is mutually exclusive to
PM callbacks.

This can make rtl8712u starts working after system resume.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2b2bbb56 13-Jan-2019 Kai-Heng Feng <kai.heng.feng@canonical.com>

staging: rtl8712u: Remove dummy reset-resume callback

An USB wireless dongle uses rtl8712u stops working after system
suspend/resume.

When a USB device lost its power during suspend, the USB core knows the
power was lost and a reset-resume or a re-probe is required. But rtl8712u
provides a dummy reset-resume callback, which gets called and renders
the device dead after resume.

So remove the reset-resume call back, if power was lost during suspend,
let the USB core unbind and probe the device to solve the issue.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e24c1f86 03-Oct-2018 Michael Straube <straube.linux@gmail.com>

staging: rtl8712: add SPDX identifiers

This satisfies a checkpatch warning and is the preferred
method for notating the license.

The SPDX identifier is a legally binding shorthand, which
can be used instead of the full boiler plate text.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a7e58591 11-Sep-2017 Liam Ryan <liamryandev@gmail.com>

staging: rtl8712: Fix unbalanced braces around else statement

Fix checkpath-reported unbalanced braces in the following areas

221: FILE: drivers/staging/rtl8712/hal_init.c:221:
392: FILE: drivers/staging/rtl8712/os_intfs.c:392:
363: FILE: drivers/staging/rtl8712/rtl8712_cmd.c:363:
889: FILE: drivers/staging/rtl8712/rtl8712_recv.c:889:
902: FILE: drivers/staging/rtl8712/rtl871x_cmd.c:902:
84: FILE: drivers/staging/rtl8712/rtl871x_ioctl_set.c:84:
580: FILE: drivers/staging/rtl8712/rtl871x_mlme.c:580:
593: FILE: drivers/staging/rtl8712/usb_intf.c:593:

Signed-off-by: Liam Ryan <liamryandev@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9b40a017 08-Aug-2017 Arvind Yadav <arvind.yadav.cs@gmail.com>

staging: rtl8712: constify usb_device_id

usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by <linux/usb.h> work with
const usb_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1140c8a6 26-Sep-2016 Gonçalo Salazar <glbsalazar@gmail.com>

staging: rtl8172: usb_intf.c: Fixed block comment coding style

Fixed a block comment indentation in the rtl8712 usb_intf.c file.

Signed-off-by: Gonçalo Salazar <glbsalazar@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# bef611a9 09-Sep-2016 Raphaël Beamonte <raphael.beamonte@gmail.com>

staging: rtl8712: checkpatch cleanup: block comments using a trailing */

Fix checkpatch.pl warning "Block comments use a trailing */ on
a separate line" on multiple files of the driver by editing the
affected comments.

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ecf2e02c 21-Feb-2016 Amitoj Kaur Chawla <amitoj1606@gmail.com>

staging: rtl8712: Remove exceptional & on function name

Remove exceptional '&' operator in front of a function name.

The Coccinelle semantic patch that is used to make this change is as
follows:

// <smpl>
@r@
identifier f;
@@
f(...) { ... }
@@
identifier r.f;
@@
- &f
+ f
@m@
type T;
identifier f;
@@
T f(...);
@@
identifier m.f;
@@
- &f
+ f
// </smpl>

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f99ca866 16-Feb-2016 Amitoj Kaur Chawla <amitoj1606@gmail.com>

staging: rtl8712: Declare function as static

Declare rtl871x_intf_resume() function static since it is defined and called
in this file only.

This fixes the following sparse warning:
warning: symbol 'rtl871x_intf_resume' was not declared. Should it be static?

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 39e9526c 03-Dec-2015 Hemmo Nieminen <hemmo.nieminen@iki.fi>

staging: rtl8712: Improve suspend/resume functionality.

Cancel pending URBs during suspend operation to avoid receiving ESHUTDOWN
in read/write completion callbacks while the device is suspended.

Receiving ESHUTDOWN in read/write completion callbacks will cause the
driver to enter a non-functioning "stopped" state from which the driver is
unable to recover without reloading the module.

Signed-off-by: Hemmo Nieminen <hemmo.nieminen@iki.fi>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4ef2de5a 19-Oct-2015 Luis de Bethencourt <luisbg@osg.samsung.com>

staging: rtl8712: spaces preferred around operands

Clean up all instances of checkpatch.pl checks:
CHECK: spaces preferred around that '+'
(and other operands)

Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 168a2c10 19-Oct-2015 Luis de Bethencourt <luisbg@osg.samsung.com>

staging: rtl8712: braces should be used on all arms

Fix all instances of the following checkpatch.pl check:
CHECK: braces {} should be used on all arms of this statement

Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1ca96884 19-Oct-2015 Luis de Bethencourt <luisbg@osg.samsung.com>

staging: rtl8712: Remove boolean comparisons

Boolean tests do not need explicit comparison to true or false.

Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1e6e6328 18-Oct-2015 Larry Finger <Larry.Finger@lwfinger.net>

staging: rtl8712: Add device ID for Sitecom WLA2100

This adds the USB ID for the Sitecom WLA2100. The Windows 10 inf file
was checked to verify that the addition is correct.

Reported-by: Frans van de Wiel <fvdw@fvdw.eu>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Frans van de Wiel <fvdw@fvdw.eu>
Cc: Stable <stable@vger.kernel.org> [All stable versions]
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# eef6c808 08-Oct-2015 Shraddha Barke <shraddha.6596@gmail.com>

Staging: rtl8712: Use ARRAY_SIZE macro

ARRAY_SIZE is more concise to use when the size of an array is divided
by the size of its type

Changes made using Coccinelle-

@@
type T;
T[] E;
@@

- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)

Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 36e4d882 29-Jan-2015 Heba Aamer <heba93aamer@gmail.com>

staging: rtl8712: fix Prefer ether_addr_copy() over memcpy()

This patch fixes the following checkpatch.pl warning:
Prefer ether_addr_copy() over memcpy()
if the Ethernet addresses are __aligned(2)

pahole showed that the struct used pnetdev->dev_addr
is aligned to u16.

Moreover mac is a simple array, pdata is a pointer that
starts from an even offset.

Signed-off-by: Heba Aamer <heba93aamer@gmail.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1007c692 27-Jan-2015 Heba Aamer <heba93aamer@gmail.com>

staging: rtl8712: remove useless printing line

This patch removes an unneeded call to printk.

Signed-off-by: Heba Aamer <heba93aamer@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e29d3ebc 27-Oct-2014 Sudip Mukherjee <sudipm.mukherjee@gmail.com>

staging: rtl8712: remove unused variables

unused variables are removed. These variables were only assigned some
values and after that they were never being used. So they are safe to
be removed , and it has been build tested.

I left a call to r8712_read32(padapter, TCR) and
r8712_read8(padapter, SDIO_HCPWM) .

r8712_read32() and r8712_read8() is ultimately calling usb_read32()
and usb_read8() respectively. and they are again calling
r8712_usbctrl_vendorreq().
this r8712_usbctrl_vendorreq() is communicating through the usb bus
and is sending and receiving the control msg.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 366ba427 06-Oct-2014 Tapasweni Pathak <tapaswenipathak@gmail.com>

staging: rtl8712: Delete explicit comparison with false and NULL

This patch delete explicit comparison to false and NULL in files of
rtl8712.

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 57b6686e 20-Sep-2014 Tapasweni Pathak <tapaswenipathak@gmail.com>

Staging: rtl8712 : Fix line over 80 characters

This patch fixes checkpatch.pl warning in files of rtl8712
WARNING : line over 80 characters

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# fbdba9c1 20-Sep-2014 Tapasweni Pathak <tapaswenipathak@gmail.com>

Staging: rtl8712: remove void function return; statement

This patch fixes checkpatch.pl warning in files of rtl8712
WARNING : void function return statement are not generally useful

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 22649bb2 01-Jun-2014 Thomas Vegas <thomas@grouk.net>

staging: rtl8712: Remove useless variable 'fw_found'

The net device only exists when firmware is loaded successfully.
Firmware presence variable is only used through r871xu_dev_remove() and
this function already checks for net device existence.

Signed-off-by: Thomas Vegas <thomas@grouk.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5947956b 01-Jun-2014 Thomas Vegas <thomas@grouk.net>

staging: rtl8712: Fix oops on dongle removal if firmware is not available

When firmware is not available, net device is not created. Upon
disconnect, we must check for net device existence before trying to
release net device private data.

Signed-off-by: Thomas Vegas <thomas@grouk.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ac082bc5 20-May-2014 Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>

staging: rtl8712: usb_intf.c: Fix for possible null pointer dereference

There is otherwise a risk of a possible null pointer dereference.

Was largely found by using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3a21f00a 24-Dec-2013 Larry Finger <Larry.Finger@lwfinger.net>

staging: r8712u: Set device type to wlan

The latest version of NetworkManager does not recognize the device as wireless
without this change.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 30765436 13-Sep-2013 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

staging: rtl8712: re-use native mac_pton() helper

There is a nice helper to parse MAC. Let's use it and remove custom
implementation.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 87a573ad 10-Dec-2012 Przemo Firszt <przemo@firszt.eu>

rtl8712: replace printk with better solutions

Replace printk with netdev_printk helpers, dev_printk helpers or
pr_err/warn/info if there is no device info available.

Signed-off-by: Przemo Firszt <przemo@firszt.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# da849a92 29-Dec-2012 Larry Finger <Larry.Finger@lwfinger.net>

staging: r8712u: Add new device ID

The ISY IWL 1000 USB WLAN stick with USB ID 050d:11f1 is a clone of
the Belkin F7D1101 V1 device.

Reported-by: Thomas Hartmann <hartmann@ict.tuwien.ac.at>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Thomas Hartmann <hartmann@ict.tuwien.ac.at>
Cc: Stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 73ee07fa 29-Aug-2012 Larry Finger <Larry.Finger@lwfinger.net>

staging: r8712u: Remove defines that are not used

This driver has a number of defines, etc. that are not used.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1c1b8621 22-Jun-2012 Larry Finger <Larry.Finger@lwfinger.net>

staging: r8712u: Remove useless driver version info

This driver contains version information that is outdated, has no real
value in terms of the Linux update process, and tends to confuse users.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3026b0e9 15-Jun-2012 Lubomir Schmidt <gentoo.lubomir@googlemail.com>

staging: r8712u: Add new USB IDs

There are two new devices for this driver.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1d73fad8 11-May-2012 Larry Finger <Larry.Finger@lwfinger.net>

staging: r8712u: Remove needless test for NULL

In commit ee6aeff, a swatch warning was fixed by moving some code inside
an if block that is executed only when the pointer padapter is not NULL.
In fact, padapter can never be NULL and the corect fix should have been
the removal of the test of padapter.

Reported-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# be10ac2b 07-May-2012 Justin P. Mattock <justinmattock@gmail.com>

staging: rtl8712: Fix typos.

Signed-off-by: Justin P. Mattock <justinmattock@gmail.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ee6aeff7 02-Mar-2012 Larry Finger <Larry.Finger@lwfinger.net>

staging: r8712u: Fix Smatch warning

The patch 2080913e017a: "staging: r8712u: Fix regression caused by
commit 8c213fa" from Feb 25, 2012, leads to the following Smatch
complaint:

drivers/staging/rtl8712/usb_intf.c:629 r871xu_dev_remove()
warn: variable dereferenced before check 'padapter' (see line 625)

The fix is to move the new statements inside the block where padapter
is not NULL.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 07b99cf5 02-Mar-2012 Martin Krause <martin.krause@tqs.de>

Staging: rtl8712/rtl8192u: move USB device ID within staging drivers.

It seems the USB device ID 0bda:8192 is wrongly assigned to the
RTL8192SU chip and not to the RTL8191SU chip in the USB database.
So this patch moves this device ID from the rtl8192u staging
driver to the rtl8712 staging driver.

This patch was tested with a Radicom WIFIHU embedded wireless
module with a RTL8191SU chip and the USB device ID 0bda:8192.
Without the patch the rtl8192u driver claims this device, but
it does not work. With the patch the rtl8712 driver services
this device and it works.

Signed-off-by: Martin Krause <martin.krause@tqs.de>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 53471702 02-Mar-2012 Martin Krause <martin.krause@tqs.de>

Staging rtl8712: Remove double USB device IDs

Remove copies of the double USB device IDs:

- 0bda:8172
- 0bda:8174

Signed-off-by: Martin Krause <martin.krause@tqs.de>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2080913e 25-Feb-2012 Larry Finger <Larry.Finger@lwfinger.net>

staging: r8712u: Fix regression caused by commit 8c213fa

In commit 8c213fa "staging: r8712u: Use asynchronous firmware loading",
the command to release the firmware was placed in the wrong routine.

In combination with the bug introduced in commit a5ee652 "staging: r8712u:
Interface-state not fully tracked", the driver attempts to upload firmware
that had already been released. This bug is the source of one of the
problems in https://bugs.archlinux.org/task/27996#comment89833.

Tested-by: Alberto Lago Ballesteros <saniukeokusainaya@gmail.com>
Tested-by: Adrian <agib@gmx.de>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 86587b67 08-Feb-2012 Larry Finger <Larry.Finger@lwfinger.net>

staging: r8712u: Simplify semaphores

I am preparing to convert this driver from semaphore to mutex locking,
The first step has been to eliminate a number of semaphores that were
initialized but never used, and one whose only use was a single "up"
after initialization. A total of 9 semaphores were removed in this process.

One other change was to remove some inline semaphore routines that were
unused.

In addition, several cases had the following structure:

down()
if () {
...
}
up()

The locking overhead was reduced by moving the up/down inside the if
block.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 8c213fa59 05-Feb-2012 Larry Finger <Larry.Finger@lwfinger.net>

staging: r8712u: Use asynchronous firmware loading

In https://bugs.archlinux.org/task/27996, failure of driver r8712u is
reported, with a timeout during module loading due to synchronous loading
of the firmware. The code now uses request_firmware_nowait().

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1793bf1de 07-Jan-2012 Larry Finger <Larry.Finger@lwfinger.net>

staging: r8712u: Add new Sitecom UsB ID

Add USB ID for SITECOM WLA-1000 V1 001 WLAN

Reported-and-tested-by: Roland Gruber <post@rolandgruber.de>
Reported-and-tested-by: Dario Lucia <dario.lucia@gmail.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# c7caf4d4 11-Dec-2011 Larry Finger <Larry.Finger@lwfinger.net>

staging: r8712u: Add new USB ID

Add USB ID for Sitecom WLA-2000 v1.001 WLAN.

Reported-and-tested-by: Roland Gruber <post@rolandgruber.de>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 81e07c06 04-Oct-2011 Stephen Rothwell <sfr@canb.auug.org.au>

staging: r8712u: include module.h where needed

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# ee5b1aad 03-Sep-2011 Ali Bahar <ali@internetdog.org>

staging: r8712u: Merging Realtek's latest (v2.6.6). Various fixes.

In r8712_generate_ie(), HT check is no longer done.
Removed r8712_add_ht_addt_info().
Changes to defragmentation handling, and queue selection.
Get TSSI command.
Added an Ad-Hoc check to is_desired_network()
r8712_ind_disconnect() now checks for Linked state.
r8712_xmit_bh() now schedules an xmit tasklet.

Signed-off-by: Ali Bahar <ali@internetDog.org>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 6c19d86b 03-Sep-2011 Ali Bahar <ali@internetdog.org>

staging: r8712u: Merging Realtek's latest (v2.6.6). stop_drv_timers moved.

stop_drv_timers() is now done in r871xu_dev_remove(), not netdev_close().

Signed-off-by: Ali Bahar <ali@internetDog.org>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 359140aa 03-Sep-2011 Ali Bahar <ali@internetdog.org>

staging: r8712u: Merging Realtek's latest (v2.6.6). Updated include directives.

These are the new include directives for header files.
The following were (somehow!) not explicity in Realtek's, but proved necessary:
"linux/usb.h" is needed for usb_alloc_urb();
"linux/interrupt.h" is needed for tasklet_struct. It was often a nested
include.

Signed-off-by: Ali Bahar <ali@internetDog.org>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 7bcd9ce6 03-Sep-2011 Ali Bahar <ali@internetdog.org>

staging: r8712u: Merging Realtek's latest (v2.6.6). Removed os_free_netdev.

Replaced (Realtek's) os_free_netdev by (linux's own) free_netdev.

Signed-off-by: Ali Bahar <ali@internetDog.org>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 7c1f4203 03-Sep-2011 Ali Bahar <ali@internetdog.org>

staging: r8712u: Merging Realtek's latest (v2.6.6). Renamed _netdev_priv.

Renamed _netdev_priv to netdev_priv.

Signed-off-by: Ali Bahar <ali@internetDog.org>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 6b284053 22-Jan-2011 Axel Köllhofer <AxelKoellhofer@web.de>

staging: r8712u: Add new device IDs

This patch adds several new device ids to the r8712u staging driver.
The new ids were retrieved from latest vendor driver (v2.6.6.0.20101111)
downloadable from www.realtek.com.tw

Signed-off-by: Axel Koellhofer <AxelKoellhofer@web.de>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Stable <stable@kernel.org> [2.6.37]
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# e33196e1 15-Nov-2010 Joe Perches <joe@perches.com>

drivers/staging: Remove unnecessary casts of netdev_priv

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 5a3acb04 31-Aug-2010 Larry Finger <Larry.Finger@lwfinger.net>

staging: r8712u: Update driver version to v7_0.20100831

Signed-off-by: Albert Wang <albert_wang@realtek.com.tw>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 2865d42c 20-Aug-2010 Larry Finger <Larry.Finger@lwfinger.net>

staging: r8712u: Add the new driver to the mainline kernel

This code is for a completely new version of the Realtek 8192 USB devices
such as the D-Link DWA-130. The Realtek code, which was originally for
Linux, Windows XP and Windows CE, has been stripped of all code not needed
for Linux. In addition, only one additional configuration variable, which
enables AP mode, remains.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Florian Schilhabel <florian.c.schilhabel@googlemail.com>
Tested-by: Frederic Leroy <fredo@starox.org>