summaryrefslogtreecommitdiff
path: root/drivers/nfc/nfcmrvl/main.c
AgeCommit message (Collapse)Author
2019-08-05NFC: nfcmrvl: fix gpio-handling regressionJohan Hovold
Fix two reset-gpio sanity checks which were never converted to use gpio_is_valid(), and make sure to use -EINVAL to indicate a missing reset line also for the UART-driver module parameter and for the USB driver. This specifically prevents the UART and USB drivers from incidentally trying to request and use gpio 0, and also avoids triggering a WARN() in gpio_to_desc() during probe when no valid reset line has been specified. Fixes: e33a3f84f88f ("NFC: nfcmrvl: allow gpio 0 for reset signalling") Reported-by: syzbot+cf35b76f35e068a1107f@syzkaller.appspotmail.com Tested-by: syzbot+cf35b76f35e068a1107f@syzkaller.appspotmail.com Signed-off-by: Johan Hovold <johan@kernel.org>
2017-06-18NFC: nfcmrvl: allow gpio 0 for reset signallingJohan Hovold
Allow gpio 0 to be used for reset signalling, and instead use negative errnos to disable the reset functionality. Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2017-06-18NFC: nfcmrvl: fix firmware-management initialisationJohan Hovold
The nci-device was never deregistered in the event that fw-initialisation failed. Fix this by moving the firmware initialisation before device registration since the firmware work queue should be available before registering. Note that this depends on a recent fix that moved device-name initialisation back to to nci_allocate_device() as the firmware-workqueue name is now derived from the nfc-device name. Fixes: 3194c6870158 ("NFC: nfcmrvl: add firmware download support") Cc: stable <stable@vger.kernel.org> # 4.4 Cc: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2017-06-18NFC: nfcmrvl: do not use device-managed resourcesJohan Hovold
This specifically fixes resource leaks in the registration error paths. Device-managed resources is a bad fit for this driver as devices can be registered from the n_nci line discipline. Firstly, a tty may not even have a corresponding device (should it be part of a Unix98 pty) something which would lead to a NULL-pointer dereference when registering resources. Secondly, if the tty has a class device, its lifetime exceeds that of the line discipline, which means that resources would leak every time the line discipline is closed (or if registration fails). Currently, the devres interface was only being used to request a reset gpio despite the fact that it was already explicitly freed in nfcmrvl_nci_unregister_dev() (along with the private data), something which also prevented the resource leak at close. Note that the driver treats gpio number 0 as invalid despite it being perfectly valid. This will be addressed in a follow-up patch. Fixes: b2fe288eac72 ("NFC: nfcmrvl: free reset gpio") Fixes: 4a2b947f56b3 ("NFC: nfcmrvl: add chip reset management") Cc: stable <stable@vger.kernel.org> # 4.2: b2fe288eac72 Cc: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2017-06-16networking: make skb_push & __skb_push return void pointersJohannes Berg
It seems like a historic accident that these return unsigned char *, and in many places that means casts are required, more often than not. Make these functions return void * and remove all the casts across the tree, adding a (u8 *) cast only where the unsigned char pointer was used directly, all done with the following spatch: @@ expression SKB, LEN; typedef u8; identifier fn = { skb_push, __skb_push, skb_push_rcsum }; @@ - *(fn(SKB, LEN)) + *(u8 *)fn(SKB, LEN) @@ expression E, SKB, LEN; identifier fn = { skb_push, __skb_push, skb_push_rcsum }; type T; @@ - E = ((T *)(fn(SKB, LEN))) + E = fn(SKB, LEN) @@ expression SKB, LEN; identifier fn = { skb_push, __skb_push, skb_push_rcsum }; @@ - fn(SKB, LEN)[0] + *(u8 *)fn(SKB, LEN) Note that the last part there converts from push(...)[0] to the more idiomatic *(u8 *)push(...). Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2015-11-05NFC: nfcmrvl: remove unneeded CONFIG_OF switchesVincent Cuissard
Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2015-11-05NFC: nfcmrvl: free reset gpioVincent Cuissard
Reset GPIO shall be freed by the driver since the device used in devm_ calls can be still valid on unregister. If user removes the module and inserts it again, the devm_gpio_request will fail because the underlying physical device (e.g i2c) was not removed so the device management won't have freed the gpio. Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2015-10-27NFC: nfcmrvl: add spi driverVincent Cuissard
This driver adds the support of SPI-based Marvell NFC controller. Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2015-10-27NFC: nfcmrvl: add i2c driverVincent Cuissard
This driver adds the support of I2C-based Marvell NFC controller. Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2015-10-27NFC: nfcmrvl: configure head/tail room values per low level driversVincent Cuissard
Low-level drivers may need to add some data before and/or after NCI packet. Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2015-10-27NFC: nfcmrvl: add firmware download supportVincent Cuissard
Implement firmware download protocol for Marvell NFC controllers. This protocol is based on NCI frames that's why parts of its implementation use some NCI generic functions. Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2015-10-27NFC: nfcmrvl: remove unneeded version definesVincent Cuissard
Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2015-06-13NFC: nfcmrvl: set PB_BAIL_OUT at setupVincent Cuissard
PB_BAIL_OUT parameter as to be set to one. This is needed because digital protocol 1.0 is used in combination with ISO15693 protocol. Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2015-06-13NFC: nfcmrvl: Allow ISO15693 protocolVincent Cuissard
Reference Marvell NFC controller as ISO15693 capable. Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2015-06-11NFC: nfcmrvl: add platform_data and DT configurationVincent Cuissard
Declare nfcmrvl platform_data structure and few DT parameters for nfcmrvl driver. Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2015-06-11NFC: nfcmrvl: add chip reset managementVincent Cuissard
Low level driver can specify a GPIO that will be used to reset the chip. Thanks to this the driver can ensure the state of the device at init. Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2015-06-11NFC: nfcmrvl: update nci recv frame APIVincent Cuissard
Update internal nci recv frame API to use skbuff phy management to generic part of the driver. Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2015-06-11NFC: nfcmrvl: add support of HCI-based transportVincent Cuissard
In some configuration NCI packet can be encapsulated in HCI packets. This patch had the support of this. Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2015-06-11NFC: nfcmrvl: remove integration related settingsVincent Cuissard
These settings are related to a specific integration that requires the firmware to drive some GPIOs for external RF coexistency. Since this is really linked to specific hardware integration let's remove them. Signed-off-by: Vincent Cuissard <cuissard@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2015-04-07NFC: logging neateningJoe Perches
Add missing terminating newlines to nfc_info and nfc_err to avoid possible interleaving from other messages. Miscellanea: o typo fix of "unknonwn" in message o remove unnecessary OOM messages as there's a generic dump_stack() o realign arguments Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-01-09NFC: nfcmrvl: Fix possible memory leak issueAmitkumar Karwar
This patch fixes memory leaks in the error paths of nfcmrvl_nci_register_dev() routine. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-01-07NFC: nfcmrvl: Add setup handlerAmitkumar Karwar
Marvell nfc device provides support for external coexistance control. It allows Device Host to inhibit the NFCC from polling when required by asserting a GPIO pin. A second pin allows the DH to have feedback on the current NFCC state. The required configuration for this feature is done in setup handler. Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2014-01-07NFC: nfcmrvl: Initial commit for Marvell NFC driverAmitkumar Karwar
This patch adds NFC support for Marvell 8897 NFC-over-USB chipset. Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>