[PATCH v1] zd1211rw: use %*ph to print small buffer

2019-09-04 Thread Andy Shevchenko
Use %*ph format to print small buffer as hex string.

Signed-off-by: Andy Shevchenko 
---
 drivers/net/wireless/zydas/zd1211rw/zd_chip.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/zydas/zd1211rw/zd_chip.c 
b/drivers/net/wireless/zydas/zd1211rw/zd_chip.c
index 40c0a86dbfc7..0af4b1986e48 100644
--- a/drivers/net/wireless/zydas/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zydas/zd1211rw/zd_chip.c
@@ -41,8 +41,7 @@ void zd_chip_clear(struct zd_chip *chip)
 static int scnprint_mac_oui(struct zd_chip *chip, char *buffer, size_t size)
 {
u8 *addr = zd_mac_get_perm_addr(zd_chip_to_mac(chip));
-   return scnprintf(buffer, size, "%02x-%02x-%02x",
-addr[0], addr[1], addr[2]);
+   return scnprintf(buffer, size, "%3phD", addr);
 }
 
 /* Prints an identifier line, which will support debugging. */
-- 
2.23.0.rc1



[PATCH v1] brcmfmac: use %*ph to print small buffer

2019-09-04 Thread Andy Shevchenko
Use %*ph format to print small buffer as hex string.

Signed-off-by: Andy Shevchenko 
---
 .../broadcom/brcm80211/brcmfmac/cfg80211.c | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 5dcaaf65799e..dd6303f5f72e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -4222,10 +4222,8 @@ brcmf_parse_vndr_ies(const u8 *vndr_ie_buf, u32 
vndr_ie_len,
 
vndr_ies->count++;
 
-   brcmf_dbg(TRACE, "** OUI %02x %02x %02x, type 0x%02x\n",
- parsed_info->vndrie.oui[0],
- parsed_info->vndrie.oui[1],
- parsed_info->vndrie.oui[2],
+   brcmf_dbg(TRACE, "** OUI %3ph, type 0x%02x\n",
+ parsed_info->vndrie.oui,
  parsed_info->vndrie.oui_type);
 
if (vndr_ies->count >= VNDR_IE_PARSE_LIMIT)
@@ -4349,12 +4347,10 @@ s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif 
*vif, s32 pktflag,
for (i = 0; i < old_vndr_ies.count; i++) {
vndrie_info = &old_vndr_ies.ie_info[i];
 
-   brcmf_dbg(TRACE, "DEL ID : %d, Len: %d , 
OUI:%02x:%02x:%02x\n",
+   brcmf_dbg(TRACE, "DEL ID : %d, Len: %d , OUI:%3ph\n",
  vndrie_info->vndrie.id,
  vndrie_info->vndrie.len,
- vndrie_info->vndrie.oui[0],
- vndrie_info->vndrie.oui[1],
- vndrie_info->vndrie.oui[2]);
+ vndrie_info->vndrie.oui);
 
del_add_ie_buf_len = brcmf_vndr_ie(curr_ie_buf, pktflag,
   vndrie_info->ie_ptr,
@@ -4386,12 +4382,10 @@ s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif 
*vif, s32 pktflag,
remained_buf_len -= (vndrie_info->ie_len +
 VNDR_IE_VSIE_OFFSET);
 
-   brcmf_dbg(TRACE, "ADDED ID : %d, Len: %d, 
OUI:%02x:%02x:%02x\n",
+   brcmf_dbg(TRACE, "ADDED ID : %d, Len: %d, OUI:%3ph\n",
  vndrie_info->vndrie.id,
  vndrie_info->vndrie.len,
- vndrie_info->vndrie.oui[0],
- vndrie_info->vndrie.oui[1],
- vndrie_info->vndrie.oui[2]);
+ vndrie_info->vndrie.oui);
 
del_add_ie_buf_len = brcmf_vndr_ie(curr_ie_buf, pktflag,
   vndrie_info->ie_ptr,
-- 
2.23.0.rc1



[PATCH v1] hostap: use %*ph to print small buffer

2019-09-04 Thread Andy Shevchenko
Use %*ph format to print small buffer as hex string.

Signed-off-by: Andy Shevchenko 
---
 drivers/net/wireless/intersil/hostap/hostap_download.c | 6 ++
 drivers/net/wireless/intersil/hostap/hostap_plx.c  | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/intersil/hostap/hostap_download.c 
b/drivers/net/wireless/intersil/hostap/hostap_download.c
index 4507614a7c5a..8722000b6c27 100644
--- a/drivers/net/wireless/intersil/hostap/hostap_download.c
+++ b/drivers/net/wireless/intersil/hostap/hostap_download.c
@@ -407,10 +407,8 @@ static int prism2_enable_genesis(local_info_t *local, int 
hcr)
   hcr);
return 0;
} else {
-   printk(KERN_DEBUG "Readback test failed, HCR 0x%02x "
-  "write %02x %02x %02x %02x read %02x %02x %02x %02x\n",
-  hcr, initseq[0], initseq[1], initseq[2], initseq[3],
-  readbuf[0], readbuf[1], readbuf[2], readbuf[3]);
+   printk(KERN_DEBUG "Readback test failed, HCR 0x%02x write %4ph 
read %4ph\n",
+  hcr, initseq, readbuf);
return 1;
}
 }
diff --git a/drivers/net/wireless/intersil/hostap/hostap_plx.c 
b/drivers/net/wireless/intersil/hostap/hostap_plx.c
index 943070d39b1e..841cfc68ce84 100644
--- a/drivers/net/wireless/intersil/hostap/hostap_plx.c
+++ b/drivers/net/wireless/intersil/hostap/hostap_plx.c
@@ -352,8 +352,7 @@ static int prism2_plx_check_cis(void __iomem *attr_mem, int 
attr_len,
/* read CIS; it is in even offsets in the beginning of attr_mem */
for (i = 0; i < CIS_MAX_LEN; i++)
cis[i] = readb(attr_mem + 2 * i);
-   printk(KERN_DEBUG "%s: CIS: %02x %02x %02x %02x %02x %02x ...\n",
-  dev_info, cis[0], cis[1], cis[2], cis[3], cis[4], cis[5]);
+   printk(KERN_DEBUG "%s: CIS: %6ph ...\n", dev_info, cis);
 
/* set reasonable defaults for Prism2 cards just in case CIS parsing
 * fails */
-- 
2.23.0.rc1



Re: [PATCH v2 00/12] NFC: nxp-nci: clean up and support new ID

2019-05-15 Thread Andy Shevchenko
On Wed, May 15, 2019 at 10:32:36AM +0200, Sedat Dilek wrote:
> On Tue, May 14, 2019 at 7:01 PM Andy Shevchenko
>  wrote:

> So, this is enough?

Yes, please send it as a formal patch, I will chain it to my series and resend
in a bunch of v3.

> $ git diff
> diff --git a/drivers/nfc/nxp-nci/Kconfig b/drivers/nfc/nxp-nci/Kconfig
> index a28c4265354d..d85a4761e271 100644
> --- a/drivers/nfc/nxp-nci/Kconfig
> +++ b/drivers/nfc/nxp-nci/Kconfig
> @@ -2,8 +2,8 @@ config NFC_NXP_NCI
> tristate "NXP-NCI NFC driver"
> depends on NFC_NCI
> ---help---
> - Generic core driver for NXP NCI chips such as the NPC100
> - or PN7150 families.
> + Generic core driver for NXP NCI chips such as the PN547 (NPC100),
> + PN548 (NPC300) or PN7150 families.
>   This is a driver based on the NCI NFC kernel layers and
>   will thus not work with NXP libnfc library.
> 
> @@ -21,4 +21,4 @@ config NFC_NXP_NCI_I2C
> 
>   To compile this driver as a module, choose m here. The module will
>   be called nxp_nci_i2c.
> - Say Y if unsure.
> + Say N if unsure.
> 
> Shall I sent a patch for this, or do you want to that yourself?
> 
> Thanks.
> 
> - Sedat -

-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH v2 00/12] NFC: nxp-nci: clean up and support new ID

2019-05-14 Thread Andy Shevchenko
On Tue, May 14, 2019 at 04:53:10PM +0200, Sedat Dilek wrote:
> On Tue, May 14, 2019 at 3:57 PM Oleg Zhurakivskyy
>  wrote:

> What about this one?
> 
> diff --git a/drivers/nfc/nxp-nci/Kconfig b/drivers/nfc/nxp-nci/Kconfig
> index a28c4265354d..b9e6486aa8fe 100644
> --- a/drivers/nfc/nxp-nci/Kconfig
> +++ b/drivers/nfc/nxp-nci/Kconfig
> @@ -2,8 +2,8 @@ config NFC_NXP_NCI
> tristate "NXP-NCI NFC driver"
> depends on NFC_NCI
> ---help---
> - Generic core driver for NXP NCI chips such as the NPC100
> - or PN7150 families.
> + Generic core driver for NXP NCI chips such as the NPC100 (PN547),
> + NPC300 (PN548) or PN7150 families.
>   This is a driver based on the NCI NFC kernel layers and
>   will thus not work with NXP libnfc library.
> 
> @@ -19,6 +19,11 @@ config NFC_NXP_NCI_I2C
>   chips.
>   Select this if your platform is using the I2C bus.
> 
> +  Furthermore, the pin control and GPIO driver of the actual SoC or
> +  PCH is needed.
> +  For example set CONFIG_PINCTRL_SUNRISEPOINT=y to activate the
> +  Intel Sunrisepoint (PCH of Intel Skylake) pinctrl and GPIO driver.
> +

Besides some indentation problems (the help lines should be prefixed with
'TAB + 2 spaces'), this is not needed — it's obvious and usually distros
provide all of pin control drivers anyway.

For debugging one may check deferred devices via DebugFS, or use
'initcall_debug', or other facilities.

>   To compile this driver as a module, choose m here. The module will
>   be called nxp_nci_i2c.
> - Say Y if unsure.
> + Say N if unsure.


-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH v2 00/12] NFC: nxp-nci: clean up and support new ID

2019-05-14 Thread Andy Shevchenko
On Mon, May 13, 2019 at 09:48:15PM +0200, Sedat Dilek wrote:
> On Mon, May 13, 2019 at 12:44 PM Andy Shevchenko
>  wrote:

> Is it possible to have an info in dmesg log when nxp-nci_i2c kernel
> module is loaded?

We have 'initcall_debug' for such purposes.

-- 
With Best Regards,
Andy Shevchenko




Re: [linux-nfc] ThinkPad T470 and NXP PN5xx (PN547 or PN548)

2019-05-13 Thread Andy Shevchenko
On Mon, May 13, 2019 at 03:32:52PM +0200, Sedat Dilek wrote:
> BTW, which Linux Kconfig setting are minimum?
> 
> scripts/config -m NFC_NCI -m NFC_NXP_NCI -m NFC_NXP_NCI_I2C
> 
> What about?
> 
> scripts/config -m NFC_NCI_SPI -m NFC_NCI_UART -m I2C_GPIO -m SPI_GPIO
> 
> Required?
> Not needed?

I2C_GPIO and SPI_GPIO has nothing to do with all this. What indeed is needed is
the pin control of the actual Intel SoC (unfortunately I don't know what
exactly you have, so, you better to check yourself), something like
CONFIG_PINCTRL_SKYLAKE=y.

-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH v2 00/12] NFC: nxp-nci: clean up and support new ID

2019-05-13 Thread Andy Shevchenko
On Mon, May 13, 2019 at 01:43:12PM +0200, Sedat Dilek wrote:
> On Mon, May 13, 2019 at 12:44 PM Andy Shevchenko
>  wrote:

> > Sedat, would be nice if you can compile kernel with this patch series 
> > applied
> > and test on your laptop.

> I have tested Andy's v2 series on my ThinkPad T470 successfully with
> Linux v5.1.1.
> 
> Additionally, I had the NFC patch "NFC: fix attrs checks in netlink
> interface" from Andrey Konovalov (see [1]).
> 
> sdi@iniza:~/src/linux-kernel/linux$ git log --oneline v5.1.1..
> 729d291510c2 (HEAD -> 5.1.1-1-amd64-gcc8-ldbfd) Merge branch
> 'for-5.1/nfc-nxp-nci' into 5.1.1-1-amd64-gcc8-ldbfd
> f083f056830c (for-5.1/nfc-nxp-nci-v2) NFC: nxp-nci: Convert to SPDX license 
> tags
> 132b5681e074 NFC: nxp-nci: Remove 'default n' for tests
> 840b1df28cab NFC: nxp-nci: Remove unused macro pr_fmt()
> 5b55e26db0c2 NFC: nxp-nci: Drop comma in terminator lines
> 0a1edd5ce3bb NFC: nxp-nci: Drop of_match_ptr() use
> acae10451393 NFC: nxp-nci: Constify acpi_device_id
> 07648528dae3 NFC: nxp-nci: Get rid of useless label
> 38b8c38f2187 NFC: nxp-nci: Get rid of code duplication in ->probe()
> 446f5aef4522 NFC: nxp-nci: Add GPIO ACPI mapping table
> 813d4243c563 NFC: nxp-nci: Convert to use GPIO descriptor
> 1e5187ddb944 NFC: nxp-nci: Get rid of platform data
> 775a4fa8fb68 NFC: nxp-nci: Add NXP1001 to the ACPI ID table
> db79db400c5b Merge branch 'for-5.1/nfc' into 5.1.1-1-amd64-cbl-asmgoto
> e1c37435140f (for-5.1/nfc) NFC: fix attrs checks in netlink interface
> 
> With neard (daemon) and neard-tools packages from Debian/buster AMD64
> I am able to access, list and poll from my NFC (nfc0) device.
> 
> root@iniza:~# systemctl status neard.service
> ● neard.service - LSB: NFC daemon
>Loaded: loaded (/etc/init.d/neard; generated)
>Active: active (running) since Mon 2019-05-13 13:14:12 CEST; 16min ago
>  Docs: man:systemd-sysv-generator(8)
>   Process: 810 ExecStart=/etc/init.d/neard start (code=exited, 
> status=0/SUCCESS)
> Tasks: 1 (limit: 4915)
>Memory: 1.6M
>CGroup: /system.slice/neard.service
>└─885 /usr/lib/neard/neard
> 
> Mai 13 13:14:12 iniza systemd[1]: Starting LSB: NFC daemon...
> Mai 13 13:14:12 iniza neard[877]: NEAR daemon version 0.16
> Mai 13 13:14:12 iniza neard[810]: Starting NFC daemon: neard.
> Mai 13 13:14:12 iniza systemd[1]: Started LSB: NFC daemon.
> 
> root@iniza:~# nfctool --list
> nfc0:
>   Tags: [ tag0 ]
>   Devices: [ ]
>   Protocols: [ Felica MIFARE Jewel ISO-DEP NFC-DEP ]
>   Powered: Yes
>   RF Mode: Initiator
>   lto: 150
>   rw: 15
>   miux: 2047
> 
> root@iniza:~# nfctool --poll -d nfc0
> Start polling on nfc0 as initiator
> 
> Targets found for nfc0
>   Tags: [ tag1 ]
>   Devices: [ ]
> 
> Thanks to all involved people.
> 
> Please, feel free to add any credits you think are appropriate.
> 
> A big Thank you from North-West Germany.

Thank you for testing. I hope Samuel will take this soon to his tree.

> [1] https://patchwork.kernel.org/patch/10339089/

-- 
With Best Regards,
Andy Shevchenko




Re: [linux-nfc] ThinkPad T470 and NXP PN5xx (PN547 or PN548)

2019-05-13 Thread Andy Shevchenko
On Mon, May 13, 2019 at 01:20:43PM +0200, Sedat Dilek wrote:
> On Mon, May 13, 2019 at 12:57 PM Andy Shevchenko
>  wrote:
> >
> > On Mon, May 13, 2019 at 12:38:27PM +0200, Sedat Dilek wrote:
> > > On Mon, May 13, 2019 at 11:51 AM Andy Shevchenko
> > >  wrote:
> > > >
> > > > On Mon, May 13, 2019 at 11:27:07AM +0200, Sedat Dilek wrote:
> > > >
> > > > > Sorry to say, I still have not get all correlations...
> > > >
> > > > Can you provide the output of the following on running Linux system 
> > > > with latest
> > > > possible kernel you can install (I am expecting v5.1) and command line 
> > > > with
> > > > 'ignore_loglevel'?
> > > >
> > > > 1. `dmesg`
> > > > 2. `grep -H 15 /sys/bus/acpi/devices/*/status`
> > > > 3. `acpidump -o t470-tables.dat` # the file t470-tables.dat
> > > > 4. `lspci -vv -nk`
> > > >
> > > > P.S. You may use GitHub gist for this set (please, don't share 
> > > > archives) or any
> > > > other resource like pastebin.
> > > >
> > >
> > > Looks like I am unable to use Debian's gist-paste package today or
> > > need more coffee.
> > >
> > > So, I add this here.
> > >
> > > I added my kernel-config.
> >
> >
> > Thanks. I just sent a series to (hopefully) support it in the vanilla 
> > kernel.
> > Can you test it?
> >
> > P.S. I see in dmesg the pn544 tries to bind to the NXP1001. Do you have some
> > custom patches for that in your kernel? If so, please drop them.

> this looks promising!
> 
> I have attached v2 of the disired outputs.

Nothing is point of interest anymore except dmesg.
But thanks for sharing.

-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH v2 00/12] NFC: nxp-nci: clean up and support new ID

2019-05-13 Thread Andy Shevchenko
On Mon, May 13, 2019 at 02:18:03PM +0200, Sedat Dilek wrote:
> On Mon, May 13, 2019 at 12:44 PM Andy Shevchenko
>  wrote:
> >
> > It has been reported that some laptops, equipped with NXP NFC300, have
> > different ID then mentioned in the driver.
> >
> > While at it, I found that the driver has a lot of duplication and redundant
> > platform data. The rest of the series (11 out of 12 patches) is dedicated to
> > clean the driver up.
> >
> > Sedat, would be nice if you can compile kernel with this patch series 
> > applied
> > and test on your laptop.
> >
> > In v2:
> > - added new ID patch
> > - added new clean up patch
> > - Cc'ed to linux-wireless@ as well, since linux-nfc@ bounces my mails
> > - Cc'ed to the reported of the problem with T470 laptop
> >
> > Andy Shevchenko (12):
> >   NFC: nxp-nci: Add NXP1001 to the ACPI ID table
> >   NFC: nxp-nci: Get rid of platform data
> >   NFC: nxp-nci: Convert to use GPIO descriptor
> >   NFC: nxp-nci: Add GPIO ACPI mapping table
> >   NFC: nxp-nci: Get rid of code duplication in ->probe()
> >   NFC: nxp-nci: Get rid of useless label
> >   NFC: nxp-nci: Constify acpi_device_id
> >   NFC: nxp-nci: Drop of_match_ptr() use
> >   NFC: nxp-nci: Drop comma in terminator lines
> >   NFC: nxp-nci: Remove unused macro pr_fmt()
> >   NFC: nxp-nci: Remove 'default n' for tests
> >   NFC: nxp-nci: Convert to SPDX license tags
> >
> >  MAINTAINERS   |   1 -
> >  drivers/nfc/nxp-nci/Kconfig   |   1 -
> >  drivers/nfc/nxp-nci/core.c|  15 +--
> >  drivers/nfc/nxp-nci/firmware.c|  13 +--
> >  drivers/nfc/nxp-nci/i2c.c | 147 ++
> >  drivers/nfc/nxp-nci/nxp-nci.h |   1 -
> >  include/linux/platform_data/nxp-nci.h |  27 -
> >  7 files changed, 37 insertions(+), 168 deletions(-)
> >  delete mode 100644 include/linux/platform_data/nxp-nci.h
> 
> Can we have NPC300 listed in the Kconfg help text?

Sure, it's good thing to do!

Either as a separate patch or I may incorporate in the next iteration.
Samuel, what do you prefer?

-- 
With Best Regards,
Andy Shevchenko




Re: [linux-nfc] ThinkPad T470 and NXP PN5xx (PN547 or PN548)

2019-05-13 Thread Andy Shevchenko
On Mon, May 13, 2019 at 12:38:27PM +0200, Sedat Dilek wrote:
> On Mon, May 13, 2019 at 11:51 AM Andy Shevchenko
>  wrote:
> >
> > On Mon, May 13, 2019 at 11:27:07AM +0200, Sedat Dilek wrote:
> >
> > > Sorry to say, I still have not get all correlations...
> >
> > Can you provide the output of the following on running Linux system with 
> > latest
> > possible kernel you can install (I am expecting v5.1) and command line with
> > 'ignore_loglevel'?
> >
> > 1. `dmesg`
> > 2. `grep -H 15 /sys/bus/acpi/devices/*/status`
> > 3. `acpidump -o t470-tables.dat` # the file t470-tables.dat
> > 4. `lspci -vv -nk`
> >
> > P.S. You may use GitHub gist for this set (please, don't share archives) or 
> > any
> > other resource like pastebin.
> >
> 
> Looks like I am unable to use Debian's gist-paste package today or
> need more coffee.
> 
> So, I add this here.
> 
> I added my kernel-config.


Thanks. I just sent a series to (hopefully) support it in the vanilla kernel.
Can you test it?

P.S. I see in dmesg the pn544 tries to bind to the NXP1001. Do you have some
custom patches for that in your kernel? If so, please drop them.

-- 
With Best Regards,
Andy Shevchenko




[PATCH v2 10/12] NFC: nxp-nci: Remove unused macro pr_fmt()

2019-05-13 Thread Andy Shevchenko
The macro had never been used.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/nxp-nci/i2c.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index 6114787e13a3..703f4c8fa751 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -23,8 +23,6 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
 #include 
 #include 
 #include 
-- 
2.20.1



[PATCH v2 11/12] NFC: nxp-nci: Remove 'default n' for tests

2019-05-13 Thread Andy Shevchenko
It seems contributors follow the style of Kconfig entries where explicit
'default n' is present.  The default 'default' is 'n' already, thus, drop
these lines from Kconfig to make it more clear.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/nxp-nci/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/nfc/nxp-nci/Kconfig b/drivers/nfc/nxp-nci/Kconfig
index 37b40612520d..a28c4265354d 100644
--- a/drivers/nfc/nxp-nci/Kconfig
+++ b/drivers/nfc/nxp-nci/Kconfig
@@ -1,7 +1,6 @@
 config NFC_NXP_NCI
tristate "NXP-NCI NFC driver"
depends on NFC_NCI
-   default n
---help---
  Generic core driver for NXP NCI chips such as the NPC100
  or PN7150 families.
-- 
2.20.1



[PATCH v2 02/12] NFC: nxp-nci: Get rid of platform data

2019-05-13 Thread Andy Shevchenko
Legacy platform data must go away. We are on the safe side here since
there are no users of it in the kernel.

If anyone by any odd reason needs it the GPIO lookup tables and
built-in device properties at your service.

Signed-off-by: Andy Shevchenko 
---
 MAINTAINERS   |  1 -
 drivers/nfc/nxp-nci/core.c|  1 -
 drivers/nfc/nxp-nci/i2c.c |  9 +
 drivers/nfc/nxp-nci/nxp-nci.h |  1 -
 include/linux/platform_data/nxp-nci.h | 27 ---
 5 files changed, 1 insertion(+), 38 deletions(-)
 delete mode 100644 include/linux/platform_data/nxp-nci.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 7707c28628b9..faa7493933de 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11068,7 +11068,6 @@ F:  include/net/nfc/
 F: include/uapi/linux/nfc.h
 F: drivers/nfc/
 F: include/linux/platform_data/nfcmrvl.h
-F: include/linux/platform_data/nxp-nci.h
 F: Documentation/devicetree/bindings/net/nfc/
 
 NFS, SUNRPC, AND LOCKD CLIENTS
diff --git a/drivers/nfc/nxp-nci/core.c b/drivers/nfc/nxp-nci/core.c
index 2e4b004a96aa..1907b1fd57a7 100644
--- a/drivers/nfc/nxp-nci/core.c
+++ b/drivers/nfc/nxp-nci/core.c
@@ -25,7 +25,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 
diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index fec904ad624b..549e09deb92f 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -34,7 +34,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
@@ -315,7 +314,6 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
 {
struct nxp_nci_i2c_phy *phy;
-   struct nxp_nci_nfc_platform_data *pdata;
int r;
 
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
@@ -334,17 +332,12 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
phy->i2c_dev = client;
i2c_set_clientdata(client, phy);
 
-   pdata = client->dev.platform_data;
-
-   if (!pdata && client->dev.of_node) {
+   if (client->dev.of_node) {
r = nxp_nci_i2c_parse_devtree(client);
if (r < 0) {
nfc_err(&client->dev, "Failed to get DT data\n");
goto probe_exit;
}
-   } else if (pdata) {
-   phy->gpio_en = pdata->gpio_en;
-   phy->gpio_fw = pdata->gpio_fw;
} else if (ACPI_HANDLE(&client->dev)) {
r = nxp_nci_i2c_acpi_config(phy);
if (r < 0)
diff --git a/drivers/nfc/nxp-nci/nxp-nci.h b/drivers/nfc/nxp-nci/nxp-nci.h
index 20408cbff4f1..e584c92fad49 100644
--- a/drivers/nfc/nxp-nci/nxp-nci.h
+++ b/drivers/nfc/nxp-nci/nxp-nci.h
@@ -25,7 +25,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 
diff --git a/include/linux/platform_data/nxp-nci.h 
b/include/linux/platform_data/nxp-nci.h
deleted file mode 100644
index d6ed28679bb2..
--- a/include/linux/platform_data/nxp-nci.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Generic platform data for the NXP NCI NFC chips.
- *
- * Copyright (C) 2014  NXP Semiconductors  All rights reserved.
- *
- * Authors: Clément Perrochaud 
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#ifndef _NXP_NCI_H_
-#define _NXP_NCI_H_
-
-struct nxp_nci_nfc_platform_data {
-   unsigned int gpio_en;
-   unsigned int gpio_fw;
-   unsigned int irq;
-};
-
-#endif /* _NXP_NCI_H_ */
-- 
2.20.1



[PATCH v2 08/12] NFC: nxp-nci: Drop of_match_ptr() use

2019-05-13 Thread Andy Shevchenko
There is no need to guard OF device ID table with of_match_ptr().
Otherwise we would get a defined but not used data.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/nxp-nci/i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index 472bedbeb5d8..69c98f2018e3 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -353,7 +353,7 @@ static struct i2c_driver nxp_nci_i2c_driver = {
.driver = {
   .name = NXP_NCI_I2C_DRIVER_NAME,
   .acpi_match_table = ACPI_PTR(acpi_id),
-  .of_match_table = of_match_ptr(of_nxp_nci_i2c_match),
+  .of_match_table = of_nxp_nci_i2c_match,
  },
.probe = nxp_nci_i2c_probe,
.id_table = nxp_nci_i2c_id_table,
-- 
2.20.1



[PATCH v2 09/12] NFC: nxp-nci: Drop comma in terminator lines

2019-05-13 Thread Andy Shevchenko
There is no need to have a comma after terminator entry
in the arrays of IDs.

This may prevent the misguided addition behind the terminator
without compiler notice.

Drop the comma in terminator lines for good.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/nxp-nci/i2c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index 69c98f2018e3..6114787e13a3 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -336,7 +336,7 @@ MODULE_DEVICE_TABLE(i2c, nxp_nci_i2c_id_table);
 
 static const struct of_device_id of_nxp_nci_i2c_match[] = {
{ .compatible = "nxp,nxp-nci-i2c", },
-   {},
+   {}
 };
 MODULE_DEVICE_TABLE(of, of_nxp_nci_i2c_match);
 
@@ -344,7 +344,7 @@ MODULE_DEVICE_TABLE(of, of_nxp_nci_i2c_match);
 static const struct acpi_device_id acpi_id[] = {
{ "NXP1001" },
{ "NXP7471" },
-   { },
+   { }
 };
 MODULE_DEVICE_TABLE(acpi, acpi_id);
 #endif
-- 
2.20.1



[PATCH v2 06/12] NFC: nxp-nci: Get rid of useless label

2019-05-13 Thread Andy Shevchenko
Return directly in ->probe() since there no special cleaning is needed.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/nxp-nci/i2c.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index 9eeb59d1199a..6379f2198524 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -276,16 +276,13 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
 
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
nfc_err(&client->dev, "Need I2C_FUNC_I2C\n");
-   r = -ENODEV;
-   goto probe_exit;
+   return -ENODEV;
}
 
phy = devm_kzalloc(&client->dev, sizeof(struct nxp_nci_i2c_phy),
   GFP_KERNEL);
-   if (!phy) {
-   r = -ENOMEM;
-   goto probe_exit;
-   }
+   if (!phy)
+   return -ENOMEM;
 
phy->i2c_dev = client;
i2c_set_clientdata(client, phy);
@@ -309,7 +306,7 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
r = nxp_nci_probe(phy, &client->dev, &i2c_phy_ops,
  NXP_NCI_I2C_MAX_PAYLOAD, &phy->ndev);
if (r < 0)
-   goto probe_exit;
+   return r;
 
r = request_threaded_irq(client->irq, NULL,
 nxp_nci_i2c_irq_thread_fn,
@@ -318,7 +315,6 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
if (r < 0)
nfc_err(&client->dev, "Unable to register IRQ handler\n");
 
-probe_exit:
return r;
 }
 
-- 
2.20.1



[PATCH v2 05/12] NFC: nxp-nci: Get rid of code duplication in ->probe()

2019-05-13 Thread Andy Shevchenko
Since OF and ACPI case almost the same get rid of code duplication
by moving gpiod_get() calls directly to ->probe().

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/nxp-nci/i2c.c | 68 +--
 1 file changed, 15 insertions(+), 53 deletions(-)

diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index 9a65dd6cd405..9eeb59d1199a 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -267,48 +267,10 @@ static const struct acpi_gpio_mapping 
acpi_nxp_nci_gpios[] = {
{ }
 };
 
-static int nxp_nci_i2c_parse_devtree(struct i2c_client *client)
-{
-   struct nxp_nci_i2c_phy *phy = i2c_get_clientdata(client);
-
-   phy->gpiod_en = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);
-   if (IS_ERR(phy->gpiod_en)) {
-   nfc_err(&client->dev, "Failed to get EN gpio\n");
-   return PTR_ERR(phy->gpiod_en);
-   }
-
-   phy->gpiod_fw = devm_gpiod_get(&client->dev, "firmware", GPIOD_OUT_LOW);
-   if (IS_ERR(phy->gpiod_fw)) {
-   nfc_err(&client->dev, "Failed to get FW gpio\n");
-   return PTR_ERR(phy->gpiod_fw);
-   }
-
-   return 0;
-}
-
-static int nxp_nci_i2c_acpi_config(struct nxp_nci_i2c_phy *phy)
-{
-   struct i2c_client *client = phy->i2c_dev;
-   int r;
-
-   r = devm_acpi_dev_add_driver_gpios(&client->dev, acpi_nxp_nci_gpios);
-   if (r)
-   return r;
-
-   phy->gpiod_en = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);
-   phy->gpiod_fw = devm_gpiod_get(&client->dev, "firmware", GPIOD_OUT_LOW);
-
-   if (IS_ERR(phy->gpiod_en) || IS_ERR(phy->gpiod_fw)) {
-   nfc_err(&client->dev, "No GPIOs\n");
-   return -EINVAL;
-   }
-
-   return 0;
-}
-
 static int nxp_nci_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
 {
+   struct device *dev = &client->dev;
struct nxp_nci_i2c_phy *phy;
int r;
 
@@ -328,20 +290,20 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
phy->i2c_dev = client;
i2c_set_clientdata(client, phy);
 
-   if (client->dev.of_node) {
-   r = nxp_nci_i2c_parse_devtree(client);
-   if (r < 0) {
-   nfc_err(&client->dev, "Failed to get DT data\n");
-   goto probe_exit;
-   }
-   } else if (ACPI_HANDLE(&client->dev)) {
-   r = nxp_nci_i2c_acpi_config(phy);
-   if (r < 0)
-   goto probe_exit;
-   } else {
-   nfc_err(&client->dev, "No platform data\n");
-   r = -EINVAL;
-   goto probe_exit;
+   r = devm_acpi_dev_add_driver_gpios(dev, acpi_nxp_nci_gpios);
+   if (r)
+   return r;
+
+   phy->gpiod_en = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
+   if (IS_ERR(phy->gpiod_en)) {
+   nfc_err(dev, "Failed to get EN gpio\n");
+   return PTR_ERR(phy->gpiod_en);
+   }
+
+   phy->gpiod_fw = devm_gpiod_get(dev, "firmware", GPIOD_OUT_LOW);
+   if (IS_ERR(phy->gpiod_fw)) {
+   nfc_err(dev, "Failed to get FW gpio\n");
+   return PTR_ERR(phy->gpiod_fw);
}
 
r = nxp_nci_probe(phy, &client->dev, &i2c_phy_ops,
-- 
2.20.1



[PATCH v2 01/12] NFC: nxp-nci: Add NXP1001 to the ACPI ID table

2019-05-13 Thread Andy Shevchenko
It seems a lot of laptops are equipped with NXP NFC300 chip with
the ACPI ID NXP1001 as per DSDT.

Append it to the driver's ACPI ID table.

Reported-by: Sedat Dilek 
Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/nxp-nci/i2c.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index ba695e392c3b..fec904ad624b 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -407,6 +407,7 @@ MODULE_DEVICE_TABLE(of, of_nxp_nci_i2c_match);
 
 #ifdef CONFIG_ACPI
 static struct acpi_device_id acpi_id[] = {
+   { "NXP1001" },
{ "NXP7471" },
{ },
 };
-- 
2.20.1



[PATCH v2 07/12] NFC: nxp-nci: Constify acpi_device_id

2019-05-13 Thread Andy Shevchenko
The content of acpi_device_id is not supposed to change at runtime.
All functions working with acpi_device_id provided by 
work with const acpi_device_id. So mark the non-const structs as const.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/nxp-nci/i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index 6379f2198524..472bedbeb5d8 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -341,7 +341,7 @@ static const struct of_device_id of_nxp_nci_i2c_match[] = {
 MODULE_DEVICE_TABLE(of, of_nxp_nci_i2c_match);
 
 #ifdef CONFIG_ACPI
-static struct acpi_device_id acpi_id[] = {
+static const struct acpi_device_id acpi_id[] = {
{ "NXP1001" },
{ "NXP7471" },
{ },
-- 
2.20.1



[PATCH v2 12/12] NFC: nxp-nci: Convert to SPDX license tags

2019-05-13 Thread Andy Shevchenko
Replace boiler plate licenses texts with the SPDX license
identifiers in the mei nfc files header.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/nxp-nci/core.c | 13 +
 drivers/nfc/nxp-nci/firmware.c | 13 +
 drivers/nfc/nxp-nci/i2c.c  | 13 +
 3 files changed, 3 insertions(+), 36 deletions(-)

diff --git a/drivers/nfc/nxp-nci/core.c b/drivers/nfc/nxp-nci/core.c
index b0b6db81a5e8..643347cac007 100644
--- a/drivers/nfc/nxp-nci/core.c
+++ b/drivers/nfc/nxp-nci/core.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Generic driver for NXP NCI NFC chips
  *
@@ -7,18 +8,6 @@
  *
  * Derived from PN544 device driver:
  * Copyright (C) 2012  Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include 
diff --git a/drivers/nfc/nxp-nci/firmware.c b/drivers/nfc/nxp-nci/firmware.c
index e50c6f67bb39..231c93b3dc5f 100644
--- a/drivers/nfc/nxp-nci/firmware.c
+++ b/drivers/nfc/nxp-nci/firmware.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Generic driver for NXP NCI NFC chips
  *
@@ -7,18 +8,6 @@
  *
  * Derived from PN544 device driver:
  * Copyright (C) 2012  Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include 
diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index 703f4c8fa751..69ab576ef438 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * I2C link layer for the NXP NCI driver
  *
@@ -9,18 +10,6 @@
  *
  * Derived from PN544 device driver:
  * Copyright (C) 2012  Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include 
-- 
2.20.1



[PATCH v2 03/12] NFC: nxp-nci: Convert to use GPIO descriptor

2019-05-13 Thread Andy Shevchenko
Since we got rid of platform data, the driver may use
GPIO descriptor directly.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/nxp-nci/core.c |  1 -
 drivers/nfc/nxp-nci/i2c.c  | 60 ++
 2 files changed, 15 insertions(+), 46 deletions(-)

diff --git a/drivers/nfc/nxp-nci/core.c b/drivers/nfc/nxp-nci/core.c
index 1907b1fd57a7..b0b6db81a5e8 100644
--- a/drivers/nfc/nxp-nci/core.c
+++ b/drivers/nfc/nxp-nci/core.c
@@ -22,7 +22,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 
diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index 549e09deb92f..6f61368ae065 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -32,8 +32,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 
 #include 
@@ -48,8 +46,8 @@ struct nxp_nci_i2c_phy {
struct i2c_client *i2c_dev;
struct nci_dev *ndev;
 
-   unsigned int gpio_en;
-   unsigned int gpio_fw;
+   struct gpio_desc *gpiod_en;
+   struct gpio_desc *gpiod_fw;
 
int hard_fault; /*
 * < 0 if hardware error occurred (e.g. i2c err)
@@ -62,8 +60,8 @@ static int nxp_nci_i2c_set_mode(void *phy_id,
 {
struct nxp_nci_i2c_phy *phy = (struct nxp_nci_i2c_phy *) phy_id;
 
-   gpio_set_value(phy->gpio_fw, (mode == NXP_NCI_MODE_FW) ? 1 : 0);
-   gpio_set_value(phy->gpio_en, (mode != NXP_NCI_MODE_COLD) ? 1 : 0);
+   gpiod_set_value(phy->gpiod_fw, (mode == NXP_NCI_MODE_FW) ? 1 : 0);
+   gpiod_set_value(phy->gpiod_en, (mode != NXP_NCI_MODE_COLD) ? 1 : 0);
usleep_range(1, 15000);
 
if (mode == NXP_NCI_MODE_COLD)
@@ -263,30 +261,18 @@ static irqreturn_t nxp_nci_i2c_irq_thread_fn(int irq, 
void *phy_id)
 static int nxp_nci_i2c_parse_devtree(struct i2c_client *client)
 {
struct nxp_nci_i2c_phy *phy = i2c_get_clientdata(client);
-   struct device_node *pp;
-   int r;
-
-   pp = client->dev.of_node;
-   if (!pp)
-   return -ENODEV;
 
-   r = of_get_named_gpio(pp, "enable-gpios", 0);
-   if (r == -EPROBE_DEFER)
-   r = of_get_named_gpio(pp, "enable-gpios", 0);
-   if (r < 0) {
-   nfc_err(&client->dev, "Failed to get EN gpio, error: %d\n", r);
-   return r;
+   phy->gpiod_en = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);
+   if (IS_ERR(phy->gpiod_en)) {
+   nfc_err(&client->dev, "Failed to get EN gpio\n");
+   return PTR_ERR(phy->gpiod_en);
}
-   phy->gpio_en = r;
 
-   r = of_get_named_gpio(pp, "firmware-gpios", 0);
-   if (r == -EPROBE_DEFER)
-   r = of_get_named_gpio(pp, "firmware-gpios", 0);
-   if (r < 0) {
-   nfc_err(&client->dev, "Failed to get FW gpio, error: %d\n", r);
-   return r;
+   phy->gpiod_fw = devm_gpiod_get(&client->dev, "firmware", GPIOD_OUT_LOW);
+   if (IS_ERR(phy->gpiod_fw)) {
+   nfc_err(&client->dev, "Failed to get FW gpio\n");
+   return PTR_ERR(phy->gpiod_fw);
}
-   phy->gpio_fw = r;
 
return 0;
 }
@@ -294,19 +280,15 @@ static int nxp_nci_i2c_parse_devtree(struct i2c_client 
*client)
 static int nxp_nci_i2c_acpi_config(struct nxp_nci_i2c_phy *phy)
 {
struct i2c_client *client = phy->i2c_dev;
-   struct gpio_desc *gpiod_en, *gpiod_fw;
 
-   gpiod_en = devm_gpiod_get_index(&client->dev, NULL, 2, GPIOD_OUT_LOW);
-   gpiod_fw = devm_gpiod_get_index(&client->dev, NULL, 1, GPIOD_OUT_LOW);
+   phy->gpiod_en = devm_gpiod_get_index(&client->dev, NULL, 2, 
GPIOD_OUT_LOW);
+   phy->gpiod_fw = devm_gpiod_get_index(&client->dev, NULL, 1, 
GPIOD_OUT_LOW);
 
-   if (IS_ERR(gpiod_en) || IS_ERR(gpiod_fw)) {
+   if (IS_ERR(phy->gpiod_en) || IS_ERR(phy->gpiod_fw)) {
nfc_err(&client->dev, "No GPIOs\n");
return -EINVAL;
}
 
-   phy->gpio_en = desc_to_gpio(gpiod_en);
-   phy->gpio_fw = desc_to_gpio(gpiod_fw);
-
return 0;
 }
 
@@ -342,24 +324,12 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
r = nxp_nci_i2c_acpi_config(phy);
if (r < 0)
goto probe_exit;
-   goto nci_probe;
} else {
nfc_err(&client->dev, "No platform data\n");
r = -EINVAL;
goto probe_exit;
}
 
-   r = devm_gpio_request_one(&phy->i2c_dev->dev, phy->gpio_en,
- GPIOF_OUT_INIT_LOW, "nxp_nci_en");
-   if (r < 0)
-   goto probe_exit;
-
-   r = devm_gpio_request_one(&phy->i2c_dev->dev, phy->gpio_fw,
- GPIOF_OUT_INIT_LOW, "nxp_nci_fw");
-   if (r < 0)
-   goto probe_exit;
-
-nci_probe:
r = nxp_nci_probe(phy, &client->dev, &i2c_phy_ops,
  NXP_NCI_I2C_MAX_PAYLOAD, &phy->ndev);
if (r < 0)
-- 
2.20.1



[PATCH v2 00/12] NFC: nxp-nci: clean up and support new ID

2019-05-13 Thread Andy Shevchenko
It has been reported that some laptops, equipped with NXP NFC300, have
different ID then mentioned in the driver.

While at it, I found that the driver has a lot of duplication and redundant
platform data. The rest of the series (11 out of 12 patches) is dedicated to
clean the driver up.

Sedat, would be nice if you can compile kernel with this patch series applied
and test on your laptop.

In v2:
- added new ID patch
- added new clean up patch
- Cc'ed to linux-wireless@ as well, since linux-nfc@ bounces my mails
- Cc'ed to the reported of the problem with T470 laptop

Andy Shevchenko (12):
  NFC: nxp-nci: Add NXP1001 to the ACPI ID table
  NFC: nxp-nci: Get rid of platform data
  NFC: nxp-nci: Convert to use GPIO descriptor
  NFC: nxp-nci: Add GPIO ACPI mapping table
  NFC: nxp-nci: Get rid of code duplication in ->probe()
  NFC: nxp-nci: Get rid of useless label
  NFC: nxp-nci: Constify acpi_device_id
  NFC: nxp-nci: Drop of_match_ptr() use
  NFC: nxp-nci: Drop comma in terminator lines
  NFC: nxp-nci: Remove unused macro pr_fmt()
  NFC: nxp-nci: Remove 'default n' for tests
  NFC: nxp-nci: Convert to SPDX license tags

 MAINTAINERS   |   1 -
 drivers/nfc/nxp-nci/Kconfig   |   1 -
 drivers/nfc/nxp-nci/core.c|  15 +--
 drivers/nfc/nxp-nci/firmware.c|  13 +--
 drivers/nfc/nxp-nci/i2c.c | 147 ++
 drivers/nfc/nxp-nci/nxp-nci.h |   1 -
 include/linux/platform_data/nxp-nci.h |  27 -
 7 files changed, 37 insertions(+), 168 deletions(-)
 delete mode 100644 include/linux/platform_data/nxp-nci.h

-- 
2.20.1



[PATCH v2 04/12] NFC: nxp-nci: Add GPIO ACPI mapping table

2019-05-13 Thread Andy Shevchenko
In order to unify GPIO resource request prepare gpiod_get_index()
to behave correctly when there is no mapping provided by firmware.

Here we add explicit mapping between _CRS GpioIo() resources and
their names used in the driver.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/nxp-nci/i2c.c | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index 6f61368ae065..9a65dd6cd405 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -258,6 +258,15 @@ static irqreturn_t nxp_nci_i2c_irq_thread_fn(int irq, void 
*phy_id)
return IRQ_NONE;
 }
 
+static const struct acpi_gpio_params firmware_gpios = { 1, 0, false };
+static const struct acpi_gpio_params enable_gpios = { 2, 0, false };
+
+static const struct acpi_gpio_mapping acpi_nxp_nci_gpios[] = {
+   { "enable-gpios", &enable_gpios, 1 },
+   { "firmware-gpios", &firmware_gpios, 1 },
+   { }
+};
+
 static int nxp_nci_i2c_parse_devtree(struct i2c_client *client)
 {
struct nxp_nci_i2c_phy *phy = i2c_get_clientdata(client);
@@ -280,9 +289,14 @@ static int nxp_nci_i2c_parse_devtree(struct i2c_client 
*client)
 static int nxp_nci_i2c_acpi_config(struct nxp_nci_i2c_phy *phy)
 {
struct i2c_client *client = phy->i2c_dev;
+   int r;
 
-   phy->gpiod_en = devm_gpiod_get_index(&client->dev, NULL, 2, 
GPIOD_OUT_LOW);
-   phy->gpiod_fw = devm_gpiod_get_index(&client->dev, NULL, 1, 
GPIOD_OUT_LOW);
+   r = devm_acpi_dev_add_driver_gpios(&client->dev, acpi_nxp_nci_gpios);
+   if (r)
+   return r;
+
+   phy->gpiod_en = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);
+   phy->gpiod_fw = devm_gpiod_get(&client->dev, "firmware", GPIOD_OUT_LOW);
 
if (IS_ERR(phy->gpiod_en) || IS_ERR(phy->gpiod_fw)) {
nfc_err(&client->dev, "No GPIOs\n");
-- 
2.20.1



Re: [linux-nfc] ThinkPad T470 and NXP PN5xx (PN547 or PN548)

2019-05-13 Thread Andy Shevchenko
On Mon, May 13, 2019 at 11:27:07AM +0200, Sedat Dilek wrote:

> Sorry to say, I still have not get all correlations...

Can you provide the output of the following on running Linux system with latest
possible kernel you can install (I am expecting v5.1) and command line with
'ignore_loglevel'?

1. `dmesg`
2. `grep -H 15 /sys/bus/acpi/devices/*/status`
3. `acpidump -o t470-tables.dat` # the file t470-tables.dat
4. `lspci -vv -nk`

P.S. You may use GitHub gist for this set (please, don't share archives) or any
other resource like pastebin.

-- 
With Best Regards,
Andy Shevchenko




Re: ThinkPad T470 and NXP PN5xx (PN547 or PN548)

2019-05-10 Thread Andy Shevchenko
tall.NT.hw]
> > AddReg=NxpNfcClientDriver_AddReg
> >
> > [MyDevice_Install.NT.Services]
> > AddService=WUDFRd,0x01fa,WUDFRD_ServiceInstall
> >
> > [MyDevice_Install.NT.CoInstallers]
> > AddReg=CoInstallers_AddReg
> >
> > [MyDevice_Install.NT.Wdf]
> > UmdfService=NxpNfcClientDriver,NxpNfcClientDriver_Install
> > UmdfServiceOrder=NxpNfcClientDriver
> > UmdfDirectHardwareAccess=AllowDirectHardwareAccess
> > UmdfFileObjectPolicy=AllowNullAndUnknownFileObjects
> > UmdfImpersonationLevel=Impersonation
> >
> > [NxpNfcClientDriver_Install]
> > UmdfLibraryVersion=2.0.0
> > ServiceBinary=%12%\UMDF\NxpNfcClientDriver.dll
> > UmdfExtensions=NfcCx0102
> >
> > [NxpNfcClientDriver_AddReg]
> > HKR,FirmwareMap,"8",0x0002,"%%SystemRoot%%\System32\NXPPN547FW.dat"
> > ; HW version of PN547 is 8
> > HKR,FirmwareMap,"10",0x0002,"%%SystemRoot%%\System32\NXPPN548FW.dat"
> > ; HW version of PN548 is 10
> > HKR,NxpNfcClientDriver, "RfConfigData",0x0001, 00
> > HKR,NxpNfcClientDriver, "EEPROMConfigBlob",0x0001, 00
> > HKR,NxpNfcClientDriver, "RfSessionMgmt",   0x00010001, 1
> > HKR,NxpNfcClientDriver, "KeepRfData",  0x00010001, 1
> >
> > ; == custom registry sections ==
> >
> > [NxpNfpProviderProximityCustomValuesRegister]
> > HKLM,"SYSTEM\CurrentControlSet\Proximity\","Dummy",0x0010,0
> >
> >
> > [NxpNfpProviderProximityCustomValuesRegister.Security]
> > "D:P(A;OICI;GA;;;LS)(A;;GA;;;BA)(A;;GA;;;SY)"
> >
> > [WUDFRD_ServiceInstall]
> > DisplayName=%WudfRdDisplayName%
> > ServiceType=1
> > StartType=3
> > ErrorControl=1
> > ServiceBinary=%12%\WUDFRd.sys
> >
> > [CoInstallers_AddReg]
> > HKR,,CoInstallers32,0x0001,"WUDFCoinstaller.dll"
> >
> >
> > [DestinationDirs]
> > UMDriverCopy=12,UMDF ; copy to Drivers\UMDF
> > Firmware.CopyFiles=11
> >
> > [UMDriverCopy]
> > NxpNfcClientDriver.dll,,,0x100
> >
> > [Firmware.CopyFiles]
> > NXPPN548FW.DAT
> > NXPPN547FW.DAT
> >
> > [ControlFlags]
> > ExcludeFromSelect=*
> >
> > ; === Generic ==
> >
> > [Strings]
> > ManufacturerName="NXP Semiconductors"
> > DiskName="NxpNfcClientDriver Installation Disk"
> > WudfRdDisplayName="NxpNfcClientDriver"
> > DeviceName="NxpNfcClientDriver"
> >
> > - EOT -
> 
> [ CC Cristian and Jeremy of NXP ]
> 
> What Linux-kernel configs do I need that PN544 I2C NFC driver works?
> 
> Additionally, I have set CONFIG_I2C_GPIO=m.
> 
> What else is important to be activated?
> 
> Thanks.
> 
> - Sedat -



-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH v3] PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry

2018-07-29 Thread Andy Shevchenko
On Sun, 2018-07-29 at 15:49 +0300, Andy Shevchenko wrote:
> On Fri, 2018-07-27 at 16:10 -0500, Bjorn Helgaas wrote:

> Do you think variant with ##vend##dev is better? I will update it for
> v4
> if needed.

Okay, I have sent v4 with your comment addressed.

-- 
Andy Shevchenko 
Intel Finland Oy


[PATCH v4] PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry

2018-07-29 Thread Andy Shevchenko
There are a lot of examples in the kernel where PCI_VDEVICE() is used and still
looks not so convenient due to additional driver_data field attached.

Introduce PCI_DEVICE_DATA() macro to fully describe device ID entry in shortest
possible form. For example,

  before:

{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
  (kernel_ulong_t) &dwc3_pci_mrfld_properties, },

  after:

{ PCI_DEVICE_DATA(INTEL, MRFLD, &dwc3_pci_mrfld_properties) },

Drivers can be converted later on in independent way.

While here, remove the unused macro with the same name
from Ralink wireless driver.

Signed-off-by: Andy Shevchenko 
---

- Add vend to the device (Bjorn)

Bjorn, this also looks good.

 drivers/net/wireless/ralink/rt2x00/rt2x00pci.h |  6 --
 include/linux/pci.h| 15 +++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h 
b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
index bc0ca5f58f38..283e2e607bba 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
@@ -27,12 +27,6 @@
 #include 
 #include 
 
-/*
- * This variable should be used with the
- * pci_driver structure initialization.
- */
-#define PCI_DEVICE_DATA(__ops) .driver_data = (kernel_ulong_t)(__ops)
-
 /*
  * PCI driver handlers.
  */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d0961aefdbae..fe060114a647 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -825,6 +825,21 @@ struct pci_driver {
.vendor = PCI_VENDOR_ID_##vend, .device = (dev), \
.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0
 
+/**
+ * PCI_DEVICE_DATA - macro used to describe a specific PCI device in very 
short form
+ * @vend: the vendor name (without PCI_VENDOR_ID_ prefix)
+ * @dev: the device name (without PCI_DEVICE_ID__ prefix)
+ * @data: the driver data to be filled
+ *
+ * This macro is used to create a struct pci_device_id that matches a
+ * specific PCI device.  The subvendor, and subdevice fields will be set
+ * to PCI_ANY_ID.
+ */
+#define PCI_DEVICE_DATA(vend, dev, data) \
+   .vendor = PCI_VENDOR_ID_##vend, .device = PCI_DEVICE_ID_##vend##_##dev, 
\
+   .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0, \
+   .driver_data = (kernel_ulong_t)(data)
+
 enum {
PCI_REASSIGN_ALL_RSRC   = 0x0001,   /* Ignore firmware setup */
PCI_REASSIGN_ALL_BUS= 0x0002,   /* Reassign all bus numbers */
-- 
2.18.0



Re: [PATCH v3] PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry

2018-07-29 Thread Andy Shevchenko
On Fri, 2018-07-27 at 16:10 -0500, Bjorn Helgaas wrote:
> On Fri, Jul 27, 2018 at 11:49:44PM +0300, Andy Shevchenko wrote:
> > There are a lot of examples in the kernel where PCI_VDEVICE() is
> > used and still
> > looks not so convenient due to additional driver_data field
> > attached.
> > 
> > Introduce PCI_DEVICE_DATA() macro to fully describe device ID entry
> > in shortest
> > possible form. For example,
> > 
> >   before:
> > 
> > { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
> >   (kernel_ulong_t) &dwc3_pci_mrfld_properties, },
> > 
> >   after:
> > 
> > { PCI_DEVICE_DATA(INTEL, INTEL_MRFLD,
> > &dwc3_pci_mrfld_properties) },
> 
> Most device IDs include the vendor ID; did you consider pasting the
> vendor ID string into the device ID, so you would end up with this?
> 
> { PCI_DEVICE_DATA(INTEL, MRFLD, &dwc3_pci_mrfld_properties) },

While it makes it slightly shorter, it breaks consistency among such
macros. I don't see any of them is using something like
PCI_DEVICE_ID_##vend##dev.

Though I see few users outside of PCI subsystem that reinvent above
line.

Do you think variant with ##vend##dev is better? I will update it for v4
if needed.

> I don't absolutely love either PCI_VDEVICE or PCI_DEVICE_DATA because
> grep doesn't work as well to find uses of the symbol, but the existing
> 2300 uses of PCI_VDEVICE are telling me pretty loudly to just get over
> it :)


-- 
Andy Shevchenko 
Intel Finland Oy


[PATCH v3] PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry

2018-07-27 Thread Andy Shevchenko
There are a lot of examples in the kernel where PCI_VDEVICE() is used and still
looks not so convenient due to additional driver_data field attached.

Introduce PCI_DEVICE_DATA() macro to fully describe device ID entry in shortest
possible form. For example,

  before:

{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
  (kernel_ulong_t) &dwc3_pci_mrfld_properties, },

  after:

{ PCI_DEVICE_DATA(INTEL, INTEL_MRFLD, &dwc3_pci_mrfld_properties) },

Drivers can be converted later on in independent way.

While here, remove the unused macro with the same name
from Ralink wireless driver.

Signed-off-by: Andy Shevchenko 
---

- fix commit message (Randy)

 drivers/net/wireless/ralink/rt2x00/rt2x00pci.h |  6 --
 include/linux/pci.h| 15 +++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h 
b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
index bc0ca5f58f38..283e2e607bba 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
@@ -27,12 +27,6 @@
 #include 
 #include 
 
-/*
- * This variable should be used with the
- * pci_driver structure initialization.
- */
-#define PCI_DEVICE_DATA(__ops) .driver_data = (kernel_ulong_t)(__ops)
-
 /*
  * PCI driver handlers.
  */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d0961aefdbae..754da6f9adb3 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -825,6 +825,21 @@ struct pci_driver {
.vendor = PCI_VENDOR_ID_##vend, .device = (dev), \
.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0
 
+/**
+ * PCI_DEVICE_DATA - macro used to describe a specific PCI device in very 
short form
+ * @vend: the vendor name (without PCI_VENDOR_ID_ prefix)
+ * @dev: the device name (without PCI_DEVICE_ID_ prefix)
+ * @data: the driver data to be filled
+ *
+ * This macro is used to create a struct pci_device_id that matches a
+ * specific PCI device.  The subvendor, and subdevice fields will be set
+ * to PCI_ANY_ID.
+ */
+#define PCI_DEVICE_DATA(vend, dev, data) \
+   .vendor = PCI_VENDOR_ID_##vend, .device = PCI_DEVICE_ID_##dev, \
+   .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0, \
+   .driver_data = (kernel_ulong_t)(data)
+
 enum {
PCI_REASSIGN_ALL_RSRC   = 0x0001,   /* Ignore firmware setup */
PCI_REASSIGN_ALL_BUS= 0x0002,   /* Reassign all bus numbers */
-- 
2.18.0



Re: [PATCH v1] PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry

2018-07-27 Thread Andy Shevchenko
On Fri, 2018-07-27 at 13:42 -0700, Randy Dunlap wrote:
> On 07/27/2018 01:41 PM, Andy Shevchenko wrote:
> > On Fri, 2018-07-27 at 23:39 +0300, Andy Shevchenko wrote:
> > > There are a lot of examples in the kernel where PCI_VDEVICE() is
> > > used
> > > and still
> > > looks not so convenient due to additional driver_data field
> > > attached.
> > > 
> > > Introduce PCI_DEVICE_DATA() macro to fully describe device ID
> > > entry in
> > > shortest
> > > possible form. For example,
> > > 
> > >   before:
> > > 
> > > { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
> > >   (kernel_ulong_t) &dwc3_pci_mrfld_properties, },
> > > 
> > >   after:
> > > 
> > > { PCI_VDEVICE(INTEL, INTEL_MRFLD, &dwc3_pci_mrfld_properties
> > > },
> > > 
> > > Drivers can be converted later on in independent way.
> > > 
> > > While here, remove the unused macro with the same name
> > > from Ralink wireless driver.
> > 
> > Skip this, it missed one comma.
> 
> s/comma/right paren/ ??

comma in the code and you are right about commit message. Btw, it missed
rename as well there.

Thanks for spotting this!

-- 
Andy Shevchenko 
Intel Finland Oy


[PATCH v2] PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry

2018-07-27 Thread Andy Shevchenko
There are a lot of examples in the kernel where PCI_VDEVICE() is used and still
looks not so convenient due to additional driver_data field attached.

Introduce PCI_DEVICE_DATA() macro to fully describe device ID entry in shortest
possible form. For example,

  before:

{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
  (kernel_ulong_t) &dwc3_pci_mrfld_properties, },

  after:

{ PCI_VDEVICE(INTEL, INTEL_MRFLD, &dwc3_pci_mrfld_properties },

Drivers can be converted later on in independent way.

While here, remove the unused macro with the same name
from Ralink wireless driver.

Signed-off-by: Andy Shevchenko 
---
 drivers/net/wireless/ralink/rt2x00/rt2x00pci.h |  6 --
 include/linux/pci.h| 15 +++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h 
b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
index bc0ca5f58f38..283e2e607bba 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
@@ -27,12 +27,6 @@
 #include 
 #include 
 
-/*
- * This variable should be used with the
- * pci_driver structure initialization.
- */
-#define PCI_DEVICE_DATA(__ops) .driver_data = (kernel_ulong_t)(__ops)
-
 /*
  * PCI driver handlers.
  */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d0961aefdbae..754da6f9adb3 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -825,6 +825,21 @@ struct pci_driver {
.vendor = PCI_VENDOR_ID_##vend, .device = (dev), \
.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0
 
+/**
+ * PCI_DEVICE_DATA - macro used to describe a specific PCI device in very 
short form
+ * @vend: the vendor name (without PCI_VENDOR_ID_ prefix)
+ * @dev: the device name (without PCI_DEVICE_ID_ prefix)
+ * @data: the driver data to be filled
+ *
+ * This macro is used to create a struct pci_device_id that matches a
+ * specific PCI device.  The subvendor, and subdevice fields will be set
+ * to PCI_ANY_ID.
+ */
+#define PCI_DEVICE_DATA(vend, dev, data) \
+   .vendor = PCI_VENDOR_ID_##vend, .device = PCI_DEVICE_ID_##dev, \
+   .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0, \
+   .driver_data = (kernel_ulong_t)(data)
+
 enum {
PCI_REASSIGN_ALL_RSRC   = 0x0001,   /* Ignore firmware setup */
PCI_REASSIGN_ALL_BUS= 0x0002,   /* Reassign all bus numbers */
-- 
2.18.0



Re: [PATCH v1] PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry

2018-07-27 Thread Andy Shevchenko
On Fri, 2018-07-27 at 23:39 +0300, Andy Shevchenko wrote:
> There are a lot of examples in the kernel where PCI_VDEVICE() is used
> and still
> looks not so convenient due to additional driver_data field attached.
> 
> Introduce PCI_DEVICE_DATA() macro to fully describe device ID entry in
> shortest
> possible form. For example,
> 
>   before:
> 
> { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
>   (kernel_ulong_t) &dwc3_pci_mrfld_properties, },
> 
>   after:
> 
> { PCI_VDEVICE(INTEL, INTEL_MRFLD, &dwc3_pci_mrfld_properties },
> 
> Drivers can be converted later on in independent way.
> 
> While here, remove the unused macro with the same name
> from Ralink wireless driver.

Skip this, it missed one comma.
Will send v2 soon.

> 
> Signed-off-by: Andy Shevchenko 
> ---
>  drivers/net/wireless/ralink/rt2x00/rt2x00pci.h |  6 --
>  include/linux/pci.h| 15 +++
>  2 files changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
> b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
> index bc0ca5f58f38..283e2e607bba 100644
> --- a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
> +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
> @@ -27,12 +27,6 @@
>  #include 
>  #include 
>  
> -/*
> - * This variable should be used with the
> - * pci_driver structure initialization.
> - */
> -#define PCI_DEVICE_DATA(__ops)   .driver_data =
> (kernel_ulong_t)(__ops)
> -
>  /*
>   * PCI driver handlers.
>   */
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index d0961aefdbae..af29a32865c5 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -825,6 +825,21 @@ struct pci_driver {
>   .vendor = PCI_VENDOR_ID_##vend, .device = (dev), \
>   .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0
>  
> +/**
> + * PCI_DEVICE_DATA - macro used to describe a specific PCI device in
> very short form
> + * @vend: the vendor name
> + * @dev: the device name (without PCI_DEVICE_ID_ prefix)
> + * @data: the driver data to be filled
> + *
> + * This macro is used to create a struct pci_device_id that matches a
> + * specific PCI device.  The subvendor, and subdevice fields will be
> set
> + * to PCI_ANY_ID.
> + */
> +#define PCI_DEVICE_DATA(vend, dev, data) \
> + .vendor = PCI_VENDOR_ID_##vend, .device =
> PCI_DEVICE_ID_##dev, \
> + .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0 \
> +     .driver_data = (kernel_ulong_t)(data)
> +
>  enum {
>   PCI_REASSIGN_ALL_RSRC   = 0x0001,   /* Ignore
> firmware setup */
>   PCI_REASSIGN_ALL_BUS= 0x0002,   /* Reassign
> all bus numbers */

-- 
Andy Shevchenko 
Intel Finland Oy


[PATCH v1] PCI: Add PCI_DEVICE_DATA() macro to fully describe device ID entry

2018-07-27 Thread Andy Shevchenko
There are a lot of examples in the kernel where PCI_VDEVICE() is used and still
looks not so convenient due to additional driver_data field attached.

Introduce PCI_DEVICE_DATA() macro to fully describe device ID entry in shortest
possible form. For example,

  before:

{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
  (kernel_ulong_t) &dwc3_pci_mrfld_properties, },

  after:

{ PCI_VDEVICE(INTEL, INTEL_MRFLD, &dwc3_pci_mrfld_properties },

Drivers can be converted later on in independent way.

While here, remove the unused macro with the same name
from Ralink wireless driver.

Signed-off-by: Andy Shevchenko 
---
 drivers/net/wireless/ralink/rt2x00/rt2x00pci.h |  6 --
 include/linux/pci.h| 15 +++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h 
b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
index bc0ca5f58f38..283e2e607bba 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00pci.h
@@ -27,12 +27,6 @@
 #include 
 #include 
 
-/*
- * This variable should be used with the
- * pci_driver structure initialization.
- */
-#define PCI_DEVICE_DATA(__ops) .driver_data = (kernel_ulong_t)(__ops)
-
 /*
  * PCI driver handlers.
  */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d0961aefdbae..af29a32865c5 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -825,6 +825,21 @@ struct pci_driver {
.vendor = PCI_VENDOR_ID_##vend, .device = (dev), \
.subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0
 
+/**
+ * PCI_DEVICE_DATA - macro used to describe a specific PCI device in very 
short form
+ * @vend: the vendor name
+ * @dev: the device name (without PCI_DEVICE_ID_ prefix)
+ * @data: the driver data to be filled
+ *
+ * This macro is used to create a struct pci_device_id that matches a
+ * specific PCI device.  The subvendor, and subdevice fields will be set
+ * to PCI_ANY_ID.
+ */
+#define PCI_DEVICE_DATA(vend, dev, data) \
+   .vendor = PCI_VENDOR_ID_##vend, .device = PCI_DEVICE_ID_##dev, \
+   .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0 \
+   .driver_data = (kernel_ulong_t)(data)
+
 enum {
PCI_REASSIGN_ALL_RSRC   = 0x0001,   /* Ignore firmware setup */
PCI_REASSIGN_ALL_BUS= 0x0002,   /* Reassign all bus numbers */
-- 
2.18.0



Re: [PATCH] brcmfmac: stop watchdog before detach and free everything

2018-05-28 Thread Andy Shevchenko
On Mon, May 28, 2018 at 12:54 PM, Michael Nazzareno Trimarchi
 wrote:
> Hi Arend
>
> On Mon, May 28, 2018 at 11:51 AM, Arend van Spriel
>  wrote:
>> On 5/28/2018 9:50 AM, Michael Trimarchi wrote:
>>>
>>> Watchdog need to be stopped in brcmf_sdio_remove to avoid
>>> i
>>> The system is going down NOW!
>>> [ 1348.110759] Unable to handle kernel NULL pointer dereference at virtual
>>> address 02f8
>>> Sent SIGTERM to all processes
>>> [ 1348.121412] Mem abort info:
>>> [ 1348.126962]   ESR = 0x9604
>>> [ 1348.130023]   Exception class = DABT (current EL), IL = 32 bits
>>> [ 1348.135948]   SET = 0, FnV = 0
>>> [ 1348.138997]   EA = 0, S1PTW = 0
>>> [ 1348.142154] Data abort info:
>>> [ 1348.145045]   ISV = 0, ISS = 0x0004
>>> [ 1348.148884]   CM = 0, WnR = 0
>>> [ 1348.151861] user pgtable: 4k pages, 48-bit VAs, pgdp = (ptrval)
>>> [ 1348.158475] [02f8] pgd=
>>> [ 1348.163364] Internal error: Oops: 9604 [#1] PREEMPT SMP
>>> [ 1348.168927] Modules linked in: ipv6
>>> [ 1348.172421] CPU: 3 PID: 1421 Comm: brcmf_wdog/mmc0 Not tainted
>>> 4.17.0-rc5-next-20180517 #18
>>> [ 1348.180757] Hardware name: Amarula A64-Relic (DT)
>>> [ 1348.185455] pstate: 6005 (nZCv daif -PAN -UAO)
>>> [ 1348.190251] pc : brcmf_sdiod_freezer_count+0x0/0x20
>>> [ 1348.195124] lr : brcmf_sdio_watchdog_thread+0x64/0x290
>>
>>
>> Hi Michael,
>>
>> Thanks for the patch. In normal scenario the callstack looks like this:
>>
>> brcmf_sdio_remove()
>> -> brcmf_detach()
>> -> brcmf_bus_stop()
>> -> brcmf_sdio_bus_stop()
>>
>> In brcmf_sdio_bus_stop() the watchdog is terminated. So in what scenario did
>> you encounter this null pointer deref?
>
> Is this happen even when there is not wifi firmware?
> boot without any firmware in the filesystem and then trigger a reboot

Something like the above I had noticed for a long (couple of kernel
releases?) time, but wasn't a big priority to me.
Though, I can test this on my side.

P.S. I think rmmod or echo > unbind will trigger that as well.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 07/33] iwlwifi: mvm: use match_string() helper

2018-05-22 Thread Andy Shevchenko
On Tue, May 22, 2018 at 6:30 AM, Yisheng Xie  wrote:

>> But it's up tu Loca.

Shame on me. I meant Luca, of course!
Luca, sorry.

> OK, I will change it if Loca agree your opinion.


-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 07/33] iwlwifi: mvm: use match_string() helper

2018-05-21 Thread Andy Shevchenko
On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie  wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.

> int ret, bt_force_ant_mode;
>
> -   for (bt_force_ant_mode = 0;
> -bt_force_ant_mode < ARRAY_SIZE(modes_str);
> -bt_force_ant_mode++) {
> -   if (!strcmp(buf, modes_str[bt_force_ant_mode]))
> -   break;
> -   }
> -
> -   if (bt_force_ant_mode >= ARRAY_SIZE(modes_str))

> +   bt_force_ant_mode = match_string(modes_str,
> +ARRAY_SIZE(modes_str), buf);

One line?

> +   if (bt_force_ant_mode < 0)
> return -EINVAL;

I would rather use

ret = match_string();
if (ret < 0)
 return ret;

bt_force_... = ret;

But it's up tu Loca.

>
> ret = 0;



-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v2 0/3] Few NFC fixes from android-4.14 tree

2018-05-03 Thread Andy Shevchenko
On Wed, 2018-05-02 at 23:18 +0530, Amit Pundir wrote:
> Hi,
> 
> Submitting v2 of NFC fixes I picked up from android-4.14 tree[1]
> for review and comments.
> 
> Again like to point out that I have not feature tested these patches
> at all. Only made small cosmetic changes to the original patches
> (removed Android-only tag and internal bug ID) and build tested for
> arm, before posting them here for review.
> 
> Really appreciate any comments or feedback on how to take it forward.
> 
> Changes since v1:
> * Dropped "NFC: st21nfca: Fix memory OOB and leak issues in
> connectivity
>   events handler" patch for now. I'm yet to verify if the additional
>   aid_len and params_len checks for buffer size are really required,
> and
>   I didn't want to hold up this patch series for one patch alone.
> * Dropped redundant __func__ use dev_dbg() in "NFC: fdp: Fix possible
>   buffer overflow in WCS4000 NFC driver" patch.
> 
> Also drivers/nfc/fdp/ is full of __func__ parameter usage in
> dev_dbg(),
> so submitting a new patch separately to clean that up.
> 

After addressing one comment, FWIW,

Reviewed-by: Andy Shevchenko 

> Regards,
> Amit Pundir
> [1] https://android.googlesource.com/kernel/common/+log/android-4.14
> 
> Suren Baghdasaryan (3):
>   NFC: st21nfca: Fix out of bounds kernel access when handling ATR_REQ
>   NFC: Fix possible memory corruption when handling SHDLC I-Frame
> commands
>   NFC: fdp: Fix possible buffer overflow in WCS4000 NFC driver
> 
>  drivers/nfc/fdp/fdp.c  | 22 +++---
>  drivers/nfc/fdp/i2c.c  | 29 ++---
>  drivers/nfc/st21nfca/dep.c |  3 ++-
>  net/nfc/hci/core.c | 10 ++
>  4 files changed, 41 insertions(+), 23 deletions(-)
> 

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH v2 3/3] NFC: fdp: Fix possible buffer overflow in WCS4000 NFC driver

2018-05-03 Thread Andy Shevchenko
On Wed, 2018-05-02 at 23:18 +0530, Amit Pundir wrote:
> From: Suren Baghdasaryan 
> 
> Possible buffer overflow when reading next_read_size bytes into
> tmp buffer after next_read_size was extracted from a previous packet.
> 
> Signed-off-by: Suren Baghdasaryan 
> Signed-off-by: Amit Pundir 
> ---
> v2:
> Remove redundant __func__ from dev_dgb().
> 
>  drivers/nfc/fdp/i2c.c | 9 +
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
> index c4da50e..b80d1ad 100644
> --- a/drivers/nfc/fdp/i2c.c
> +++ b/drivers/nfc/fdp/i2c.c
> @@ -176,6 +176,15 @@ static int fdp_nci_i2c_read(struct fdp_i2c_phy
> *phy, struct sk_buff **skb)
>   /* Packet that contains a length */
>   if (tmp[0] == 0 && tmp[1] == 0) {
>   phy->next_read_size = (tmp[2] << 8) + tmp[3]
> + 3;
> + /*
> +  * Ensure next_read_size does not exceed
> sizeof(tmp)
> +  * for reading that many bytes during next
> iteration
> +  */
> + if (phy->next_read_size >
> FDP_NCI_I2C_MAX_PAYLOAD) {
> + dev_dbg(&client->dev, "corrupted
> packet\n");

> + phy->next_read_size = 5;

Shouldn't be this magic replaced by

phy->next_read_size = FDP_NCI_I2C_MIN_PAYLOAD;

? 

> +     goto flush;
> + }
>   } else {
>   phy->next_read_size =
> FDP_NCI_I2C_MIN_PAYLOAD;
>  

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH v2] NFC: fdp: Remove __func__ from dev_dbg()

2018-05-03 Thread Andy Shevchenko
On Thu, 2018-05-03 at 11:26 +0530, Amit Pundir wrote:
> Remove redundant __func__ parameter from dev_dgb() calls.
> 
> v2:
> Deleted empty dev_dbg() trace calls, which are redundant if
> function tracer is enabled.

Actually this would be indeed part of commit message.

FWIW,
Reviewed-by: Andy Shevchenko 

> 
> Signed-off-by: Amit Pundir 
> ---
>  drivers/nfc/fdp/fdp.c | 18 +++---
>  drivers/nfc/fdp/i2c.c | 17 -
>  2 files changed, 7 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/nfc/fdp/fdp.c b/drivers/nfc/fdp/fdp.c
> index d5784a4..f64a6fd 100644
> --- a/drivers/nfc/fdp/fdp.c
> +++ b/drivers/nfc/fdp/fdp.c
> @@ -249,8 +249,6 @@ static int fdp_nci_open(struct nci_dev *ndev)
>   struct fdp_nci_info *info = nci_get_drvdata(ndev);
>   struct device *dev = &info->phy->i2c_dev->dev;
>  
> - dev_dbg(dev, "%s\n", __func__);
> -
>   r = info->phy_ops->enable(info->phy);
>  
>   return r;
> @@ -261,7 +259,6 @@ static int fdp_nci_close(struct nci_dev *ndev)
>   struct fdp_nci_info *info = nci_get_drvdata(ndev);
>   struct device *dev = &info->phy->i2c_dev->dev;
>  
> - dev_dbg(dev, "%s\n", __func__);
>   return 0;
>  }
>  
> @@ -270,8 +267,6 @@ static int fdp_nci_send(struct nci_dev *ndev,
> struct sk_buff *skb)
>   struct fdp_nci_info *info = nci_get_drvdata(ndev);
>   struct device *dev = &info->phy->i2c_dev->dev;
>  
> - dev_dbg(dev, "%s\n", __func__);
> -
>   if (atomic_dec_and_test(&info->data_pkt_counter))
>   info->data_pkt_counter_cb(ndev);
>  
> @@ -283,7 +278,6 @@ int fdp_nci_recv_frame(struct nci_dev *ndev,
> struct sk_buff *skb)
>   struct fdp_nci_info *info = nci_get_drvdata(ndev);
>   struct device *dev = &info->phy->i2c_dev->dev;
>  
> - dev_dbg(dev, "%s\n", __func__);
>   return nci_recv_frame(ndev, skb);
>  }
>  EXPORT_SYMBOL(fdp_nci_recv_frame);
> @@ -498,8 +492,6 @@ static int fdp_nci_setup(struct nci_dev *ndev)
>   int r;
>   u8 patched = 0;
>  
> - dev_dbg(dev, "%s\n", __func__);
> -
>   r = nci_core_init(ndev);
>   if (r)
>   goto error;
> @@ -609,7 +601,6 @@ static int fdp_nci_core_reset_ntf_packet(struct
> nci_dev *ndev,
>   struct fdp_nci_info *info = nci_get_drvdata(ndev);
>   struct device *dev = &info->phy->i2c_dev->dev;
>  
> - dev_dbg(dev, "%s\n", __func__);
>   info->setup_reset_ntf = 1;
>   wake_up(&info->setup_wq);
>  
> @@ -622,7 +613,6 @@ static int fdp_nci_prop_patch_ntf_packet(struct
> nci_dev *ndev,
>   struct fdp_nci_info *info = nci_get_drvdata(ndev);
>   struct device *dev = &info->phy->i2c_dev->dev;
>  
> - dev_dbg(dev, "%s\n", __func__);
>   info->setup_patch_ntf = 1;
>   info->setup_patch_status = skb->data[0];
>   wake_up(&info->setup_wq);
> @@ -637,7 +627,7 @@ static int fdp_nci_prop_patch_rsp_packet(struct
> nci_dev *ndev,
>   struct device *dev = &info->phy->i2c_dev->dev;
>   u8 status = skb->data[0];
>  
> - dev_dbg(dev, "%s: status 0x%x\n", __func__, status);
> + dev_dbg(dev, "status 0x%x\n", status);
>   nci_req_complete(ndev, status);
>  
>   return 0;
> @@ -650,7 +640,7 @@ static int
> fdp_nci_prop_set_production_data_rsp_packet(struct nci_dev *ndev,
>   struct device *dev = &info->phy->i2c_dev->dev;
>   u8 status = skb->data[0];
>  
> - dev_dbg(dev, "%s: status 0x%x\n", __func__, status);
> + dev_dbg(dev, "status 0x%x\n", status);
>   nci_req_complete(ndev, status);
>  
>   return 0;
> @@ -695,7 +685,7 @@ static int
> fdp_nci_core_get_config_rsp_packet(struct nci_dev *ndev,
>   dev_dbg(dev, "OTP version %d\n", info->otp_version);
>   dev_dbg(dev, "RAM version %d\n", info->ram_version);
>   dev_dbg(dev, "key index %d\n", info->key_index);
> - dev_dbg(dev, "%s: status 0x%x\n", __func__, rsp->status);
> + dev_dbg(dev, "status 0x%x\n", rsp->status);
>  
>   nci_req_complete(ndev, rsp->status);
>  
> @@ -798,8 +788,6 @@ void fdp_nci_remove(struct nci_dev *ndev)
>   struct fdp_nci_info *info = nci_get_drvdata(ndev);
>   struct device *dev = &info->phy->i2c_dev->dev;
>  
> - dev_dbg(dev, "%s\n", __func__);
> -
>   nci_unregister_device(ndev);
>   nci_free_device(ndev);
>  }
> diff --git 

Re: [PATCH] NFC: fdp: Remove __func__ parameter from dev_dbg() call

2018-05-02 Thread Andy Shevchenko
On Wed, 2018-05-02 at 23:19 +0530, Amit Pundir wrote:

> - dev_dbg(dev, "%s\n", __func__);
> + dev_dbg(dev, "\n");

If one enables function tracer this will be redundant completely. 

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [RESEND][PATCH 4/4] NFC: fdp: Fix possible buffer overflow in WCS4000 NFC driver

2018-04-20 Thread Andy Shevchenko
On Wed, 2018-04-18 at 15:35 +0530, Amit Pundir wrote:

> + if (phy->next_read_size >
> FDP_NCI_I2C_MAX_PAYLOAD) {

> + dev_dbg(&client->dev, "%s: corrupted
> packet\n",
> + __func__);

If Android people would follow the kernel in reasonable time they may
have noticed Dynamic Debug functionality and how it works.

In this case the __func__ is superfluous.

> + phy->next_read_size = 5;
> + goto flush;
> + }
>   } else {
>   phy->next_read_size =
> FDP_NCI_I2C_MIN_PAYLOAD;
>  

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [RESEND][PATCH 2/4] NFC: st21nfca: Fix memory OOB and leak issues in connectivity events handler

2018-04-20 Thread Andy Shevchenko
On Wed, 2018-04-18 at 15:35 +0530, Amit Pundir wrote:

>   if (skb->data[transaction->aid_len + 2] !=
> - NFC_EVT_TRANSACTION_PARAMS_TAG)
> + NFC_EVT_TRANSACTION_PARAMS_TAG ||
> + skb->len < transaction->aid_len + transaction-
> >params_len + 4) {

> + devm_kfree(dev, transaction);

Oh, no.

This is not memory leak per se, this is bad choice of devm_ API where it
should use plain kmalloc() / kfree().

>   return -EPROTO;
> + }

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [RESEND] rsi: Remove stack VLA usage

2018-03-13 Thread Andy Shevchenko
On Tue, Mar 13, 2018 at 10:17 PM, tcharding  wrote:
> On Mon, Mar 12, 2018 at 09:46:06AM +, Kalle Valo wrote:
>> tcharding  wrote:

I'm pretty much sure it depends on the original email headers, like
above ^^^ — no name.
Perhaps git config on your side should be done.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] wireless: zd1211rw: remove redundant assignment of pointer 'q'

2018-01-31 Thread Andy Shevchenko
On Tue, Jan 30, 2018 at 8:25 PM, Colin King  wrote:
> From: Colin Ian King 
>
> Pointer q is initialized and then almost immediately afterwards being
> re-assigned the same value. Remove the second redundant assignment.
>

Don't you see strange that in the same context of the patch two users
of q are present?

How did you test this?

> Cleans up clang warning:
> drivers/net/wireless/zydas/zd1211rw/zd_mac.c:503:23: warning: Value
> stored to 'q' during its initialization is never read

> -   q = &mac->ack_wait_queue;
> spin_lock_irqsave(&q->lock, flags);
>
> skb_queue_walk(q, skb) {



-- 
With Best Regards,
Andy Shevchenko


Re: [v2] ath9k: add MSI support

2018-01-08 Thread Andy Shevchenko
On Mon, Jan 8, 2018 at 2:24 PM, Kalle Valo  wrote:
> (Adding AceLan)
>
> Daniel Drake  writes:
>
>> On Wed, Nov 15, 2017 at 7:38 AM, Daniel Drake  wrote:
>>> On Tue, Nov 14, 2017 at 8:15 PM, Kalle Valo  wrote:
>>>>> Can't be fixed in firmware, but it would be good to have confirmation
>>>>> of the hardware behavivour, and maybe some other solution is possible?
>>>>> Are you following this up within Qualcomm?
>>>>
>>>> No time to do that right now, sorry.
>>>
>>> I got several autoresponders from people on this thread from Qualcomm
>>> Taiwan. Would it be useful for us to drop off a sample of the affected
>>> product at your Taipei or Hsinchu office so that you can investigate
>>> further?
>>
>> Ping - how can we collaborate on this?
>
> Are you asking me? While looking at my todo list for this year I doubt I
> can find time to help with the MSI implementation or bugfixing.
>
> But my plan is that first I would apply Russel's patch which makes it
> possible to enable MSI with a module parameter:
>
> https://patchwork.kernel.org/patch/249/

Just in case it was missed during review:

The variables like

+ bool msi_enabled;

usually are redundant because PCI core keeps track of MSI/MSI-X status
(enabled/disabled)
So, if there is no MSI-X involved or MSI-X is handled in the same way
as MSI in the driver, one can use

pci_dev_msi_enabled() instead.

> Are everyone happy with this plan?

Sounds reasonable.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] brcmfmac: Use zeroing memory allocator than allocator/memset

2017-12-31 Thread Andy Shevchenko
On Sat, Dec 30, 2017 at 5:51 PM, Himanshu Jha
 wrote:
> Use dma_zalloc_coherent for allocating zeroed
> memory and remove unnecessary memset function.
>
> Done using Coccinelle.
> Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
> 0-day tested with no failures.
>

Makes sense.

Reviewed-by: Andy Shevchenko 

> Suggested-by: Luis R. Rodriguez 
> Signed-off-by: Himanshu Jha 
> ---
>  .../net/wireless/broadcom/brcm80211/brcmfmac/pcie.c| 18 
> --
>  1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c 
> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> index 3c87157..bdef2ac 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> @@ -1251,14 +1251,13 @@ static int brcmf_pcie_init_scratchbuffers(struct 
> brcmf_pciedev_info *devinfo)
> u64 address;
> u32 addr;
>
> -   devinfo->shared.scratch = dma_alloc_coherent(&devinfo->pdev->dev,
> -   BRCMF_DMA_D2H_SCRATCH_BUF_LEN,
> -   &devinfo->shared.scratch_dmahandle, GFP_KERNEL);
> +   devinfo->shared.scratch =
> +   dma_zalloc_coherent(&devinfo->pdev->dev,
> +   BRCMF_DMA_D2H_SCRATCH_BUF_LEN,
> +   &devinfo->shared.scratch_dmahandle,
> +   GFP_KERNEL);
> if (!devinfo->shared.scratch)
> goto fail;
>
> -   memset(devinfo->shared.scratch, 0, BRCMF_DMA_D2H_SCRATCH_BUF_LEN);
> -
> addr = devinfo->shared.tcm_base_address +
>BRCMF_SHARED_DMA_SCRATCH_ADDR_OFFSET;
> address = (u64)devinfo->shared.scratch_dmahandle;
> @@ -1268,14 +1267,13 @@ static int brcmf_pcie_init_scratchbuffers(struct 
> brcmf_pciedev_info *devinfo)
>BRCMF_SHARED_DMA_SCRATCH_LEN_OFFSET;
> brcmf_pcie_write_tcm32(devinfo, addr, BRCMF_DMA_D2H_SCRATCH_BUF_LEN);
>
> -   devinfo->shared.ringupd = dma_alloc_coherent(&devinfo->pdev->dev,
> -   BRCMF_DMA_D2H_RINGUPD_BUF_LEN,
> -   &devinfo->shared.ringupd_dmahandle, GFP_KERNEL);
> +   devinfo->shared.ringupd =
> +   dma_zalloc_coherent(&devinfo->pdev->dev,
> +   BRCMF_DMA_D2H_RINGUPD_BUF_LEN,
> +   &devinfo->shared.ringupd_dmahandle,
> +   GFP_KERNEL);
> if (!devinfo->shared.ringupd)
> goto fail;
>
> -   memset(devinfo->shared.ringupd, 0, BRCMF_DMA_D2H_RINGUPD_BUF_LEN);
> -
> addr = devinfo->shared.tcm_base_address +
>BRCMF_SHARED_DMA_RINGUPD_ADDR_OFFSET;
> address = (u64)devinfo->shared.ringupd_dmahandle;
> --
> 2.7.4
>



-- 
With Best Regards,
Andy Shevchenko


Re: [trivial PATCH] treewide: Align function definition open/close braces

2017-12-18 Thread Andy Shevchenko
On Mon, Dec 18, 2017 at 2:28 AM, Joe Perches  wrote:
> Some functions definitions have either the initial open brace and/or
> the closing brace outside of column 1.
>
> Move those braces to column 1.
>
> This allows various function analyzers like gnu complexity to work
> properly for these modified functions.
>
> Miscellanea:
>
> o Remove extra trailing ; and blank line from xfs_agf_verify
>
> Signed-off-by: Joe Perches 

>  drivers/platform/x86/eeepc-laptop.c  |  2 +-

> diff --git a/drivers/platform/x86/eeepc-laptop.c 
> b/drivers/platform/x86/eeepc-laptop.c
> index 5a681962899c..4c38904a8a32 100644
> --- a/drivers/platform/x86/eeepc-laptop.c
> +++ b/drivers/platform/x86/eeepc-laptop.c
> @@ -492,7 +492,7 @@ static void eeepc_platform_exit(struct eeepc_laptop 
> *eeepc)
>   * potentially bad time, such as a timer interrupt.
>   */
>  static void tpd_led_update(struct work_struct *work)
> - {
> +{
> struct eeepc_laptop *eeepc;
>
> eeepc = container_of(work, struct eeepc_laptop, tpd_led_work);
> diff --git a/drivers/rtc/rtc-ab-b5ze-s3.c b/drivers/rtc/rtc-ab-b5ze-s3.c
> index a319bf1e49de..ef5c16dfabfa 100644

Acked-by: Andy Shevchenko 

for PDx86 changes.


-- 
With Best Regards,
Andy Shevchenko


[PATCH v1] brcmfmac: Avoid build error with make W=1

2017-11-23 Thread Andy Shevchenko
When I run make W=1 on gcc (Debian 7.2.0-16) 7.2.0 I got an error for
the first run, all next ones are okay.

  CC [M]  drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.o
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c:2078: error: Cannot 
parse struct or union!
scripts/Makefile.build:310: recipe for target 
'drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.o' failed

Seems like something happened with W=1 and wrong kernel doc format.
As a quick fix remove dubious /** in the code.

Signed-off-by: Andy Shevchenko 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index e3495ea95553..870e00cea29c 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -2070,7 +2070,7 @@ static int brcmf_sdio_txpkt_hdalign(struct brcmf_sdio 
*bus, struct sk_buff *pkt)
return head_pad;
 }
 
-/**
+/*
  * struct brcmf_skbuff_cb reserves first two bytes in sk_buff::cb for
  * bus layer usage.
  */
-- 
2.15.0



Re: [PATCH 05/18] net: use ARRAY_SIZE

2017-10-03 Thread Andy Shevchenko
On Tue, Oct 3, 2017 at 4:22 AM, Jérémy Lefaure
 wrote:
> On Mon, 2 Oct 2017 16:07:36 +0300
> Andy Shevchenko  wrote:
>
>> > +   {&gainctrl_lut_core0_rev0, ARRAY_SIZE(gainctrl_lut_core0_rev0), 
>> > 26, 192,
>> > +32},
>>
>> For all such cases I would rather put on one line disregard checkpatch
>> warning for better readability.
> I agree that it would be better. I didn't know that it was possible to
> not follow this rule for anything else than a string.

IMO, it increases readability quite enough to overrule checkpatch recomendation.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 05/18] net: use ARRAY_SIZE

2017-10-02 Thread Andy Shevchenko
On Sun, Oct 1, 2017 at 10:30 PM, Jérémy Lefaure
 wrote:
> Using the ARRAY_SIZE macro improves the readability of the code. Also,
> it is not always useful to use a variable to store this constant
> calculated at compile time.
>

> +   {&gainctrl_lut_core0_rev0, ARRAY_SIZE(gainctrl_lut_core0_rev0), 26, 
> 192,
> +32},

For all such cases I would rather put on one line disregard checkpatch
warning for better readability.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v1 3/6] staging: unisys: Switch to use new generic UUID API

2017-08-30 Thread Andy Shevchenko
On Wed, 2017-08-30 at 14:38 +0200, Christoph Hellwig wrote:
> On Mon, Jul 31, 2017 at 08:20:25PM +0300, Andy Shevchenko wrote:
> > Yep! There are so many conflicts that would be better just to push
> > through your tree.
> > 
> > I have just sent a v2 of this patch separately.
> 
> Greg, did you pick that patch up?

That patch in his tree.

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH v1] ath10k: Switch to use new generic UUID API

2017-08-02 Thread Andy Shevchenko
On Wed, 2017-08-02 at 14:44 +, Kalle Valo wrote:
> Andy Shevchenko  writes:
> 
> > There are new types and helpers that are supposed to be used in new
> > code.
> > 
> > As a preparation to get rid of legacy types and API functions do
> > the conversion here.
> > 
> > Signed-off-by: Andy Shevchenko 
> 
> To which tree are you planning to submit this? Can I take this to my
> ath.git tree?

I guess it's precisely for your tree.


-- 
Andy Shevchenko 
Intel Finland Oy


[PATCH v1] ath10k: Switch to use new generic UUID API

2017-08-02 Thread Andy Shevchenko
There are new types and helpers that are supposed to be used in new code.

As a preparation to get rid of legacy types and API functions do
the conversion here.

Signed-off-by: Andy Shevchenko 
---
 drivers/net/wireless/ath/ath10k/core.h  | 2 +-
 drivers/net/wireless/ath/ath10k/debug.c | 6 +++---
 drivers/net/wireless/ath/ath10k/pci.c   | 8 
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index 2b499af722ad..4b13e0078cf6 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -459,7 +459,7 @@ struct ath10k_ce_crash_hdr {
 struct ath10k_fw_crash_data {
bool crashed_since_read;
 
-   uuid_le uuid;
+   guid_t guid;
struct timespec timestamp;
__le32 registers[REG_DUMP_COUNT_QCA988X];
struct ath10k_ce_crash_data ce_crash_data[CE_COUNT_MAX];
diff --git a/drivers/net/wireless/ath/ath10k/debug.c 
b/drivers/net/wireless/ath/ath10k/debug.c
index 56404fe4e8f5..df514507d3f1 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -70,7 +70,7 @@ struct ath10k_dump_file_data {
 
/* some info we can get from ath10k struct that might help */
 
-   u8 uuid[16];
+   guid_t guid;
 
__le32 chip_id;
 
@@ -719,7 +719,7 @@ ath10k_debug_get_new_fw_crash_data(struct ath10k *ar)
lockdep_assert_held(&ar->data_lock);
 
crash_data->crashed_since_read = true;
-   uuid_le_gen(&crash_data->uuid);
+   guid_gen(&crash_data->guid);
getnstimeofday(&crash_data->timestamp);
 
return crash_data;
@@ -766,7 +766,7 @@ static struct ath10k_dump_file_data 
*ath10k_build_dump_file(struct ath10k *ar,
 
dump_data->version = cpu_to_le32(ATH10K_FW_CRASH_DUMP_VERSION);
 
-   memcpy(dump_data->uuid, &crash_data->uuid, sizeof(dump_data->uuid));
+   guid_copy(&dump_data->guid, &crash_data->guid);
dump_data->chip_id = cpu_to_le32(ar->chip_id);
dump_data->bus_type = cpu_to_le32(0);
dump_data->target_version = cpu_to_le32(ar->target_version);
diff --git a/drivers/net/wireless/ath/ath10k/pci.c 
b/drivers/net/wireless/ath/ath10k/pci.c
index a697caec6579..0a5b88e80214 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -1463,7 +1463,7 @@ static void ath10k_pci_dump_registers(struct ath10k *ar,
 static void ath10k_pci_fw_crashed_dump(struct ath10k *ar)
 {
struct ath10k_fw_crash_data *crash_data;
-   char uuid[50];
+   char guid[UUID_STRING_LEN + 1];
 
spin_lock_bh(&ar->data_lock);
 
@@ -1472,11 +1472,11 @@ static void ath10k_pci_fw_crashed_dump(struct ath10k 
*ar)
crash_data = ath10k_debug_get_new_fw_crash_data(ar);
 
if (crash_data)
-   scnprintf(uuid, sizeof(uuid), "%pUl", &crash_data->uuid);
+   scnprintf(guid, sizeof(guid), "%pUl", &crash_data->guid);
else
-   scnprintf(uuid, sizeof(uuid), "n/a");
+   scnprintf(guid, sizeof(guid), "n/a");
 
-   ath10k_err(ar, "firmware crashed! (uuid %s)\n", uuid);
+   ath10k_err(ar, "firmware crashed! (guid %s)\n", guid);
ath10k_print_driver_info(ar);
ath10k_pci_dump_registers(ar, crash_data);
ath10k_ce_dump_registers(ar, crash_data);
-- 
2.13.2



Re: [PATCH v1 3/6] staging: unisys: Switch to use new generic UUID API

2017-07-31 Thread Andy Shevchenko
On Sun, 2017-07-30 at 10:37 -0700, Greg Kroah-Hartman wrote:
> On Sun, Jul 30, 2017 at 08:26:48PM +0300, Andy Shevchenko wrote:
> > On Sun, Jul 30, 2017 at 6:32 PM, Greg Kroah-Hartman
> >  wrote:

> > > Doesn't apply to the staging tree at all :(
> > 
> > No surprises, it was cooked against uuid tree in the first place.
> > If you agree to take it through staging tree I will prepare a
> > rebased version.
> > Does it sound good?
> 
> You can take it through the uuid tree if it's easier for you, but then
> someone will have to deal with the merge issues...
> 
> If it's easier, I can take it to prevent the merge problems.

Yep! There are so many conflicts that would be better just to push
through your tree.

I have just sent a v2 of this patch separately.

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH v1 3/6] staging: unisys: Switch to use new generic UUID API

2017-07-30 Thread Andy Shevchenko
On Sun, Jul 30, 2017 at 6:32 PM, Greg Kroah-Hartman
 wrote:
> On Wed, Jul 26, 2017 at 01:01:41PM +0300, Andy Shevchenko wrote:
>> On Wed, 2017-07-19 at 21:28 +0300, Andy Shevchenko wrote:
>> > There are new types and helpers that are supposed to be used in new
>> > code.
>> >
>> > As a preparation to get rid of legacy types and API functions do
>> > the conversion here.
>> >
>> > While here, re-indent couple of lines to increase readability.
>>
>> This looks like no user space UUID API is involved, can be routed via
>> either tree (uuid or staging).
>>
>> Anyone to comment?
>
> Doesn't apply to the staging tree at all :(

No surprises, it was cooked against uuid tree in the first place.
If you agree to take it through staging tree I will prepare a rebased version.
Does it sound good?


-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v1 6/6] device property: Switch to use new generic UUID API

2017-07-26 Thread Andy Shevchenko
On Wed, 2017-07-26 at 02:27 +0200, Rafael J. Wysocki wrote:
> On Wednesday, July 26, 2017 03:35:01 AM Andy Shevchenko wrote:
> > On Wed, Jul 26, 2017 at 3:21 AM, Rafael J. Wysocki  > t> wrote:

> > > Andy, do you want me to apply this?
> > 
> > If you would like to.
> > 
> > The patch is now pretty independent since necessary stuff made
> > v4.13-rc1.
> 
> OK

Thanks!

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH v1 3/6] staging: unisys: Switch to use new generic UUID API

2017-07-26 Thread Andy Shevchenko
On Wed, 2017-07-19 at 21:28 +0300, Andy Shevchenko wrote:
> There are new types and helpers that are supposed to be used in new
> code.
> 
> As a preparation to get rid of legacy types and API functions do
> the conversion here.
> 
> While here, re-indent couple of lines to increase readability.

This looks like no user space UUID API is involved, can be routed via
either tree (uuid or staging).

Anyone to comment?

> 
> Cc: David Kershner 
> Cc: Greg Kroah-Hartman 
> Cc: sparmaintai...@unisys.com
> Cc: de...@driverdev.osuosl.org
> Signed-off-by: Andy Shevchenko 
> ---
>  drivers/staging/unisys/Documentation/overview.txt  | 14 +++
>  drivers/staging/unisys/include/channel.h   | 45 ++---
> ---
>  drivers/staging/unisys/include/iochannel.h | 14 +--
>  drivers/staging/unisys/include/visorbus.h  | 12 +++---
>  drivers/staging/unisys/visorbus/controlvmchannel.h | 24 ---
>  drivers/staging/unisys/visorbus/vbuschannel.h  |  7 ++--
>  drivers/staging/unisys/visorbus/visorbus_main.c| 28 ++---
>  drivers/staging/unisys/visorbus/visorbus_private.h |  6 +--
>  drivers/staging/unisys/visorbus/visorchannel.c | 48 +++
> ---
>  drivers/staging/unisys/visorbus/visorchipset.c | 39 ++---
> -
>  drivers/staging/unisys/visorhba/visorhba_main.c|  6 +--
>  drivers/staging/unisys/visorinput/visorinput.c | 38 -
> 
>  drivers/staging/unisys/visornic/visornic_main.c|  6 +--
>  13 files changed, 135 insertions(+), 152 deletions(-)
> 
> diff --git a/drivers/staging/unisys/Documentation/overview.txt
> b/drivers/staging/unisys/Documentation/overview.txt
> index e0466bfada2f..9ab30af265a5 100644
> --- a/drivers/staging/unisys/Documentation/overview.txt
> +++ b/drivers/staging/unisys/Documentation/overview.txt
> @@ -221,7 +221,7 @@ The following files exist under
> /sys/devices/visorbus/vbus:dev:
>  
>  The visorhba driver registers with visorbus as the function driver to
>  handle virtual scsi disk devices, specified using the
> -VISOR_VHBA_CHANNEL_UUID type in the visorbus_register_visor_driver()
> +VISOR_VHBA_CHANNEL_GUID type in the visorbus_register_visor_driver()
>  call. visorhba uses scsi_add_host() to expose a Linux block device
>  (e.g., /sys/block/) in the guest environment for each s-Par virtual
> device.
>  
> @@ -240,7 +240,7 @@ When compiled as a module, visorhba can be
> autoloaded by visorbus in
>  standard udev/systemd environments, as it includes the modules.alias
>  definition:
>  
> -"visorbus:"+VISOR_VHBA_CHANNEL_UUID_STR
> +"visorbus:"+VISOR_VHBA_CHANNEL_GUID_STR
>  
>  i.e.:
>  
> @@ -252,7 +252,7 @@ i.e.:
>  
>  The visornic driver registers with visorbus as the function driver to
>  handle virtual network devices, specified using the
> -VISOR_VNIC_CHANNEL_UUID type in the visorbus_register_visor_driver()
> +VISOR_VNIC_CHANNEL_GUID type in the visorbus_register_visor_driver()
>  call. visornic uses register_netdev() to expose a Linux device of
> class net
>  (e.g., /sys/class/net/) in the guest environment for each s-Par
> virtual
>  device.
> @@ -270,7 +270,7 @@ When compiled as a module, visornic can be
> autoloaded by visorbus in
>  standard udev/systemd environments, as it includes the modules.alias
>  definition:
>  
> -"visorbus:"+VISOR_VNIC_CHANNEL_UUID_STR
> +"visorbus:"+VISOR_VNIC_CHANNEL_GUID_STR
>  
>  i.e.:
>  
> @@ -282,7 +282,7 @@ i.e.:
>  
>  The visorinput driver registers with visorbus as the function driver
> to
>  handle human input devices, specified using the
> -VISOR_KEYBOARD_CHANNEL_UUID and VISOR_MOUSE_CHANNEL_UUID
> +VISOR_KEYBOARD_CHANNEL_GUID and VISOR_MOUSE_CHANNEL_GUID
>  types in the visorbus_register_visor_driver() call. visorinput uses
>  input_register_device() to expose devices of class input
>  (e.g., /sys/class/input/) for virtual keyboard and virtual mouse
> devices.
> @@ -307,8 +307,8 @@ When compiled as a module, visorinput can be
> autoloaded by visorbus in
>  standard udev/systemd environments, as it includes the modules.alias
>  definition:
>  
> -"visorbus:"+VISOR_MOUSE_CHANNEL_UUID_STR
> -"visorbus:"+VISOR_KEYBOARD_CHANNEL_UUID_STR
> +"visorbus:"+VISOR_MOUSE_CHANNEL_GUID_STR
> +"visorbus:"+VISOR_KEYBOARD_CHANNEL_GUID_STR
>  
>  i.e.:
>  
> diff --git a/drivers/staging/unisys/include/channel.h
> b/drivers/staging/unisys/include/channel.h
> index 692efcb38245..b09b1f55a6f1 100644
> --- a/drivers/staging/unisys/include/channel.h
> +++ b/drivers/staging/unisys/include/channel.h
> @@ -116,13 +116,13 @@ struct cha

Re: [PATCH v1 6/6] device property: Switch to use new generic UUID API

2017-07-25 Thread Andy Shevchenko
On Wed, Jul 26, 2017 at 3:21 AM, Rafael J. Wysocki  wrote:
> On Tuesday, July 25, 2017 05:12:35 PM Mika Westerberg wrote:
>> On Wed, Jul 19, 2017 at 09:28:57PM +0300, Andy Shevchenko wrote:
>> > There are new types and helpers that are supposed to be used in new code.
>> >
>> > As a preparation to get rid of legacy types and API functions do
>> > the conversion here.
>> >
>> > Cc: "Rafael J. Wysocki" 
>> > Cc: Mika Westerberg 
>>
>> Acked-by: Mika Westerberg 
>
> OK
>
> Andy, do you want me to apply this?

If you would like to.

The patch is now pretty independent since necessary stuff made v4.13-rc1.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v1 1/6] efi: Switch to use new generic UUID API

2017-07-25 Thread Andy Shevchenko
On Thu, 2017-07-20 at 13:18 +0100, Ard Biesheuvel wrote:
> On 19 July 2017 at 19:28, Andy Shevchenko
>  wrote:
> > There are new types and helpers that are supposed to be used in new
> > code.
> > 
> > As a preparation to get rid of legacy types and API functions do
> > the conversion here.
> > 
> > Cc: Matt Fleming 
> > Cc: Ard Biesheuvel 
> > Signed-off-by: Andy Shevchenko 
> 
> Acked-by: Ard Biesheuvel 


Thanks!

Christoph, can we apply this one at least to move things forward?

> 
> > ---
> >  drivers/firmware/efi/cper.c | 10 ++---
> >  include/linux/cper.h| 94 ++--
> > -
> >  include/linux/efi.h |  4 +-
> >  3 files changed, 54 insertions(+), 54 deletions(-)
> > 
> > diff --git a/drivers/firmware/efi/cper.c
> > b/drivers/firmware/efi/cper.c
> > index 48a8f69da42a..684e65c11dde 100644
> > --- a/drivers/firmware/efi/cper.c
> > +++ b/drivers/firmware/efi/cper.c
> > @@ -534,7 +534,7 @@ static void
> >  cper_estatus_print_section(const char *pfx, struct
> > acpi_hest_generic_data *gdata,
> >    int sec_no)
> >  {
> > -   uuid_le *sec_type = (uuid_le *)gdata->section_type;
> > +   guid_t *sec_type = (guid_t *)gdata->section_type;
> > __u16 severity;
> > char newpfx[64];
> > 
> > @@ -545,12 +545,12 @@ cper_estatus_print_section(const char *pfx,
> > struct acpi_hest_generic_data *gdata
> > printk("%s""Error %d, type: %s\n", pfx, sec_no,
> >    cper_severity_str(severity));
> > if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
> > -   printk("%s""fru_id: %pUl\n", pfx, (uuid_le *)gdata-
> > >fru_id);
> > +   printk("%s""fru_id: %pUl\n", pfx, gdata->fru_id);
> > if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
> > printk("%s""fru_text: %.20s\n", pfx, gdata-
> > >fru_text);
> > 
> > snprintf(newpfx, sizeof(newpfx), "%s%s", pfx, INDENT_SP);
> > -   if (!uuid_le_cmp(*sec_type, CPER_SEC_PROC_GENERIC)) {
> > +   if (guid_equal(sec_type, &CPER_SEC_PROC_GENERIC)) {
> > struct cper_sec_proc_generic *proc_err =
> > acpi_hest_get_payload(gdata);
> > 
> > printk("%s""section_type: general processor
> > error\n", newpfx);
> > @@ -558,7 +558,7 @@ cper_estatus_print_section(const char *pfx,
> > struct acpi_hest_generic_data *gdata
> > cper_print_proc_generic(newpfx, proc_err);
> > else
> > goto err_section_too_small;
> > -   } else if (!uuid_le_cmp(*sec_type, CPER_SEC_PLATFORM_MEM)) {
> > +   } else if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
> > struct cper_sec_mem_err *mem_err =
> > acpi_hest_get_payload(gdata);
> > 
> > printk("%s""section_type: memory error\n", newpfx);
> > @@ -568,7 +568,7 @@ cper_estatus_print_section(const char *pfx,
> > struct acpi_hest_generic_data *gdata
> >    gdata->error_data_length);
> > else
> > goto err_section_too_small;
> > -   } else if (!uuid_le_cmp(*sec_type, CPER_SEC_PCIE)) {
> > +   } else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
> > struct cper_sec_pcie *pcie =
> > acpi_hest_get_payload(gdata);
> > 
> > printk("%s""section_type: PCIe error\n", newpfx);
> > diff --git a/include/linux/cper.h b/include/linux/cper.h
> > index 4c671fc2081e..723e952fde0d 100644
> > --- a/include/linux/cper.h
> > +++ b/include/linux/cper.h
> > @@ -74,36 +74,36 @@ enum {
> >   * Corrected Machine Check
> >   */
> >  #define
> > CPER_NOTIFY_CMC 
> >    \
> > -   UUID_LE(0x2DCE8BB1, 0xBDD7, 0x450e, 0xB9, 0xAD, 0x9C,
> > 0xF4, \
> > -   0xEB, 0xD4, 0xF8, 0x90)
> > +   GUID_INIT(0x2DCE8BB1, 0xBDD7, 0x450e, 0xB9, 0xAD, 0x9C,
> > 0xF4,   \
> > + 0xEB, 0xD4, 0xF8, 0x90)
> >  /* Corrected Platform Error */
> >  #define
> > CPER_NOTIFY_CPE 
> >    \
> > -   UUID_LE(0x4E292F96, 0xD843, 0x4a55, 0xA8, 0xC2, 0xD4,
> > 0x81, \
> > - 

Re: [PATCH v1 4/6] vmbus: Switch to use new generic UUID API

2017-07-19 Thread Andy Shevchenko
On Wed, Jul 19, 2017 at 11:18 PM, Haiyang Zhang  wrote:

>>  struct hv_fcopy_hdr {
>>   __u32 operation;
>> - uuid_le service_id0; /* currently unused */
>> - uuid_le service_id1; /* currently unused */
>> + __u8 service_id0[16]; /* currently unused */
>> + __u8 service_id1[16]; /* currently unused */
>>  } __attribute__((packed));
>
> Even user space may not have all guid_t operations, could you still
> put guid_t here for consistency?

I'm not sure how this code has been designed, though uuid_le followed
by guid_t are kernel internal types mistakenly put to UAPI in the
first place.

Consistency here is how we treat those types in user space, starting
from v4.13 uuid_be gone from that header. uuid_le is luckily will be
gone soon.

> This file is also used by our kernel
> mode code.

It will work still the same after this change.

-- 
With Best Regards,
Andy Shevchenko


[PATCH v1 5/6] uuid: Kill uapi/uuid.h

2017-07-19 Thread Andy Shevchenko
There is no more users for uapi/uuid.h. Remove it for good.

Anyone needs it in user space better to use libuuid.

Signed-off-by: Andy Shevchenko 
---
 include/linux/uuid.h  | 20 +++-
 include/uapi/linux/uuid.h | 42 --
 scripts/mod/file2alias.c  |  4 ++--
 3 files changed, 21 insertions(+), 45 deletions(-)
 delete mode 100644 include/uapi/linux/uuid.h

diff --git a/include/linux/uuid.h b/include/linux/uuid.h
index 2251e1925ea4..3bc3e88c9fbd 100644
--- a/include/linux/uuid.h
+++ b/include/linux/uuid.h
@@ -16,7 +16,19 @@
 #ifndef _LINUX_UUID_H_
 #define _LINUX_UUID_H_
 
-#include 
+#include 
+#include 
+
+typedef struct {
+   __u8 b[16];
+} guid_t;
+
+#define GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) 
\
+((guid_t)  \
+{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
+   (b) & 0xff, ((b) >> 8) & 0xff,  \
+   (c) & 0xff, ((c) >> 8) & 0xff,  \
+   (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
 
 #define UUID_SIZE 16
 
@@ -84,12 +96,18 @@ int guid_parse(const char *uuid, guid_t *u);
 int uuid_parse(const char *uuid, uuid_t *u);
 
 /* backwards compatibility, don't use in new code */
+typedef guid_t uuid_le;
 typedef uuid_t uuid_be;
 #define UUID_BE(a, _b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
UUID_INIT(a, _b, c, d0, d1, d2, d3, d4, d5, d6, d7)
+#define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)   \
+   GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)
 #define NULL_UUID_BE   \
UUID_BE(0x, 0x, 0x, 0x00, 0x00, 0x00, 0x00, \
 0x00, 0x00, 0x00, 0x00)
+#define NULL_UUID_LE   \
+   UUID_LE(0x, 0x, 0x, 0x00, 0x00, 0x00, 0x00, \
+0x00, 0x00, 0x00, 0x00)
 
 #define uuid_le_gen(u) guid_gen(u)
 #define uuid_be_gen(u) uuid_gen(u)
diff --git a/include/uapi/linux/uuid.h b/include/uapi/linux/uuid.h
deleted file mode 100644
index 8ef82f433877..
--- a/include/uapi/linux/uuid.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * UUID/GUID definition
- *
- * Copyright (C) 2010, Intel Corp.
- * Huang Ying 
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version
- * 2 as published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#ifndef _UAPI_LINUX_UUID_H_
-#define _UAPI_LINUX_UUID_H_
-
-#include 
-#include 
-
-typedef struct {
-   __u8 b[16];
-} guid_t;
-
-#define GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) 
\
-((guid_t)  \
-{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
-   (b) & 0xff, ((b) >> 8) & 0xff,  \
-   (c) & 0xff, ((c) >> 8) & 0xff,  \
-   (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
-
-/* backwards compatibility, don't use in new code */
-typedef guid_t uuid_le;
-#define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)   \
-   GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)
-#define NULL_UUID_LE   \
-   UUID_LE(0x, 0x, 0x, 0x00, 0x00, 0x00, 0x00, \
-0x00, 0x00, 0x00, 0x00)
-
-#endif /* _UAPI_LINUX_UUID_H_ */
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 29d6699d5a06..1c68709123aa 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -36,7 +36,7 @@ typedef uint16_t  __u16;
 typedef unsigned char  __u8;
 typedef struct {
__u8 b[16];
-} uuid_le;
+} guid_t;
 
 /* Big exception to the "don't include kernel headers into userspace, which
  * even potentially has different endianness and word sizes, since
@@ -134,7 +134,7 @@ static inline void add_wildcard(char *str)
strcat(str + len, "*");
 }
 
-static inline void add_uuid(char *str, uuid_le uuid)
+static inline void add_uuid(char *str, guid_t uuid)
 {
int len = strlen(str);
 
-- 
2.11.0



[PATCH v1 0/6] uuid: Convert rest users to new API

2017-07-19 Thread Andy Shevchenko
This series is converting the rest of the users of old UUID API to a new
one and dropping UUID UAPI header away. Note, ABI is kept the same.

User space should have not used those headers. We have libuuid and it
likely would be extended to cover GUID operations.

All patches have been compiled tested on x86_64 machine.

The series is supposed to go via UUID tree with immutable branch
(in case we have new users of obsolete API).

I dunno if it's a good idea to put them to v4.13-rc2 where first part of
the changes is applied.

Cc: Matt Fleming 
Cc: Ard Biesheuvel 
Cc: Tomas Winkler 
Cc: Samuel Ortiz 
Cc: Guenter Roeck 
Cc: David Kershner 
Cc: Greg Kroah-Hartman 
Cc: "K. Y. Srinivasan" 
Cc: Haiyang Zhang 
Cc: Stephen Hemminger 
Cc: "Rafael J. Wysocki" 
Cc: Len Brown 


Andy Shevchenko (6):
  efi: Switch to use new generic UUID API
  mei: Switch to use new generic UUID API
  staging: unisys: Switch to use new generic UUID API
  vmbus: Switch to use new generic UUID API
  uuid: Kill uapi/uuid.h
  device property: Switch to use new generic UUID API

 drivers/acpi/property.c| 50 +--
 drivers/firmware/efi/cper.c| 10 +--
 drivers/hv/channel.c   |  4 +-
 drivers/hv/channel_mgmt.c  | 18 ++--
 drivers/hv/hyperv_vmbus.h  |  4 +-
 drivers/hv/vmbus_drv.c | 43 --
 drivers/misc/mei/bus-fixup.c   | 35 
 drivers/misc/mei/bus.c | 14 ++--
 drivers/misc/mei/client.c  | 21 +++--
 drivers/misc/mei/client.h  | 12 +--
 drivers/misc/mei/hbm.c |  2 +-
 drivers/misc/mei/hw.h  |  2 +-
 drivers/misc/mei/main.c|  2 +-
 drivers/nfc/mei_phy.h  |  5 +-
 drivers/staging/unisys/Documentation/overview.txt  | 14 ++--
 drivers/staging/unisys/include/channel.h   | 45 +-
 drivers/staging/unisys/include/iochannel.h | 14 +---
 drivers/staging/unisys/include/visorbus.h  | 12 +--
 drivers/staging/unisys/visorbus/controlvmchannel.h | 24 ++
 drivers/staging/unisys/visorbus/vbuschannel.h  |  7 +-
 drivers/staging/unisys/visorbus/visorbus_main.c| 28 +++
 drivers/staging/unisys/visorbus/visorbus_private.h |  6 +-
 drivers/staging/unisys/visorbus/visorchannel.c | 48 +--
 drivers/staging/unisys/visorbus/visorchipset.c | 39 +
 drivers/staging/unisys/visorhba/visorhba_main.c|  6 +-
 drivers/staging/unisys/visorinput/visorinput.c | 38 -
 drivers/staging/unisys/visornic/visornic_main.c|  6 +-
 drivers/watchdog/mei_wdt.c |  5 +-
 include/linux/cper.h   | 94 ++---
 include/linux/efi.h|  4 +-
 include/linux/hyperv.h | 98 +++---
 include/linux/mei_cl_bus.h |  2 +-
 include/linux/mod_devicetable.h|  8 +-
 include/linux/uuid.h   | 20 -
 include/uapi/linux/hyperv.h|  6 +-
 include/uapi/linux/mei.h   |  4 +-
 include/uapi/linux/uuid.h  | 42 --
 samples/mei/mei-amt-version.c  | 21 -
 scripts/mod/file2alias.c   |  4 +-
 39 files changed, 387 insertions(+), 430 deletions(-)
 delete mode 100644 include/uapi/linux/uuid.h

-- 
2.11.0



[PATCH v1 2/6] mei: Switch to use new generic UUID API

2017-07-19 Thread Andy Shevchenko
There are new types and helpers that are supposed to be used in new code.

As a preparation to get rid of legacy types and API functions do
the conversion here.

Cc: Tomas Winkler 
Cc: Guenter Roeck 
Cc: Samuel Ortiz 
Signed-off-by: Andy Shevchenko 
---
 drivers/misc/mei/bus-fixup.c| 35 +++
 drivers/misc/mei/bus.c  | 14 +++---
 drivers/misc/mei/client.c   | 21 ++---
 drivers/misc/mei/client.h   | 12 ++--
 drivers/misc/mei/hbm.c  |  2 +-
 drivers/misc/mei/hw.h   |  2 +-
 drivers/misc/mei/main.c |  2 +-
 drivers/nfc/mei_phy.h   |  5 +++--
 drivers/watchdog/mei_wdt.c  |  5 +++--
 include/linux/mei_cl_bus.h  |  2 +-
 include/linux/mod_devicetable.h |  6 +++---
 include/uapi/linux/mei.h|  4 +---
 samples/mei/mei-amt-version.c   | 21 +
 13 files changed, 73 insertions(+), 58 deletions(-)

diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c
index 0208c4b027c5..9eaac4f2d427 100644
--- a/drivers/misc/mei/bus-fixup.c
+++ b/drivers/misc/mei/bus-fixup.c
@@ -27,21 +27,27 @@
 #include "mei_dev.h"
 #include "client.h"
 
-#define MEI_UUID_NFC_INFO UUID_LE(0xd2de1625, 0x382d, 0x417d, \
-   0x48, 0xa4, 0xef, 0xab, 0xba, 0x8a, 0x12, 0x06)
+#define MEI_UUID_NFC_INFO  \
+   GUID_INIT(0xd2de1625, 0x382d, 0x417d,   \
+ 0x48, 0xa4, 0xef, 0xab, 0xba, 0x8a, 0x12, 0x06)
 
-static const uuid_le mei_nfc_info_guid = MEI_UUID_NFC_INFO;
+static const guid_t mei_nfc_info_guid = MEI_UUID_NFC_INFO;
 
-#define MEI_UUID_NFC_HCI UUID_LE(0x0bb17a78, 0x2a8e, 0x4c50, \
-   0x94, 0xd4, 0x50, 0x26, 0x67, 0x23, 0x77, 0x5c)
+#define MEI_UUID_NFC_HCI   \
+   GUID_INIT(0x0bb17a78, 0x2a8e, 0x4c50,   \
+ 0x94, 0xd4, 0x50, 0x26, 0x67, 0x23, 0x77, 0x5c)
 
-#define MEI_UUID_WD UUID_LE(0x05B79A6F, 0x4628, 0x4D7F, \
-   0x89, 0x9D, 0xA9, 0x15, 0x14, 0xCB, 0x32, 0xAB)
+#define MEI_UUID_WD\
+   GUID_INIT(0x05B79A6F, 0x4628, 0x4D7F,   \
+ 0x89, 0x9D, 0xA9, 0x15, 0x14, 0xCB, 0x32, 0xAB)
 
-#define MEI_UUID_MKHIF_FIX UUID_LE(0x55213584, 0x9a29, 0x4916, \
-   0xba, 0xdf, 0xf, 0xb7, 0xed, 0x68, 0x2a, 0xeb)
+#define MEI_UUID_MKHIF_FIX \
+   GUID_INIT(0x55213584, 0x9a29, 0x4916,   \
+ 0xba, 0xdf, 0x0f, 0xb7, 0xed, 0x68, 0x2a, 0xeb)
 
-#define MEI_UUID_ANY NULL_UUID_LE
+#define MEI_UUID_ANY   \
+   GUID_INIT(0x, 0x, 0x,   \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
 
 /**
  * number_of_connections - determine whether an client be on the bus
@@ -391,7 +397,7 @@ static void mei_nfc(struct mei_cl_device *cldev)
 
 static struct mei_fixup {
 
-   const uuid_le uuid;
+   const guid_t uuid;
void (*hook)(struct mei_cl_device *cldev);
 } mei_fixups[] = {
MEI_FIXUP(MEI_UUID_ANY, number_of_connections),
@@ -409,15 +415,12 @@ static struct mei_fixup {
 void mei_cl_bus_dev_fixup(struct mei_cl_device *cldev)
 {
struct mei_fixup *f;
-   const uuid_le *uuid = mei_me_cl_uuid(cldev->me_cl);
+   const guid_t *uuid = mei_me_cl_uuid(cldev->me_cl);
int i;
 
for (i = 0; i < ARRAY_SIZE(mei_fixups); i++) {
-
f = &mei_fixups[i];
-   if (uuid_le_cmp(f->uuid, MEI_UUID_ANY) == 0 ||
-   uuid_le_cmp(f->uuid, *uuid) == 0)
+   if (guid_is_null(&f->uuid) || guid_equal(&f->uuid, uuid))
f->hook(cldev);
}
 }
-
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 40c79089e548..c5165f2ec842 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -417,7 +417,7 @@ EXPORT_SYMBOL_GPL(mei_cldev_set_drvdata);
  *
  * Return: me client uuid
  */
-const uuid_le *mei_cldev_uuid(const struct mei_cl_device *cldev)
+const guid_t *mei_cldev_uuid(const struct mei_cl_device *cldev)
 {
return mei_me_cl_uuid(cldev->me_cl);
 }
@@ -606,7 +606,7 @@ struct mei_cl_device_id *mei_cl_device_find(struct 
mei_cl_device *cldev,
struct mei_cl_driver *cldrv)
 {
const struct mei_cl_device_id *id;
-   const uuid_le *uuid;
+   const guid_t *uuid;
u8 version;
bool match;
 
@@ -614,8 +614,8 @@ struct mei_cl_device_id *mei_cl_device_find(struct 
mei_cl_device *cldev,
version = mei_me_cl_ver(cldev->me_cl);
 
id = cldrv->id_table;
-   while (uuid_le_cmp(NULL_UUID_LE, id->uuid)) 

[PATCH v1 3/6] staging: unisys: Switch to use new generic UUID API

2017-07-19 Thread Andy Shevchenko
There are new types and helpers that are supposed to be used in new code.

As a preparation to get rid of legacy types and API functions do
the conversion here.

While here, re-indent couple of lines to increase readability.

Cc: David Kershner 
Cc: Greg Kroah-Hartman 
Cc: sparmaintai...@unisys.com
Cc: de...@driverdev.osuosl.org
Signed-off-by: Andy Shevchenko 
---
 drivers/staging/unisys/Documentation/overview.txt  | 14 +++
 drivers/staging/unisys/include/channel.h   | 45 ++--
 drivers/staging/unisys/include/iochannel.h | 14 +--
 drivers/staging/unisys/include/visorbus.h  | 12 +++---
 drivers/staging/unisys/visorbus/controlvmchannel.h | 24 ---
 drivers/staging/unisys/visorbus/vbuschannel.h  |  7 ++--
 drivers/staging/unisys/visorbus/visorbus_main.c| 28 ++---
 drivers/staging/unisys/visorbus/visorbus_private.h |  6 +--
 drivers/staging/unisys/visorbus/visorchannel.c | 48 +++---
 drivers/staging/unisys/visorbus/visorchipset.c | 39 ++
 drivers/staging/unisys/visorhba/visorhba_main.c|  6 +--
 drivers/staging/unisys/visorinput/visorinput.c | 38 -
 drivers/staging/unisys/visornic/visornic_main.c|  6 +--
 13 files changed, 135 insertions(+), 152 deletions(-)

diff --git a/drivers/staging/unisys/Documentation/overview.txt 
b/drivers/staging/unisys/Documentation/overview.txt
index e0466bfada2f..9ab30af265a5 100644
--- a/drivers/staging/unisys/Documentation/overview.txt
+++ b/drivers/staging/unisys/Documentation/overview.txt
@@ -221,7 +221,7 @@ The following files exist under 
/sys/devices/visorbus/vbus:dev:
 
 The visorhba driver registers with visorbus as the function driver to
 handle virtual scsi disk devices, specified using the
-VISOR_VHBA_CHANNEL_UUID type in the visorbus_register_visor_driver()
+VISOR_VHBA_CHANNEL_GUID type in the visorbus_register_visor_driver()
 call. visorhba uses scsi_add_host() to expose a Linux block device
 (e.g., /sys/block/) in the guest environment for each s-Par virtual device.
 
@@ -240,7 +240,7 @@ When compiled as a module, visorhba can be autoloaded by 
visorbus in
 standard udev/systemd environments, as it includes the modules.alias
 definition:
 
-"visorbus:"+VISOR_VHBA_CHANNEL_UUID_STR
+"visorbus:"+VISOR_VHBA_CHANNEL_GUID_STR
 
 i.e.:
 
@@ -252,7 +252,7 @@ i.e.:
 
 The visornic driver registers with visorbus as the function driver to
 handle virtual network devices, specified using the
-VISOR_VNIC_CHANNEL_UUID type in the visorbus_register_visor_driver()
+VISOR_VNIC_CHANNEL_GUID type in the visorbus_register_visor_driver()
 call. visornic uses register_netdev() to expose a Linux device of class net
 (e.g., /sys/class/net/) in the guest environment for each s-Par virtual
 device.
@@ -270,7 +270,7 @@ When compiled as a module, visornic can be autoloaded by 
visorbus in
 standard udev/systemd environments, as it includes the modules.alias
 definition:
 
-"visorbus:"+VISOR_VNIC_CHANNEL_UUID_STR
+"visorbus:"+VISOR_VNIC_CHANNEL_GUID_STR
 
 i.e.:
 
@@ -282,7 +282,7 @@ i.e.:
 
 The visorinput driver registers with visorbus as the function driver to
 handle human input devices, specified using the
-VISOR_KEYBOARD_CHANNEL_UUID and VISOR_MOUSE_CHANNEL_UUID
+VISOR_KEYBOARD_CHANNEL_GUID and VISOR_MOUSE_CHANNEL_GUID
 types in the visorbus_register_visor_driver() call. visorinput uses
 input_register_device() to expose devices of class input
 (e.g., /sys/class/input/) for virtual keyboard and virtual mouse devices.
@@ -307,8 +307,8 @@ When compiled as a module, visorinput can be autoloaded by 
visorbus in
 standard udev/systemd environments, as it includes the modules.alias
 definition:
 
-"visorbus:"+VISOR_MOUSE_CHANNEL_UUID_STR
-"visorbus:"+VISOR_KEYBOARD_CHANNEL_UUID_STR
+"visorbus:"+VISOR_MOUSE_CHANNEL_GUID_STR
+"visorbus:"+VISOR_KEYBOARD_CHANNEL_GUID_STR
 
 i.e.:
 
diff --git a/drivers/staging/unisys/include/channel.h 
b/drivers/staging/unisys/include/channel.h
index 692efcb38245..b09b1f55a6f1 100644
--- a/drivers/staging/unisys/include/channel.h
+++ b/drivers/staging/unisys/include/channel.h
@@ -116,13 +116,13 @@ struct channel_header {
u32 header_size;/* sizeof(struct channel_header) */
u64 size;   /* Total size of this channel in bytes */
u64 features;   /* Flags to modify behavior */
-   uuid_le chtype; /* Channel type: data, bus, control, etc. */
+   guid_t chtype;  /* Channel type: data, bus, control, etc. */
u64 partition_handle;   /* ID of guest partition */
u64 handle; /* Device number of this channel in client */
u64 ch_space_offset;/* Offset in bytes to channel specific area */
u32 version_id; /* struct channel_header Version ID */
u32 partition_index;/* Index of guest partitio

[PATCH v1 1/6] efi: Switch to use new generic UUID API

2017-07-19 Thread Andy Shevchenko
There are new types and helpers that are supposed to be used in new code.

As a preparation to get rid of legacy types and API functions do
the conversion here.

Cc: Matt Fleming 
Cc: Ard Biesheuvel 
Signed-off-by: Andy Shevchenko 
---
 drivers/firmware/efi/cper.c | 10 ++---
 include/linux/cper.h| 94 ++---
 include/linux/efi.h |  4 +-
 3 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
index 48a8f69da42a..684e65c11dde 100644
--- a/drivers/firmware/efi/cper.c
+++ b/drivers/firmware/efi/cper.c
@@ -534,7 +534,7 @@ static void
 cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data 
*gdata,
   int sec_no)
 {
-   uuid_le *sec_type = (uuid_le *)gdata->section_type;
+   guid_t *sec_type = (guid_t *)gdata->section_type;
__u16 severity;
char newpfx[64];
 
@@ -545,12 +545,12 @@ cper_estatus_print_section(const char *pfx, struct 
acpi_hest_generic_data *gdata
printk("%s""Error %d, type: %s\n", pfx, sec_no,
   cper_severity_str(severity));
if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
-   printk("%s""fru_id: %pUl\n", pfx, (uuid_le *)gdata->fru_id);
+   printk("%s""fru_id: %pUl\n", pfx, gdata->fru_id);
if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
printk("%s""fru_text: %.20s\n", pfx, gdata->fru_text);
 
snprintf(newpfx, sizeof(newpfx), "%s%s", pfx, INDENT_SP);
-   if (!uuid_le_cmp(*sec_type, CPER_SEC_PROC_GENERIC)) {
+   if (guid_equal(sec_type, &CPER_SEC_PROC_GENERIC)) {
struct cper_sec_proc_generic *proc_err = 
acpi_hest_get_payload(gdata);
 
printk("%s""section_type: general processor error\n", newpfx);
@@ -558,7 +558,7 @@ cper_estatus_print_section(const char *pfx, struct 
acpi_hest_generic_data *gdata
cper_print_proc_generic(newpfx, proc_err);
else
goto err_section_too_small;
-   } else if (!uuid_le_cmp(*sec_type, CPER_SEC_PLATFORM_MEM)) {
+   } else if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
struct cper_sec_mem_err *mem_err = acpi_hest_get_payload(gdata);
 
printk("%s""section_type: memory error\n", newpfx);
@@ -568,7 +568,7 @@ cper_estatus_print_section(const char *pfx, struct 
acpi_hest_generic_data *gdata
   gdata->error_data_length);
else
goto err_section_too_small;
-   } else if (!uuid_le_cmp(*sec_type, CPER_SEC_PCIE)) {
+   } else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
struct cper_sec_pcie *pcie = acpi_hest_get_payload(gdata);
 
printk("%s""section_type: PCIe error\n", newpfx);
diff --git a/include/linux/cper.h b/include/linux/cper.h
index 4c671fc2081e..723e952fde0d 100644
--- a/include/linux/cper.h
+++ b/include/linux/cper.h
@@ -74,36 +74,36 @@ enum {
  * Corrected Machine Check
  */
 #define CPER_NOTIFY_CMC
\
-   UUID_LE(0x2DCE8BB1, 0xBDD7, 0x450e, 0xB9, 0xAD, 0x9C, 0xF4, \
-   0xEB, 0xD4, 0xF8, 0x90)
+   GUID_INIT(0x2DCE8BB1, 0xBDD7, 0x450e, 0xB9, 0xAD, 0x9C, 0xF4,   \
+ 0xEB, 0xD4, 0xF8, 0x90)
 /* Corrected Platform Error */
 #define CPER_NOTIFY_CPE
\
-   UUID_LE(0x4E292F96, 0xD843, 0x4a55, 0xA8, 0xC2, 0xD4, 0x81, \
-   0xF2, 0x7E, 0xBE, 0xEE)
+   GUID_INIT(0x4E292F96, 0xD843, 0x4a55, 0xA8, 0xC2, 0xD4, 0x81,   \
+ 0xF2, 0x7E, 0xBE, 0xEE)
 /* Machine Check Exception */
 #define CPER_NOTIFY_MCE
\
-   UUID_LE(0xE8F56FFE, 0x919C, 0x4cc5, 0xBA, 0x88, 0x65, 0xAB, \
-   0xE1, 0x49, 0x13, 0xBB)
+   GUID_INIT(0xE8F56FFE, 0x919C, 0x4cc5, 0xBA, 0x88, 0x65, 0xAB,   \
+ 0xE1, 0x49, 0x13, 0xBB)
 /* PCI Express Error */
 #define CPER_NOTIFY_PCIE   \
-   UUID_LE(0xCF93C01F, 0x1A16, 0x4dfc, 0xB8, 0xBC, 0x9C, 0x4D, \
-   0xAF, 0x67, 0xC1, 0x04)
+   GUID_INIT(0xCF93C01F, 0x1A16, 0x4dfc, 0xB8, 0xBC, 0x9C, 0x4D,   \
+ 0xAF, 0x67, 0xC1, 0x04)
 /* INIT Record (for IPF) */
 #define CPER_NOTIFY_INIT   \
-   UUID_LE(0xCC5263E8, 0x9308, 0x454a, 0x89, 0xD0, 0x34, 0x0B, \
-   0xD3, 0x9B, 0xC9, 0x8E)
+   GUID_INIT(0xCC5263E8, 0x9308, 0x454a, 0x89, 0xD0, 0x34, 0x0B,   \
+ 0xD3, 0x9B, 0xC9, 0x8E)
 /* Non-Maskable Interrupt */
 

[PATCH v1 6/6] device property: Switch to use new generic UUID API

2017-07-19 Thread Andy Shevchenko
There are new types and helpers that are supposed to be used in new code.

As a preparation to get rid of legacy types and API functions do
the conversion here.

Cc: "Rafael J. Wysocki" 
Cc: Mika Westerberg 
Cc: linux-a...@vger.kernel.org
Signed-off-by: Andy Shevchenko 
---
 drivers/acpi/property.c | 50 -
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 917c789f953d..a7fdbe083a7e 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -24,16 +24,14 @@ static int acpi_data_get_property_array(struct 
acpi_device_data *data,
acpi_object_type type,
const union acpi_object **obj);
 
-/* ACPI _DSD device properties UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301 */
-static const u8 prp_uuid[16] = {
-   0x14, 0xd8, 0xff, 0xda, 0xba, 0x6e, 0x8c, 0x4d,
-   0x8a, 0x91, 0xbc, 0x9b, 0xbf, 0x4a, 0xa3, 0x01
-};
-/* ACPI _DSD data subnodes UUID: dbb8e3e6-5886-4ba6-8795-1319f52a966b */
-static const u8 ads_uuid[16] = {
-   0xe6, 0xe3, 0xb8, 0xdb, 0x86, 0x58, 0xa6, 0x4b,
-   0x87, 0x95, 0x13, 0x19, 0xf5, 0x2a, 0x96, 0x6b
-};
+/* ACPI _DSD device properties GUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301 */
+static const guid_t prp_guid =
+   GUID_INIT(0xdaffd814, 0x6eba, 0x4d8c,
+ 0x8a, 0x91, 0xbc, 0x9b, 0xbf, 0x4a, 0xa3, 0x01);
+/* ACPI _DSD data subnodes GUID: dbb8e3e6-5886-4ba6-8795-1319f52a966b */
+static const guid_t ads_guid =
+   GUID_INIT(0xdbb8e3e6, 0x5886, 0x4ba6,
+ 0x87, 0x95, 0x13, 0x19, 0xf5, 0x2a, 0x96, 0x6b);
 
 static bool acpi_enumerate_nondev_subnodes(acpi_handle scope,
   const union acpi_object *desc,
@@ -190,22 +188,23 @@ static bool acpi_enumerate_nondev_subnodes(acpi_handle 
scope,
 {
int i;
 
-   /* Look for the ACPI data subnodes UUID. */
+   /* Look for the ACPI data subnodes GUID. */
for (i = 0; i < desc->package.count; i += 2) {
-   const union acpi_object *uuid, *links;
+   const union acpi_object *guid, *links;
 
-   uuid = &desc->package.elements[i];
+   guid = &desc->package.elements[i];
links = &desc->package.elements[i + 1];
 
/*
-* The first element must be a UUID and the second one must be
+* The first element must be a GUID and the second one must be
 * a package.
 */
-   if (uuid->type != ACPI_TYPE_BUFFER || uuid->buffer.length != 16
-   || links->type != ACPI_TYPE_PACKAGE)
+   if (guid->type != ACPI_TYPE_BUFFER ||
+   guid->buffer.length != 16 ||
+   links->type != ACPI_TYPE_PACKAGE)
break;
 
-   if (memcmp(uuid->buffer.pointer, ads_uuid, sizeof(ads_uuid)))
+   if (!guid_equal((guid_t *)guid->buffer.pointer, &ads_guid))
continue;
 
return acpi_add_nondev_subnodes(scope, links, &data->subnodes,
@@ -298,26 +297,27 @@ static bool acpi_extract_properties(const union 
acpi_object *desc,
if (desc->package.count % 2)
return false;
 
-   /* Look for the device properties UUID. */
+   /* Look for the device properties GUID. */
for (i = 0; i < desc->package.count; i += 2) {
-   const union acpi_object *uuid, *properties;
+   const union acpi_object *guid, *properties;
 
-   uuid = &desc->package.elements[i];
+   guid = &desc->package.elements[i];
properties = &desc->package.elements[i + 1];
 
/*
-* The first element must be a UUID and the second one must be
+* The first element must be a GUID and the second one must be
 * a package.
 */
-   if (uuid->type != ACPI_TYPE_BUFFER || uuid->buffer.length != 16
-   || properties->type != ACPI_TYPE_PACKAGE)
+   if (guid->type != ACPI_TYPE_BUFFER ||
+   guid->buffer.length != 16 ||
+   properties->type != ACPI_TYPE_PACKAGE)
break;
 
-   if (memcmp(uuid->buffer.pointer, prp_uuid, sizeof(prp_uuid)))
+   if (!guid_equal((guid_t *)guid->buffer.pointer, &prp_guid))
continue;
 
/*
-* We found the matching UUID. Now validate the format of the
+* We found the matching GUID. Now validate the format of the
 * package immediately following it.
 */
if (!acpi_properties_format_valid(properties))
-- 
2.11.0



[PATCH v1 4/6] vmbus: Switch to use new generic UUID API

2017-07-19 Thread Andy Shevchenko
There are new types and helpers that are supposed to be used in new code.

As a preparation to get rid of legacy types and API functions do
the conversion here.

Cc: "K. Y. Srinivasan" 
Cc: Haiyang Zhang 
Cc: Stephen Hemminger 
Cc: de...@linuxdriverproject.org
Signed-off-by: Andy Shevchenko 
---
 drivers/hv/channel.c|  4 +-
 drivers/hv/channel_mgmt.c   | 18 
 drivers/hv/hyperv_vmbus.h   |  4 +-
 drivers/hv/vmbus_drv.c  | 43 ++
 include/linux/hyperv.h  | 98 -
 include/linux/mod_devicetable.h |  2 +-
 include/uapi/linux/hyperv.h |  6 +--
 7 files changed, 79 insertions(+), 96 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index e9bf0bb87ac4..ecc11df389e1 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -225,8 +225,8 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 
send_ringbuffer_size,
 EXPORT_SYMBOL_GPL(vmbus_open);
 
 /* Used for Hyper-V Socket: a guest client's connect() to the host */
-int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id,
- const uuid_le *shv_host_servie_id)
+int vmbus_send_tl_connect_request(const guid_t *shv_guest_servie_id,
+ const guid_t *shv_host_servie_id)
 {
struct vmbus_channel_tl_connect_request conn_msg;
 
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 4bbb8dea4727..28550e1e2cec 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -141,7 +141,7 @@ static const struct vmbus_device vmbus_devs[] = {
 };
 
 static const struct {
-   uuid_le guid;
+   guid_t guid;
 } vmbus_unsupported_devs[] = {
{ HV_AVMA1_GUID },
{ HV_AVMA2_GUID },
@@ -171,26 +171,26 @@ static void vmbus_rescind_cleanup(struct vmbus_channel 
*channel)
spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 }
 
-static bool is_unsupported_vmbus_devs(const uuid_le *guid)
+static bool is_unsupported_vmbus_devs(const guid_t *guid)
 {
int i;
 
for (i = 0; i < ARRAY_SIZE(vmbus_unsupported_devs); i++)
-   if (!uuid_le_cmp(*guid, vmbus_unsupported_devs[i].guid))
+   if (guid_equal(guid, &vmbus_unsupported_devs[i].guid))
return true;
return false;
 }
 
 static u16 hv_get_dev_type(const struct vmbus_channel *channel)
 {
-   const uuid_le *guid = &channel->offermsg.offer.if_type;
+   const guid_t *guid = &channel->offermsg.offer.if_type;
u16 i;
 
if (is_hvsock_channel(channel) || is_unsupported_vmbus_devs(guid))
return HV_UNKNOWN;
 
for (i = HV_IDE; i < HV_UNKNOWN; i++) {
-   if (!uuid_le_cmp(*guid, vmbus_devs[i].guid))
+   if (guid_equal(guid, &vmbus_devs[i].guid))
return i;
}
pr_info("Unknown GUID: %pUl\n", guid);
@@ -452,10 +452,10 @@ static void vmbus_process_offer(struct vmbus_channel 
*newchannel)
mutex_lock(&vmbus_connection.channel_mutex);
 
list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
-   if (!uuid_le_cmp(channel->offermsg.offer.if_type,
-   newchannel->offermsg.offer.if_type) &&
-   !uuid_le_cmp(channel->offermsg.offer.if_instance,
-   newchannel->offermsg.offer.if_instance)) {
+   if (guid_equal(&channel->offermsg.offer.if_type,
+   &newchannel->offermsg.offer.if_type) &&
+   guid_equal(&channel->offermsg.offer.if_instance,
+   &newchannel->offermsg.offer.if_instance)) {
fnew = false;
break;
}
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 1b6a5e0dfa75..e32a816a55d1 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -378,8 +378,8 @@ extern const struct vmbus_channel_message_table_entry
 
 /* General vmbus interface */
 
-struct hv_device *vmbus_device_create(const uuid_le *type,
- const uuid_le *instance,
+struct hv_device *vmbus_device_create(const guid_t *type,
+ const guid_t *instance,
  struct vmbus_channel *channel);
 
 int vmbus_device_register(struct hv_device *child_device_obj);
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index ed84e96715a0..04e3acddebd4 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -535,21 +535,12 @@ static int vmbus_uevent(struct device *device, struct 
kobj_uevent_env *env)
return ret;
 }
 
-static const uuid_le null_guid;
-
-static inline bool is_null_guid(const uuid_le *guid)
-{
-  

[PATCH v3 10/13] NFC: st-nci: Use unified device properties API meaningfully

2017-06-19 Thread Andy Shevchenko
Use unified device properties API in meaningful way.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/st-nci/i2c.c | 30 ++
 drivers/nfc/st-nci/spi.c | 29 +
 2 files changed, 11 insertions(+), 48 deletions(-)

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index 93a621e27d4e..2ee381586f14 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -209,7 +209,6 @@ static int st_nci_i2c_acpi_request_resources(struct 
i2c_client *client)
 {
struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
struct device *dev = &client->dev;
-   u8 tmp;
 
/* Get RESET GPIO from ACPI */
phy->gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET,
@@ -219,19 +218,6 @@ static int st_nci_i2c_acpi_request_resources(struct 
i2c_client *client)
return -ENODEV;
}
 
-   phy->se_status.is_ese_present = false;
-   phy->se_status.is_uicc_present = false;
-
-   if (device_property_present(dev, "ese-present")) {
-   device_property_read_u8(dev, "ese-present", &tmp);
-   phy->se_status.is_ese_present = tmp;
-   }
-
-   if (device_property_present(dev, "uicc-present")) {
-   device_property_read_u8(dev, "uicc-present", &tmp);
-   phy->se_status.is_uicc_present = tmp;
-   }
-
return 0;
 }
 
@@ -239,11 +225,6 @@ static int st_nci_i2c_of_request_resources(struct 
i2c_client *client)
 {
struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
struct device *dev = &client->dev;
-   struct device_node *pp;
-
-   pp = client->dev.of_node;
-   if (!pp)
-   return -ENODEV;
 
/* Get GPIO from device tree */
phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
@@ -252,17 +233,13 @@ static int st_nci_i2c_of_request_resources(struct 
i2c_client *client)
return PTR_ERR(phy->gpiod_reset);
}
 
-   phy->se_status.is_ese_present =
-   of_property_read_bool(pp, "ese-present");
-   phy->se_status.is_uicc_present =
-   of_property_read_bool(pp, "uicc-present");
-
return 0;
 }
 
 static int st_nci_i2c_probe(struct i2c_client *client,
  const struct i2c_device_id *id)
 {
+   struct device *dev = &client->dev;
struct st_nci_i2c_phy *phy;
int r;
 
@@ -301,6 +278,11 @@ static int st_nci_i2c_probe(struct i2c_client *client,
return -ENODEV;
}
 
+   phy->se_status.is_ese_present =
+   device_property_read_bool(dev, "ese-present");
+   phy->se_status.is_uicc_present =
+   device_property_read_bool(dev, "uicc-present");
+
r = ndlc_probe(phy, &i2c_phy_ops, &client->dev,
ST_NCI_FRAME_HEADROOM, ST_NCI_FRAME_TAILROOM,
&phy->ndlc, &phy->se_status);
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index 2834f6984608..383bf69163ef 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -224,7 +224,6 @@ static int st_nci_spi_acpi_request_resources(struct 
spi_device *spi_dev)
 {
struct st_nci_spi_phy *phy = spi_get_drvdata(spi_dev);
struct device *dev = &spi_dev->dev;
-   u8 tmp;
 
/* Get RESET GPIO from ACPI */
phy->gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET,
@@ -234,19 +233,6 @@ static int st_nci_spi_acpi_request_resources(struct 
spi_device *spi_dev)
return PTR_ERR(phy->gpiod_reset);
}
 
-   phy->se_status.is_ese_present = false;
-   phy->se_status.is_uicc_present = false;
-
-   if (device_property_present(dev, "ese-present")) {
-   device_property_read_u8(dev, "ese-present", &tmp);
-   tmp = phy->se_status.is_ese_present;
-   }
-
-   if (device_property_present(dev, "uicc-present")) {
-   device_property_read_u8(dev, "uicc-present", &tmp);
-   tmp = phy->se_status.is_uicc_present;
-   }
-
return 0;
 }
 
@@ -254,11 +240,6 @@ static int st_nci_spi_of_request_resources(struct 
spi_device *spi)
 {
struct st_nci_spi_phy *phy = spi_get_drvdata(spi);
struct device *dev = &spi->dev;
-   struct device_node *pp;
-
-   pp = spi->dev.of_node;
-   if (!pp)
-   return -ENODEV;
 
/* Get GPIO from device tree */
phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
@@ -267,11 +248,6 @@ static int st_nci_spi_of_request_resources(struct 
spi_device *spi)

[PATCH v3 09/13] NFC: st-nci: Covert to use GPIO descriptor

2017-06-19 Thread Andy Shevchenko
Since we got rid of platform data, the driver may use GPIO descriptor
directly.

Looking deeply to the use of the GPIO pin it looks like it should be
a GPIO based reset control rather than custom GPIO handling. But this
is out of scope of the change.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/st-nci/i2c.c | 39 ---
 drivers/nfc/st-nci/spi.c | 47 ---
 2 files changed, 28 insertions(+), 58 deletions(-)

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index bdfbd543e671..93a621e27d4e 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -19,13 +19,12 @@
 
 #include 
 #include 
-#include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include "st-nci.h"
 
@@ -49,7 +48,7 @@ struct st_nci_i2c_phy {
 
bool irq_active;
 
-   unsigned int gpio_reset;
+   struct gpio_desc *gpiod_reset;
 
struct st_nci_se_status se_status;
 };
@@ -58,9 +57,9 @@ static int st_nci_i2c_enable(void *phy_id)
 {
struct st_nci_i2c_phy *phy = phy_id;
 
-   gpio_set_value(phy->gpio_reset, 0);
+   gpiod_set_value(phy->gpiod_reset, 0);
usleep_range(1, 15000);
-   gpio_set_value(phy->gpio_reset, 1);
+   gpiod_set_value(phy->gpiod_reset, 1);
usleep_range(8, 85000);
 
if (phy->ndlc->powered == 0 && phy->irq_active == 0) {
@@ -209,20 +208,17 @@ static struct nfc_phy_ops i2c_phy_ops = {
 static int st_nci_i2c_acpi_request_resources(struct i2c_client *client)
 {
struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
-   struct gpio_desc *gpiod_reset;
struct device *dev = &client->dev;
u8 tmp;
 
/* Get RESET GPIO from ACPI */
-   gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET, 1,
-  GPIOD_OUT_HIGH);
-   if (IS_ERR(gpiod_reset)) {
+   phy->gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET,
+   1, GPIOD_OUT_HIGH);
+   if (IS_ERR(phy->gpiod_reset)) {
nfc_err(dev, "Unable to get RESET GPIO\n");
return -ENODEV;
}
 
-   phy->gpio_reset = desc_to_gpio(gpiod_reset);
-
phy->se_status.is_ese_present = false;
phy->se_status.is_uicc_present = false;
 
@@ -242,30 +238,19 @@ static int st_nci_i2c_acpi_request_resources(struct 
i2c_client *client)
 static int st_nci_i2c_of_request_resources(struct i2c_client *client)
 {
struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
+   struct device *dev = &client->dev;
struct device_node *pp;
-   int gpio;
-   int r;
 
pp = client->dev.of_node;
if (!pp)
return -ENODEV;
 
/* Get GPIO from device tree */
-   gpio = of_get_named_gpio(pp, "reset-gpios", 0);
-   if (gpio < 0) {
-   nfc_err(&client->dev,
-   "Failed to retrieve reset-gpios from device tree\n");
-   return gpio;
-   }
-
-   /* GPIO request and configuration */
-   r = devm_gpio_request_one(&client->dev, gpio,
-   GPIOF_OUT_INIT_HIGH, ST_NCI_GPIO_NAME_RESET);
-   if (r) {
-   nfc_err(&client->dev, "Failed to request reset pin\n");
-   return r;
+   phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+   if (IS_ERR(phy->gpiod_reset)) {
+   nfc_err(dev, "Unable to get RESET GPIO\n");
+   return PTR_ERR(phy->gpiod_reset);
}
-   phy->gpio_reset = gpio;
 
phy->se_status.is_ese_present =
of_property_read_bool(pp, "ese-present");
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index 4585e205778b..2834f6984608 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -19,13 +19,12 @@
 
 #include 
 #include 
-#include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "st-nci.h"
@@ -50,7 +49,7 @@ struct st_nci_spi_phy {
 
bool irq_active;
 
-   unsigned int gpio_reset;
+   struct gpio_desc *gpiod_reset;
 
struct st_nci_se_status se_status;
 };
@@ -59,9 +58,9 @@ static int st_nci_spi_enable(void *phy_id)
 {
struct st_nci_spi_phy *phy = phy_id;
 
-   gpio_set_value(phy->gpio_reset, 0);
+   gpiod_set_value(phy->gpiod_reset, 0);
usleep_range(1, 15000);
-   gpio_set_value(phy->gpio_reset, 1);
+   gpiod_set_value(phy->gpiod_reset, 1);
usleep_range(8, 85000);
 
if (phy->ndlc->powered == 0 && phy->irq_active == 0) {
@@ -224,20 +223,17 @@ static struct nfc_phy_ops sp

[PATCH v3 02/13] NFC: st21nfca: Add GPIO ACPI mapping table

2017-06-19 Thread Andy Shevchenko
In order to make GPIO ACPI library stricter prepare users of
gpiod_get_index() to correctly behave when there no mapping is
provided by firmware.

Here we add explicit mapping between _CRS GpioIo() resources and
their names used in the driver.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/st21nfca/i2c.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c
index 4bff76baa341..3621290807f6 100644
--- a/drivers/nfc/st21nfca/i2c.c
+++ b/drivers/nfc/st21nfca/i2c.c
@@ -501,14 +501,25 @@ static struct nfc_phy_ops i2c_phy_ops = {
.disable = st21nfca_hci_i2c_disable,
 };
 
+static const struct acpi_gpio_params enable_gpios = { 1, 0, false };
+
+static const struct acpi_gpio_mapping acpi_st21nfca_gpios[] = {
+   { "enable-gpios", &enable_gpios, 1 },
+   {},
+};
+
 static int st21nfca_hci_i2c_acpi_request_resources(struct i2c_client *client)
 {
struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client);
struct device *dev = &client->dev;
+   int ret;
+
+   ret = devm_acpi_dev_add_driver_gpios(dev, acpi_st21nfca_gpios);
+   if (ret)
+   return ret;
 
/* Get EN GPIO from ACPI */
-   phy->gpiod_ena = devm_gpiod_get_index(dev, ST21NFCA_GPIO_NAME_EN, 1,
- GPIOD_OUT_LOW);
+   phy->gpiod_ena = devm_gpiod_get(dev, ST21NFCA_GPIO_NAME_EN, 
GPIOD_OUT_LOW);
if (IS_ERR(phy->gpiod_ena)) {
nfc_err(dev, "Unable to get ENABLE GPIO\n");
return PTR_ERR(phy->gpiod_ena);
@@ -523,8 +534,7 @@ static int st21nfca_hci_i2c_of_request_resources(struct 
i2c_client *client)
struct device *dev = &client->dev;
 
/* Get GPIO from device tree */
-   phy->gpiod_ena = devm_gpiod_get_index(dev, ST21NFCA_GPIO_NAME_EN, 0,
- GPIOD_OUT_HIGH);
+   phy->gpiod_ena = devm_gpiod_get(dev, ST21NFCA_GPIO_NAME_EN, 
GPIOD_OUT_HIGH);
if (IS_ERR(phy->gpiod_ena)) {
nfc_err(dev, "Failed to request enable pin\n");
return PTR_ERR(phy->gpiod_ena);
-- 
2.11.0



[PATCH v3 04/13] NFC: fdp: Convert I2C driver to ->probe_new()

2017-06-19 Thread Andy Shevchenko
There is no platform code that uses i2c module table.
Remove it altogether and adjust ->probe() to be ->probe_new().

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/fdp/i2c.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
index e0baec848ff2..8a66b1845f27 100644
--- a/drivers/nfc/fdp/i2c.c
+++ b/drivers/nfc/fdp/i2c.c
@@ -281,8 +281,7 @@ static void fdp_nci_i2c_read_device_properties(struct 
device *dev,
*clock_type, *clock_freq, *fw_vsc_cfg != NULL ? "yes" : "no");
 }
 
-static int fdp_nci_i2c_probe(struct i2c_client *client,
-const struct i2c_device_id *id)
+static int fdp_nci_i2c_probe(struct i2c_client *client)
 {
struct fdp_i2c_phy *phy;
struct device *dev = &client->dev;
@@ -360,12 +359,6 @@ static int fdp_nci_i2c_remove(struct i2c_client *client)
return 0;
 }
 
-static struct i2c_device_id fdp_nci_i2c_id_table[] = {
-   {"int339a", 0},
-   {}
-};
-MODULE_DEVICE_TABLE(i2c, fdp_nci_i2c_id_table);
-
 static const struct acpi_device_id fdp_nci_i2c_acpi_match[] = {
{"INT339A", 0},
{}
@@ -377,8 +370,7 @@ static struct i2c_driver fdp_nci_i2c_driver = {
   .name = FDP_I2C_DRIVER_NAME,
   .acpi_match_table = ACPI_PTR(fdp_nci_i2c_acpi_match),
  },
-   .id_table = fdp_nci_i2c_id_table,
-   .probe = fdp_nci_i2c_probe,
+   .probe_new = fdp_nci_i2c_probe,
.remove = fdp_nci_i2c_remove,
 };
 module_i2c_driver(fdp_nci_i2c_driver);
-- 
2.11.0



[PATCH v3 01/13] NFC: pn544: Switch to devm_acpi_dev_add_driver_gpios()

2017-06-19 Thread Andy Shevchenko
Switch to use managed variant of acpi_dev_add_driver_gpios() to simplify
error path and fix potentially wrong assignment if ->probe() fails.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/pn544/i2c.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c
index fedde9d46ab6..4b14740edb67 100644
--- a/drivers/nfc/pn544/i2c.c
+++ b/drivers/nfc/pn544/i2c.c
@@ -904,7 +904,7 @@ static int pn544_hci_i2c_probe(struct i2c_client *client,
phy->i2c_dev = client;
i2c_set_clientdata(client, phy);
 
-   r = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_pn544_gpios);
+   r = devm_acpi_dev_add_driver_gpios(dev, acpi_pn544_gpios);
if (r)
dev_dbg(dev, "Unable to add GPIO mapping table\n");
 
@@ -958,7 +958,6 @@ static int pn544_hci_i2c_remove(struct i2c_client *client)
if (phy->powered)
pn544_hci_i2c_disable(phy);
 
-   acpi_dev_remove_driver_gpios(ACPI_COMPANION(&client->dev));
return 0;
 }
 
-- 
2.11.0



[PATCH v3 08/13] NFC: st-nci: Get rid of "interesting" use of interrupt polarity

2017-06-19 Thread Andy Shevchenko
I2C and SPI frameworks followed by IRQ framework do set
interrupt polarity correctly if it's properly specified in firmware
(ACPI or DT).

Get rid of the redundant trick when requesting interrupt.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/st-nci/i2c.c | 8 +---
 drivers/nfc/st-nci/spi.c | 8 +---
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index 6d3d8e43fa50..bdfbd543e671 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -21,7 +21,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -51,7 +50,6 @@ struct st_nci_i2c_phy {
bool irq_active;
 
unsigned int gpio_reset;
-   unsigned int irq_polarity;
 
struct st_nci_se_status se_status;
 };
@@ -225,8 +223,6 @@ static int st_nci_i2c_acpi_request_resources(struct 
i2c_client *client)
 
phy->gpio_reset = desc_to_gpio(gpiod_reset);
 
-   phy->irq_polarity = irq_get_trigger_type(client->irq);
-
phy->se_status.is_ese_present = false;
phy->se_status.is_uicc_present = false;
 
@@ -271,8 +267,6 @@ static int st_nci_i2c_of_request_resources(struct 
i2c_client *client)
}
phy->gpio_reset = gpio;
 
-   phy->irq_polarity = irq_get_trigger_type(client->irq);
-
phy->se_status.is_ese_present =
of_property_read_bool(pp, "ese-present");
phy->se_status.is_uicc_present =
@@ -333,7 +327,7 @@ static int st_nci_i2c_probe(struct i2c_client *client,
phy->irq_active = true;
r = devm_request_threaded_irq(&client->dev, client->irq, NULL,
st_nci_irq_thread_fn,
-   phy->irq_polarity | IRQF_ONESHOT,
+   IRQF_ONESHOT,
ST_NCI_DRIVER_NAME, phy);
if (r < 0)
nfc_err(&client->dev, "Unable to register IRQ handler\n");
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index ee8ea708d5b7..4585e205778b 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -21,7 +21,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -52,7 +51,6 @@ struct st_nci_spi_phy {
bool irq_active;
 
unsigned int gpio_reset;
-   unsigned int irq_polarity;
 
struct st_nci_se_status se_status;
 };
@@ -240,8 +238,6 @@ static int st_nci_spi_acpi_request_resources(struct 
spi_device *spi_dev)
 
phy->gpio_reset = desc_to_gpio(gpiod_reset);
 
-   phy->irq_polarity = irq_get_trigger_type(spi_dev->irq);
-
phy->se_status.is_ese_present = false;
phy->se_status.is_uicc_present = false;
 
@@ -286,8 +282,6 @@ static int st_nci_spi_of_request_resources(struct 
spi_device *dev)
}
phy->gpio_reset = gpio;
 
-   phy->irq_polarity = irq_get_trigger_type(dev->irq);
-
phy->se_status.is_ese_present =
of_property_read_bool(pp, "ese-present");
phy->se_status.is_uicc_present =
@@ -349,7 +343,7 @@ static int st_nci_spi_probe(struct spi_device *dev)
phy->irq_active = true;
r = devm_request_threaded_irq(&dev->dev, dev->irq, NULL,
st_nci_irq_thread_fn,
-   phy->irq_polarity | IRQF_ONESHOT,
+   IRQF_ONESHOT,
ST_NCI_SPI_DRIVER_NAME, phy);
if (r < 0)
nfc_err(&dev->dev, "Unable to register IRQ handler\n");
-- 
2.11.0



[PATCH v3 00/13] NFC: clean up for ACPI GPIO usage

2017-06-19 Thread Andy Shevchenko
This clean up series to NFC drivers that are using GPIOs on ACPI enabled
platforms. Since GPIO ACPI library goes stricter about requesting
resources we need to amend drivers for that. Here we are for NFC
subsystem.

While doing above, get rid of legacy and unused platform data as well as
some artificial IDs.

Changelog v3:
- incorporate Samuel's fixes
- fix the bug kbuild bot complains about
- add MAINTAINERS patch

Changelog v2:
- add patches 1,4-12

Andy Shevchenko (13):
  NFC: pn544: Switch to devm_acpi_dev_add_driver_gpios()
  NFC: st21nfca: Add GPIO ACPI mapping table
  NFC: st21nfca: Get rid of code duplication in ->probe()
  NFC: fdp: Convert I2C driver to ->probe_new()
  NFC: fdp: Convert to use devres API
  NFC: fdp: Add GPIO ACPI mapping table
  NFC: st-nci: Get rid of platform data
  NFC: st-nci: Get rid of "interesting" use of interrupt polarity
  NFC: st-nci: Covert to use GPIO descriptor
  NFC: st-nci: Use unified device properties API meaningfully
  NFC: st-nci: Add GPIO ACPI mapping table
  NFC: st-nci: Get rid of code duplication in ->probe()
  MAINTAINERS: Remove non-existing NFC platform data files

 MAINTAINERS  |   3 -
 drivers/nfc/fdp/fdp.c|  15 +---
 drivers/nfc/fdp/i2c.c|  38 
 drivers/nfc/pn544/i2c.c  |   3 +-
 drivers/nfc/st-nci/i2c.c | 164 ++-
 drivers/nfc/st-nci/spi.c | 162 ++
 drivers/nfc/st21nfca/i2c.c   |  62 -
 include/linux/platform_data/st-nci.h |  31 ---
 8 files changed, 90 insertions(+), 388 deletions(-)
 delete mode 100644 include/linux/platform_data/st-nci.h

-- 
2.11.0



[PATCH v3 12/13] NFC: st-nci: Get rid of code duplication in ->probe()

2017-06-19 Thread Andy Shevchenko
Since OF and ACPI case almost the same get rid of code duplication
by moving gpiod_get() calls directly to ->probe().

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/st-nci/i2c.c | 61 +++-
 drivers/nfc/st-nci/spi.c | 60 +++
 2 files changed, 18 insertions(+), 103 deletions(-)

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index edda253b07fe..515f08d037fb 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -210,41 +210,6 @@ static const struct acpi_gpio_mapping acpi_st_nci_gpios[] 
= {
{},
 };
 
-static int st_nci_i2c_acpi_request_resources(struct i2c_client *client)
-{
-   struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
-   struct device *dev = &client->dev;
-   int r;
-
-   r = devm_acpi_dev_add_driver_gpios(dev, acpi_st_nci_gpios);
-   if (r)
-   return r;
-
-   /* Get RESET GPIO from ACPI */
-   phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
-   if (IS_ERR(phy->gpiod_reset)) {
-   nfc_err(dev, "Unable to get RESET GPIO\n");
-   return -ENODEV;
-   }
-
-   return 0;
-}
-
-static int st_nci_i2c_of_request_resources(struct i2c_client *client)
-{
-   struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
-   struct device *dev = &client->dev;
-
-   /* Get GPIO from device tree */
-   phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
-   if (IS_ERR(phy->gpiod_reset)) {
-   nfc_err(dev, "Unable to get RESET GPIO\n");
-   return PTR_ERR(phy->gpiod_reset);
-   }
-
-   return 0;
-}
-
 static int st_nci_i2c_probe(struct i2c_client *client,
  const struct i2c_device_id *id)
 {
@@ -260,8 +225,7 @@ static int st_nci_i2c_probe(struct i2c_client *client,
return -ENODEV;
}
 
-   phy = devm_kzalloc(&client->dev, sizeof(struct st_nci_i2c_phy),
-  GFP_KERNEL);
+   phy = devm_kzalloc(dev, sizeof(struct st_nci_i2c_phy), GFP_KERNEL);
if (!phy)
return -ENOMEM;
 
@@ -269,21 +233,14 @@ static int st_nci_i2c_probe(struct i2c_client *client,
 
i2c_set_clientdata(client, phy);
 
-   if (client->dev.of_node) {
-   r = st_nci_i2c_of_request_resources(client);
-   if (r) {
-   nfc_err(&client->dev, "No platform data\n");
-   return r;
-   }
-   } else if (ACPI_HANDLE(&client->dev)) {
-   r = st_nci_i2c_acpi_request_resources(client);
-   if (r) {
-   nfc_err(&client->dev, "Cannot get ACPI data\n");
-   return r;
-   }
-   } else {
-   nfc_err(&client->dev,
-   "st_nci platform resources not available\n");
+   r = devm_acpi_dev_add_driver_gpios(dev, acpi_st_nci_gpios);
+   if (r)
+   dev_dbg(dev, "Unable to add GPIO mapping table\n");
+
+   /* Get RESET GPIO */
+   phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+   if (IS_ERR(phy->gpiod_reset)) {
+   nfc_err(dev, "Unable to get RESET GPIO\n");
return -ENODEV;
}
 
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index 99ecf92edc8c..14705591b0fb 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -225,41 +225,6 @@ static const struct acpi_gpio_mapping acpi_st_nci_gpios[] 
= {
{},
 };
 
-static int st_nci_spi_acpi_request_resources(struct spi_device *spi_dev)
-{
-   struct st_nci_spi_phy *phy = spi_get_drvdata(spi_dev);
-   struct device *dev = &spi_dev->dev;
-   int r;
-
-   r = devm_acpi_dev_add_driver_gpios(dev, acpi_st_nci_gpios);
-   if (r)
-   return r;
-
-   /* Get RESET GPIO from ACPI */
-   phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
-   if (IS_ERR(phy->gpiod_reset)) {
-   nfc_err(dev, "Unable to get RESET GPIO\n");
-   return PTR_ERR(phy->gpiod_reset);
-   }
-
-   return 0;
-}
-
-static int st_nci_spi_of_request_resources(struct spi_device *spi)
-{
-   struct st_nci_spi_phy *phy = spi_get_drvdata(spi);
-   struct device *dev = &spi->dev;
-
-   /* Get GPIO from device tree */
-   phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
-   if (IS_ERR(phy->gpiod_reset)) {
-   nfc_err(dev, "Unable to get RESET GPIO\n");
-   return PTR_ERR(phy->gpiod_reset);
-   }
-
-   return 0;
-}
-
 static int st_nci_spi_probe(struct spi_devi

[PATCH v3 07/13] NFC: st-nci: Get rid of platform data

2017-06-19 Thread Andy Shevchenko
Legacy platform data must go away. We are on the safe side here since
there are no users of it in the kernel.

If anyone by any odd reason needs it the GPIO lookup tables and
built-in device properties at your service.

Signed-off-by: Andy Shevchenko 
---
 MAINTAINERS  |  1 -
 drivers/nfc/st-nci/i2c.c | 43 ++--
 drivers/nfc/st-nci/spi.c | 43 ++--
 include/linux/platform_data/st-nci.h | 31 --
 4 files changed, 4 insertions(+), 114 deletions(-)
 delete mode 100644 include/linux/platform_data/st-nci.h

diff --git a/MAINTAINERS b/MAINTAINERS
index e3d41ceaf20d..6f2d96313230 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9177,7 +9177,6 @@ F:include/linux/platform_data/nfcmrvl.h
 F: include/linux/platform_data/nxp-nci.h
 F: include/linux/platform_data/pn544.h
 F: include/linux/platform_data/st21nfca.h
-F: include/linux/platform_data/st-nci.h
 F: Documentation/devicetree/bindings/net/nfc/
 
 NFS, SUNRPC, AND LOCKD CLIENTS
diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index 9dfae0efa922..6d3d8e43fa50 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -27,7 +27,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "st-nci.h"
 
@@ -40,6 +39,7 @@
 #define ST_NCI_I2C_MIN_SIZE 4   /* PCB(1) + NCI Packet header(3) */
 #define ST_NCI_I2C_MAX_SIZE 250 /* req 4.2.1 */
 
+#define ST_NCI_DRIVER_NAME "st_nci"
 #define ST_NCI_I2C_DRIVER_NAME "st_nci_i2c"
 
 #define ST_NCI_GPIO_NAME_RESET "reset"
@@ -281,41 +281,10 @@ static int st_nci_i2c_of_request_resources(struct 
i2c_client *client)
return 0;
 }
 
-static int st_nci_i2c_request_resources(struct i2c_client *client)
-{
-   struct st_nci_nfc_platform_data *pdata;
-   struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
-   int r;
-
-   pdata = client->dev.platform_data;
-   if (pdata == NULL) {
-   nfc_err(&client->dev, "No platform data\n");
-   return -EINVAL;
-   }
-
-   /* store for later use */
-   phy->gpio_reset = pdata->gpio_reset;
-   phy->irq_polarity = pdata->irq_polarity;
-
-   r = devm_gpio_request_one(&client->dev,
-   phy->gpio_reset, GPIOF_OUT_INIT_HIGH,
-   ST_NCI_GPIO_NAME_RESET);
-   if (r) {
-   pr_err("%s : reset gpio_request failed\n", __FILE__);
-   return r;
-   }
-
-   phy->se_status.is_ese_present = pdata->is_ese_present;
-   phy->se_status.is_uicc_present = pdata->is_uicc_present;
-
-   return 0;
-}
-
 static int st_nci_i2c_probe(struct i2c_client *client,
  const struct i2c_device_id *id)
 {
struct st_nci_i2c_phy *phy;
-   struct st_nci_nfc_platform_data *pdata;
int r;
 
dev_dbg(&client->dev, "%s\n", __func__);
@@ -335,20 +304,12 @@ static int st_nci_i2c_probe(struct i2c_client *client,
 
i2c_set_clientdata(client, phy);
 
-   pdata = client->dev.platform_data;
-   if (!pdata && client->dev.of_node) {
+   if (client->dev.of_node) {
r = st_nci_i2c_of_request_resources(client);
if (r) {
nfc_err(&client->dev, "No platform data\n");
return r;
}
-   } else if (pdata) {
-   r = st_nci_i2c_request_resources(client);
-   if (r) {
-   nfc_err(&client->dev,
-   "Cannot get platform resources\n");
-   return r;
-   }
} else if (ACPI_HANDLE(&client->dev)) {
r = st_nci_i2c_acpi_request_resources(client);
if (r) {
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index 89e341eba3eb..ee8ea708d5b7 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -28,7 +28,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "st-nci.h"
 
@@ -41,6 +40,7 @@
 #define ST_NCI_SPI_MIN_SIZE 4   /* PCB(1) + NCI Packet header(3) */
 #define ST_NCI_SPI_MAX_SIZE 250 /* req 4.2.1 */
 
+#define ST_NCI_DRIVER_NAME "st_nci"
 #define ST_NCI_SPI_DRIVER_NAME "st_nci_spi"
 
 #define ST_NCI_GPIO_NAME_RESET "reset"
@@ -296,40 +296,9 @@ static int st_nci_spi_of_request_resources(struct 
spi_device *dev)
return 0;
 }
 
-static int st_nci_spi_request_resources(struct spi_device *dev)
-{
-   struct st_nci_nfc_platform_data *pdata;
-   struct st_nci_spi_phy *phy = spi_get_drvdata(dev);
-   int r;
-
-   pdata = dev->dev.platform_data;
-   if (pdata == NULL) {
-   nfc_err(&dev->dev, "No pl

[PATCH v3 13/13] MAINTAINERS: Remove non-existing NFC platform data files

2017-06-19 Thread Andy Shevchenko
There are no longer platform data files for NFC drivers.
Remove it from MAINTAINERS data base.

Signed-off-by: Andy Shevchenko 
---
 MAINTAINERS | 2 --
 1 file changed, 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 6f2d96313230..6b6079ad91f4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9175,8 +9175,6 @@ F:include/uapi/linux/nfc.h
 F: drivers/nfc/
 F: include/linux/platform_data/nfcmrvl.h
 F: include/linux/platform_data/nxp-nci.h
-F: include/linux/platform_data/pn544.h
-F: include/linux/platform_data/st21nfca.h
 F: Documentation/devicetree/bindings/net/nfc/
 
 NFS, SUNRPC, AND LOCKD CLIENTS
-- 
2.11.0



[PATCH v3 05/13] NFC: fdp: Convert to use devres API

2017-06-19 Thread Andy Shevchenko
It looks like there are two leftovers, at least one of which can leak
the resource (IRQ).

Convert both places to use managed variants of the functions.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/fdp/fdp.c | 15 ---
 drivers/nfc/fdp/i2c.c | 10 +-
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/nfc/fdp/fdp.c b/drivers/nfc/fdp/fdp.c
index badd8167ac73..ec50027b0d8b 100644
--- a/drivers/nfc/fdp/fdp.c
+++ b/drivers/nfc/fdp/fdp.c
@@ -749,11 +749,9 @@ int fdp_nci_probe(struct fdp_i2c_phy *phy, struct 
nfc_phy_ops *phy_ops,
u32 protocols;
int r;
 
-   info = kzalloc(sizeof(struct fdp_nci_info), GFP_KERNEL);
-   if (!info) {
-   r = -ENOMEM;
-   goto err_info_alloc;
-   }
+   info = devm_kzalloc(dev, sizeof(struct fdp_nci_info), GFP_KERNEL);
+   if (!info)
+   return -ENOMEM;
 
info->phy = phy;
info->phy_ops = phy_ops;
@@ -775,8 +773,7 @@ int fdp_nci_probe(struct fdp_i2c_phy *phy, struct 
nfc_phy_ops *phy_ops,
   tx_tailroom);
if (!ndev) {
nfc_err(dev, "Cannot allocate nfc ndev\n");
-   r = -ENOMEM;
-   goto err_alloc_ndev;
+   return -ENOMEM;
}
 
r = nci_register_device(ndev);
@@ -792,9 +789,6 @@ int fdp_nci_probe(struct fdp_i2c_phy *phy, struct 
nfc_phy_ops *phy_ops,
 
 err_regdev:
nci_free_device(ndev);
-err_alloc_ndev:
-   kfree(info);
-err_info_alloc:
return r;
 }
 EXPORT_SYMBOL(fdp_nci_probe);
@@ -808,7 +802,6 @@ void fdp_nci_remove(struct nci_dev *ndev)
 
nci_unregister_device(ndev);
nci_free_device(ndev);
-   kfree(info);
 }
 EXPORT_SYMBOL(fdp_nci_remove);
 
diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
index 8a66b1845f27..c955f1f5139d 100644
--- a/drivers/nfc/fdp/i2c.c
+++ b/drivers/nfc/fdp/i2c.c
@@ -303,8 +303,7 @@ static int fdp_nci_i2c_probe(struct i2c_client *client)
return -ENODEV;
}
 
-   phy = devm_kzalloc(dev, sizeof(struct fdp_i2c_phy),
-  GFP_KERNEL);
+   phy = devm_kzalloc(dev, sizeof(struct fdp_i2c_phy), GFP_KERNEL);
if (!phy)
return -ENOMEM;
 
@@ -312,9 +311,10 @@ static int fdp_nci_i2c_probe(struct i2c_client *client)
phy->next_read_size = FDP_NCI_I2C_MIN_PAYLOAD;
i2c_set_clientdata(client, phy);
 
-   r = request_threaded_irq(client->irq, NULL, fdp_nci_i2c_irq_thread_fn,
-IRQF_TRIGGER_RISING | IRQF_ONESHOT,
-FDP_I2C_DRIVER_NAME, phy);
+   r = devm_request_threaded_irq(dev, client->irq,
+ NULL, fdp_nci_i2c_irq_thread_fn,
+ IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+ FDP_I2C_DRIVER_NAME, phy);
 
if (r < 0) {
nfc_err(&client->dev, "Unable to register IRQ handler\n");
-- 
2.11.0



[PATCH v3 11/13] NFC: st-nci: Add GPIO ACPI mapping table

2017-06-19 Thread Andy Shevchenko
In order to make GPIO ACPI library stricter prepare users of
gpiod_get_index() to correctly behave when there no mapping is
provided by firmware.

Here we add explicit mapping between _CRS GpioIo() resources and
their names used in the driver.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/st-nci/i2c.c | 17 +
 drivers/nfc/st-nci/spi.c | 17 +
 2 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index 2ee381586f14..edda253b07fe 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -40,8 +40,6 @@
 #define ST_NCI_DRIVER_NAME "st_nci"
 #define ST_NCI_I2C_DRIVER_NAME "st_nci_i2c"
 
-#define ST_NCI_GPIO_NAME_RESET "reset"
-
 struct st_nci_i2c_phy {
struct i2c_client *i2c_dev;
struct llt_ndlc *ndlc;
@@ -205,14 +203,25 @@ static struct nfc_phy_ops i2c_phy_ops = {
.disable = st_nci_i2c_disable,
 };
 
+static const struct acpi_gpio_params reset_gpios = { 1, 0, false };
+
+static const struct acpi_gpio_mapping acpi_st_nci_gpios[] = {
+   { "reset-gpios", &reset_gpios, 1 },
+   {},
+};
+
 static int st_nci_i2c_acpi_request_resources(struct i2c_client *client)
 {
struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
struct device *dev = &client->dev;
+   int r;
+
+   r = devm_acpi_dev_add_driver_gpios(dev, acpi_st_nci_gpios);
+   if (r)
+   return r;
 
/* Get RESET GPIO from ACPI */
-   phy->gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET,
-   1, GPIOD_OUT_HIGH);
+   phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(phy->gpiod_reset)) {
nfc_err(dev, "Unable to get RESET GPIO\n");
return -ENODEV;
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index 383bf69163ef..99ecf92edc8c 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -41,8 +41,6 @@
 #define ST_NCI_DRIVER_NAME "st_nci"
 #define ST_NCI_SPI_DRIVER_NAME "st_nci_spi"
 
-#define ST_NCI_GPIO_NAME_RESET "reset"
-
 struct st_nci_spi_phy {
struct spi_device *spi_dev;
struct llt_ndlc *ndlc;
@@ -220,14 +218,25 @@ static struct nfc_phy_ops spi_phy_ops = {
.disable = st_nci_spi_disable,
 };
 
+static const struct acpi_gpio_params reset_gpios = { 1, 0, false };
+
+static const struct acpi_gpio_mapping acpi_st_nci_gpios[] = {
+   { "reset-gpios", &reset_gpios, 1 },
+   {},
+};
+
 static int st_nci_spi_acpi_request_resources(struct spi_device *spi_dev)
 {
struct st_nci_spi_phy *phy = spi_get_drvdata(spi_dev);
struct device *dev = &spi_dev->dev;
+   int r;
+
+   r = devm_acpi_dev_add_driver_gpios(dev, acpi_st_nci_gpios);
+   if (r)
+   return r;
 
/* Get RESET GPIO from ACPI */
-   phy->gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET,
-   1, GPIOD_OUT_HIGH);
+   phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(phy->gpiod_reset)) {
nfc_err(dev, "Unable to get RESET GPIO\n");
return PTR_ERR(phy->gpiod_reset);
-- 
2.11.0



[PATCH v3 03/13] NFC: st21nfca: Get rid of code duplication in ->probe()

2017-06-19 Thread Andy Shevchenko
Since OF and ACPI case almost the same get rid of code duplication
by moving gpiod_get() calls directly to ->probe().

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/st21nfca/i2c.c | 62 --
 1 file changed, 10 insertions(+), 52 deletions(-)

diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c
index 3621290807f6..cd1f7bfa75eb 100644
--- a/drivers/nfc/st21nfca/i2c.c
+++ b/drivers/nfc/st21nfca/i2c.c
@@ -61,8 +61,6 @@
 #define ST21NFCA_HCI_DRIVER_NAME "st21nfca_hci"
 #define ST21NFCA_HCI_I2C_DRIVER_NAME "st21nfca_hci_i2c"
 
-#define ST21NFCA_GPIO_NAME_EN "enable"
-
 struct st21nfca_i2c_phy {
struct i2c_client *i2c_dev;
struct nfc_hci_dev *hdev;
@@ -508,44 +506,10 @@ static const struct acpi_gpio_mapping 
acpi_st21nfca_gpios[] = {
{},
 };
 
-static int st21nfca_hci_i2c_acpi_request_resources(struct i2c_client *client)
-{
-   struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client);
-   struct device *dev = &client->dev;
-   int ret;
-
-   ret = devm_acpi_dev_add_driver_gpios(dev, acpi_st21nfca_gpios);
-   if (ret)
-   return ret;
-
-   /* Get EN GPIO from ACPI */
-   phy->gpiod_ena = devm_gpiod_get(dev, ST21NFCA_GPIO_NAME_EN, 
GPIOD_OUT_LOW);
-   if (IS_ERR(phy->gpiod_ena)) {
-   nfc_err(dev, "Unable to get ENABLE GPIO\n");
-   return PTR_ERR(phy->gpiod_ena);
-   }
-
-   return 0;
-}
-
-static int st21nfca_hci_i2c_of_request_resources(struct i2c_client *client)
-{
-   struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client);
-   struct device *dev = &client->dev;
-
-   /* Get GPIO from device tree */
-   phy->gpiod_ena = devm_gpiod_get(dev, ST21NFCA_GPIO_NAME_EN, 
GPIOD_OUT_HIGH);
-   if (IS_ERR(phy->gpiod_ena)) {
-   nfc_err(dev, "Failed to request enable pin\n");
-   return PTR_ERR(phy->gpiod_ena);
-   }
-
-   return 0;
-}
-
 static int st21nfca_hci_i2c_probe(struct i2c_client *client,
  const struct i2c_device_id *id)
 {
+   struct device *dev = &client->dev;
struct st21nfca_i2c_phy *phy;
int r;
 
@@ -572,21 +536,15 @@ static int st21nfca_hci_i2c_probe(struct i2c_client 
*client,
mutex_init(&phy->phy_lock);
i2c_set_clientdata(client, phy);
 
-   if (client->dev.of_node) {
-   r = st21nfca_hci_i2c_of_request_resources(client);
-   if (r) {
-   nfc_err(&client->dev, "No platform data\n");
-   return r;
-   }
-   } else if (ACPI_HANDLE(&client->dev)) {
-   r = st21nfca_hci_i2c_acpi_request_resources(client);
-   if (r) {
-   nfc_err(&client->dev, "Cannot get ACPI data\n");
-   return r;
-   }
-   } else {
-   nfc_err(&client->dev, "st21nfca platform resources not 
available\n");
-   return -ENODEV;
+   r = devm_acpi_dev_add_driver_gpios(dev, acpi_st21nfca_gpios);
+   if (r)
+   dev_dbg(dev, "Unable to add GPIO mapping table\n");
+
+   /* Get EN GPIO from resource provider */
+   phy->gpiod_ena = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
+   if (IS_ERR(phy->gpiod_ena)) {
+   nfc_err(dev, "Unable to get ENABLE GPIO\n");
+   return PTR_ERR(phy->gpiod_ena);
}
 
phy->se_status.is_ese_present =
-- 
2.11.0



[PATCH v3 06/13] NFC: fdp: Add GPIO ACPI mapping table

2017-06-19 Thread Andy Shevchenko
In order to make GPIO ACPI library stricter prepare users of
gpiod_get_index() to correctly behave when there no mapping is
provided by firmware.

Here we add explicit mapping between _CRS GpioIo() resources and
their names used in the driver.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/fdp/i2c.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
index c955f1f5139d..c4da50e07bbc 100644
--- a/drivers/nfc/fdp/i2c.c
+++ b/drivers/nfc/fdp/i2c.c
@@ -27,7 +27,6 @@
 
 #define FDP_I2C_DRIVER_NAME"fdp_nci_i2c"
 
-#define FDP_DP_POWER_GPIO_NAME "power"
 #define FDP_DP_CLOCK_TYPE_NAME "clock-type"
 #define FDP_DP_CLOCK_FREQ_NAME "clock-freq"
 #define FDP_DP_FW_VSC_CFG_NAME "fw-vsc-cfg"
@@ -281,6 +280,13 @@ static void fdp_nci_i2c_read_device_properties(struct 
device *dev,
*clock_type, *clock_freq, *fw_vsc_cfg != NULL ? "yes" : "no");
 }
 
+static const struct acpi_gpio_params power_gpios = { 0, 0, false };
+
+static const struct acpi_gpio_mapping acpi_fdp_gpios[] = {
+   { "power-gpios", &power_gpios, 1 },
+   {},
+};
+
 static int fdp_nci_i2c_probe(struct i2c_client *client)
 {
struct fdp_i2c_phy *phy;
@@ -321,10 +327,12 @@ static int fdp_nci_i2c_probe(struct i2c_client *client)
return r;
}
 
-   /* Requesting the power gpio */
-   phy->power_gpio = devm_gpiod_get(dev, FDP_DP_POWER_GPIO_NAME,
-GPIOD_OUT_LOW);
+   r = devm_acpi_dev_add_driver_gpios(dev, acpi_fdp_gpios);
+   if (r)
+   dev_dbg(dev, "Unable to add GPIO mapping table\n");
 
+   /* Requesting the power gpio */
+   phy->power_gpio = devm_gpiod_get(dev, "power", GPIOD_OUT_LOW);
if (IS_ERR(phy->power_gpio)) {
nfc_err(dev, "Power GPIO request failed\n");
return PTR_ERR(phy->power_gpio);
-- 
2.11.0



Re: [PATCH v2 00/12] NFC: clean up for ACPI GPIO usage

2017-06-13 Thread Andy Shevchenko
On Mon, 2017-06-12 at 22:56 +0200, Samuel Ortiz wrote:
> On Mon, Jun 12, 2017 at 06:36:12PM +0300, Andy Shevchenko wrote:

> > Samuel, anything to comment?
> 
> I will get to my pending NFC patches during the week.

Thanks!

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH v2 00/12] NFC: clean up for ACPI GPIO usage

2017-06-12 Thread Andy Shevchenko
On Mon, 2017-06-05 at 23:19 +0300, Andy Shevchenko wrote:
> This clean up series to NFC drivers that are using GPIOs on ACPI
> enabled
> platforms. Since GPIO ACPI library goes stricter about requesting
> resources we need to amend drivers for that. Here we are for NFC
> subsystem.
> 
> While doing above, get rid of legacy and unused platform data as well
> as
> some artificial IDs.

Samuel, anything to comment?

> 
> Changelog v2:
> - add patches 1,4-12
> 
> Andy Shevchenko (12):
>   NFC: pn544: Switch to devm_acpi_dev_add_driver_gpios()
>   NFC: st21nfca: Add GPIO ACPI mapping table
>   NFC: st21nfca: Get rid of code duplication in ->probe()
>   NFC: fdp: Convert I2C driver to ->probe_new()
>   NFC: fdp: Convert to use devres API
>   NFC: fdp: Add GPIO ACPI mapping table
>   NFC: st-nci: Get rid of platform data
>   NFC: st-nci: Get rid of "interesting" use of interrupt polarity
>   NFC: st-nci: Covert to use GPIO descriptor
>   NFC: st-nci: Use unified device property API meaningfully
>   NFC: st-nci: Add GPIO ACPI mapping table
>   NFC: st-nci: Get rid of code duplication in ->probe()
> 
>  drivers/nfc/fdp/fdp.c|  15 +---
>  drivers/nfc/fdp/i2c.c|  38 
>  drivers/nfc/pn544/i2c.c  |   3 +-
>  drivers/nfc/st-nci/i2c.c | 164 ++--
> --
>  drivers/nfc/st-nci/spi.c | 165 ++--
> ---
>  drivers/nfc/st21nfca/i2c.c   |  62 -
>  include/linux/platform_data/st-nci.h |  31 ---
>  7 files changed, 91 insertions(+), 387 deletions(-)
>  delete mode 100644 include/linux/platform_data/st-nci.h
> 

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH v2] brcmfmac: Fix glom_skb leak in brcmf_sdiod_recv_chain

2017-06-11 Thread Andy Shevchenko
On Sat, Jun 10, 2017 at 10:27 PM, Arend van Spriel
 wrote:
> On 03-06-17 17:36, Andy Shevchenko wrote:
>> On Sat, Jun 3, 2017 at 1:29 AM, Peter S. Housel  wrote:

The following looks good to me.
Feel free to add
Reviewed-by: Andy Shevchenko 

> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
> @@ -705,7 +705,7 @@ int brcmf_sdiod_recv_pkt(struct brcmf_sdio_dev
> *sdiodev, struct sk_buff *pkt)
>  int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev *sdiodev,
>struct sk_buff_head *pktq, uint totlen)
>  {
> -   struct sk_buff *glom_skb;
> +   struct sk_buff *glom_skb = NULL;
> struct sk_buff *skb;
> u32 addr = sdiodev->sbwad;
> int err = 0;
> @@ -726,10 +726,8 @@ int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev
> *sdiodev,
> return -ENOMEM;
> err = brcmf_sdiod_buffrw(sdiodev, SDIO_FUNC_2, false, addr,
>  glom_skb);
> -   if (err) {
> -   brcmu_pkt_buf_free_skb(glom_skb);
> +   if (err)
> goto done;
> -   }
>
> skb_queue_walk(pktq, skb) {
> memcpy(skb->data, glom_skb->data, skb->len);
> @@ -740,6 +738,7 @@ int brcmf_sdiod_recv_chain(struct brcmf_sdio_dev
> *sdiodev,
> pktq);
>
>  done:
> +   brcmu_pkt_buf_free_skb(glom_skb);
> return err;
>  }
>



-- 
With Best Regards,
Andy Shevchenko


[PATCH v1] net: rfkill: gpio: Switch to devm_acpi_dev_add_driver_gpios()

2017-06-10 Thread Andy Shevchenko
Switch to use managed variant of acpi_dev_add_driver_gpios() to simplify
error path and fix potentially wrong assingment if ->probe() fails.

Signed-off-by: Andy Shevchenko 
---
 net/rfkill/rfkill-gpio.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
index 76c01cbd56e3..41bd496531d4 100644
--- a/net/rfkill/rfkill-gpio.c
+++ b/net/rfkill/rfkill-gpio.c
@@ -81,8 +81,7 @@ static int rfkill_gpio_acpi_probe(struct device *dev,
 
rfkill->type = (unsigned)id->driver_data;
 
-   return acpi_dev_add_driver_gpios(ACPI_COMPANION(dev),
-acpi_rfkill_default_gpios);
+   return devm_acpi_dev_add_driver_gpios(dev, acpi_rfkill_default_gpios);
 }
 
 static int rfkill_gpio_probe(struct platform_device *pdev)
@@ -154,8 +153,6 @@ static int rfkill_gpio_remove(struct platform_device *pdev)
rfkill_unregister(rfkill->rfkill_dev);
rfkill_destroy(rfkill->rfkill_dev);
 
-   acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev));
-
return 0;
 }
 
-- 
2.11.0



[PATCH v2 09/12] NFC: st-nci: Covert to use GPIO descriptor

2017-06-05 Thread Andy Shevchenko
Since we got rid of platform data, the driver may use GPIO descriptor
directly.

Looking deeply to the use of the GPIO pin it looks like it should be
a GPIO based reset control rather than custom GPIO handling. But this
is out of scope of the change.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/st-nci/i2c.c | 38 +++---
 drivers/nfc/st-nci/spi.c | 40 
 2 files changed, 23 insertions(+), 55 deletions(-)

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index bdfbd543e671..cc63c2f6823f 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -19,13 +19,12 @@
 
 #include 
 #include 
-#include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include "st-nci.h"
 
@@ -49,7 +48,7 @@ struct st_nci_i2c_phy {
 
bool irq_active;
 
-   unsigned int gpio_reset;
+   struct gpio_desc *gpiod_reset;
 
struct st_nci_se_status se_status;
 };
@@ -58,9 +57,9 @@ static int st_nci_i2c_enable(void *phy_id)
 {
struct st_nci_i2c_phy *phy = phy_id;
 
-   gpio_set_value(phy->gpio_reset, 0);
+   gpiod_set_value(phy->gpiod_reset, 0);
usleep_range(1, 15000);
-   gpio_set_value(phy->gpio_reset, 1);
+   gpiod_set_value(phy->gpiod_reset, 1);
usleep_range(8, 85000);
 
if (phy->ndlc->powered == 0 && phy->irq_active == 0) {
@@ -209,20 +208,16 @@ static struct nfc_phy_ops i2c_phy_ops = {
 static int st_nci_i2c_acpi_request_resources(struct i2c_client *client)
 {
struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
-   struct gpio_desc *gpiod_reset;
struct device *dev = &client->dev;
u8 tmp;
 
/* Get RESET GPIO from ACPI */
-   gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET, 1,
-  GPIOD_OUT_HIGH);
-   if (IS_ERR(gpiod_reset)) {
+   phy->gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET, 1, 
GPIOD_OUT_HIGH);
+   if (IS_ERR(phy->gpiod_reset)) {
nfc_err(dev, "Unable to get RESET GPIO\n");
return -ENODEV;
}
 
-   phy->gpio_reset = desc_to_gpio(gpiod_reset);
-
phy->se_status.is_ese_present = false;
phy->se_status.is_uicc_present = false;
 
@@ -242,30 +237,19 @@ static int st_nci_i2c_acpi_request_resources(struct 
i2c_client *client)
 static int st_nci_i2c_of_request_resources(struct i2c_client *client)
 {
struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
+   struct device *dev = &client->dev;
struct device_node *pp;
-   int gpio;
-   int r;
 
pp = client->dev.of_node;
if (!pp)
return -ENODEV;
 
/* Get GPIO from device tree */
-   gpio = of_get_named_gpio(pp, "reset-gpios", 0);
-   if (gpio < 0) {
-   nfc_err(&client->dev,
-   "Failed to retrieve reset-gpios from device tree\n");
-   return gpio;
-   }
-
-   /* GPIO request and configuration */
-   r = devm_gpio_request_one(&client->dev, gpio,
-   GPIOF_OUT_INIT_HIGH, ST_NCI_GPIO_NAME_RESET);
-   if (r) {
-   nfc_err(&client->dev, "Failed to request reset pin\n");
-   return r;
+   phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+   if (IS_ERR(phy->gpiod_reset)) {
+   nfc_err(dev, "Unable to get RESET GPIO\n");
+   return PTR_ERR(phy->gpiod_reset);
}
-   phy->gpio_reset = gpio;
 
phy->se_status.is_ese_present =
of_property_read_bool(pp, "ese-present");
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index 4585e205778b..acf339d83360 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -19,13 +19,12 @@
 
 #include 
 #include 
-#include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "st-nci.h"
@@ -50,7 +49,7 @@ struct st_nci_spi_phy {
 
bool irq_active;
 
-   unsigned int gpio_reset;
+   struct gpio_desc *gpiod_reset;
 
struct st_nci_se_status se_status;
 };
@@ -59,9 +58,9 @@ static int st_nci_spi_enable(void *phy_id)
 {
struct st_nci_spi_phy *phy = phy_id;
 
-   gpio_set_value(phy->gpio_reset, 0);
+   gpiod_set_value(phy->gpiod_reset, 0);
usleep_range(1, 15000);
-   gpio_set_value(phy->gpio_reset, 1);
+   gpiod_set_value(phy->gpiod_reset, 1);
usleep_range(8, 85000);
 
if (phy->ndlc->powered == 0 && phy->irq_active == 0) {
@@ -224,20 +223,16 @@ static struct nfc_phy_ops spi_phy_ops = {
 static int st_nci_spi_acpi_request_resources(s

[PATCH v2 11/12] NFC: st-nci: Add GPIO ACPI mapping table

2017-06-05 Thread Andy Shevchenko
In order to make GPIO ACPI library stricter prepare users of
gpiod_get_index() to correctly behave when there no mapping is
provided by firmware.

Here we add explicit mapping between _CRS GpioIo() resources and
their names used in the driver.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/st-nci/i2c.c | 16 +---
 drivers/nfc/st-nci/spi.c | 16 +---
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index 157e2eae..edda253b07fe 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -40,8 +40,6 @@
 #define ST_NCI_DRIVER_NAME "st_nci"
 #define ST_NCI_I2C_DRIVER_NAME "st_nci_i2c"
 
-#define ST_NCI_GPIO_NAME_RESET "reset"
-
 struct st_nci_i2c_phy {
struct i2c_client *i2c_dev;
struct llt_ndlc *ndlc;
@@ -205,13 +203,25 @@ static struct nfc_phy_ops i2c_phy_ops = {
.disable = st_nci_i2c_disable,
 };
 
+static const struct acpi_gpio_params reset_gpios = { 1, 0, false };
+
+static const struct acpi_gpio_mapping acpi_st_nci_gpios[] = {
+   { "reset-gpios", &reset_gpios, 1 },
+   {},
+};
+
 static int st_nci_i2c_acpi_request_resources(struct i2c_client *client)
 {
struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
struct device *dev = &client->dev;
+   int r;
+
+   r = devm_acpi_dev_add_driver_gpios(dev, acpi_st_nci_gpios);
+   if (r)
+   return r;
 
/* Get RESET GPIO from ACPI */
-   phy->gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET, 1, 
GPIOD_OUT_HIGH);
+   phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(phy->gpiod_reset)) {
nfc_err(dev, "Unable to get RESET GPIO\n");
return -ENODEV;
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index d21259cf42c0..80afdb9ea248 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -41,8 +41,6 @@
 #define ST_NCI_DRIVER_NAME "st_nci"
 #define ST_NCI_SPI_DRIVER_NAME "st_nci_spi"
 
-#define ST_NCI_GPIO_NAME_RESET "reset"
-
 struct st_nci_spi_phy {
struct spi_device *spi_dev;
struct llt_ndlc *ndlc;
@@ -220,13 +218,25 @@ static struct nfc_phy_ops spi_phy_ops = {
.disable = st_nci_spi_disable,
 };
 
+static const struct acpi_gpio_params reset_gpios = { 1, 0, false };
+
+static const struct acpi_gpio_mapping acpi_st_nci_gpios[] = {
+   { "reset-gpios", &reset_gpios, 1 },
+   {},
+};
+
 static int st_nci_spi_acpi_request_resources(struct spi_device *spi_dev)
 {
struct st_nci_spi_phy *phy = spi_get_drvdata(spi_dev);
struct device *dev = &spi_dev->dev;
+   int r;
+
+   r = devm_acpi_dev_add_driver_gpios(dev, acpi_st_nci_gpios);
+   if (r)
+   return r;
 
/* Get RESET GPIO from ACPI */
-   phy->gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET, 1, 
GPIOD_OUT_HIGH);
+   phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(phy->gpiod_reset)) {
nfc_err(dev, "Unable to get RESET GPIO\n");
return PTR_ERR(phy->gpiod_reset);
-- 
2.11.0



Re: [PATCH v1 1/2] NFC: st21nfca: Add GPIO ACPI mapping table

2017-06-05 Thread Andy Shevchenko
On Mon, 2017-05-22 at 21:33 +0300, Andy Shevchenko wrote:
> On Mon, 2017-04-24 at 21:41 +0300, Andy Shevchenko wrote:
> > In order to make GPIO ACPI library stricter prepare users of
> > gpiod_get_index() to correctly behave when there no mapping is
> > provided by firmware.
> > 
> > Here we add explicit mapping between _CRS GpioIo() resources and
> > their names used in the driver.
> > 
> 
> Samuel, can you apply this if no objections?

Never mind, I just sent v2 with other drivers fixed / cleaned up as
well.

Please, review, we already at rc4.

-- 
Andy Shevchenko 
Intel Finland Oy


[PATCH v2 07/12] NFC: st-nci: Get rid of platform data

2017-06-05 Thread Andy Shevchenko
Legacy platform data must go away. We are on the safe side here since
there are no users of it in the kernel.

If anyone by any odd reason needs it the GPIO lookup tables and
built-in device properties at your service.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/st-nci/i2c.c | 43 ++--
 drivers/nfc/st-nci/spi.c | 43 ++--
 include/linux/platform_data/st-nci.h | 31 --
 3 files changed, 4 insertions(+), 113 deletions(-)
 delete mode 100644 include/linux/platform_data/st-nci.h

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index 9dfae0efa922..6d3d8e43fa50 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -27,7 +27,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "st-nci.h"
 
@@ -40,6 +39,7 @@
 #define ST_NCI_I2C_MIN_SIZE 4   /* PCB(1) + NCI Packet header(3) */
 #define ST_NCI_I2C_MAX_SIZE 250 /* req 4.2.1 */
 
+#define ST_NCI_DRIVER_NAME "st_nci"
 #define ST_NCI_I2C_DRIVER_NAME "st_nci_i2c"
 
 #define ST_NCI_GPIO_NAME_RESET "reset"
@@ -281,41 +281,10 @@ static int st_nci_i2c_of_request_resources(struct 
i2c_client *client)
return 0;
 }
 
-static int st_nci_i2c_request_resources(struct i2c_client *client)
-{
-   struct st_nci_nfc_platform_data *pdata;
-   struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
-   int r;
-
-   pdata = client->dev.platform_data;
-   if (pdata == NULL) {
-   nfc_err(&client->dev, "No platform data\n");
-   return -EINVAL;
-   }
-
-   /* store for later use */
-   phy->gpio_reset = pdata->gpio_reset;
-   phy->irq_polarity = pdata->irq_polarity;
-
-   r = devm_gpio_request_one(&client->dev,
-   phy->gpio_reset, GPIOF_OUT_INIT_HIGH,
-   ST_NCI_GPIO_NAME_RESET);
-   if (r) {
-   pr_err("%s : reset gpio_request failed\n", __FILE__);
-   return r;
-   }
-
-   phy->se_status.is_ese_present = pdata->is_ese_present;
-   phy->se_status.is_uicc_present = pdata->is_uicc_present;
-
-   return 0;
-}
-
 static int st_nci_i2c_probe(struct i2c_client *client,
  const struct i2c_device_id *id)
 {
struct st_nci_i2c_phy *phy;
-   struct st_nci_nfc_platform_data *pdata;
int r;
 
dev_dbg(&client->dev, "%s\n", __func__);
@@ -335,20 +304,12 @@ static int st_nci_i2c_probe(struct i2c_client *client,
 
i2c_set_clientdata(client, phy);
 
-   pdata = client->dev.platform_data;
-   if (!pdata && client->dev.of_node) {
+   if (client->dev.of_node) {
r = st_nci_i2c_of_request_resources(client);
if (r) {
nfc_err(&client->dev, "No platform data\n");
return r;
}
-   } else if (pdata) {
-   r = st_nci_i2c_request_resources(client);
-   if (r) {
-   nfc_err(&client->dev,
-   "Cannot get platform resources\n");
-   return r;
-   }
} else if (ACPI_HANDLE(&client->dev)) {
r = st_nci_i2c_acpi_request_resources(client);
if (r) {
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index 89e341eba3eb..ee8ea708d5b7 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -28,7 +28,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "st-nci.h"
 
@@ -41,6 +40,7 @@
 #define ST_NCI_SPI_MIN_SIZE 4   /* PCB(1) + NCI Packet header(3) */
 #define ST_NCI_SPI_MAX_SIZE 250 /* req 4.2.1 */
 
+#define ST_NCI_DRIVER_NAME "st_nci"
 #define ST_NCI_SPI_DRIVER_NAME "st_nci_spi"
 
 #define ST_NCI_GPIO_NAME_RESET "reset"
@@ -296,40 +296,9 @@ static int st_nci_spi_of_request_resources(struct 
spi_device *dev)
return 0;
 }
 
-static int st_nci_spi_request_resources(struct spi_device *dev)
-{
-   struct st_nci_nfc_platform_data *pdata;
-   struct st_nci_spi_phy *phy = spi_get_drvdata(dev);
-   int r;
-
-   pdata = dev->dev.platform_data;
-   if (pdata == NULL) {
-   nfc_err(&dev->dev, "No platform data\n");
-   return -EINVAL;
-   }
-
-   /* store for later use */
-   phy->gpio_reset = pdata->gpio_reset;
-   phy->irq_polarity = pdata->irq_polarity;
-
-   r = devm_gpio_request_one(&dev->dev,
-   phy->gpio_reset, GPIOF_OUT_INIT_HIGH,
-   ST_NCI_GPIO_NAME_RESET);
-   if (r) {
-   pr_err("%s : reset gpio_request failed\n", __FILE__);
-   return r;

[PATCH v2 00/12] NFC: clean up for ACPI GPIO usage

2017-06-05 Thread Andy Shevchenko
This clean up series to NFC drivers that are using GPIOs on ACPI enabled
platforms. Since GPIO ACPI library goes stricter about requesting
resources we need to amend drivers for that. Here we are for NFC
subsystem.

While doing above, get rid of legacy and unused platform data as well as
some artificial IDs.

Changelog v2:
- add patches 1,4-12

Andy Shevchenko (12):
  NFC: pn544: Switch to devm_acpi_dev_add_driver_gpios()
  NFC: st21nfca: Add GPIO ACPI mapping table
  NFC: st21nfca: Get rid of code duplication in ->probe()
  NFC: fdp: Convert I2C driver to ->probe_new()
  NFC: fdp: Convert to use devres API
  NFC: fdp: Add GPIO ACPI mapping table
  NFC: st-nci: Get rid of platform data
  NFC: st-nci: Get rid of "interesting" use of interrupt polarity
  NFC: st-nci: Covert to use GPIO descriptor
  NFC: st-nci: Use unified device property API meaningfully
  NFC: st-nci: Add GPIO ACPI mapping table
  NFC: st-nci: Get rid of code duplication in ->probe()

 drivers/nfc/fdp/fdp.c|  15 +---
 drivers/nfc/fdp/i2c.c|  38 
 drivers/nfc/pn544/i2c.c  |   3 +-
 drivers/nfc/st-nci/i2c.c | 164 ++
 drivers/nfc/st-nci/spi.c | 165 ++-
 drivers/nfc/st21nfca/i2c.c   |  62 -
 include/linux/platform_data/st-nci.h |  31 ---
 7 files changed, 91 insertions(+), 387 deletions(-)
 delete mode 100644 include/linux/platform_data/st-nci.h

-- 
2.11.0



[PATCH v2 12/12] NFC: st-nci: Get rid of code duplication in ->probe()

2017-06-05 Thread Andy Shevchenko
Since OF and ACPI case almost the same get rid of code duplication
by moving gpiod_get() calls directly to ->probe().

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/st-nci/i2c.c | 61 +++---
 drivers/nfc/st-nci/spi.c | 63 
 2 files changed, 19 insertions(+), 105 deletions(-)

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index edda253b07fe..515f08d037fb 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -210,41 +210,6 @@ static const struct acpi_gpio_mapping acpi_st_nci_gpios[] 
= {
{},
 };
 
-static int st_nci_i2c_acpi_request_resources(struct i2c_client *client)
-{
-   struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
-   struct device *dev = &client->dev;
-   int r;
-
-   r = devm_acpi_dev_add_driver_gpios(dev, acpi_st_nci_gpios);
-   if (r)
-   return r;
-
-   /* Get RESET GPIO from ACPI */
-   phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
-   if (IS_ERR(phy->gpiod_reset)) {
-   nfc_err(dev, "Unable to get RESET GPIO\n");
-   return -ENODEV;
-   }
-
-   return 0;
-}
-
-static int st_nci_i2c_of_request_resources(struct i2c_client *client)
-{
-   struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
-   struct device *dev = &client->dev;
-
-   /* Get GPIO from device tree */
-   phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
-   if (IS_ERR(phy->gpiod_reset)) {
-   nfc_err(dev, "Unable to get RESET GPIO\n");
-   return PTR_ERR(phy->gpiod_reset);
-   }
-
-   return 0;
-}
-
 static int st_nci_i2c_probe(struct i2c_client *client,
  const struct i2c_device_id *id)
 {
@@ -260,8 +225,7 @@ static int st_nci_i2c_probe(struct i2c_client *client,
return -ENODEV;
}
 
-   phy = devm_kzalloc(&client->dev, sizeof(struct st_nci_i2c_phy),
-  GFP_KERNEL);
+   phy = devm_kzalloc(dev, sizeof(struct st_nci_i2c_phy), GFP_KERNEL);
if (!phy)
return -ENOMEM;
 
@@ -269,21 +233,14 @@ static int st_nci_i2c_probe(struct i2c_client *client,
 
i2c_set_clientdata(client, phy);
 
-   if (client->dev.of_node) {
-   r = st_nci_i2c_of_request_resources(client);
-   if (r) {
-   nfc_err(&client->dev, "No platform data\n");
-   return r;
-   }
-   } else if (ACPI_HANDLE(&client->dev)) {
-   r = st_nci_i2c_acpi_request_resources(client);
-   if (r) {
-   nfc_err(&client->dev, "Cannot get ACPI data\n");
-   return r;
-   }
-   } else {
-   nfc_err(&client->dev,
-   "st_nci platform resources not available\n");
+   r = devm_acpi_dev_add_driver_gpios(dev, acpi_st_nci_gpios);
+   if (r)
+   dev_dbg(dev, "Unable to add GPIO mapping table\n");
+
+   /* Get RESET GPIO */
+   phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+   if (IS_ERR(phy->gpiod_reset)) {
+   nfc_err(dev, "Unable to get RESET GPIO\n");
return -ENODEV;
}
 
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index 80afdb9ea248..5be9fd326488 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -225,41 +225,6 @@ static const struct acpi_gpio_mapping acpi_st_nci_gpios[] 
= {
{},
 };
 
-static int st_nci_spi_acpi_request_resources(struct spi_device *spi_dev)
-{
-   struct st_nci_spi_phy *phy = spi_get_drvdata(spi_dev);
-   struct device *dev = &spi_dev->dev;
-   int r;
-
-   r = devm_acpi_dev_add_driver_gpios(dev, acpi_st_nci_gpios);
-   if (r)
-   return r;
-
-   /* Get RESET GPIO from ACPI */
-   phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
-   if (IS_ERR(phy->gpiod_reset)) {
-   nfc_err(dev, "Unable to get RESET GPIO\n");
-   return PTR_ERR(phy->gpiod_reset);
-   }
-
-   return 0;
-}
-
-static int st_nci_spi_of_request_resources(struct spi_device *dev)
-{
-   struct st_nci_spi_phy *phy = spi_get_drvdata(dev);
-   struct device *dev = &dev->dev;
-
-   /* Get GPIO from device tree */
-   phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
-   if (IS_ERR(phy->gpiod_reset)) {
-   nfc_err(dev, "Unable to get RESET GPIO\n");
-   return PTR_ERR(phy->gpiod_reset);
-   }
-
-   return 0;
-}
-
 static int st_nci_spi_pro

[PATCH v2 04/12] NFC: fdp: Convert I2C driver to ->probe_new()

2017-06-05 Thread Andy Shevchenko
There is no platform code that uses i2c module table. Remove it altogether and
adjust ->probe() to be ->probe_new().

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/fdp/i2c.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
index 712936f5d2d6..754d8d89c580 100644
--- a/drivers/nfc/fdp/i2c.c
+++ b/drivers/nfc/fdp/i2c.c
@@ -281,8 +281,7 @@ static void fdp_nci_i2c_read_device_properties(struct 
device *dev,
*clock_type, *clock_freq, *fw_vsc_cfg != NULL ? "yes" : "no");
 }
 
-static int fdp_nci_i2c_probe(struct i2c_client *client,
-const struct i2c_device_id *id)
+static int fdp_nci_i2c_probe(struct i2c_client *client)
 {
struct fdp_i2c_phy *phy;
struct device *dev = &client->dev;
@@ -360,12 +359,6 @@ static int fdp_nci_i2c_remove(struct i2c_client *client)
return 0;
 }
 
-static struct i2c_device_id fdp_nci_i2c_id_table[] = {
-   {"int339a", 0},
-   {}
-};
-MODULE_DEVICE_TABLE(i2c, fdp_nci_i2c_id_table);
-
 static const struct acpi_device_id fdp_nci_i2c_acpi_match[] = {
{"INT339A", 0},
{}
@@ -377,8 +370,7 @@ static struct i2c_driver fdp_nci_i2c_driver = {
   .name = FDP_I2C_DRIVER_NAME,
   .acpi_match_table = ACPI_PTR(fdp_nci_i2c_acpi_match),
  },
-   .id_table = fdp_nci_i2c_id_table,
-   .probe = fdp_nci_i2c_probe,
+   .probe_new = fdp_nci_i2c_probe,
.remove = fdp_nci_i2c_remove,
 };
 module_i2c_driver(fdp_nci_i2c_driver);
-- 
2.11.0



[PATCH v2 02/12] NFC: st21nfca: Add GPIO ACPI mapping table

2017-06-05 Thread Andy Shevchenko
In order to make GPIO ACPI library stricter prepare users of
gpiod_get_index() to correctly behave when there no mapping is
provided by firmware.

Here we add explicit mapping between _CRS GpioIo() resources and
their names used in the driver.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/st21nfca/i2c.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c
index 02a920ca07c8..9b889e017a9d 100644
--- a/drivers/nfc/st21nfca/i2c.c
+++ b/drivers/nfc/st21nfca/i2c.c
@@ -501,14 +501,25 @@ static struct nfc_phy_ops i2c_phy_ops = {
.disable = st21nfca_hci_i2c_disable,
 };
 
+static const struct acpi_gpio_params enable_gpios = { 1, 0, false };
+
+static const struct acpi_gpio_mapping acpi_st21nfca_gpios[] = {
+   { "enable-gpios", &enable_gpios, 1 },
+   {},
+};
+
 static int st21nfca_hci_i2c_acpi_request_resources(struct i2c_client *client)
 {
struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client);
struct device *dev = &client->dev;
+   int ret;
+
+   ret = devm_acpi_dev_add_driver_gpios(dev, acpi_st21nfca_gpios);
+   if (ret)
+   return ret;
 
/* Get EN GPIO from ACPI */
-   phy->gpiod_ena = devm_gpiod_get_index(dev, ST21NFCA_GPIO_NAME_EN, 1,
- GPIOD_OUT_LOW);
+   phy->gpiod_ena = devm_gpiod_get(dev, ST21NFCA_GPIO_NAME_EN, 
GPIOD_OUT_LOW);
if (IS_ERR(phy->gpiod_ena)) {
nfc_err(dev, "Unable to get ENABLE GPIO\n");
return PTR_ERR(phy->gpiod_ena);
@@ -523,8 +534,7 @@ static int st21nfca_hci_i2c_of_request_resources(struct 
i2c_client *client)
struct device *dev = &client->dev;
 
/* Get GPIO from device tree */
-   phy->gpiod_ena = devm_gpiod_get_index(dev, ST21NFCA_GPIO_NAME_EN, 0,
- GPIOD_OUT_HIGH);
+   phy->gpiod_ena = devm_gpiod_get(dev, ST21NFCA_GPIO_NAME_EN, 
GPIOD_OUT_HIGH);
if (IS_ERR(phy->gpiod_ena)) {
nfc_err(dev, "Failed to request enable pin\n");
return PTR_ERR(phy->gpiod_ena);
-- 
2.11.0



[PATCH v2 03/12] NFC: st21nfca: Get rid of code duplication in ->probe()

2017-06-05 Thread Andy Shevchenko
Since OF and ACPI case almost the same get rid of code duplication
by moving gpiod_get() calls directly to ->probe().

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/st21nfca/i2c.c | 62 --
 1 file changed, 10 insertions(+), 52 deletions(-)

diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c
index 9b889e017a9d..e0efe3e77745 100644
--- a/drivers/nfc/st21nfca/i2c.c
+++ b/drivers/nfc/st21nfca/i2c.c
@@ -61,8 +61,6 @@
 #define ST21NFCA_HCI_DRIVER_NAME "st21nfca_hci"
 #define ST21NFCA_HCI_I2C_DRIVER_NAME "st21nfca_hci_i2c"
 
-#define ST21NFCA_GPIO_NAME_EN "enable"
-
 struct st21nfca_i2c_phy {
struct i2c_client *i2c_dev;
struct nfc_hci_dev *hdev;
@@ -508,44 +506,10 @@ static const struct acpi_gpio_mapping 
acpi_st21nfca_gpios[] = {
{},
 };
 
-static int st21nfca_hci_i2c_acpi_request_resources(struct i2c_client *client)
-{
-   struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client);
-   struct device *dev = &client->dev;
-   int ret;
-
-   ret = devm_acpi_dev_add_driver_gpios(dev, acpi_st21nfca_gpios);
-   if (ret)
-   return ret;
-
-   /* Get EN GPIO from ACPI */
-   phy->gpiod_ena = devm_gpiod_get(dev, ST21NFCA_GPIO_NAME_EN, 
GPIOD_OUT_LOW);
-   if (IS_ERR(phy->gpiod_ena)) {
-   nfc_err(dev, "Unable to get ENABLE GPIO\n");
-   return PTR_ERR(phy->gpiod_ena);
-   }
-
-   return 0;
-}
-
-static int st21nfca_hci_i2c_of_request_resources(struct i2c_client *client)
-{
-   struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client);
-   struct device *dev = &client->dev;
-
-   /* Get GPIO from device tree */
-   phy->gpiod_ena = devm_gpiod_get(dev, ST21NFCA_GPIO_NAME_EN, 
GPIOD_OUT_HIGH);
-   if (IS_ERR(phy->gpiod_ena)) {
-   nfc_err(dev, "Failed to request enable pin\n");
-   return PTR_ERR(phy->gpiod_ena);
-   }
-
-   return 0;
-}
-
 static int st21nfca_hci_i2c_probe(struct i2c_client *client,
  const struct i2c_device_id *id)
 {
+   struct device *dev = &client->dev;
struct st21nfca_i2c_phy *phy;
int r;
 
@@ -572,21 +536,15 @@ static int st21nfca_hci_i2c_probe(struct i2c_client 
*client,
mutex_init(&phy->phy_lock);
i2c_set_clientdata(client, phy);
 
-   if (client->dev.of_node) {
-   r = st21nfca_hci_i2c_of_request_resources(client);
-   if (r) {
-   nfc_err(&client->dev, "No platform data\n");
-   return r;
-   }
-   } else if (ACPI_HANDLE(&client->dev)) {
-   r = st21nfca_hci_i2c_acpi_request_resources(client);
-   if (r) {
-   nfc_err(&client->dev, "Cannot get ACPI data\n");
-   return r;
-   }
-   } else {
-   nfc_err(&client->dev, "st21nfca platform resources not 
available\n");
-   return -ENODEV;
+   r = devm_acpi_dev_add_driver_gpios(dev, acpi_st21nfca_gpios);
+   if (r)
+   dev_dbg(dev, "Unable to add GPIO mapping table\n");
+
+   /* Get EN GPIO from resource provider */
+   phy->gpiod_ena = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
+   if (IS_ERR(phy->gpiod_ena)) {
+   nfc_err(dev, "Unable to get ENABLE GPIO\n");
+   return PTR_ERR(phy->gpiod_ena);
}
 
phy->se_status.is_ese_present =
-- 
2.11.0



[PATCH v2 06/12] NFC: fdp: Add GPIO ACPI mapping table

2017-06-05 Thread Andy Shevchenko
In order to make GPIO ACPI library stricter prepare users of
gpiod_get_index() to correctly behave when there no mapping is
provided by firmware.

Here we add explicit mapping between _CRS GpioIo() resources and
their names used in the driver.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/fdp/i2c.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
index 250cbaddb5a9..9f79f2c53525 100644
--- a/drivers/nfc/fdp/i2c.c
+++ b/drivers/nfc/fdp/i2c.c
@@ -27,7 +27,6 @@
 
 #define FDP_I2C_DRIVER_NAME"fdp_nci_i2c"
 
-#define FDP_DP_POWER_GPIO_NAME "power"
 #define FDP_DP_CLOCK_TYPE_NAME "clock-type"
 #define FDP_DP_CLOCK_FREQ_NAME "clock-freq"
 #define FDP_DP_FW_VSC_CFG_NAME "fw-vsc-cfg"
@@ -281,6 +280,13 @@ static void fdp_nci_i2c_read_device_properties(struct 
device *dev,
*clock_type, *clock_freq, *fw_vsc_cfg != NULL ? "yes" : "no");
 }
 
+static const struct acpi_gpio_params power_gpios = { 0, 0, false };
+
+static const struct acpi_gpio_mapping acpi_fdp_gpios[] = {
+   { "power-gpios", &power_gpios, 1 },
+   {},
+};
+
 static int fdp_nci_i2c_probe(struct i2c_client *client)
 {
struct fdp_i2c_phy *phy;
@@ -321,10 +327,12 @@ static int fdp_nci_i2c_probe(struct i2c_client *client)
return r;
}
 
-   /* Requesting the power gpio */
-   phy->power_gpio = devm_gpiod_get(dev, FDP_DP_POWER_GPIO_NAME,
-GPIOD_OUT_LOW);
+   r = devm_acpi_dev_add_driver_gpios(dev, acpi_fdp_gpios);
+   if (r)
+   dev_dbg(dev, "Unable to add GPIO mapping table\n");
 
+   /* Requesting the power gpio */
+   phy->power_gpio = devm_gpiod_get(dev, "power", GPIOD_OUT_LOW);
if (IS_ERR(phy->power_gpio)) {
nfc_err(dev, "Power GPIO request failed\n");
return PTR_ERR(phy->power_gpio);
-- 
2.11.0



[PATCH v2 05/12] NFC: fdp: Convert to use devres API

2017-06-05 Thread Andy Shevchenko
It looks like there are two leftovers, at least one of which can leak
the resource (IRQ).

Convert both places to use devm variants of functions.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/fdp/fdp.c | 15 ---
 drivers/nfc/fdp/i2c.c | 10 +-
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/nfc/fdp/fdp.c b/drivers/nfc/fdp/fdp.c
index 7c1eaea3b685..8946eb21128d 100644
--- a/drivers/nfc/fdp/fdp.c
+++ b/drivers/nfc/fdp/fdp.c
@@ -750,11 +750,9 @@ int fdp_nci_probe(struct fdp_i2c_phy *phy, struct 
nfc_phy_ops *phy_ops,
u32 protocols;
int r;
 
-   info = kzalloc(sizeof(struct fdp_nci_info), GFP_KERNEL);
-   if (!info) {
-   r = -ENOMEM;
-   goto err_info_alloc;
-   }
+   info = devm_kzalloc(dev, sizeof(struct fdp_nci_info), GFP_KERNEL);
+   if (!info)
+   return -ENOMEM;
 
info->phy = phy;
info->phy_ops = phy_ops;
@@ -776,8 +774,7 @@ int fdp_nci_probe(struct fdp_i2c_phy *phy, struct 
nfc_phy_ops *phy_ops,
   tx_tailroom);
if (!ndev) {
nfc_err(dev, "Cannot allocate nfc ndev\n");
-   r = -ENOMEM;
-   goto err_alloc_ndev;
+   return -ENOMEM;
}
 
r = nci_register_device(ndev);
@@ -793,9 +790,6 @@ int fdp_nci_probe(struct fdp_i2c_phy *phy, struct 
nfc_phy_ops *phy_ops,
 
 err_regdev:
nci_free_device(ndev);
-err_alloc_ndev:
-   kfree(info);
-err_info_alloc:
return r;
 }
 EXPORT_SYMBOL(fdp_nci_probe);
@@ -809,7 +803,6 @@ void fdp_nci_remove(struct nci_dev *ndev)
 
nci_unregister_device(ndev);
nci_free_device(ndev);
-   kfree(info);
 }
 EXPORT_SYMBOL(fdp_nci_remove);
 
diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
index 754d8d89c580..250cbaddb5a9 100644
--- a/drivers/nfc/fdp/i2c.c
+++ b/drivers/nfc/fdp/i2c.c
@@ -303,8 +303,7 @@ static int fdp_nci_i2c_probe(struct i2c_client *client)
return -ENODEV;
}
 
-   phy = devm_kzalloc(dev, sizeof(struct fdp_i2c_phy),
-  GFP_KERNEL);
+   phy = devm_kzalloc(dev, sizeof(struct fdp_i2c_phy), GFP_KERNEL);
if (!phy)
return -ENOMEM;
 
@@ -312,9 +311,10 @@ static int fdp_nci_i2c_probe(struct i2c_client *client)
phy->next_read_size = FDP_NCI_I2C_MIN_PAYLOAD;
i2c_set_clientdata(client, phy);
 
-   r = request_threaded_irq(client->irq, NULL, fdp_nci_i2c_irq_thread_fn,
-IRQF_TRIGGER_RISING | IRQF_ONESHOT,
-FDP_I2C_DRIVER_NAME, phy);
+   r = devm_request_threaded_irq(dev, client->irq,
+ NULL, fdp_nci_i2c_irq_thread_fn,
+ IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+ FDP_I2C_DRIVER_NAME, phy);
 
if (r < 0) {
nfc_err(&client->dev, "Unable to register IRQ handler\n");
-- 
2.11.0



[PATCH v2 01/12] NFC: pn544: Switch to devm_acpi_dev_add_driver_gpios()

2017-06-05 Thread Andy Shevchenko
Switch to use managed variant of acpi_dev_add_driver_gpios() to simplify
error path and fix potentially wrong assingment if ->probe() fails.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/pn544/i2c.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c
index 71ac0836c9f4..619181e5b395 100644
--- a/drivers/nfc/pn544/i2c.c
+++ b/drivers/nfc/pn544/i2c.c
@@ -904,7 +904,7 @@ static int pn544_hci_i2c_probe(struct i2c_client *client,
phy->i2c_dev = client;
i2c_set_clientdata(client, phy);
 
-   r = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_pn544_gpios);
+   r = devm_acpi_dev_add_driver_gpios(dev, acpi_pn544_gpios);
if (r)
dev_dbg(dev, "Unable to add GPIO mapping table\n");
 
@@ -958,7 +958,6 @@ static int pn544_hci_i2c_remove(struct i2c_client *client)
if (phy->powered)
pn544_hci_i2c_disable(phy);
 
-   acpi_dev_remove_driver_gpios(ACPI_COMPANION(&client->dev));
return 0;
 }
 
-- 
2.11.0



[PATCH v2 10/12] NFC: st-nci: Use unified device property API meaningfully

2017-06-05 Thread Andy Shevchenko
Use unified device property API in meaningful way.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/st-nci/i2c.c | 30 ++
 drivers/nfc/st-nci/spi.c | 29 +
 2 files changed, 11 insertions(+), 48 deletions(-)

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index cc63c2f6823f..157e2eae 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -209,7 +209,6 @@ static int st_nci_i2c_acpi_request_resources(struct 
i2c_client *client)
 {
struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
struct device *dev = &client->dev;
-   u8 tmp;
 
/* Get RESET GPIO from ACPI */
phy->gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET, 1, 
GPIOD_OUT_HIGH);
@@ -218,19 +217,6 @@ static int st_nci_i2c_acpi_request_resources(struct 
i2c_client *client)
return -ENODEV;
}
 
-   phy->se_status.is_ese_present = false;
-   phy->se_status.is_uicc_present = false;
-
-   if (device_property_present(dev, "ese-present")) {
-   device_property_read_u8(dev, "ese-present", &tmp);
-   phy->se_status.is_ese_present = tmp;
-   }
-
-   if (device_property_present(dev, "uicc-present")) {
-   device_property_read_u8(dev, "uicc-present", &tmp);
-   phy->se_status.is_uicc_present = tmp;
-   }
-
return 0;
 }
 
@@ -238,11 +224,6 @@ static int st_nci_i2c_of_request_resources(struct 
i2c_client *client)
 {
struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
struct device *dev = &client->dev;
-   struct device_node *pp;
-
-   pp = client->dev.of_node;
-   if (!pp)
-   return -ENODEV;
 
/* Get GPIO from device tree */
phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
@@ -251,17 +232,13 @@ static int st_nci_i2c_of_request_resources(struct 
i2c_client *client)
return PTR_ERR(phy->gpiod_reset);
}
 
-   phy->se_status.is_ese_present =
-   of_property_read_bool(pp, "ese-present");
-   phy->se_status.is_uicc_present =
-   of_property_read_bool(pp, "uicc-present");
-
return 0;
 }
 
 static int st_nci_i2c_probe(struct i2c_client *client,
  const struct i2c_device_id *id)
 {
+   struct device *dev = &client->dev;
struct st_nci_i2c_phy *phy;
int r;
 
@@ -300,6 +277,11 @@ static int st_nci_i2c_probe(struct i2c_client *client,
return -ENODEV;
}
 
+   phy->se_status.is_ese_present =
+   device_property_read_bool(dev, "ese-present");
+   phy->se_status.is_uicc_present =
+   device_property_read_bool(dev, "uicc-present");
+
r = ndlc_probe(phy, &i2c_phy_ops, &client->dev,
ST_NCI_FRAME_HEADROOM, ST_NCI_FRAME_TAILROOM,
&phy->ndlc, &phy->se_status);
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index acf339d83360..d21259cf42c0 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -224,7 +224,6 @@ static int st_nci_spi_acpi_request_resources(struct 
spi_device *spi_dev)
 {
struct st_nci_spi_phy *phy = spi_get_drvdata(spi_dev);
struct device *dev = &spi_dev->dev;
-   u8 tmp;
 
/* Get RESET GPIO from ACPI */
phy->gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET, 1, 
GPIOD_OUT_HIGH);
@@ -233,19 +232,6 @@ static int st_nci_spi_acpi_request_resources(struct 
spi_device *spi_dev)
return PTR_ERR(phy->gpiod_reset);
}
 
-   phy->se_status.is_ese_present = false;
-   phy->se_status.is_uicc_present = false;
-
-   if (device_property_present(dev, "ese-present")) {
-   device_property_read_u8(dev, "ese-present", &tmp);
-   tmp = phy->se_status.is_ese_present;
-   }
-
-   if (device_property_present(dev, "uicc-present")) {
-   device_property_read_u8(dev, "uicc-present", &tmp);
-   tmp = phy->se_status.is_uicc_present;
-   }
-
return 0;
 }
 
@@ -253,11 +239,6 @@ static int st_nci_spi_of_request_resources(struct 
spi_device *dev)
 {
struct st_nci_spi_phy *phy = spi_get_drvdata(dev);
struct device *dev = &dev->dev;
-   struct device_node *pp;
-
-   pp = dev->dev.of_node;
-   if (!pp)
-   return -ENODEV;
 
/* Get GPIO from device tree */
phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
@@ -266,11 +247,6 @@ static

[PATCH v2 08/12] NFC: st-nci: Get rid of "interesting" use of interrupt polarity

2017-06-05 Thread Andy Shevchenko
I2C and SPI frameworks followed by IRQ framework do set
interrupt polarity correctly if it's properly specified in firmware
(ACPI or DT).

Get rid of the redundant trick when requesting interrupt.

Signed-off-by: Andy Shevchenko 
---
 drivers/nfc/st-nci/i2c.c | 8 +---
 drivers/nfc/st-nci/spi.c | 8 +---
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index 6d3d8e43fa50..bdfbd543e671 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -21,7 +21,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -51,7 +50,6 @@ struct st_nci_i2c_phy {
bool irq_active;
 
unsigned int gpio_reset;
-   unsigned int irq_polarity;
 
struct st_nci_se_status se_status;
 };
@@ -225,8 +223,6 @@ static int st_nci_i2c_acpi_request_resources(struct 
i2c_client *client)
 
phy->gpio_reset = desc_to_gpio(gpiod_reset);
 
-   phy->irq_polarity = irq_get_trigger_type(client->irq);
-
phy->se_status.is_ese_present = false;
phy->se_status.is_uicc_present = false;
 
@@ -271,8 +267,6 @@ static int st_nci_i2c_of_request_resources(struct 
i2c_client *client)
}
phy->gpio_reset = gpio;
 
-   phy->irq_polarity = irq_get_trigger_type(client->irq);
-
phy->se_status.is_ese_present =
of_property_read_bool(pp, "ese-present");
phy->se_status.is_uicc_present =
@@ -333,7 +327,7 @@ static int st_nci_i2c_probe(struct i2c_client *client,
phy->irq_active = true;
r = devm_request_threaded_irq(&client->dev, client->irq, NULL,
st_nci_irq_thread_fn,
-   phy->irq_polarity | IRQF_ONESHOT,
+   IRQF_ONESHOT,
ST_NCI_DRIVER_NAME, phy);
if (r < 0)
nfc_err(&client->dev, "Unable to register IRQ handler\n");
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index ee8ea708d5b7..4585e205778b 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -21,7 +21,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -52,7 +51,6 @@ struct st_nci_spi_phy {
bool irq_active;
 
unsigned int gpio_reset;
-   unsigned int irq_polarity;
 
struct st_nci_se_status se_status;
 };
@@ -240,8 +238,6 @@ static int st_nci_spi_acpi_request_resources(struct 
spi_device *spi_dev)
 
phy->gpio_reset = desc_to_gpio(gpiod_reset);
 
-   phy->irq_polarity = irq_get_trigger_type(spi_dev->irq);
-
phy->se_status.is_ese_present = false;
phy->se_status.is_uicc_present = false;
 
@@ -286,8 +282,6 @@ static int st_nci_spi_of_request_resources(struct 
spi_device *dev)
}
phy->gpio_reset = gpio;
 
-   phy->irq_polarity = irq_get_trigger_type(dev->irq);
-
phy->se_status.is_ese_present =
of_property_read_bool(pp, "ese-present");
phy->se_status.is_uicc_present =
@@ -349,7 +343,7 @@ static int st_nci_spi_probe(struct spi_device *dev)
phy->irq_active = true;
r = devm_request_threaded_irq(&dev->dev, dev->irq, NULL,
st_nci_irq_thread_fn,
-   phy->irq_polarity | IRQF_ONESHOT,
+   IRQF_ONESHOT,
ST_NCI_SPI_DRIVER_NAME, phy);
if (r < 0)
nfc_err(&dev->dev, "Unable to register IRQ handler\n");
-- 
2.11.0



  1   2   >