Commit Graph

7 Commits

Author SHA1 Message Date
Himangi Saraogi 2a211f320e thunderbolt: Use kcalloc
The advantage of kcalloc is, that will prevent integer overflows
which could result from the multiplication of number of elements
and size and it is also a bit nicer to read.

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Acked-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-13 13:16:50 -07:00
Himangi Saraogi fc51768ba2 thunderbolt: Correct the size argument to devm_kzalloc
nhi->rx_rings does not have type as struct tb_ring *, as it is a
double pointer so the elements of the array should have pointer type,
not structure type.

The Coccinelle semantic patch that makes this change is as follows:

// <smpl>
@disable sizeof_type_expr@
type T;
T **x;
@@

  x =
  <+...sizeof(
- T
+ *x
  )...+>
// </smpl>

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Cc: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-07 18:56:20 -07:00
Sachin Kamat 620863f71c thunderbolt: Staticize nhi_ids
'nhi_ids' is local to this file.

Signed-off-by: Sachin Kamat <sachin.kamat@samsung.com>
Acked-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-06-20 09:44:42 -07:00
Sachin Kamat f19b72c6e8 thunderbolt: Use NULL instead of 0 in nhi.c
'descriptors' is a pointer. Use NULL isntead of 0.

Signed-off-by: Sachin Kamat <sachin.kamat@samsung.com>
Acked-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-06-20 09:44:42 -07:00
Andreas Noever 23dd5bb49d thunderbolt: Add suspend/hibernate support
We use _noirq since we have to restore the pci tunnels before the pci
core wakes the tunneled devices.

Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-06-19 14:13:00 -07:00
Andreas Noever d6cc51cd1a thunderbolt: Setup control channel
Add struct tb which will contain our view of the thunderbolt bus.  For
now it just contains a pointer to the control channel and a workqueue
for hotplug events.

Add thunderbolt_alloc_and_start() and thunderbolt_shutdown_and_free()
which are responsible for setup and teardown of struct tb.

Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-06-19 14:07:07 -07:00
Andreas Noever 1660315366 thunderbolt: Add initial cactus ridge NHI support
Thunderbolt hotplug is supposed to be handled by the firmware. But Apple
decided to implement thunderbolt at the operating system level. The
firmare only initializes thunderbolt devices that are present at boot
time. This driver enables hotplug of thunderbolt of non-chained
thunderbolt devices on Apple systems with a cactus ridge controller.

This first patch adds the Kconfig file as well the parts of the driver
which talk directly to the hardware (that is pci device setup, interrupt
handling and RX/TX ring management).

Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-06-19 14:04:52 -07:00