Commit graph

41 commits

Author SHA1 Message Date
Christian Gromm
4b1a7cf1cc staging: most: hdm-usb: remove completion object
Waiting for the urb_compl object to complete evaluates always as false.
This patch removes this unnecessary completion object.

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 16:53:57 +02:00
Christian Gromm
b24c9fe9fc staging: most: hdm-usb: synchronize release of struct buf_anchor
In case a channel that is going to be destroyed has been tagged as not
"healthy" by the function hdm_poison_channel() while the functions
hdm_write_completion() or hdm_read_completion() are being executed, they
race for destruction of buf_anchor.

This patch fixes the problem.

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 16:53:57 +02:00
Christian Gromm
cf6a599ef7 staging: most: hdm-usb: assign spinlock to local variable
This patch assigns the spinlock of struct mdev to local spinlock_t
variable to get rid of all the ugly dereferencing.

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 16:53:57 +02:00
Christian Gromm
bf9503f11d staging: most: hdm-usb: fix race between enqueue and most_stop_enqueue
The "broken in pipe" handler of the USB-HDM calls most_stop_enqueue() to
stop the MBO traffic before returning all MBOs back to the Mostcore.  As
the enqueue() call from the Mostcore may run in parallel with the
most_stop_enqueue(), the HDM may run into the inconsistent state and
crash the kernel.

This patch synchronizes enqueue(), most_stop_enqueue() and
most_resume_enqueue() with a mutex, hence avoiding the race condition.

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 16:53:57 +02:00
Christian Gromm
cf05918370 staging: most: hdm-usb: simplify initialization of mbo->status.
This patch simplifies the code that initializes mbo->status.

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 16:53:57 +02:00
Christian Gromm
4246501e23 staging: most: hdm-usb: remove redundant conditions
This patch removes the duplication of the expression
(urb->status == -ENOENT || urb->status == -ECONNRESET).

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 16:53:57 +02:00
Christian Gromm
879c93fefd staging: most: hdm-usb: make use of is_channel_healthy flag
This patch makes the write completion handler use the is_channel_healthy
flag to prevent the hdm from scheduling a second clear_halt workqueue in
case an endpoint reported a STALL condition.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 16:53:57 +02:00
Christian Gromm
654f7ec4b3 staging: most: hdm-usb: rename ID_INIC for consistency
In order to have a consistent naming convention this patch renames
USB_DEV_ID_INIC to USB_DEV_ID_OS81118.

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 16:53:56 +02:00
Christian Gromm
b50762eaf8 staging: most: hdm-usb: add USB product id
This patch adds support for the OS81119 MOST network interface controller
to the driver.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 16:53:56 +02:00
Christian Gromm
72df4a55e9 staging: most: hdm-usb: stop core from submitting buffers in case of broken pipe
This patch ensures that no more packets are submitted by the core in
case an USB endpoint has reported a broken pipe (-EPIPE).

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 16:53:56 +02:00
Christian Gromm
cc28983c32 staging: most: hdm-usb: fix clear halt processing
This patch is needed to ensure that submitted URBs get unlinked before
the driver calls usb_clear_halt(). Since the halt condition of an USB
endpoint is channel related, the work_struct is moved from a buffer
basis to a channel basis.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 16:53:56 +02:00
Christian Gromm
9ed745ff8e staging: most: hdm-usb: provide MBO status when freeing buffers
This patch adds the additional status parameter to function
free_anchored_buffers. This allows to dispatch further processing based
on this flag.

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 16:53:56 +02:00
Christian Gromm
cce9301937 staging: most: hdm-usb: remove unused macro HW_RESYNC
This patch removes the macro HW_RESYNC that is not used anymore.

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-21 16:53:56 +02:00
Christian Gromm
ec7e0a189b staging: most: hdm-usb: reduce context of list_del mutex
This patch reduces context of the list_del mutex for the function
hdm_enqueue().

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-15 20:36:47 +02:00
Wolfram Sang
ca47d8f3ff staging: most: hdm-usb: hdm_usb: don't print error when allocating urb fails
kmalloc will print enough information in case of failure.

Signed-off-by: Wolfram Sang <wsa-dev@sang-engineering.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-15 15:56:33 +02:00
Amitoj Kaur Chawla
720f7a7850 staging: most: hdm-usb: Remove invalid reference error
commit e3479f77("staging: most: hdm-usb: Remove create_workqueue()")
cancel_work_sync(&anchor->clear_work_obj) is introduced after freeing
`anchor` causing a invalid reference error. This patch removes this
error by shifting the call to cancel_work_sync before freeing
`anchor`.

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-11 22:09:09 -08:00
Sandhya Bankar
afd14cef01 Staging: most: Use usb_endpoint_dir_in(endpoint) instead of (endpoint->bEndpointAddress & USB_DIR_IN).
Use usb_endpoint_dir_in(endpoint) instead of (endpoint->bEndpointAddress & USB_DIR_IN) to check if the endpoint has IN direction.
This correction is based on following semantic patch,

@@
struct usb_endpoint_descriptor *endpoint;
expression E;
@@

(
- endpoint->bEndpointAddress & USB_DIR_IN
+ usb_endpoint_dir_in(endpoint)
|
- endpoint->bEndpointAddress == USB_DIR_IN
+ usb_endpoint_dir_in(endpoint)
|
- (endpoint->bEndpointAddress & E) == USB_DIR_IN
+ usb_endpoint_dir_in(endpoint)
)

Signed-off-by: Sandhya Bankar <bankarsandhya512@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-10 19:26:05 -08:00
Bhaktipriya Shridhar
dce57aef61 staging: most: hdm-usb: Use macro DIV_ROUND_UP
The macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /(d)).
It clarifies the divisor calculations. This occurence was detected using the
coccinelle script:
@@
expression e1;
expression e2;
@@
(
- ((e1) + e2 - 1) / (e2)
+ DIV_ROUND_UP(e1,e2)
|
- ((e1) + (e2 - 1))/ (e2)
+ DIV_ROUND_UP(e1,e2)
)

The macro CEILING was dropped altogether and has been replaced with
DIV_ROUND_UP.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-25 22:35:10 -08:00
Amitoj Kaur Chawla
e3479f774e staging: most: hdm-usb: Remove create_workqueue()
With concurrency managed workqueues, use of dedicated workqueues can
be replaced by using system_wq. Drop schedule_usb_work by using
system_wq.

Since there is only one work item per buf_anchor and most_dev and they
do not need to be ordered, increase of concurrency by switching to
system_wq should not break anything.

Both work items are sync canceled before the driver can be
unregistered, to ensure no work item is pending or executing on any
CPU by the time exit path is in flight.

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-20 15:02:06 -08:00
Muhammad Falak R Wani
bff1d83d78 staging: most: hdm-usb: Use setup_timer
Use the timer API function setup_timer instead of init_timer, removing
the structure field assignments.

<smpl>

@timer@
expression e1,e2,e3,fn_ptr;
@@
-init_timer(&e1);
+setup_timer(&e1, fn_ptr, e2);
... when != fn_ptr = e3
-e1.function = fn_ptr;
-e1.data = e2;

</smpl>

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-24 19:09:03 -07:00
Christian Gromm
f96d48aaa9 staging: most: remove comparison to NULL
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-24 19:08:20 -07:00
Christian Gromm
9cbe5aa65d staging: most: use blank line after declarations
This patch fixes style violation regarding blank lines after
function/struct/union/enum declarations.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-24 19:08:16 -07:00
Christian Gromm
9deba73de5 staging: most: use braces on all arms of statement
This patch fixes style issues regarding braces on all arms of a statement.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-24 19:08:16 -07:00
Christian Gromm
9ac23b344e staging: most: remove multiple blank lines
This patch removes the usage of multiple blank lines from driver modules.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-24 19:08:16 -07:00
Christian Gromm
ba170ee2b9 staging: most: make hdm-usb follow the coding style
This patch fixes a couple of issues of the hdm-usb module found by
checkpatch.pl.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-16 23:09:41 -07:00
Masanari Iida
9f17591fa7 Staging: most: Fix typo in staging/most
This patch fix spelling typo found in most

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-12 20:35:21 -07:00
Christian Gromm
c81c9c3e0f staging: most: consolidate code
The function drci_rd_reg() always delivers little endian representation of
the 16-bit DCI register. The value returned by this function must always be
carefully converted from __le16 to u16 type. This patch moves all those
conversions to the function itself.

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-09-29 03:18:50 +02:00
Christian Gromm
2637022887 staging: most: prevent DMA on stack
This patch is needed to avoid having DMA on the stack.

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-09-29 03:18:50 +02:00
Christian Gromm
cc8d993513 staging: most: simplify code
This patch simply rearranges code for better readability.

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-09-29 03:18:50 +02:00
Christian Gromm
1ea7e502c4 staging: most: fix MAC address representation
This patch fixes the representation of the MAC address within the HDM USB
module.

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-09-29 03:18:50 +02:00
Christian Gromm
f1b9a84382 staging: most: remove macro cpu_to_le16
This patch removes the wrongly used macros cpu_to_le16

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-09-29 03:18:50 +02:00
Christian Gromm
d747e8ec1c staging: most: fix buffer synchronization request
Revision D of OS81118 network interface controller have the internal
buffer synchronization mechanism changed. This patch adapts the driver
to this.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-09-29 03:18:49 +02:00
Christian Gromm
a2cfae06ac staging: most: remove dead code
The case where the channel type is neither synchronous nor isochronous is
already covered by a previous condition.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-09-29 03:18:49 +02:00
Christian Gromm
d6f7737d5a staging: most: remove unnecessary field initialization
Since conf->extra_len has already been reset in most_start_channel() when
function hdm_configure_channel() gets called, it can safely be removed
here.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-09-29 03:18:49 +02:00
Christian Gromm
9161e9311c staging: most: fix USB babble on IN pipe
This patch prevents the HDM USB from submitting an URB with a buffer size
unaligned to 512 bytes to the USB subsystem.

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-09-29 03:18:49 +02:00
Sudip Mukherjee
ec58d2a872 staging: most: style of bool comparison
BOOLEAN tests do not need any comparison to TRUE or FALSE.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-09-12 18:24:44 -07:00
Sudip Mukherjee
9153b5b128 staging: most: remove unused variable
The variable conf was only assigned the value but was never used.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-09-12 18:24:31 -07:00
Adrian Remonda
23fe15fadf Staging: most: hdm-usb/hdm_usb.c. Fix "missing static keyword" warnings
This is a patch to the most/hdm-usb/hdm_usb.c file. It
makes several local functions and structures static to prevent global
visibility.

Signed-off-by: Adrian Remonda <adrianremonda@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-08-14 17:34:42 -07:00
Christian Gromm
59ed0480b9 Staging: most: replace pr_*() functions by dev_*()
This patch replaces pr_*() functions with dev_*().

Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-07-31 16:17:20 -07:00
Christian Gromm
412c8232ed Staging: most: fix doing DMA on stack
This patch fixes error "doing DMA on the stack" by using kzalloc
for buffer allocation.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-07-31 16:17:20 -07:00
Christian Gromm
a4198cdf0c Staging: most: add MOST driver's hdm-usb module
This patch adds the hdm-usb module of the MOST driver to the kernel's
driver staging area. This module is part of the MOST driver and handles
the USB interface of the MOST network interface controller.

This patch is needed in order to use the USB peripheral interface of the
network interface controller.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-07-24 13:50:43 -07:00