]> asedeno.scripts.mit.edu Git - linux.git/log
linux.git
6 years agoiio: accel: adxl345: convert address field usage in iio_chan_spec
Akinobu Mita [Mon, 25 Jun 2018 15:22:41 +0000 (00:22 +0900)]
iio: accel: adxl345: convert address field usage in iio_chan_spec

Currently the address field in iio_chan_spec is filled with an accel
data register address for the corresponding axis.

In preparation for adding calibration offset support, this sets the
address field to the index of accel data registers instead of the actual
register address.

This change makes it easier to access both accel registers and
calibration offset registers with fewer lines of code as these are
located in X-axis, Y-axis, Z-axis order.

Cc: Eva Rachel Retuya <eraretuya@gmail.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: accel: adxl345: add link to datasheet
Akinobu Mita [Mon, 25 Jun 2018 15:22:40 +0000 (00:22 +0900)]
iio: accel: adxl345: add link to datasheet

Add a link to the ADXL345 datasheet

Cc: Eva Rachel Retuya <eraretuya@gmail.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agostaging:iio:impedance-analyzer:ad5933: Macro replacement Cleanups.
Karim Eshapa [Mon, 25 Jun 2018 19:11:23 +0000 (21:11 +0200)]
staging:iio:impedance-analyzer:ad5933: Macro replacement Cleanups.

Doing some macro replacement to start an array of structures
so it can be reused by manipulating it with different values.

Signed-off-by: Karim Eshapa <karim.eshapa@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agostaging: rtl8188eu: remove whitespace - coding style
Michael Straube [Wed, 27 Jun 2018 18:47:32 +0000 (20:47 +0200)]
staging: rtl8188eu: remove whitespace - coding style

Remove unrequired whitespace in some declarations,
fix an indentation and remove unrequired blank lines.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: use mac_pton() in rtw_macaddr_cfg()
Michael Straube [Wed, 27 Jun 2018 17:36:49 +0000 (19:36 +0200)]
staging: rtl8723bs: use mac_pton() in rtw_macaddr_cfg()

Use the mac_pton() helper to convert the mac address string.

The functions key_char2num() and key_2char2num() are not used
anywhere else and can be removed.

This also has the benefit of validating the input since mac_pton()
returns false if the string is not valid.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: use ether_addr_copy() in rtw_macaddr_cfg()
Michael Straube [Wed, 27 Jun 2018 17:36:48 +0000 (19:36 +0200)]
staging: rtl8723bs: use ether_addr_copy() in rtw_macaddr_cfg()

Use ether_addr_copy() instead of memcpy() to copy the mac address.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: refactor rtw_macaddr_cfg()
Michael Straube [Wed, 27 Jun 2018 17:36:47 +0000 (19:36 +0200)]
staging: rtl8723bs: refactor rtw_macaddr_cfg()

Using is_broadcast_ether_addr() and is_zero_ether_addr() instead of
testing each byte of the mac[] array for 0xff and 0x00 shortens the
code and improves readability.

If np == NULL, of_get_property() returns NULL, hence the "np" check
is not needed.

Instead of a fixed default mac address use a random one to reduce the
likelihood of mac address collision.

Thanks to Joe Perches and Dan Carpenter.

Suggested-by: Joe Perches <joe@perches.com>
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: fix comparsion to NULL - coding style
Michael Straube [Wed, 27 Jun 2018 17:36:46 +0000 (19:36 +0200)]
staging: rtl8723bs: fix comparsion to NULL - coding style

Fix comparsion to NULL issues found by checkpatch.
Use !x instead of x == NULL.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: Convert random_ether_addr to eth_random_addr
Joe Perches [Sat, 23 Jun 2018 17:27:58 +0000 (10:27 -0700)]
staging: Convert random_ether_addr to eth_random_addr

random_ether_addr is a #define for eth_random_addr which is
generally preferred in kernel code by ~3:1

Convert the uses of random_ether_addr to enable removing the #define

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8188eu: remove blank lines
Michael Straube [Tue, 26 Jun 2018 15:38:56 +0000 (17:38 +0200)]
staging: rtl8188eu: remove blank lines

Remove unrequired blank lines after open and before close braces.
Reported by checkpatch.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wlan-ng: add parentheses to macro argument usage in prism2mgmt.c
Tim Collier [Fri, 22 Jun 2018 19:39:34 +0000 (20:39 +0100)]
staging: wlan-ng: add parentheses to macro argument usage in prism2mgmt.c

Fix two "CHECK: Macro argument 'N' may be better as '(N)' to avoid
precedence issue" messages, reported by checkpatch, by adding
parentheses around the offending macro argument references.

Signed-off-by: Tim Collier <osdevtc@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wlan-ng: replace macro with inline function in prism2mgmt.c
Tim Collier [Fri, 22 Jun 2018 19:39:33 +0000 (20:39 +0100)]
staging: wlan-ng: replace macro with inline function in prism2mgmt.c

checkpatch gives the following message for the p80211rate_to_p2bit
macro:

CHECK: Macro argument reuse 'n' - possible side-effects?

To fix the message, replace the macro with an equivalent inline
function.

Signed-off-by: Tim Collier <osdevtc@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wlan-ng: replace WLAN_CTL_FRAMELEN with inline function in p80211hdr.h
Tim Collier [Fri, 22 Jun 2018 19:39:32 +0000 (20:39 +0100)]
staging: wlan-ng: replace WLAN_CTL_FRAMELEN with inline function in p80211hdr.h

checkpatch reports a "CHECK" diagnostic for WLAN_CTL_FRAMELEN as the
macro reuses its argument, leading to possible side-effects. Avoid
this by replacing the macro with an equivalent function, named
wlan_ctl_framelen (as recommended in the coding style). All references
to the macro also updated accordingly.

Signed-off-by: Tim Collier <osdevtc@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wlan-ng: fix coding style (indentation) in prism2mib.c
Tim Collier [Fri, 22 Jun 2018 19:39:31 +0000 (20:39 +0100)]
staging: wlan-ng: fix coding style (indentation) in prism2mib.c

Fix "CHECK: Alignment should match open parenthesis" reported by
checkpatch.pl.

Signed-off-by: Tim Collier <osdevtc@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtlwifi: Fix a possible sleep-in-atomic-context bug in _is_fw_read_cmd_down()
Jia-Ju Bai [Wed, 20 Jun 2018 02:58:01 +0000 (10:58 +0800)]
staging: rtlwifi: Fix a possible sleep-in-atomic-context bug in _is_fw_read_cmd_down()

The driver may sleep with holding a spinlock.
The function call path (from bottom to top) in Linux-4.16.7 is:

[FUNC] schedule
drivers/staging/rtlwifi/halmac/rtl_halmac.c, 884:
schedule in _is_fw_read_cmd_down
drivers/staging/rtlwifi/halmac/rtl_halmac.c, 912:
_is_fw_read_cmd_down in rtl_halmac_send_h2c
drivers/staging/rtlwifi/halmac/rtl_halmac.c, 907:
_raw_spin_lock_irqsave in rtl_halmac_send_h2c

To fix this bug, schedule() is replaced with mdelay(1).

This bug is found by my static analysis tool (DSAC-2) and checked by
my code review.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wlan-ng: improved readability of function prism2_add_key
Chris Opperman [Fri, 22 Jun 2018 15:29:02 +0000 (17:29 +0200)]
staging: wlan-ng: improved readability of function prism2_add_key

Improve readability of prism2_add_key:
a) Reduce nesting and removed goto statement by using more return statements.

Signed-off-by: Chris Opperman <eklikeroomys@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtsx: remove rtsx_trace() and related code
Arnd Bergmann [Mon, 18 Jun 2018 14:38:02 +0000 (16:38 +0200)]
staging: rtsx: remove rtsx_trace() and related code

The driver has rather excessive amount of tracing code, which would be
better done using ftrace. This is obviously not a main feature of the
driver, and it should work just as well without it.

Removing it saves over 1300 lines of code and likely makes the driver
a bit faster by avoiding lots of calls into the timekeeping code.

I came across this while cleaning up the last users of the deprecated
getnstimeofday64() function, of which there is one in the now-removed
get_current_time() function of the rtsx driver that was only used for
tracing.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: use BIT_ULL for NL80211_STA_INFO_* attribute types
Omer Efrat [Mon, 18 Jun 2018 14:18:11 +0000 (17:18 +0300)]
staging: use BIT_ULL for NL80211_STA_INFO_* attribute types

The BIT macro uses unsigned long which some architectures handle as 32 bit
and therefore might cause macro's shift to overflow when used on a value
equals or larger than 32 (NL80211_STA_INFO_RX_DURATION and afterwards).

Since 'filled' member in station_info changed to u64, BIT_ULL macro
should be used with all NL80211_STA_INFO_* attribute types instead of BIT
to prevent future possible bugs when one will use BIT macro for higher
attributes by mistake.

This commit cleans up all usages of BIT macro with the above field
in cfg80211 by changing it to BIT_ULL instead.

Signed-off-by: Omer Efrat <omer.efrat@tandemg.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: most: fix sparse warning Using plain integer as NULL pointer
Marcin Ciupak [Fri, 15 Jun 2018 14:21:09 +0000 (14:21 +0000)]
staging: most: fix sparse warning Using plain integer as NULL pointer

This patch fixes following sparse warning:
Using plain integer as NULL pointer
in drivers/staging/most/dim2/dim2.c

Signed-off-by: Marcin Ciupak <marcin.s.ciupak@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: remove rtw_set_tx_chksum_offload()
Michael Straube [Mon, 25 Jun 2018 14:50:25 +0000 (16:50 +0200)]
staging: rtl8723bs: remove rtw_set_tx_chksum_offload()

The function rtw_set_tx_chksum_offload() has empty definition.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Fix comment on variable init
Henriette Hofmeier [Fri, 22 Jun 2018 14:01:59 +0000 (16:01 +0200)]
staging: rtl8723bs: Fix comment on variable init

Change comment from 'local variable' to 'global variables'
and change style to comply with coding-style.

Signed-off-by: Henriette Hofmeier <passt@h-hofmeier.de>
Signed-off-by: Florian Harbecke <florian.harbecke@fau.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Remove unnecessary initializations
Henriette Hofmeier [Fri, 22 Jun 2018 14:01:58 +0000 (16:01 +0200)]
staging: rtl8723bs: Remove unnecessary initializations

Remove initializations of global variables with 0.
Criticized by checkpatch.

Signed-off-by: Henriette Hofmeier <passt@h-hofmeier.de>
Signed-off-by: Florian Harbecke <florian.harbecke@fau.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Move definition open brace
Henriette Hofmeier [Fri, 22 Jun 2018 14:01:57 +0000 (16:01 +0200)]
staging: rtl8723bs: Move definition open brace

Move open braces of definitions to the next line
to comply with codestyle.
Criticized by checkpatch.

Signed-off-by: Henriette Hofmeier <passt@h-hofmeier.de>
Signed-off-by: Florian Harbecke <florian.harbecke@fau.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Fix two possible sleep-in-atomic-context bugs in translate_scan()
Jia-Ju Bai [Wed, 20 Jun 2018 09:50:16 +0000 (17:50 +0800)]
staging: rtl8723bs: Fix two possible sleep-in-atomic-context bugs in translate_scan()

The driver may sleep with holding a spinlock.
The function call paths (from bottom to top) in Linux-4.16.7 are:

[FUNC] kzalloc(GFP_KERNEL)
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 323:
kzalloc in translate_scan
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 1554:
translate_scan in rtw_wx_get_scan
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 1533:
spin_lock_bh in rtw_wx_get_scan

[FUNC] kzalloc(GFP_KERNEL)
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 455:
kzalloc in translate_scan
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 1554:
translate_scan in rtw_wx_get_scan
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 1533:
spin_lock_bh in rtw_wx_get_scan

To fix these bugs, GFP_KERNEL is replaced with GFP_ATOMIC.

These bugs are found by my static analysis tool (DSAC-2) and checked by
my code review.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: remove get_monotonic_boottime()
Arnd Bergmann [Mon, 18 Jun 2018 15:06:50 +0000 (17:06 +0200)]
staging: rtl8723bs: remove get_monotonic_boottime()

get_monotonic_boottime() is deprecated because it uses the
old 'timespec' structure. This replaces one of the last callers
with a call to ktime_get_boottime, which also simplifies it
a bit by avoiding a double conversion.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Add missing curly braces on else statement.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:40 +0000 (22:30 -0700)]
staging: rtl8723bs: Add missing curly braces on else statement.

Fix 'braces {} should be used on all arms of this statement' coding
style problem in 'phy_get_tx_pwr_lmt()'.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Merge workaround conditionals into single else-if.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:39 +0000 (22:30 -0700)]
staging: rtl8723bs: Merge workaround conditionals into single else-if.

The if conditionals used to work around wrong TX power limit indices
can be condensed into a single if/else-if statement for more concise
expression.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Merge conditionals with similar bodies.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:38 +0000 (22:30 -0700)]
staging: rtl8723bs: Merge conditionals with similar bodies.

Two conditionals that set 'channel' based on 'band_type' in
'phy_get_tx_pwr_lmt()' can be simplified into one single-line conditional.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Fix spelling mistake in comment.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:37 +0000 (22:30 -0700)]
staging: rtl8723bs: Fix spelling mistake in comment.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Move bandwidth index lookup to new function.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:36 +0000 (22:30 -0700)]
staging: rtl8723bs: Move bandwidth index lookup to new function.

Factoring out the conditional lookup of bandwidth index into the power
limit table into it's own function simplifies the logic of
'phy_get_tx_pwr_lmt()'.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Move rate section index lookup to new function.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:35 +0000 (22:30 -0700)]
staging: rtl8723bs: Move rate section index lookup to new function.

The rate section lookup is a large switch statement in the middle of
'phy_get_tx_pwr_lmt()'; refactor this statement into it's own function
for increased readability.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Remove empty else-if conditional.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:34 +0000 (22:30 -0700)]
staging: rtl8723bs: Remove empty else-if conditional.

This else-if conditional block does nothing; remove it.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Combine if statements with equivalent body.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:33 +0000 (22:30 -0700)]
staging: rtl8723bs: Combine if statements with equivalent body.

Two if statements that carry out the same operation can be combined with
a logical OR.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Fix camel-case names in phy_get_tx_pwr_lmt().
Quytelda Kahja [Sun, 17 Jun 2018 05:30:32 +0000 (22:30 -0700)]
staging: rtl8723bs: Fix camel-case names in phy_get_tx_pwr_lmt().

Change camel-case names to snake-case names; to avoid variable name
conflicts, rename table index variables to idx_*.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Rename PHY_GetTxPowerLimit().
Quytelda Kahja [Sun, 17 Jun 2018 05:30:31 +0000 (22:30 -0700)]
staging: rtl8723bs: Rename PHY_GetTxPowerLimit().

Rename camel-case 'PHY_GetTxPowerLimit()' to 'phy_get_tx_pwr_lmt()'.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()'.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:30 +0000 (22:30 -0700)]
staging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()'.

Wrap lines longer than 80 characters where possible, delete double
newlines, and fix alignment per the kernel coding style guidelines.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: pi433: cleanup comments in rf69.h
Valentin Vidic [Mon, 25 Jun 2018 12:04:41 +0000 (14:04 +0200)]
staging: pi433: cleanup comments in rf69.h

Fixes checkpatch warning:

  WARNING: line over 80 characters

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: pi433: add SPDX-License-Identifier tag
Valentin Vidic [Mon, 25 Jun 2018 11:52:23 +0000 (13:52 +0200)]
staging: pi433: add SPDX-License-Identifier tag

Use GPL-2.0+ based on the license text in each of the files.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: pi433: replace simple switch statements
Valentin Vidic [Sun, 24 Jun 2018 16:31:38 +0000 (18:31 +0200)]
staging: pi433: replace simple switch statements

Use const array to map switch cases to resulting values.

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: pi433: fix race condition in pi433_open
Hugo Lefeuvre [Wed, 20 Jun 2018 13:37:19 +0000 (09:37 -0400)]
staging: pi433: fix race condition in pi433_open

The device structure contains a useless non-atomic users counter which
is subject to race conditions. It has probably been created to handle
the case where remove is executed while operations are still executing
on open fds but this will never happen because of reference counts.

Drop the users counter and move rx buffer {de,}allocation to probe()
and remove(). Remove associated dead code from open() and release().
Remove related TODO entry from ioctl().

Signed-off-by: Hugo Lefeuvre <hle@owl.eu.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: android/vsoc: stop using 'timespec'
Arnd Bergmann [Mon, 18 Jun 2018 15:09:09 +0000 (17:09 +0200)]
staging: android/vsoc: stop using 'timespec'

The timespec structure suffers from the y2038 overflow and should not
be used. This changes handle_vsoc_cond_wait() to use ktime_t directly.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Martijn Coenen <maco@android.com>
Tested-by: Alistair Strachan <astrachan@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: android: ashmem: Fix mmap size validation
Alistair Strachan [Wed, 20 Jun 2018 00:57:35 +0000 (17:57 -0700)]
staging: android: ashmem: Fix mmap size validation

The ashmem driver did not check that the size/offset of the vma passed
to its .mmap() function was not larger than the ashmem object being
mapped. This could cause mmap() to succeed, even though accessing parts
of the mapping would later fail with a segmentation fault.

Ensure an error is returned by the ashmem_mmap() function if the vma
size is larger than the ashmem object size. This enables safer handling
of the problem in userspace.

Cc: Todd Kjos <tkjos@android.com>
Cc: devel@driverdev.osuosl.org
Cc: linux-kernel@vger.kernel.org
Cc: kernel-team@android.com
Cc: Joel Fernandes <joel@joelfernandes.org>
Signed-off-by: Alistair Strachan <astrachan@google.com>
Acked-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Reviewed-by: Martijn Coenen <maco@android.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: android: ashmem: Remove use of unlikely()
Alistair Strachan [Wed, 20 Jun 2018 00:57:34 +0000 (17:57 -0700)]
staging: android: ashmem: Remove use of unlikely()

There is no speed difference, and it makes the code harder to read.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Todd Kjos <tkjos@android.com>
Cc: Martijn Coenen <maco@android.com>
Cc: devel@driverdev.osuosl.org
Cc: linux-kernel@vger.kernel.org
Cc: kernel-team@android.com
Cc: Joel Fernandes <joel@joelfernandes.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Alistair Strachan <astrachan@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: updated TODO file
Ajay Singh [Tue, 26 Jun 2018 06:07:14 +0000 (11:37 +0530)]
staging: wilc1000: updated TODO file

Item [1] in TODO list is already addressed, so removed it from TODO file.

[1]. Move handling for each individual members of 'union message_body' out
into a separate 'struct work_struct' and completely remove the
multiplexerthat is currently part of host_if_work(), allowing movement
of the implementation of each message handler into the callsite of the
function that currently queues the 'host_if_msg'.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: avoid use of static variable 'rssi'
Ajay Singh [Tue, 26 Jun 2018 06:07:13 +0000 (11:37 +0530)]
staging: wilc1000: avoid use of static variable 'rssi'

Instead of static variable now allocating the data and passing to
handle_get_rssi() to fill the rssi information.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: avoid use of static variable 'inactive_time'
Ajay Singh [Tue, 26 Jun 2018 06:07:12 +0000 (11:37 +0530)]
staging: wilc1000: avoid use of static variable 'inactive_time'

Avoided the use of static variable 'inactive_time' and move it as part of
'sta_inactive_t' structure.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: handle freeing of 'key' & 'seq' data in wilc_add_rx_gtk()
Ajay Singh [Tue, 26 Jun 2018 06:07:11 +0000 (11:37 +0530)]
staging: wilc1000: handle freeing of 'key' & 'seq' data in wilc_add_rx_gtk()

Handle freeing of memory allocated to keep 'key' & 'seq' in wilc_add_rx_gtk().
Once completion event is received, free the memory allocated for
to avoid missing of free in work function.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: handle freeing of key data in wilc_add_ptk()
Ajay Singh [Tue, 26 Jun 2018 06:07:10 +0000 (11:37 +0530)]
staging: wilc1000: handle freeing of key data in wilc_add_ptk()

Handle freeing of memory allocated to store the 'key' in wilc_add_ptk()
function. Once work completion notification is received, free the
memory allocated to avoid missing of free in work function sepecially
for error scenario.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: handle freeing of key data in wep add key
Ajay Singh [Tue, 26 Jun 2018 06:07:09 +0000 (11:37 +0530)]
staging: wilc1000: handle freeing of key data in wep add key

Modified the code to free the allocated memory, used to store the key in
wilc_add_wep_key_bss_sta() and wilc_add_wep_key_bss_ap().
After work completion notification is received, free the
memory allocated to avoid missing of free in work function.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: rename wilc_enqueue_cmd() to wilc_enqueue_work()
Ajay Singh [Tue, 26 Jun 2018 06:07:08 +0000 (11:37 +0530)]
staging: wilc1000: rename wilc_enqueue_cmd() to wilc_enqueue_work()

Rename wilc_enqueue_cmd() to wilc_enqueue_work() because its used to
enqueue the work queue. Also removed the function header comment for
wilc_enqueue_cmd() as its not correct.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: remove 'hif_thread_comp' completions
Ajay Singh [Tue, 26 Jun 2018 06:07:07 +0000 (11:37 +0530)]
staging: wilc1000: remove 'hif_thread_comp' completions

Remove 'hif_thread_comp' completions as its not required after adding
completion event as part work data to handle each sync call.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: added 'work_comp' completion as part of host_if_msg
Ajay Singh [Tue, 26 Jun 2018 06:07:06 +0000 (11:37 +0530)]
staging: wilc1000: added 'work_comp' completion as part of host_if_msg

Added 'work_comp' completion in 'host_if_msg'. It allows handling the
sync call to wait for sepecific completion event.
The commands can be run in sync way waiting for their specific
completion event.
Added is_sync flag in wilc_create_work_queue() to handle the sync call to
host interface.

After adding completion as part of host_if_msg now
below completion are not required
 comp_test_key_block;
 comp_test_disconn_block
 comp_get_rssi
 comp_inactive_time
 hif_wait_response

Modified wilc_get_statistics() API to handle get statistic in sync &
async way.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: move the allocation of cmd out of wilc_enqueue_cmd()
Ajay Singh [Tue, 26 Jun 2018 06:07:05 +0000 (11:37 +0530)]
staging: wilc1000: move the allocation of cmd out of wilc_enqueue_cmd()

Instead of allocating the host_if_cmd in wilc_enqueue_cmd() now moved
the allocation of cmd in the caller. Added the NULL check for
'hif_workqueue' before posting the work queue in wilc_enqueue_cmd().

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: remove unused marco related to HIF commands
Ajay Singh [Tue, 26 Jun 2018 06:07:04 +0000 (11:37 +0530)]
staging: wilc1000: remove unused marco related to HIF commands

After removing the multiplexing of hif commands in hif_if_work()
macros prefix with 'HOST_IF_MSG_' are not required. Also 'id' field in
host_if_msg is not required anymore.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: remove host_if_work() to handle TODO list issue
Ajay Singh [Tue, 26 Jun 2018 06:07:03 +0000 (11:37 +0530)]
staging: wilc1000: remove host_if_work() to handle TODO list issue

Remove multiplexing of command at host_if_work().
Make use of function pointer instead of command ID to track individual
work_struct separately.

Modified the handler function to take work_struct pointer as argument
and its return type is changes to void. Now prototype of 'handle_'
function is same work_struct i.e. 'void (*fun)(struct struct *)' to
register with work_queue.
Removed host_if_work() because its not required now.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: Use common structs to parse ip packets
Thibaut Robert [Tue, 19 Jun 2018 18:44:19 +0000 (20:44 +0200)]
staging: wilc1000: Use common structs to parse ip packets

Use structs ethhdr, iphdr and tcphdr instead of manual parsing in
tcp_process.
This commit fix handling of ip packets containing options.
It also fixes the following sparse warning:

drivers/staging/wilc1000//wilc_wlan.c:201:19: warning: cast to restricted __be16

Signed-off-by: Thibaut Robert <thibaut.robert@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: avoid use banks in device tree
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:20 +0000 (11:36 +0200)]
staging: mt7621-gpio: avoid use banks in device tree

Banks shouldn't be defined in DT if number of resources
per bank is not variable. We actually know that this SoC
has three banks so take that into account in order to don't
overspecify the device tree. Device tree will only have one
node making it simple. Update device tree, binding doc and
code accordly.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: update Kconfig with SoC details
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:19 +0000 (11:36 +0200)]
staging: mt7621-gpio: update Kconfig with SoC details

Kconfig is using a generic 'Mediatek GPIO Support' in
description and help which is not specific at all about
the current SoC which is MT7621. Update it.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: avoid long line in a comment
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:18 +0000 (11:36 +0200)]
staging: mt7621-gpio: avoid long line in a comment

Checkpatch script is complaining about a comment line
which exceeds 80 characteres. Just silence it.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: set different names for each gpio_chip and irq_chip
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:17 +0000 (11:36 +0200)]
staging: mt7621-gpio: set different names for each gpio_chip and irq_chip

Currently the driver defines 3 gpiochips, one for each bank.

/sys/class/gpio/gpiochip416/label:1e000600.gpio
/sys/class/gpio/gpiochip448/label:1e000600.gpio
/sys/class/gpio/gpiochip480/label:1e000600.gpio

Unfortunately they all have the same label

Interrupts from /proc/interrupt show the same name which is
confusing:

/proc/interrupts:

17: 0  0  0  0  MIPS GIC  19  mt7621, mt7621, mt7621

which is the interrupt from the GPIO controller.
It is a little weird that all three banks are named "mt7621"
here. We also have:

26: 0  0  0  0  GPIO  18  reset

which is the interrupt from GPIO which provides the "reset"
button. I suspect that if I had interrupts form two different
banks they would both be called "GPIO" which would be a little
confusing.

In order to unify all of this set different names for each chip
Use a 'bank-based' name instead the same for all: 'mt7621-bank[0-2]'.
Create a new 'mediatek_gpio_bank_name' function which return the
name depending on the bank number. This function is allways called
with a valid index 0, 1 or 2.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: avoid one level indentation in interrupt handler
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:16 +0000 (11:36 +0200)]
staging: mt7621-gpio: avoid one level indentation in interrupt handler

There is no need to check for 'pending' before loop over the
interrupts using 'for_each_set_bit' if nothing is set the
return values will be the same so just avoid this check avoiding
also one level intentation and improving readability.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: avoid to set up irqs if not defined in dts
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:15 +0000 (11:36 +0200)]
staging: mt7621-gpio: avoid to set up irqs if not defined in dts

If there is no interrupt defined in the dts 'irq_of_parse_and_map'
returns 0 and we should't set up interrupts for each gpio chip in
that case.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: avoid check for NULL in 'to_mediatek_gpio' calls
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:14 +0000 (11:36 +0200)]
staging: mt7621-gpio: avoid check for NULL in 'to_mediatek_gpio' calls

Function 'to_mediatek_gpio' cannot return NULL, so this NULL
checkings are pointless.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: align indentation for all defines
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:13 +0000 (11:36 +0200)]
staging: mt7621-gpio: align indentation for all defines

There was two remaining defines which weren't properly
aligned with the rest. Align them improving readability.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: update kerneldoc for state containers
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:12 +0000 (11:36 +0200)]
staging: mt7621-gpio: update kerneldoc for state containers

Update kernel doc for mtk_data and also remove no needed
documentation for mtk_gc which is clear enough to don't
need it.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: remove no more necessary PIN_MASK macro
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:11 +0000 (11:36 +0200)]
staging: mt7621-gpio: remove no more necessary PIN_MASK macro

PIN_MASK macro was being used because of the fact we were only
using one interrupt controller for all of the gpio chips. This
has been changed to use one per gpio chip and each has 32 irqs.
Because of this this macro is not needed anymore. Use BIT macro
instead.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: avoid custom irq_domain for gpio
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:10 +0000 (11:36 +0200)]
staging: mt7621-gpio: avoid custom irq_domain for gpio

Instead of create a custom irq_domain for this chip, use
'gpiochip_set_chained_irqchip' from GPIOLIB_IRQCHIP. It
is ok to call this function several times. We have to
manually mark the line with 'IRQF_SHARED' and then loop
over the three banks until you find a hit. There were
some problems with removing an irqchip like that but this
driver is a bool so it might work just fine. After this
changes the functions 'mediatek_gpio_to_irq' is not needed
anymore and also the 'gpio_irq_domain' field from the state
container. Instead of use the custom irq domain in the irq
handler use the associated domain from the gpio_chip in
'irq_find_mapping' function. Function 'mediatek_gpio_bank_probe'
has been moved a it to the botton to have all the irq related
functions together and avoid some forward declarations to resolve
some symbols along the code.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: implement high level and low level irqs
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:09 +0000 (11:36 +0200)]
staging: mt7621-gpio: implement high level and low level irqs

This chip support high level and low level interrupts. Those
have to be implemented also to get a complete and clean driver.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: add kerneldoc for state data containers
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:08 +0000 (11:36 +0200)]
staging: mt7621-gpio: add kerneldoc for state data containers

This commit adds kerneldoc for the two data containers in
order to better understanding of its existence.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: add COMPILE_TEST
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:07 +0000 (11:36 +0200)]
staging: mt7621-gpio: add COMPILE_TEST

This driver is actually platform-agnostic.  Add COMPILE_TEST for
the compilation test coverage.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: implement '.irq_[request|release]_resources' functions
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:06 +0000 (11:36 +0200)]
staging: mt7621-gpio: implement '.irq_[request|release]_resources' functions

When implementing custom irqchips it is important to also
implement .irq_request_resources() and .irq_release_resources()
and make sure these call gpiochip_[un]lock_as_irq().
Add those two for this driver. Also store struct device pointer
in global state structure to be able to use 'dev_err' with the
device from 'mediatek_request_resources' function.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: make use of 'builtin_platform_driver'
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:05 +0000 (11:36 +0200)]
staging: mt7621-gpio: make use of 'builtin_platform_driver'

This driver was being registered using 'module_platform_driver'
but it is not a module at all. Instead of this use
'builtin_platform_driver' which seems to be the correct one.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: avoid including 'gpio.h'
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:04 +0000 (11:36 +0200)]
staging: mt7621-gpio: avoid including 'gpio.h'

Including file '<linux/gpio.h>' should be avoided in
new drivers code, so just remove it because it is
no necessary at all.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: make use 'bgpio_init' from GPIO_GENERIC
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:03 +0000 (11:36 +0200)]
staging: mt7621-gpio: make use 'bgpio_init' from GPIO_GENERIC

Gpio complexity is just masking the fact that offset is always
0..n and writes to bits 0..n of some memory address. Because
of this whole thing can just me converted to use GPIO_GENERIC
and avoid duplications of a lot of driver custom functions.
So use bgpio_init instead of custom code adding GPIO_GENERIC
dependency to the Kconfig file. Also to make easier using
bgpio_init function offset for each gpio bank, enumeration
where register were defined has been replaced in favour of
some macros which handle each gpio offset taking into account
the bank where are located. Because of this change write and
read functions which are being used for remaining irq handling
stuff have been updated also as well as its dependencies along
the code.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-eth: Use eth_hw_addr_random()
Kamal Heib [Wed, 20 Jun 2018 10:47:11 +0000 (13:47 +0300)]
staging: mt7621-eth: Use eth_hw_addr_random()

Use eth_hw_addr_random() to set a random dev_addr and update
addr_assign_type.

Fixes: e3cbf478f846 ('staging: mt7621-eth: add the drivers core files')
Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-eth: Fix memory leak in mtk_add_mac() error path
Kamal Heib [Tue, 19 Jun 2018 17:04:08 +0000 (20:04 +0300)]
staging: mt7621-eth: Fix memory leak in mtk_add_mac() error path

Fix memory leak in error path of mtk_add_mac() by make sure to free
the allocated netdev.

Fixes: e3cbf478f846 ('staging: mt7621-eth: add the drivers core files')
Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-dts: Fix remaining pcie warnings
Rosen Penev [Sun, 17 Jun 2018 02:17:50 +0000 (19:17 -0700)]
staging: mt7621-dts: Fix remaining pcie warnings

This currently fixes the remaining dtb warnings:

Node /pcie@1e140000/pcie0 has a reg or ranges property, but no unit name
Node /pcie@1e140000/pcie1 has a reg or ranges property, but no unit name
Node /pcie@1e140000/pcie2 has a reg or ranges property, but no unit name
Node /pcie@1e140000/pcie0 node name is not "pci" or "pcie"
Node /pcie@1e140000/pcie0 missing ranges for PCI bridge (or not a bridge)
Node /pcie@1e140000/pcie0 missing bus-range for PCI bridge
Node /pcie@1e140000/pcie1 node name is not "pci" or "pcie"
Node /pcie@1e140000/pcie1 missing ranges for PCI bridge (or not a bridge)
Node /pcie@1e140000/pcie1 missing bus-range for PCI bridge
Node /pcie@1e140000/pcie2 node name is not "pci" or "pcie"
Node /pcie@1e140000/pcie2 missing ranges for PCI bridge (or not a bridge)
Node /pcie@1e140000/pcie2 missing bus-range for PCI bridge
Warning (unit_address_format): Failed prerequisite 'pci_bridge'
Warning (pci_device_reg): Failed prerequisite 'pci_bridge'
Warning (pci_device_bus_num): Failed prerequisite 'pci_bridge'

device_type was removed since according to documentation, it's deprecated
for pci(e) devices.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Find response of SD_APP_OP_COND by default
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:15:08 +0000 (16:15 +0200)]
staging: mt7621-mmc: Find response of SD_APP_OP_COND by default

The response type of the SD_APP_OP_COND command is correctly
determined using the mmc_resp_type macro, because the only use of that
opcode, mmc_send_app_op_cond, correctly places MMC_RSP_R3 in cmd.flags.

So there is no need to treat that opcode separately.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Find response of MMC_SEND_OP_COND by default
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:15:07 +0000 (16:15 +0200)]
staging: mt7621-mmc: Find response of MMC_SEND_OP_COND by default

The response type of the MMC_SEND_OP_COND command is correctly
determined using the mmc_resp_type macro, because the only use of that
opcode, mmc_send_op_cond, correctly places MMC_RSP_R3 in cmd.flags.

So there is no need to treat that opcode separately.

Signed-off-by: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-mmc: Factor out from msdc_command_start()
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:15:06 +0000 (16:15 +0200)]
staging: mt7621-mmc: Factor out from msdc_command_start()

Currently msdc_command_start does multiple things and is hard to read,
so factor out the finding of the response type.

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 argument from msdc_do_command
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:15:05 +0000 (16:15 +0200)]
staging: mt7621-mmc: Remove unused argument from msdc_do_command

The argument tune of msdc_do_command 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 macro is_card_present
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:15:04 +0000 (16:15 +0200)]
staging: mt7621-mmc: Remove unused macro is_card_present

The macro is_card_present is unused and also a duplicate of a macro in
mmc, 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 define MAX_PHY_SGMTS
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:15:03 +0000 (16:15 +0200)]
staging: mt7621-mmc: Remove unused define MAX_PHY_SGMTS

The define MAX_PHY_SGMTS 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 enum msdc_mode
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:15:02 +0000 (16:15 +0200)]
staging: mt7621-mmc: Remove unused enum msdc_mode

The enum msdc_mode 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 define IRQ_SDC
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:15:01 +0000 (16:15 +0200)]
staging: mt7621-mmc: Remove unused define IRQ_SDC

The define IRQ_SDC 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 define RALINK_MSDC_BASE
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:15:00 +0000 (16:15 +0200)]
staging: mt7621-mmc: Remove unused define RALINK_MSDC_BASE

The define RALINK_MSDC_BASE 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: Cleanup source of base address for io
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:14:59 +0000 (16:14 +0200)]
staging: mt7621-mmc: Cleanup source of base address for io

Currently the base address for all io operations is hidden behind a
macro, REG_ADD. This macro uses the symbol "base" as the base address
and all functions set base = host->base. This is hard to read, so the
whole wrapping is removed and host->base is directly inserted in the
io access.

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 MSDC_MODE_* defines
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:14:58 +0000 (16:14 +0200)]
staging: mt7621-mmc: Remove MSDC_MODE_* defines

The MSDC_MODE_* defines are all never used and do not contain any
information about the device, so remove them.

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 variable from msdc_tune_request
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:14:57 +0000 (16:14 +0200)]
staging: mt7621-mmc: Remove unused variable from msdc_tune_request

The variable cmd in the function msdc_tune_request is set but 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 macro MAX_BD_PER_GPD
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:14:56 +0000 (16:14 +0200)]
staging: mt7621-mmc: Remove unused macro MAX_BD_PER_GPD

The macro MAX_BD_PER_GPD 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 macro msdc_retry
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:14:55 +0000 (16:14 +0200)]
staging: mt7621-mmc: Remove unused macro msdc_retry

The macro msdc_retry 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: Make msdc_clr_fifo a function and relax cpu
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:14:54 +0000 (16:14 +0200)]
staging: mt7621-mmc: Make msdc_clr_fifo a function and relax cpu

In the current code, msdc_clr_fifo is a macro and just busy waits for
a limited amount of time for the fifo clear to finish. That is not
correct, the programming manual hits, that the user should wait until
the bit is cleared by hardware and not a limited amount of time.

So the code is changed to a function, that also relaxes the cpu while
busy waiting.

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 unnecessary BUG_ON() in msdc_dma_setup
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:14:53 +0000 (16:14 +0200)]
staging: mt7621-mmc: Remove unnecessary BUG_ON() in msdc_dma_setup

The BUG_ON() removed by this patch is just a duplicate of a prior
BUG_ON() statement. There the condition is just clearer, it checks
weather sglen > MAX_BD_NUM and MAX_BD_NUM is equal MAX_BD_PER_GPD. So
this statement can be safely 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 variable num form msdc_dma_setup
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:14:52 +0000 (16:14 +0200)]
staging: mt7621-mmc: Remove variable num form msdc_dma_setup

The variable num in msdc_dma_setup is only used for a BUG_ON
statement, so it can be removed by inlining the condition.

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 sglen from msdc_dma
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:14:51 +0000 (16:14 +0200)]
staging: mt7621-mmc: Remove unused field sglen from msdc_dma

The field sglen from struct msdc_dma is once set and never read, 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 sg from msdc_dma
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:14:50 +0000 (16:14 +0200)]
staging: mt7621-mmc: Remove unused field sg from msdc_dma

The field sg from struct msdc_dma is once set and never read, 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: Refactor dma setup process
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:14:49 +0000 (16:14 +0200)]
staging: mt7621-mmc: Refactor dma setup process

Current code uses two functions for dma setup, msdc_dma_config and
msdc_dma_setup. By now msdc_dma_setup is nearly empty and mainly calls
msdc_dma_config, so the later one can be inline into the first
one. While doing this there is also some refactoring done.

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 mode from msdc_dma
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:14:48 +0000 (16:14 +0200)]
staging: mt7621-mmc: Remove unused field mode from msdc_dma

The field mode of struct msdc_dma has no remaining use, 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 DMA basic mode code
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:14:47 +0000 (16:14 +0200)]
staging: mt7621-mmc: Remove DMA basic mode code

The driver currently only uses DMA linked mode and the upstream
driver does the same, so remove the basic mode code.

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 register debugging structures
Christian Lütke-Stetzkamp [Sat, 16 Jun 2018 14:14:46 +0000 (16:14 +0200)]
staging: mt7621-mmc: Remove register debugging structures

Current code has structures for all the registers of the device, but
these are never used and there are also masks for all of them, so
these structures do not contain any useful information.

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