Age | Commit message (Collapse) | Author | Files | Lines |
|
return"
scripts/checkpatch.pl -f drivers/nfc/st21nfca.c is throwing the following:
WARNING: else is not generally useful after a break or return
#866: FILE: drivers/nfc/st21nfca/st21nfca.c:866:
+ return 0;
+ } else {
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Align every macros on the same column.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Clean up st21nfca.h macros and move the one only used in st21nfca.c.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
When retrying to read the NCI header, the CLF might not be
available the first time. However it may not be successful
the second time and this may cause an error in the function.
Enforce the retrieve data length is as expected.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
gb_len in st21nfca_tm_send_atr_res can be negative. Not checking for
that could lead to a potential kernel oops.
We now make sure that atr_req->length > sizeof(struct st21nfca_atr_req)
to avoid such situation.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
skb is already verified to be not null from the below hci layer.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
On top of st21nfca_im_recv_atr_res_cb and st21nfca_im_recv_dep_res_cb a
condition if (err != 0) is present. Because err is never modified in the
code err will always be 0 at the end.
The condition can be removed.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
nfcid3 is based on sensf_res value. target->sensf is never NULL
as it is a table.
Check the sensf_res_len instead to make sure sensf_res is set or not.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Remove a useless new line in nfc_err call.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
If dev_num >= ST21NFCA_NUM_DEVICES, the driver was returning an incorrect
success return code.
Once dev_num is set, it was not stated as busy.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
In case of an error during driver probe, info pointer was freed with kfree.
No need to free anything when using devm_kzalloc.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Remove a uselss new line in nfc_err call.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
The .owner member of struct device_driver is assigned THIS_MODULE twice.
Introduced by:
commit 35630df68d6030daf12dde12ed07bbe26324e6ac
NFC: st21nfcb: Add driver for STMicroelectronics ST21NFCB NFC chip
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Simplify the code a bit as mention by Axel Lin in a previous patch for
st21nfca.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
where possible"
Fixing scripts/checkpatch.pl error "code indent should use tabs where possible" in:
- i2c.c in st21nfcb_nci_irq_thread_fn function.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
after declarations"
Fixing scripts/checkpatch.pl warning "Missing a blank line after declarations" in:
- st21nfca.c:
- check_presence after fwi variable declaration.
- get_frame_size after len variable declaration.
- st21nfca_hci_i2c_repack after "i, j, r, size" variable declaration.
- st21nfca_dep.c st21nfca_tx_work after skb pointer declaration.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Fixing "sparse: cast to restricted __be32" message when building with
make C=1 CF=-D__CHECK_ENDIAN__
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
This simplifies the code a bit.
Acked-by: Christophe RICARD <christophe-h.ricard@st.com>
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
The .owner member of struct device_driver is assigned THIS_MODULE twice.
Introduced by:
commit c44cb2edd01ca31471d9385f0895891b006ab904
("NFC: dts: st21nfca: Add device-tree (Open Firmware) support to st21nfca")
Acked-by: Christophe RICARD <christophe-h.ricard@st.com>
Signed-off-by: Emil Goode <emilgoode@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
In the previous makefile 2 modules were generated for CONFIG_NFC_ST21NFCA
(st21nfca.ko and st21nfca_dep.ko). Merge both of them into st21nfca_hci.ko
and fix a potential depmod dependency cycle, similar to the one we saw
on st21nfcb:
depmod: WARNING: found 6 modules in dependency cycles!
depmod: WARNING:
/lib/modules/3.17.0-rc3-00002-g7505cea/kernel/drivers/nfc/st21nfcb/st21nfcb.ko
in dependency cycle!
depmod: WARNING:
/lib/modules/3.17.0-rc3-00002-g7505cea/kernel/drivers/nfc/st21nfcb/ndlc.ko
in dependency cycle!
depmod: WARNING:
/lib/modules/3.17.0-rc3-00002-g7505cea/kernel/net/rfkill/rfkill.ko in
dependency cycle!
depmod: WARNING:
/lib/modules/3.17.0-rc3-00002-g7505cea/kernel/net/nfc/nfc.ko in
dependency cycle!
depmod: WARNING:
/lib/modules/3.17.0-rc3-00002-g7505cea/kernel/net/nfc/nci/nci.ko in
dependency cycle!
depmod: WARNING:
/lib/modules/3.17.0-rc3-00002-g7505cea/kernel/lib/crc-ccitt.ko in
dependency cycle!
./scripts/depmod.sh: line 57: 23387 Segmentation fault (core
dumped) "$DEPMOD" "$@" "$KERNELRELEASE" $SYMBOL_PREFIX
make: *** [_modinst_post] Error 139
Reported-by: Daniel Wagner <wagi@monom.org>
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
This fix issue reported here:
https://lists.01.org/pipermail/linux-nfc/2014-September/002871.html
depmod: WARNING: found 6 modules in dependency cycles!
depmod: WARNING:
/lib/modules/3.17.0-rc3-00002-g7505cea/kernel/drivers/nfc/st21nfcb/st21nfcb.ko
in dependency cycle!
depmod: WARNING:
/lib/modules/3.17.0-rc3-00002-g7505cea/kernel/drivers/nfc/st21nfcb/ndlc.ko
in dependency cycle!
depmod: WARNING:
/lib/modules/3.17.0-rc3-00002-g7505cea/kernel/net/rfkill/rfkill.ko in
dependency cycle!
depmod: WARNING:
/lib/modules/3.17.0-rc3-00002-g7505cea/kernel/net/nfc/nfc.ko in
dependency cycle!
depmod: WARNING:
/lib/modules/3.17.0-rc3-00002-g7505cea/kernel/net/nfc/nci/nci.ko in
dependency cycle!
depmod: WARNING:
/lib/modules/3.17.0-rc3-00002-g7505cea/kernel/lib/crc-ccitt.ko in
dependency cycle!
./scripts/depmod.sh: line 57: 23387 Segmentation fault (core
dumped) "$DEPMOD" "$@" "$KERNELRELEASE" $SYMBOL_PREFIX
make: *** [_modinst_post] Error 139
Reported-by: Daniel Wagner <wagi@monom.org>
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Add the ability to detect the mode (i.e., RF technology)
used by the initiator. The RF technology that was
detected can be retrieved by calling the 'tg_get_rf_tech'
driver hook.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Add target mode support to the trf7970a
NFC driver. This effectively enables full
Peer-to-Peer support.
To handle changing framing between sending
a response frame and receiving the subsequent
request frame, most of the framing changes
take effect in the interrupt handler and not
in trf7970a_tg_config_framing().
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
The digital layer can try to send a command with a
timeout value of zero (e.g., digital_tg_send_psl_res().
The zero value is used as a flag to indicate that
the driver should not expect a response. To handle
this, the driver sets an internal timer because it
should still get an interrupt with the TX bit set
in the IRQ Status Register. When it gets that
interrupt, it returns a return value of '0'.
If it doesn't get the interrupt before timing out,
it returns ETIMEDOUT as usual.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Some paths leave a timer still running when
trf7970a_send_err_upstream() is called. This
can cause a timeout to occur in a subsequent
transaction making it fail. Fix this by ensuring
there is no timer running before sending an error
upstream.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Currently, the trf7970a driver blindly turns on its
RF field when configuring its framing. This isn't
a good idea if there is already a device generating
an RF field. Instead, check if there is already an
RF field present before turning on this device's RF
field and, if there is, return EBUSY.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
When trf7970a_init() initializes the trf7970a it
implicitly turns off the RF transmitter. Track
this by clearing the TRF7970A_CHIP_STATUS_RF_ON
bit in the cached trf->chip_status_ctrl.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Don't try to turn off of RF transmitter is its
already off.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Rename trf7970a_config_rf_tech() and trf7970a_config_framing()
to trf7970a_in_config_rf_tech() and trf7970a_in_config_framing(),
respectively to avoid confusion when target support is added.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
The trf7970a should be given at least 1 ms to
completely initialize after the 'Software Init'
and 'Idle' commands have been issued.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Add system suspend/resume support by gracefully
shutting things down when suspending and bringing
the device back to full power when resuming.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Encapsulate the code to start up and gracefully
shutdown the driver and trf7970a device. Doing
this makes adding system suspend/resume support
easier and the resulting code cleaner.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
The current code assumes that CONFIG_PM_RUNTIME
is always defined so it won't power up the trf7970a
when it isn't enabled. Fix this by moving the power
up/down code from the pm_runtime_resume/suspend
routines into their own routines and calling the
power up function from the probe routine. This
ensures the device is powered up even when
CONFIG_PM_RUNTIME is not defined.
In order to not power on/off a device that is
already powered on/off, create a new state to
indicate that the power is off (TRF7970A_ST_PWR_OFF).
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Rename the 'TRF7970A_ST_OFF' state to 'TRF7970A_ST_RF_OFF'
to make it clear that this state means that the RF is
off and not the entire device.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
trf7970a_switch_rf_on() is currently a void function
but turning on the RF could fail so it should return
a return code. That return code should also be
propagated back to the entity that initiated the
action.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Depending on the interrupt status value given by the
trf7970a, the driver may not know when a receive operation
is complete. To handle this, the driver waits for a period
of time in case the trf7970a interrupts it again indicating
there are more RX data in the FIFO. It is possible that the
timeout will occur when there are RX data in the FIFO but
before the trf7970a has generated an interrupt to tell the
driver about it. Handle this by calling trf7970a_drain_fifo()
(instead of trf7970a_send_upstream() which just passes up the
data gathered to far) to check if there are more data in the
FIFO. If so, gather that data into the receive buffer. If
not, pass the data collected so far upstream as before.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Receiving an interrupt whose Interrupt Status Register
value has only the SRX bit set is supposed to mean that
all of the data from the tag has been received. That
turns out to not be true so we need to reread the FIFO
Status Register to tell if there are any new bytes in
the FIFO. If there are, continue receiving them; if
there aren't, assume that the receive is complete and
pass the data up.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Commit 4dd836e46c3d ("NFC: trf7970a: Reset FIFO when
'End of TX' Interrupt Occurs") fixes the issue that
it was meant to fix but adds the unfortunate side
effect of causing the driver to report an error
when the TX low-watermark level is passed during
transmits. This can be fixed by checking whether
the IRQ status indicates that the low-watermark
has been passed when transmitting. If it has been
passed and the FIFO is empty, then its safe to reset
the FIFO. Otherwise, silently continue since another
TX interrupt will be generated and the FIFO will be
reset then.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Handle the case where trf7970a_fill_fifo() is
called but there is no room in the FIFO for
more TX data. When this happens, wait for
another interrupt indicating that there is
now space (and set a timer in case that
interrupt never occurs).
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
When refilling the FIFO with more TX data (using a new
SPI transaction), the driver must prefix the TX data with
a write to the FIFO I/O Register. This tells the trf7970a
that the following data is destined for the FIFO so it can
be transmitted.
To accomplish this, the driver cannot simply push the
prefix data just before the next set of TX data that
is to be transmitted because that will overwrite part
of the TX data provided by the digital layer. Instead,
separate the prefix data and the TX data when calling
trf7970a_transmit(). trf7970a_transmit() can then send
the prefix and TX data from different memory locations
with one spi_sync() operation. This also means that
the driver doesn't require any skb "tx_headroom" as
provided by the digital layer (see
nfc_digital_allocate_device() and digital_skb_alloc()).
Also ensure that the prefix is of type 'u8' and not
'char'.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
It is no longer necessary to reset the FIFO and
read the 'RSSI Levels and Oscillator Status Register'
so remove that code.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
The trf7970a occasionally generates spurious interrupts
which can confuse the driver. To help alleviate this,
clear any interrupts by reading the 'IRQ Status Register'
before starting a new transaction.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Some of the timeout values used in the driver
are not long enough to handle worst-case scenarios
so they need to be recalculated.
The time to wait for the FIFO to drain past the
low-watermark is now 20 ms because it can take
around 14.35 ms to send 95 bytes (127 bytes in
full FIFO minus 32 bytes where the low-watermark
interrupt will fire). 95 bytes will take around
14.35 ms at 6.62 kbps (the lowest supported bit
rate used by ISO/IEC 15693) so 20 ms should be a
safe value.
The time to wait before issuing an EOF to complete
an ISO/IEC 15693 write or lock command is 40 ms--
20 ms to drain the FIFO and another 20 ms to ensure
the wait is long enough before sending an EOF.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
When turning on the RF field, the driver must wait
an RF-technology-specific amount of time (known as
the guard time) before modulating the field.
Currently, the driver waits 5 ms but that is too
short for NFCF and too long for ISO/IEC 15693.
Fix this by determining the guard time when the
RF technology is set and delaying that amount
of time when turning on the RF field.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Currently, the trf7970a is reset & initialized only
when the pm_runtime resume hook is called. Instead,
initialize it every time the RF is enabled to ensure
that the trf7970a is quiesced and in a known state
before being set up for another RF technology.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Currently, support for providing the external
SYS_CLK signal on pin 27 is not supported so
turn it off by writing to the 'Modulator and
SYS_CLK Control' register immediately after
reset.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
There is no need to sleep for 1-2 ms before
transmitting a new command.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
Despite what the manual says, the FIFO size
on the trf7970a is really 127 bytes so make
the code respect that.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
The Overflow bit in the 'FIFO Status Register' has
proven to be untrustworthy so ignore it.
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|
|
To more efficiently handle long continuous reads,
use spi_sync() instead of spi_write_then_read().
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
|