platform/kernel/linux-rpi.git
6 years agostaging: ks7010: avoid blank line between definitions in hostif_data_request
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:52 +0000 (15:44 +0200)]
staging: ks7010: avoid blank line between definitions in hostif_data_request

This commit removes a blank line between definition in
hostif_data_request function.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: fix warning aout long line in init_request
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:51 +0000 (15:44 +0200)]
staging: ks7010: fix warning aout long line in init_request

This commit fix length of the definition line of init_request
function. Warning from checkpatch script for this is fixed.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: remove superfluous comments in ks_hostif source file
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:50 +0000 (15:44 +0200)]
staging: ks7010: remove superfluous comments in ks_hostif source file

This commit removes some comments which are not necessary at all
because code is clear enough to understand its intention.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: avoid one level indentation in devio_rec_ind function
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:49 +0000 (15:44 +0200)]
staging: ks7010: avoid one level indentation in devio_rec_ind function

This commit changes logic to handle with the status of the device
at first checking for close state to return directly instead
of just do the stuff when device is open. This improves readability
avoiding one level indentation.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: change name and type for device_open_status field
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:48 +0000 (15:44 +0200)]
staging: ks7010: change name and type for device_open_status field

This commit changes type for device_open_status field of ks_wlan_private
structure from int to bool. This variable is only be set to 1
on ks_wlan_net_start and set to 0 on ks_wlan_net_stop. For this
purpose it is not necessary at all to use an integer because a bool
is enough. This also renames field name from device_open_status to
is_device_open.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: assign dev_alloc_name() result to variable before check it
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:47 +0000 (15:44 +0200)]
staging: ks7010: assign dev_alloc_name() result to variable before check it

This commit assigns dev_alloc_name() call to 'ret' variable to
check it after instead of check directly the call in the if
condition. This improves a bit readability. It also add an empty
line before the new assignment to separate it from the previous
check statement block.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: use u8 instead of unsigned char for firmware buffers
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:46 +0000 (15:44 +0200)]
staging: ks7010: use u8 instead of unsigned char for firmware buffers

This commit replaces type unsigned char which is the one which
is being used for firmware buffers with u8 type which is preferred.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: fix error paths in ks7010_sdio_remove function
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:45 +0000 (15:44 +0200)]
staging: ks7010: fix error paths in ks7010_sdio_remove function

This commit reviews and fixes error paths in ks7010_sdio_remove
driver function. It change logic to handle error directly
after priv dereference to avoid one level indentation. It also
removes a temporal netdev variable which wasn't being used in all
of the function calls. Also if send_stop_request call fails it
was making a direct 'return' instead of doing a properly cleaning.
Because of this a new 'err_free_card' label has been added.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: check sdio_set_block_size return value
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:44 +0000 (15:44 +0200)]
staging: ks7010: check sdio_set_block_size return value

This commit checks sdio_set_block_size function return value.
If it fails abort driver initialization.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: replace create_workqueue with alloc_workqueue
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:43 +0000 (15:44 +0200)]
staging: ks7010: replace create_workqueue with alloc_workqueue

This commit replaces deprecated create_workqueue call with the
alloc_workqueue one which is the one to be used now for this
purpose.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: move MODULE_DEVICE_TABLE related code
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:42 +0000 (15:44 +0200)]
staging: ks7010: move MODULE_DEVICE_TABLE related code

This commit moves MODULE_DEVICE_TABLE related code to the end of
the file. This is not necessary at all but moving it just before
its use improves readability.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: avoid one extra level indentation in ks_wlan_hw_rx function
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:41 +0000 (15:44 +0200)]
staging: ks7010: avoid one extra level indentation in ks_wlan_hw_rx function

This commit use an and operator in a if condition to avoid one
indentation level which is not needed at all.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: review debug and error messages in ks7010_sdio source
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:40 +0000 (15:44 +0200)]
staging: ks7010: review debug and error messages in ks7010_sdio source

This commit reviews debug and error messages in code located
in ks7010_sdio source file avoiding to use 'error' or 'ks7010'
because this file is using netdev_* functions and has non
sense to repeat information in log messages.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: review comment style in ks7010_sdio source file
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:39 +0000 (15:44 +0200)]
staging: ks7010: review comment style in ks7010_sdio source file

This commit reviews comment style used in ks7010_sdio source file
in order to be coherent with the rest of the code. Most comments
in this source are before definitions but only two of them have
been written at the right. So, be coherent moving this two to the
top of definitions. Also fix one multiline comment style to use
the normal preferred kernel style.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: add REG suffix to sdio register definitions
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:38 +0000 (15:44 +0200)]
staging: ks7010: add REG suffix to sdio register definitions

This commit adds REG suffix to register definitions related
with SDIO in order to improve readability.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: delete not used definitions in ks7010_sdio source
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:37 +0000 (15:44 +0200)]
staging: ks7010: delete not used definitions in ks7010_sdio source

This commit removes two definitions inside ks7010_sdio source file
because they are not being used at all.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: move sdio specific register definitions into source file
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:36 +0000 (15:44 +0200)]
staging: ks7010: move sdio specific register definitions into source file

This commit moves SDIO related register definitions from header
to source file. There is no need to have those into the header
because they are only being used in specific SDIO code.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: move ROM_FILE definition into source file
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:35 +0000 (15:44 +0200)]
staging: ks7010: move ROM_FILE definition into source file

This commit moves ROM_FILE from header to source file because
there is not being used outside this.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: ks7010: avoid casts in michael_mic_function calls
Sergio Paracuellos [Mon, 23 Apr 2018 13:44:34 +0000 (15:44 +0200)]
staging: ks7010: avoid casts in michael_mic_function calls

This commit removes casts in calls to michael_mic_function.
Most of them are nosense because types match perfectly function
parameters. To avoid also int casting for len parameter just
pass unsigned len to function which makes sense because is only
being called with unsigned int len parameters.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix calculation typo in msdc_init_gpd_bd
Christian Lütke-Stetzkamp [Wed, 25 Apr 2018 06:43:18 +0000 (08:43 +0200)]
staging: mt7621-mmc: Fix calculation typo in msdc_init_gpd_bd

When refactoring the function msdc_init_gpd_bd, an error in the
calculation of the bd.next address was introduced. The offset has to
be added to the base address, not multiplied.

Fixes: 8f2395586cf0 ("staging: mt7621-mmc: Refactor msdc_init_gpd_bd")
Reported-by: NeilBrown <neil@brown.name>
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Tested-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused card_workqueue from msdc_host
Christian Lütke-Stetzkamp [Tue, 24 Apr 2018 18:01:29 +0000 (20:01 +0200)]
staging: mt7621-mmc: Remove unused card_workqueue from msdc_host

The card_workqueue field of msdc_host is already if 0'd out and there
are no references to it in the code (not even in unused code), so
remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove old references to tasklet
Christian Lütke-Stetzkamp [Tue, 24 Apr 2018 18:01:28 +0000 (20:01 +0200)]
staging: mt7621-mmc: Remove old references to tasklet

In the current code there are '#if 0' out references on using a
tasklet instead of delayed_work. Removing these improves readability.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Add annotations about held locks
Christian Lütke-Stetzkamp [Tue, 24 Apr 2018 18:01:27 +0000 (20:01 +0200)]
staging: mt7621-mmc: Add annotations about held locks

The functions msdc_command_resp and msdc_do_request are always called
with the host->lock lock held. By adding annotations, sparse is
informed about that.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Correct datatypes for io and sanitize io access
Christian Lütke-Stetzkamp [Tue, 24 Apr 2018 18:01:26 +0000 (20:01 +0200)]
staging: mt7621-mmc: Correct datatypes for io and sanitize io access

Current code discard the address space information on the base address
of the mmc controller, that causes sparse warnings. It uses the raw
read write function, that is correct for the mips architecture (little
endian), but for portability the non-raw function should be used. Also
the clear/set bit macros do direct memory access, that is also correct
for mips, but not portable.

So the type of the base address is changed to void __iomem *, that is
the type returned by the ioremap function. The set/clear bit macros
are changed to functions, that use the portable read and write
functions. The use of the raw access functions is changed to use the
non-raw ones.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Replace dma dir with mmc_get_dma_dir
Christian Lütke-Stetzkamp [Tue, 24 Apr 2018 18:01:25 +0000 (20:01 +0200)]
staging: mt7621-mmc: Replace dma dir with mmc_get_dma_dir

Currently the dma direction is manually determined by the read status,
there is a more portable function for it, mmc_get_dma_dir, use it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix dma_map_sg may map to fewer entries
Christian Lütke-Stetzkamp [Tue, 24 Apr 2018 18:01:24 +0000 (20:01 +0200)]
staging: mt7621-mmc: Fix dma_map_sg may map to fewer entries

The dma_map_sg function may merge several sglist entries into one, the
return value has to be saved to consider that. The data->sg_count
field is the position, where it should be saved, like it is done in
other mmc host drivers. Also the count of mapped entries is needed for
the dma setup.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove multiple assignments
Christian Lütke-Stetzkamp [Tue, 24 Apr 2018 18:01:23 +0000 (20:01 +0200)]
staging: mt7621-mmc: Remove multiple assignments

Fix checkpatch: multiple assignments should be avoided, to improve
readability.
It aslo moves the second assignment out of the if/else block, that is
valid, because drv_mode is of type msdc_mode, an enum with only those
three elements, so one of the if/ else if statements is always
taken. And the second assignment can happen after the conditions.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix dereference before check in msdc_drv_pm
Christian Lütke-Stetzkamp [Tue, 24 Apr 2018 18:01:22 +0000 (20:01 +0200)]
staging: mt7621-mmc: Fix dereference before check in msdc_drv_pm

In the msdc_drv_pm function the variable mmc is dereferenced before
checked. Reordering fixes that.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agoRevert "staging: nvec: Augment TODO file with GPIO work item"
Marc Dietrich [Mon, 23 Apr 2018 15:17:51 +0000 (17:17 +0200)]
Revert "staging: nvec: Augment TODO file with GPIO work item"

This reverts commit 5a3e59ce3acf2f52c8b4a6fc656c3b1e4a329f06, because the
necessary changes were applied in the "staging: nvec: convert to use GPIO
descriptors" patch.

Signed-off-by: Marc Dietrich <marvin24@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agoMAINTAINERS: add maintainer for the DPAA2 PTP clock driver
Yangbo Lu [Mon, 23 Apr 2018 03:55:01 +0000 (11:55 +0800)]
MAINTAINERS: add maintainer for the DPAA2 PTP clock driver

This patch is to add maintainer for the DPAA2 PTP clock driver.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: fsl-dpaa2/rtc: add rtc driver
Yangbo Lu [Mon, 23 Apr 2018 03:55:00 +0000 (11:55 +0800)]
staging: fsl-dpaa2/rtc: add rtc driver

This patch is to add driver for the DPAA2 1588 timer module (RTC)
which interfaces to up to an unlimited number of 10/100/1000 or
10G ethernet MACs, providing current time, alarm, and fiper support.
The 1588 IP control block includes these distinctive features.

- External GPIO trigger for time-stamping
- 2 Time-stamp alarms
- 3 FIPER pulse generators
- Phase adjusted output timer clock

Currently this driver only supports basic functions like
settime/gettime/adjtime/adjfreq.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agodrivers/staging/fsl-mc: Fix DPIO error path issue
Roy Pledge [Tue, 27 Mar 2018 18:13:32 +0000 (14:13 -0400)]
drivers/staging/fsl-mc: Fix DPIO error path issue

Remove unneeded call to dev_set_drvdata(dev, NULL) since the device
will be deallocated in any case.

Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agodrivers/staging/fsl-mc: Use devm_memremap/devm_ioremap for DPIO
Roy Pledge [Tue, 27 Mar 2018 18:13:31 +0000 (14:13 -0400)]
drivers/staging/fsl-mc: Use devm_memremap/devm_ioremap for DPIO

Change the mapping of the QBMan cache enabled area from using ioremap_wc()
to devm_memremap(). This allows the __iomem attribute to be removed from
the pointer (which makes sense as accesses treat this as cacheable memory
not IO memory).  These changes allow sparse checks to pass.

Also use devm_ioremap() for the cache inhibited area so unmap occurs
automatically when the device is released.

Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8192u: Replace mdelay with usleep_range in dm_TXPowerTrackingCallback_TSSI
Jia-Ju Bai [Tue, 10 Apr 2018 12:25:34 +0000 (20:25 +0800)]
staging: rtl8192u: Replace mdelay with usleep_range in dm_TXPowerTrackingCallback_TSSI

dm_TXPowerTrackingCallback_TSSI() is never called in atomic context.

dm_TXPowerTrackingCallback_TSSI() is only called by
dm_txpower_trackingcallback(), which is set a parameter of
INIT_DELAYED_WORK() in rtl8192_init_priv_task().

Despite never getting called from atomic context,
dm_TXPowerTrackingCallback_TSSI() calls mdelay() to busily wait.
This is not necessary and can be replaced with usleep_range() to
avoid busy waiting.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8192u: Replace mdelay with usleep_range in rtl8192_usb_disconnect
Jia-Ju Bai [Tue, 10 Apr 2018 12:25:09 +0000 (20:25 +0800)]
staging: rtl8192u: Replace mdelay with usleep_range in rtl8192_usb_disconnect

rtl8192_usb_disconnect() is never called in atomic context.

rtl8192_usb_disconnect() is only set as ".disconnect" in
struct usb_driver.

Despite never getting called from atomic context,
rtl8192_usb_disconnect() calls mdelay() to busily wait.
This is not necessary and can be replaced with usleep_range() to
avoid busy waiting.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8192u: Replace GFP_ATOMIC with GFP_KERNEL in ieee80211_softmac_init
Jia-Ju Bai [Tue, 10 Apr 2018 12:24:23 +0000 (20:24 +0800)]
staging: rtl8192u: Replace GFP_ATOMIC with GFP_KERNEL in ieee80211_softmac_init

ieee80211_softmac_init() is never called in atomic context.

The call chains ending up at ieee80211_softmac_init() is:
[1] ieee80211_softmac_init() <- alloc_ieee80211_rsl() <-
    rtl8192_usb_probe()

rtl8192_usb_probe() is set as ".probe" in struct usb_driver.

Despite never getting called from atomic context,
ieee80211_softmac_init() calls kzalloc() with GFP_ATOMIC,
which does not sleep for allocation.
GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
which can sleep and improve the possibility of sucessful allocation.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8192u: Replace GFP_ATOMIC with GFP_KERNEL in prism2_wep_init
Jia-Ju Bai [Tue, 10 Apr 2018 12:23:54 +0000 (20:23 +0800)]
staging: rtl8192u: Replace GFP_ATOMIC with GFP_KERNEL in prism2_wep_init

prism2_wep_init() is never called in atomic context.

prism2_wep_init() is only set as ".init" in
struct ieee80211_crypto_ops.
The call chains ending up at "->init" function are:
[1] ->init() <- ieee80211_wpa_set_encryption() <-
    ieee80211_wpa_supplicant_ioctl()
[2] ->init() <- ieee80211_wx_set_encode_ext_rsl() <-
    r8192_wx_set_enc_ext()
[3] ->init() <- ieee80211_wx_set_encode_rsl() <-
    r8192_wx_set_enc()

ieee80211_wpa_supplicant_ioctl(), r8192_wx_set_enc_ext() and
r8192_wx_set_enc() call mutex_lock(), which indicates these functions
are not called in atomic context.

Despite never getting called from atomic context,
prism2_wep_init() calls kzalloc() with GFP_ATOMIC,
which does not sleep for allocation.
GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
which can sleep and improve the possibility of sucessful allocation.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8192u: Replace GFP_ATOMIC with GFP_KERNEL in ieee80211_tkip_init
Jia-Ju Bai [Tue, 10 Apr 2018 12:23:29 +0000 (20:23 +0800)]
staging: rtl8192u: Replace GFP_ATOMIC with GFP_KERNEL in ieee80211_tkip_init

ieee80211_tkip_init() is never called in atomic context.

ieee80211_tkip_init() is only set as ".init" in
struct ieee80211_crypto_ops.
The call chains ending up at "->init" function are:
[1] ->init() <- ieee80211_wpa_set_encryption() <-
    ieee80211_wpa_supplicant_ioctl()
[2] ->init() <- ieee80211_wx_set_encode_ext_rsl() <-
    r8192_wx_set_enc_ext()
[3] ->init() <- ieee80211_wx_set_encode_rsl() <-
    r8192_wx_set_enc()

ieee80211_wpa_supplicant_ioctl(), r8192_wx_set_enc_ext() and
r8192_wx_set_enc() call mutex_lock(), which indicates these functions
are not called in atomic context.

Despite never getting called from atomic context,
ieee80211_tkip_init() calls kzalloc() with GFP_ATOMIC,
which does not sleep for allocation.
GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
which can sleep and improve the possibility of sucessful allocation.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8192u: Replace GFP_ATOMIC with GFP_KERNEL in ieee80211_ccmp_init
Jia-Ju Bai [Tue, 10 Apr 2018 12:23:00 +0000 (20:23 +0800)]
staging: rtl8192u: Replace GFP_ATOMIC with GFP_KERNEL in ieee80211_ccmp_init

ieee80211_ccmp_init() is never called in atomic context.

ieee80211_ccmp_init() is only set as ".init" in
struct ieee80211_crypto_ops.
The call chains ending up at "->init" function are:
[1] ->init() <- ieee80211_wpa_set_encryption() <-
ieee80211_wpa_supplicant_ioctl()
[2] ->init() <- ieee80211_wx_set_encode_ext_rsl() <-
r8192_wx_set_enc_ext()
[3] ->init() <- ieee80211_wx_set_encode_rsl() <-
r8192_wx_set_enc()

ieee80211_wpa_supplicant_ioctl(), r8192_wx_set_enc_ext() and
r8192_wx_set_enc() call mutex_lock(), which indicates these functions
are not called in atomic context.

Despite never getting called from atomic context,
ieee80211_ccmp_init() calls kzalloc() with GFP_ATOMIC,
which does not sleep for allocation.
GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
which can sleep and improve the possibility of sucessful allocation.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8192e: Fixed coding style around a plus sign
Joao Dalben [Tue, 3 Apr 2018 23:36:43 +0000 (20:36 -0300)]
staging: rtl8192e: Fixed coding style around a plus sign

Added blank spaces between a plus sign in order to standardize the coding
style.

Signed-off-by: Joao Dalben <jhdalben@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: comedi: cb_pcidas64: fix alignment of function parameters
Gabriel Francisco Mandaji [Tue, 10 Apr 2018 22:50:07 +0000 (19:50 -0300)]
staging: comedi: cb_pcidas64: fix alignment of function parameters

Fix most checkpatch.pl issues of type:

CHECK: Alignment should match open parenthesis

Signed-off-by: Gabriel Francisco Mandaji <gfmandaji@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: vc04_services: Remove depends on HAS_DMA in case of platform dependency
Geert Uytterhoeven [Tue, 17 Apr 2018 17:49:19 +0000 (19:49 +0200)]
staging: vc04_services: Remove depends on HAS_DMA in case of platform dependency

Remove dependencies on HAS_DMA where a Kconfig symbol depends on another
symbol that implies HAS_DMA, and, optionally, on "|| COMPILE_TEST".
In most cases this other symbol is an architecture or platform specific
symbol, or PCI.

Generic symbols and drivers without platform dependencies keep their
dependencies on HAS_DMA, to prevent compiling subsystems or drivers that
cannot work anyway.

This simplifies the dependencies, and allows to improve compile-testing.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
Acked-by: Robin Murphy <robin.murphy@arm.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: vchiq_core: Free kthreads in error case
Stefan Wahren [Sat, 31 Mar 2018 20:09:47 +0000 (22:09 +0200)]
staging: vchiq_core: Free kthreads in error case

We need to free the kthreads in error case before leaving
vchiq_init_state() otherwise we leak resources.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: vchiq_core: Move all wake-ups to one point
Stefan Wahren [Sat, 31 Mar 2018 20:09:46 +0000 (22:09 +0200)]
staging: vchiq_core: Move all wake-ups to one point

Move all calls of wake_up_process to one point, whichs makes the
following implementation of clean-up code easier.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: vchiq_arm: Avoid long udelay
Stefan Wahren [Sat, 31 Mar 2018 20:09:45 +0000 (22:09 +0200)]
staging: vchiq_arm: Avoid long udelay

vchiq_initialise() is used in non-interrupt context, so we can
replace udelay with usleep_range as suggested by timers-howto.txt.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: vchiq_arm: Fix multiline dereferences
Stefan Wahren [Sat, 31 Mar 2018 20:09:44 +0000 (22:09 +0200)]
staging: vchiq_arm: Fix multiline dereferences

Multiline dereferences aren't nice to review. So fix this checkpatch
warning.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: vc04_services: Use __func__ macro
Stefan Wahren [Sat, 31 Mar 2018 20:09:43 +0000 (22:09 +0200)]
staging: vc04_services: Use __func__ macro

It's better to use the __func__ macro instead of open-code the function
name. This fixes the following checkpatch warning:

WARNING: Prefer using '"%s...", __func__' to using 'x',
this function's name, in a string

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: vchiq_core: remove BITSET_ZERO
Stefan Wahren [Sat, 31 Mar 2018 20:09:39 +0000 (22:09 +0200)]
staging: vchiq_core: remove BITSET_ZERO

Hiding memset behind a macro isn't the best, because it relies on that
the parameter is not a pointer. Luckily all user has been removed, so
we can remove BITSET_ZERO too.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: vchiq_core: Remove stackhog in process_free_queue
Stefan Wahren [Sat, 31 Mar 2018 20:09:38 +0000 (22:09 +0200)]
staging: vchiq_core: Remove stackhog in process_free_queue

This removes the stackhog in process_free_queue by allocating the
necessary memory within the recycle thread main function instead
of the stack.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: vchiq_core: Fix missing semaphore release in error case
Stefan Wahren [Sat, 31 Mar 2018 20:09:37 +0000 (22:09 +0200)]
staging: vchiq_core: Fix missing semaphore release in error case

The bail out branch in case of a invalid tx_pos missed a semaphore
release. Dan Carpenter found this with a static checker.

Fixes: d1eab9dec610 ("staging: vchiq_core: Bail out in case of invalid tx_pos")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: vboxvideo: Fix line size exceeding 80 columns.
Daniel Junho [Sun, 15 Apr 2018 18:08:42 +0000 (15:08 -0300)]
staging: vboxvideo: Fix line size exceeding 80 columns.

This patch fixes the checkpatch.pl warning:

WARNING: line over 80 characters
+               vbva = (void __force *)vbox->vbva_buffers + i *
VBVA_MIN_BUFFER_SIZE;

Signed-off-by: Daniel Junho <djunho@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: Remove unnecessary braces {} around single statement block
Eyal Ilsar [Thu, 12 Apr 2018 07:59:32 +0000 (17:59 +1000)]
staging: wilc1000: Remove unnecessary braces {} around single statement block

Remove unnecessary braces {} around an 'if' statement block with a single
statement. Issue found by checkpatch.

Signed-off-by: Eyal Ilsar <edilsar@gmail.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agoStaging: most: Move comments to the end of line
Ian Liu Rodrigues [Tue, 10 Apr 2018 22:57:21 +0000 (19:57 -0300)]
Staging: most: Move comments to the end of line

Signed-off-by: Ian Liu Rodrigues <ian.liu88@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: pi433: Fixed typos and grammar in documentation
Shannon Booth [Thu, 12 Apr 2018 02:58:21 +0000 (14:58 +1200)]
staging: pi433: Fixed typos and grammar in documentation

Some typos and grammar issues were found in the documentation. These
mistakes were fixed.

Signed-off-by: Shannon Booth <shannon.ml.booth@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: pi433: use help in Kconfig description
Valentin Vidic [Sun, 15 Apr 2018 11:42:36 +0000 (13:42 +0200)]
staging: pi433: use help in Kconfig description

Fixes checkpatch warning:

  WARNING: prefer 'help' over '---help---' for new help texts

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: pi433: break long lines in rf69.c
Simon Sandström [Fri, 6 Apr 2018 21:05:15 +0000 (23:05 +0200)]
staging: pi433: break long lines in rf69.c

Breaks long lines in rf69.c, fixing checkpatch.pl warnings:
"WARNING: line over 80 characters"

Signed-off-by: Simon Sandström <simon@nikanor.nu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: pi433: break long lines
Simon Sandström [Fri, 6 Apr 2018 20:33:05 +0000 (22:33 +0200)]
staging: pi433: break long lines

Breaks long lines in rf69.h, fixing checkpatch.pl warnings:
"WARNING: line over 80 characters"

Signed-off-by: Simon Sandström <simon@nikanor.nu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: pi433: cleanup tx_fifo locking
Valentin Vidic [Thu, 19 Apr 2018 10:25:30 +0000 (12:25 +0200)]
staging: pi433: cleanup tx_fifo locking

pi433_write requires locking due to multiple writers.  After acquiring
the lock check if enough free space is available in the kfifo to write
the whole message. This check should prevent partial writes to tx_fifo
so kfifo_reset is not needed anymore.

pi433_tx_thread is the only reader so it does not require locking
after kfifo_reset is removed.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Reviewed-by: Marcus Wolf <marcus.wolf@wolf-entwicklungen.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: greybus: simplify getting .drvdata
Wolfram Sang [Thu, 19 Apr 2018 14:06:17 +0000 (16:06 +0200)]
staging: greybus: simplify getting .drvdata

We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: greybus: Fix warning to limit chars per line
Gaurav Dhingra [Fri, 6 Apr 2018 11:09:22 +0000 (16:39 +0530)]
staging: greybus: Fix warning to limit chars per line

Wrap comment to fix warning "prefer a maximum 75 chars per line"

Signed-off-by: Gaurav Dhingra <gauravdhingra.gxyd@gmail.com>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field dma_addr of msdc_host
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:50 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field dma_addr of msdc_host

The dma_addr field of msdc_host is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field cmd_rsp_done of msdc_host
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:49 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field cmd_rsp_done of msdc_host

The cmd_rsp_done field of msdc_host is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field cmd_r1b_done in msdc_host
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:48 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field cmd_r1b_done in msdc_host

The field cmd_r1b_done in msdc_host is unused, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field dma_left_size of msdc_host
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:46 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field dma_left_size of msdc_host

The dma_left_size field of msdc_host is never used, remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621:mmc: Remove unused field reserved from msdc_host
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:45 +0000 (17:27 +0200)]
staging: mt7621:mmc: Remove unused field reserved from msdc_host

The reserved field of msdc_host is never used and msdc_host is also
never exposed to hardware, so remove that field.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field starttime from msdc_host
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:44 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field starttime from msdc_host

The starttime field of msdc_host is never used, remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Change default transfer mode to DMA
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:43 +0000 (17:27 +0200)]
staging: mt7621-mmc: Change default transfer mode to DMA

The current default transfer is to use DMA or not depending on the
size of the data. The upstream driver mtk-sd uses DMA all times,
change the standard mode here to DMA for testing, if there are any
performance problems with DMA for small data sizes. If not, the option
for transfer mode should be removed in the future,

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Refactor msdc_init_gpd_bd
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:41 +0000 (17:27 +0200)]
staging: mt7621-mmc: Refactor msdc_init_gpd_bd

The msdc_init_gpd_bd function is currently hard to read, because of
old, commented out code and a while loop, where a for loop is much
easier to read. Refactor it to make the code more readable.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field xfersz from msdc_dma
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:36 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field xfersz from msdc_dma

The xfersz field of msdc_dma is only set to host->xfer_size and this
is also available at the (few) positions, where dma.xfersz is used, so
it is removed.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove flags from msdc_dma
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:35 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove flags from msdc_dma

The flags of msdc_dma are set to a constant value, so block and dword
padding are disabled and checksum is enabled. By removing the field
the code is easier to read and the difference to the mtk-sd driver is
smaller.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused fields from msdc_dma
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:34 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused fields from msdc_dma

The fields used_gpd|bd in struct msdc_dma are only set and reset, but
never used, so remove them. The other removed fields are never used,
so they were removed either.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Start cleanup of msdc_dma_config
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:33 +0000 (17:27 +0200)]
staging: mt7621-mmc: Start cleanup of msdc_dma_config

Currently the msdc_dma_config function has some variables, that are
not needed, uses the macro msdc_init_bd that is only used here and
does not use the for_each_sg iterator. That last fact could cause a
bug if the scatterlist is chained.

The function is changed to remove these things, but none of the
changes should change the behavior of it (despite the case of a linked
scatterlist).

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused function msdc_dma_dump
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:32 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused function msdc_dma_dump

The msdc_dma_dump function is disabled by a preprocessor macro, was
only used in the msdc_dma_setup function. The code also contains no
information about the device, it only dumps some memory for debug.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field burstsz from msdc_dma
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:31 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field burstsz from msdc_dma

The burstsz field in msdc_dma is set to a constant value and later
only used two times, using the constant directly in that places allows
to remove the field and improves readability.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field data_offset from msdc_hw
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:29 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field data_offset from msdc_hw

The data_offset field in msdc_hw is never used, so remove it.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Relax cpu while waiting for stable clock
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:28 +0000 (17:27 +0200)]
staging: mt7621-mmc: Relax cpu while waiting for stable clock

Current code just busy waits with nop for clock becoming stable,
relaxing the cpu here improves readability and portability and also
removes a unnecessary difference with the mtk-sd driver.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove code for not existent config
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:27 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove code for not existent config

The MT7621|7628_FPGA config flags are non existent in the tree, so
code guarded by this flags can be removed.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Refactor and rename msdc_reset to msdc_reset_hw
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:26 +0000 (17:27 +0200)]
staging: mt7621-mmc: Refactor and rename msdc_reset to msdc_reset_hw

In the current code the hardware reset is realised via a macro and
does only wait for a certain ammount of time for the controller to
come out of reset state, but it should wait until it IS out of reset
state. So it is refactored to improve this, it is also changed from a
macro to a function and renamed to msdc_reset_hw to match the mtk-sd
driver.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove power callbacks from msdc_hw
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:25 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove power callbacks from msdc_hw

The ext_power_on|off fields of msdc_hw are never set, and only once
checked for not being zero, so they can just be removed.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix null pointer deref if ext sdio irq enabled
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:24 +0000 (17:27 +0200)]
staging: mt7621-mmc: Fix null pointer deref if ext sdio irq enabled

The enable|disable_sdio_irq() fields of msdc_hw are never set, so when
they are called, they are null pointer. In case of the
MSDC_EXT_SDIO_IRQ flag set in msdc0_hw, this happens. But because
these fields are never set, they can simply be removed.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field disable_cd_eirq
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:23 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field disable_cd_eirq

The disable_cd_eirq() field of msdc_hw is never set and only once
checked for being non zero, so it is deleted.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field enable_cd_eirq from msdc_hw
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:22 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field enable_cd_eirq from msdc_hw

The enable_cd_eirq() field of msdc_hw is never set and only once
checked for not being zero, so it is removed.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused field get_cd_status from msdc_hw
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:21 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused field get_cd_status from msdc_hw

The get_cd_status() field of msdc_hw is never set and there is only
one check for it being non zero, so it is deleted.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused code from board.h
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 15:27:20 +0000 (17:27 +0200)]
staging: mt7621-mmc: Remove unused code from board.h

The board.h file contins lot of never used code, to clean up the
driver, this code is removed.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-spi: Remove redundant owner assignment
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 17:37:32 +0000 (19:37 +0200)]
staging: mt7621-spi: Remove redundant owner assignment

Remove the owner assignment form the platform driver as
platform_driver_register() already initializes the owner.
Found using coccinelle.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-pinctrl: Remove redundant owner assignment
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 17:35:29 +0000 (19:35 +0200)]
staging: mt7621-pinctrl: Remove redundant owner assignment

Remove the owner assignment form the platform driver as
platform_driver_register() already initializes the owner.
Found using coccinelle.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-pci: Remove redundant owner assignment
Christian Lütke-Stetzkamp [Wed, 18 Apr 2018 16:40:11 +0000 (18:40 +0200)]
staging: mt7621-pci: Remove redundant owner assignment

Remove the owner assignment form the platform driver as
platform_driver_register() already initializes the owner.
Found using coccinelle.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove redundant opcode check
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:25 +0000 (10:16 +0200)]
staging: mt7621-mmc: Remove redundant opcode check

The opcode check in msdc_command_start is redundant in case of
MMC_SET_RELATIVE_ADDR, this is 3 like SD_SEND_RELATIVE_ADDR, so the
second check can be removed.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix: copy_from_user() returns a positive value
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:24 +0000 (10:16 +0200)]
staging: mt7621-mmc: Fix: copy_from_user() returns a positive value

copy_from_user() returns a positive value in case of an error, to fix
this the check is turned around, also a better return value is chosen.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix debug file world writable
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:23 +0000 (10:16 +0200)]
staging: mt7621-mmc: Fix debug file world writable

Currently the debug file in proc fs is world writable, remove the
access for other.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove error message in debug
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:22 +0000 (10:16 +0200)]
staging: mt7621-mmc: Remove error message in debug

If the debug file in proc fs is not successfully created current code
prints an error message, this is removed. de is also not an error
pointer, so the IS_ERR() call leads to a static checker warning. The
unused return value of the msdc_debug_proc_init function is also removed.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove constant flag MSDC_HIGHSPEED
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:20 +0000 (10:16 +0200)]
staging: mt7621-mmc: Remove constant flag MSDC_HIGHSPEED

The MSDC_HIGHSPEED flag is always set and never unset, remove it to
clean up the code.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused functions
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:19 +0000 (10:16 +0200)]
staging: mt7621-mmc: Remove unused functions

The functions msdc_eirq_cd and msdc_eirq_sdio are defined but never
used, so they are removed. This also fixes two compiler warnings:

drivers/staging/mt7621-mmc/sd.c:517:13: warning: ‘msdc_eirq_cd’ defined but
not used [-Wunused-function]
 static void msdc_eirq_cd(void *data)
             ^~~~~~~~~~~~
drivers/staging/mt7621-mmc/sd.c:507:13: warning: ‘msdc_eirq_sdio’ defined but
not used [-Wunused-function]
 static void msdc_eirq_sdio(void *data)

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove unused global: msdc_6575_host
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:18 +0000 (10:16 +0200)]
staging: mt7621-mmc: Remove unused global: msdc_6575_host

The mt6575_host variable is never used, only set and
exported. Removing it for code cleanup.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove constant flag
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:17 +0000 (10:16 +0200)]
staging: mt7621-mmc: Remove constant flag

The MSDC_SYS_SUSPEND flag is always set and is never unset. Removing
it cleans up the code.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix power management by removing old api
Christian Lütke-Stetzkamp [Sat, 7 Apr 2018 08:16:16 +0000 (10:16 +0200)]
staging: mt7621-mmc: Fix power management by removing old api

The mmc_suspend|resume_host functions have been decrepated in the
3.11 [1] release and were completely removed in 3.13 [2]. Removing the
calls to this functions as it was done for other mmc host drivers
before the old api was removed (eg. [3]) fixes compile errors in this
driver while CONFIG_PM is enabled.

The rest of the removed code is simply dead, the MSDC_SYS_SUSPEND flag
is always set and will be removed in a later patch.

[1] commit 986892ca78ee ("mmc: core: Initiate suspend|resume from mmc bus instead of mmc host")
[2] commit 3c0d22e8180b ("mmc: core: Remove deprecated mmc_suspend|resume_host APIs")
[3] commit 1e63d4854202 ("mmc: au1xmmc: Move away from using deprecated APIs")

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove duplicate defines
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:43 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove duplicate defines

Remove defines that are both in board.h and sd.c from sd.c, this file
already includes board.h

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix requesting of irq
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:42 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix requesting of irq

The request of the irq line is not correctly handled by the current
code, platform_get_irq may fail and if the irq is requested via
devm_request_irq, its release is automatically done.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Fix dma_alloc_coherent should get device as first param
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:41 +0000 (22:15 +0200)]
staging: mt7621-mmc: Fix dma_alloc_coherent should get device as first param

The dma_alloc_coherent (and also dma_free_coherent) should get the
device, the dma memory is allocated for as the first parameter.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Remove dead codepath from probe function
Christian Lütke-Stetzkamp [Wed, 4 Apr 2018 20:15:40 +0000 (22:15 +0200)]
staging: mt7621-mmc: Remove dead codepath from probe function

The probe function contains lots of code, that is never used, because
the fields it checks for in the msdc_hw structure are never
initialized. Removing them should be safe.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>