Commit Graph

76 Commits

Author SHA1 Message Date
Waldemar Rymarkiewicz
9e2d493e74 NFC: pn533: Introduce ops for frame logic
Encapsulate whole frame logic (tx/rx frame structure and size) inside
the ops structure to make the core driver generic for devices which
handle frames in non standard menner (different then pn533 spec say).

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:46 +01:00
Waldemar Rymarkiewicz
16f7541914 NFC: pn533: Remove unused dev->wq_in_frame
Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:46 +01:00
Waldemar Rymarkiewicz
0c33d2626d NFC: pn533: Cleanup pn533_cmd_complete_t
'params' arg in pn533_cmd_complete_t definition has been deprecated and
currently is not in use (resp skb is pass in arg ptr), so remove it.

Also 'params_len' arg is used as a transfer status indicator, so simply
reword it appropriately.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:45 +01:00
Waldemar Rymarkiewicz
a5798094e9 NFC: pn533: Remove deprecated dev->out_frame buff
As it's not used anymore get rid of that buffer.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:44 +01:00
Waldemar Rymarkiewicz
e8f4053111 NFC: pn533: Use skb in __pn533_send_cmd_frame_asyn
__pn533_send_cmd_frame_async() should be frame type independent. So, don't
use pn533_frame type params and instead use skb for req and resp pointers.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:44 +01:00
Waldemar Rymarkiewicz
5b5a4437ae NFC: pn533: Don't use out_frame in pn533_send_ack
dev->out_frame buffer is much bigger for ACK frame needs. Use
local buffer instead.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:43 +01:00
Waldemar Rymarkiewicz
fcfafc7690 NFC: pn533: Cleanup debug messages
Remove debug messages which do not include valueable informations
in debug mode. Add some new ones for better tracking or reword when
if necessary.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:42 +01:00
Waldemar Rymarkiewicz
f8f991710b NFC: pn533: Fix urb->status handling
Fix text message to be more suitable for the error code and treat
ESHUTDOWN as an error not debug msg.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:41 +01:00
Waldemar Rymarkiewicz
89fb202567 NFC: pn533: Remove unused pn533_send_cmd_frame_asy
Remove obsolete send async api as it's no longer used. Remove
global dev->in_frame as well, as each packet is kept is a
seperate skb struct now, so that's not used anymore.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:41 +01:00
Waldemar Rymarkiewicz
b08e860355 NFC: pn533: Fix minor style issues
Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:40 +01:00
Waldemar Rymarkiewicz
5d467742bc NFC: pn533: Fix open parenthesis alignment
Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:39 +01:00
Waldemar Rymarkiewicz
37cf4fc6c9 NFC: pn533: Fix spacing issues
Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:39 +01:00
Waldemar Rymarkiewicz
6ca55372bf NFC: pn533: Fix quoted strings split across lines
Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:38 +01:00
Waldemar Rymarkiewicz
b5193e5da2 NFC: pn533: Remove frame logic from poll cmds
Remove frame logic from start_pool cb using the new iface
for async send.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:37 +01:00
Waldemar Rymarkiewicz
99e591be3d NFC: pn533: Dump tx and rx data in debug mode
Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:36 +01:00
Waldemar Rymarkiewicz
b1e666f503 NFC: pn533: Del frame logic from Data Exchange cmd
Remove frame logic from transceive cb using new iface
for async send.

For pn533_wq_mi_recv() use pn533_send_cmd_direct_async which
sends the cmd directly to the hardware, skipping cmd queue.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:36 +01:00
Waldemar Rymarkiewicz
13003649b1 NFC: pn533: Del frame logic from InJumForDep cmd
Remove frame logic from InJmumpForDEP command using
the new iface for async send.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:35 +01:00
Waldemar Rymarkiewicz
e487882345 NFC: pn533: Del frame logic from TgGet/SetData cmd
Remove frame logic from TgSetData and TgGetData commands
using the new iface for async send.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:51:34 +01:00
Waldemar Rymarkiewicz
cb950d9304 NFC: pn533: Remove pn533_send_cmd_frame_sync
Remove obsolate pn533_send_cmd_frame_sync() and use
previously added new iface for sync send.

The new interface require the use of individual skb for each
cmd which removes some memcpy calls and hides frame logic.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:44:30 +01:00
Waldemar Rymarkiewicz
d22b2db690 NFC: pn533: Add pn533_alloc_skb for req allocation
Allocate sk_buff for the request.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:44:30 +01:00
Waldemar Rymarkiewicz
94c5c1561d NFC: pn533: Add a new pn533_send_sync iface
It is intended to replace pn533_send_cmd_frame_sync() iface which
requires from the caller to create complete frame.

The new function constructs a complete frame itself and sends it out
in sync manner. This way frame logic is hidden from the caller.

pn533_send_cmd_sync() returns ERR_PTR in case of an error or a pointer
to valid response sk_buff otherwise. The pointer must be freed by the
caller when it's been consumed.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:44:29 +01:00
Waldemar Rymarkiewicz
15461aeb53 NFC: pn533: Add a new pn533_send_data_async iface
This iface is intended to be used with DEP transfers. It differs
from pn533_send_cmd_async() in the way the response skb is allocated.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:44:28 +01:00
Waldemar Rymarkiewicz
aada17ac70 NFC: pn533: Add a new pn533_send_cmd_async iface
This is intendend to replace pn533_send_cmd_frame_async() which
requires from the caller to create a complete frame.

The new function constructs a frame and sends it out which hides the
frame logic and avoid code duplication.

The caller has to allocate skb and put its payload there, and finally
provide the skb together with a complete cb to pn533_send_cmd_async().

Response skb is allocated by the core part and pass to the caller cb.
Next, the caller has to free it when is not needed anymore or pass it
up to the stack.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:44:28 +01:00
Waldemar Rymarkiewicz
d94ea4f545 NFC: pn533: Remove pointless flags param
__pn533_send_cmd_frame_async() is called when lock is held so GFP_KERNEL
flag will be always used. Thus, having extra param does not optimise the
code.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:44:27 +01:00
Waldemar Rymarkiewicz
b1bb290ac2 NFC: pn533: Add frame header length define
PN533_CMD_DATAEXCH_HEAD_LEN includes a frame header length which is not
seen at a glance. It can be missleading, so split it and define the
frame header length explicitly.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:44:26 +01:00
Waldemar Rymarkiewicz
a449ae1cbd NFC: pn533: Remove unused definitions
Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:44:25 +01:00
Waldemar Rymarkiewicz
8d25ca7997 NFC: pn533: Remove in/out_maxlen as it is not used
in_maxlen and out_maxlen was replaced with PN533_NORMAL_FRAME_MAX_LEN

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-10 00:44:25 +01:00
David S. Miller
24bc518a68 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Conflicts:
	drivers/net/wireless/iwlwifi/pcie/tx.c

Minor iwlwifi conflict in TX queue disabling between 'net', which
removed a bogus warning, and 'net-next' which added some status
register poking code.

Signed-off-by: David S. Miller <davem@davemloft.net>
2012-11-25 12:49:17 -05:00
Thierry Escande
5b412fd11c NFC: Fix pn533 target mode memory leak
In target mode, sent sk_buff were not freed in pn533_tm_send_complete

Signed-off-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-11-20 00:09:26 +01:00
Waldemar Rymarkiewicz
70418e6efc NFC: pn533: Fix mem leak in pn533_in_dep_link_up
cmd is allocated in pn533_dep_link_up and passed as an arg to
pn533_send_cmd_frame_async together with a complete cb.

arg is passed to the cb and must be kfreed there.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-11-20 00:09:26 +01:00
Szymon Janc
770f750bc2 NFC: pn533: Fix use after free
cmd was freed in pn533_dep_link_up regardless of
pn533_send_cmd_frame_async return code. Cmd is passed as argument to
pn533_in_dep_link_up_complete callback and should be freed there.

Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-11-20 00:09:26 +01:00
Szymon Janc
60ad07ab6b NFC: pn533: Fix missing lock while operating on commands list
In pn533_wq_cmd command was removed from list without cmd_lock held
(race with pn533_send_cmd_frame_async) which could lead to list
corruption. Delete command from list before releasing lock.

Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-11-20 00:09:25 +01:00
Waldemar Rymarkiewicz
ab34a1813c NFC: pn533: Remove unused arg parameter
Get rid of unused arg param in pn533_init_target_complete and
in pn533_start_poll_complete.

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-10-26 18:26:51 +02:00
Waldemar Rymarkiewicz
82dec34df6 NFC: pn533: Fix in/out frame buffer allocation
Max frame size should be 264 bytes as per spec and not limited to
endpoint MaxPacketSize which is 64 in my case (acr122 reader).

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-10-26 18:26:51 +02:00
Szymon Janc
ee5e8d812c NFC: Fix missing mutex unlock in pn533_send_cmd_frame_async
If command allocation failed cmd_lock was not released and deadlock
would occur.

Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-09-27 10:47:48 +02:00
Tejun Heo
58637c9b65 NFC: Don't use WQ_MEM_RECLAIM for pn533
NFC driver doesn't sit in memory reclaim path and has no reason to use
WQ_MEM_RECLAIM.  Drop WQ_MEM_RECLAIM from pn533->wq and use
alloc_ordered_workqueue() instead of WQ_UNBOUND w/ max_active == 1.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-09-25 00:17:24 +02:00
Samuel Ortiz
5d50b364e6 NFC: Queue pn533 commands
Instead of returning EBUSY when getting a command while another one is
running, we queue them. Upon completion of the pending command, the next
one is processed.
Besides the fact that it simplifies the pn533 locking scheme, it also
comes with the nice side effect of fixing the following warning:

[   82.274297] =====================================
[   82.274297] [ BUG: bad unlock balance detected! ]
[   82.274298] 3.5.0-rc1+ #1 Not tainted
[   82.274299] -------------------------------------
[   82.274300] kworker/u:1/16 is trying to release lock (&dev->cmd_lock) at:
[   82.274305] [<ffffffff8144f246>] mutex_unlock+0x9/0xb
[   82.274305] but there are no more locks to release!
[   82.274306]
[   82.274306] other info that might help us debug this:
[   82.274306] 2 locks held by kworker/u:1/16:
[   82.274311]  #0:  (pn533){.+.+..}, at: [<ffffffff8103a67d>]
+process_one_work+0x145/0x2e2
[   82.274314]  #1:  ((&dev->cmd_work)){+.+...}, at: [<ffffffff8103a67d>]
+process_one_work+0x145/0x2e2
[   82.274314]
[   82.274314] stack backtrace:
[   82.274315] Pid: 16, comm: kworker/u:1 Not tainted 3.5.0-rc1+ #1
[   82.274315] Call Trace:
[   82.274317]  [<ffffffff8144f246>] ? mutex_unlock+0x9/0xb
[   82.274321]  [<ffffffff81059841>] print_unlock_inbalance_bug+0xda/0xe4
[   82.274323]  [<ffffffff8105c74c>] lock_release_non_nested+0xb2/0x232
[   82.274325]  [<ffffffff8105a61e>] ? mark_held_locks+0x6d/0x95
[   82.274326]  [<ffffffff8144f246>] ? mutex_unlock+0x9/0xb
[   82.274328]  [<ffffffff81451105>] ? _raw_spin_unlock_irqrestore+0x40/0x5c
[   82.274329]  [<ffffffff8144f246>] ? mutex_unlock+0x9/0xb
[   82.274330]  [<ffffffff8105ca42>] lock_release+0x176/0x1ac
[   82.274333]  [<ffffffff8123de14>] ? pn533_send_complete+0xa8/0xa8
[   82.274334]  [<ffffffff8144f1d6>] __mutex_unlock_slowpath+0xb0/0x117
[   82.274336]  [<ffffffff8144f246>] mutex_unlock+0x9/0xb
[   82.274337]  [<ffffffff8123de65>] pn533_wq_cmd_complete+0x51/0x55
[   82.274338]  [<ffffffff8103a6db>] process_one_work+0x1a3/0x2e2
[   82.274340]  [<ffffffff8103a67d>] ? process_one_work+0x145/0x2e2
[   82.274341]  [<ffffffff8103b119>] worker_thread+0xcf/0x153
[   82.274343]  [<ffffffff8103b04a>] ? manage_workers.isra.22+0x16b/0x16b
[   82.274344]  [<ffffffff8103b04a>] ? manage_workers.isra.22+0x16b/0x16b
[   82.274346]  [<ffffffff8103eb11>] kthread+0x95/0x9d
[   82.274348]  [<ffffffff81452ef4>] kernel_thread_helper+0x4/0x10
[   82.274351]  [<ffffffff81046561>] ? finish_task_switch+0x45/0xc3
[   82.274352]  [<ffffffff814514f0>] ? retint_restore_args+0x13/0x13
[   82.274353]  [<ffffffff8103ea7c>] ? __init_kthread_worker+0x55/0x55
[   82.274354]  [<ffffffff81452ef0>] ? gs_change+0x13/0x13

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-09-25 00:17:23 +02:00
Samuel Ortiz
01d719a228 NFC: Add ISO 14443 type B protocol
Some devices (e.g. Sony's PaSoRi) can not do type B polling, so we have
to make a distinction between ISO14443 type A and B poll modes.

Cc: Eric Lapuyade <eric.lapuyade@intel.com>
Cc: Ilan Elias <ilane@ti.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 16:42:24 -04:00
Samuel Ortiz
a1fbbf1817 NFC: Use communicate thru only for PaSoRi when trying to read Felica tags
Otherwise DATA_EXCHANGE seems to be just fine.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 16:42:23 -04:00
Samuel Ortiz
5c7b053129 NFC: Add initial Sony RC-S360 support to pn533
Sony RC-S360 is also known as the Sony PaSoRi contactless reader.
Only type 2, 3 and 4 tag reading is supported at the moment.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 16:42:22 -04:00
Samuel Ortiz
51ad304cc8 NFC: Monitor pn533 target mode
When receiving a DEP link down event, we should cancel all pending URBs
if we're activated as a target or if we're an initiator.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-06-04 21:34:34 +02:00
Samuel Ortiz
0201ed0349 NFC: Convert pn533 from semaphore to mutex
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-06-04 21:34:34 +02:00
Samuel Ortiz
41a8ec496d NFC: Set the proper baud rate when trying to activate pn533 targets
We get the right baud rate from the last polled modulation.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-06-04 21:34:33 +02:00
Samuel Ortiz
6fbbdc16be NFC: Implement pn533 polling loop
After going through all the modulations, the pn533 driver spends 2
seconds listening for targets.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-06-04 21:34:33 +02:00
Samuel Ortiz
51d9e803b9 NFC: Add type A and type F parameters for pn533 target mode
Without those settings several devices will not activate pn533 as a target.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-06-04 21:34:32 +02:00
Samuel Ortiz
d7f3345d3a NFC: Add passive initiator data for pn533
When trying to enable a DEP link as a passive initiator, pn533 needs to
provide the polling request command payload.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-06-04 21:34:32 +02:00
Samuel Ortiz
34a85bfcfb NFC: Configure pn533 RF timings
Those define the ATR_RES response timeout after which the pn533 considers the
target to be mute.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-06-04 21:34:32 +02:00
Samuel Ortiz
9f2f8ba172 NFC: Unregister device if pn533 initial configuration fails
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-06-04 21:34:32 +02:00
Samuel Ortiz
7c2a04a933 NFC: Reset poll mod list when stopping pn533 poll
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-06-04 21:34:31 +02:00
Samuel Ortiz
dadb06f270 NFC: Implement the pn533 target mode Tx op
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-06-04 21:34:31 +02:00