24 Aug, 2018

1 commit

  • [ Upstream commit ecc443c03fb14abfb8a6af5e3b2d43b5257e60f2 ]

    pn533_recv_response() is an urb completion handler, so it must use
    GFP_ATOMIC. pn533_usb_send_frame() OTOH runs from a regular sleeping
    context, so the pn533_submit_urb_for_response() there (and only there)
    can use the regular GFP_KERNEL flags.

    BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1514134
    Fixes: 9815c7cf22da ("NFC: pn533: Separate physical layer from ...")
    Cc: Michael Thalmeier
    Signed-off-by: Hans de Goede
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Hans de Goede
     

16 Jun, 2018

1 commit

  • commit dbafc28955fa6779dc23d1607a0fee5e509a278b upstream.

    It's amazing that this driver ever worked, but now that x86 doesn't
    allow USB data to be sent off of the stack, it really does not work at
    all. Fix this up by properly allocating the data for the small
    "commands" that get sent to the device off of the stack.

    We do this for one command by having a whole urb just for ack messages,
    as they can be submitted in interrupt context, so we can not use
    usb_bulk_msg(). But the poweron command can sleep (and does), so use
    usb_bulk_msg() for that transfer.

    Reported-by: Carlos Manuel Santos
    Cc: Samuel Ortiz
    Cc: Stephen Hemminger
    Cc: stable
    Reviewed-by: Johan Hovold
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

02 Jul, 2017

1 commit

  • Samuel Ortiz says:

    ====================
    NFC 4.13 pull request

    This is the NFC pull requesy for 4.13. We have:

    - A conversion to unified device and GPIO APIs for the
    fdp, pn544, and st{21,-nci} drivers.
    - A fix for NFC device IDs allocation.
    - A fix for the nfcmrvl driver firmware download mechanism.
    - A trf7970a DT and GPIO cleanup and clock setting fix.
    - A few fixes for potential overflows in the digital and LLCP code.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

28 Jun, 2017

1 commit


23 Jun, 2017

15 commits

  • NULL checks at line 457: if (!link0 || !link1) {, implies that both
    pointers link0 and link1 might be NULL.
    Function nfcsim_link_free() dereference pointers link0 and link1.
    Add NULL checks before calling nfcsim_link_free() to avoid a
    potential NULL pointer dereference.

    Addresses-Coverity-ID: 1364857
    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Samuel Ortiz

    Gustavo A. R. Silva
     
  • This reverts commit ab714817d7e891608d31f6996b1e4c43cf2bf342.

    The original commit was designed to handle a bug in the trf7970a NFC
    controller where an extra byte was returned in Read Multiple Blocks (RMB)
    command responses. However, it has become less clear whether it is a bug
    in the trf7970a or in the tag. In addition, it was assumed that the extra
    byte was always returned but it turns out that is not always the case. The
    result is that a byte of good data is trimmed off when the extra byte is
    not present ultimately causing the neard deamon to fail the read.

    Since the trf7970a driver does not have the context to know when to trim
    the byte or not, remove the code from the trf7970a driver all together
    (and move it up to the neard daemon). This has the added benefit of
    simplifying the kernel driver and putting the extra complexity into
    userspace.

    CC: Rob Herring
    CC: devicetree@vger.kernel.org
    Signed-off-by: Mark Greer
    Signed-off-by: Samuel Ortiz

    Mark Greer
     
  • The "or" condition (clk_freq != TRF7970A_27MHZ_CLOCK_FREQUENCY) ||
    (clk_freq != TRF7970A_13MHZ_CLOCK_FREQUE) will always be true because
    clk_freq cannot be equal to two different values at the same time. Use
    the && operator instead of || to fix this.

    Detected by CoverityScan, CID#1430468 ("Constant expression result")

    Fixes: 837eb4d21ecde7 ("NFC: trf7970a: add device tree option for 27MHz clock")
    Signed-off-by: Colin Ian King
    Acked-by: Geoff Lansberry
    Signed-off-by: Samuel Ortiz

    Colin Ian King
     
  • 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
    Signed-off-by: Samuel Ortiz

    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
    Signed-off-by: Samuel Ortiz

    Andy Shevchenko
     
  • Use unified device properties API in meaningful way.

    Signed-off-by: Andy Shevchenko
    Signed-off-by: Samuel Ortiz

    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
    Signed-off-by: Samuel Ortiz

    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
    Signed-off-by: Samuel Ortiz

    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
    Signed-off-by: Samuel Ortiz

    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
    Signed-off-by: Samuel Ortiz

    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
    Signed-off-by: Samuel Ortiz

    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
    Signed-off-by: Samuel Ortiz

    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
    Signed-off-by: Samuel Ortiz

    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
    Signed-off-by: Samuel Ortiz

    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
    Signed-off-by: Samuel Ortiz

    Andy Shevchenko
     

21 Jun, 2017

1 commit


19 Jun, 2017

14 commits

  • Allow gpio 0 to be used for reset signalling, and instead use negative
    errnos to disable the reset functionality.

    Signed-off-by: Johan Hovold
    Signed-off-by: Samuel Ortiz

    Johan Hovold
     
  • Use the USB-interface rather than parent USB-device device, which is
    what this driver binds to, when registering the nci device.

    Note that using the right device is important when dealing with device-
    managed resources as the interface can be unbound independently of the
    parent device.

    Also note that private device pointer had already been set by
    nfcmrvl_nci_register_dev() so the redundant assignment can therefore be
    removed.

    Signed-off-by: Johan Hovold
    Signed-off-by: Samuel Ortiz

    Johan Hovold
     
  • Make sure to release the device-node reference when done parsing the
    node.

    Fixes: e097dc624f78 ("NFC: nfcmrvl: add UART driver")
    Cc: Vincent Cuissard
    Signed-off-by: Johan Hovold
    Signed-off-by: Samuel Ortiz

    Johan Hovold
     
  • The nci-device was never deregistered in the event that
    fw-initialisation failed.

    Fix this by moving the firmware initialisation before device
    registration since the firmware work queue should be available before
    registering.

    Note that this depends on a recent fix that moved device-name
    initialisation back to to nci_allocate_device() as the
    firmware-workqueue name is now derived from the nfc-device name.

    Fixes: 3194c6870158 ("NFC: nfcmrvl: add firmware download support")
    Cc: stable # 4.4
    Cc: Vincent Cuissard
    Signed-off-by: Johan Hovold
    Signed-off-by: Samuel Ortiz

    Johan Hovold
     
  • Use the nfc- rather than phy-device in firmware-management code that
    needs a valid struct device.

    This specifically fixes a NULL-pointer dereference in
    nfcmrvl_fw_dnld_init() during registration when the underlying tty is
    one end of a Unix98 pty.

    Note that the driver still uses the phy device for any debugging, which
    is fine for now.

    Fixes: 3194c6870158 ("NFC: nfcmrvl: add firmware download support")
    Cc: stable # 4.4
    Cc: Vincent Cuissard
    Signed-off-by: Johan Hovold
    Signed-off-by: Samuel Ortiz

    Johan Hovold
     
  • This specifically fixes resource leaks in the registration error paths.

    Device-managed resources is a bad fit for this driver as devices can be
    registered from the n_nci line discipline. Firstly, a tty may not even
    have a corresponding device (should it be part of a Unix98 pty)
    something which would lead to a NULL-pointer dereference when
    registering resources.

    Secondly, if the tty has a class device, its lifetime exceeds that of
    the line discipline, which means that resources would leak every time
    the line discipline is closed (or if registration fails).

    Currently, the devres interface was only being used to request a reset
    gpio despite the fact that it was already explicitly freed in
    nfcmrvl_nci_unregister_dev() (along with the private data), something
    which also prevented the resource leak at close.

    Note that the driver treats gpio number 0 as invalid despite it being
    perfectly valid. This will be addressed in a follow-up patch.

    Fixes: b2fe288eac72 ("NFC: nfcmrvl: free reset gpio")
    Fixes: 4a2b947f56b3 ("NFC: nfcmrvl: add chip reset management")
    Cc: stable # 4.2: b2fe288eac72
    Cc: Vincent Cuissard
    Signed-off-by: Johan Hovold
    Signed-off-by: Samuel Ortiz

    Johan Hovold
     
  • Make sure to check the tty-device pointer before trying to access the
    parent device to avoid dereferencing a NULL-pointer when the tty is one
    end of a Unix98 pty.

    Fixes: e097dc624f78 ("NFC: nfcmrvl: add UART driver")
    Cc: stable # 4.2
    Cc: Vincent Cuissard
    Signed-off-by: Johan Hovold
    Signed-off-by: Samuel Ortiz

    Johan Hovold
     
  • Clean up coding style issues according to scripts/Lindent.
    Some scripts/Lindent changes were reverted when it appeared
    to make the code less readable or when it made the line run
    over 80 characters.

    Signed-off-by: Mark Greer
    Signed-off-by: Samuel Ortiz

    Mark Greer
     
  • The trf7970a driver uses the deprecated integer-based GPIO consumer
    interface so convert it to use the new descriptor-based GPIO
    consumer interface.

    Signed-off-by: Mark Greer
    Signed-off-by: Samuel Ortiz

    Mark Greer
     
  • The 'vin-voltage-override' DT property is used by the trf7970a
    driver to override the voltage presented to the driver by the
    regulator subsystem. This is unnecessary as properly specifying
    the regulator chain via DT properties will accomplish the same
    thing. Therefore, remove support for 'vin-voltage-override'.

    Signed-off-by: Mark Greer
    Signed-off-by: Samuel Ortiz

    Mark Greer
     
  • The last entry in the trf7970a_of_match[] table must be an empty
    entry to demarcate the end of the table. Currently, there is a
    comment indicating this but it is obvious so remove the comment.

    Signed-off-by: Mark Greer
    Signed-off-by: Samuel Ortiz

    Mark Greer
     
  • The quirk indicated by the 'en2-rf-quirk' device tree property
    is only relevant when there is a GPIO connected to the EN2 pin
    of the trf7970a. This means we should only check for 'en2-rf-quirk'
    when EN2 is specified in the 'ti,enable-gpios' property of the
    device tree.

    Signed-off-by: Mark Greer
    Signed-off-by: Samuel Ortiz

    Mark Greer
     
  • As of commit ce69b95ca4e4 ("NFC: Make EN2 pin optional in the
    TRF7970A driver"), only the GPIO for the 'EN' enable pin needs
    to be specified in the device tree so update the comments that
    says both 'EN' and 'EN2' must be specified.

    Signed-off-by: Mark Greer
    Signed-off-by: Samuel Ortiz

    Mark Greer
     
  • When the trf7970a part has the bug related to 'en2-rf-quirk',
    the GPIO connected to the EN2 pin will not be asserted by the
    driver when powering up so it shouldn't be de-asserted when
    powering down.

    Signed-off-by: Mark Greer
    Signed-off-by: Samuel Ortiz

    Mark Greer
     

16 Jun, 2017

5 commits

  • Joe and Bjørn suggested that it'd be nicer to not have the
    cast in the fairly common case of doing
    *(u8 *)skb_put(skb, 1) = c;

    Add skb_put_u8() for this case, and use it across the code,
    using the following spatch:

    @@
    expression SKB, C, S;
    typedef u8;
    identifier fn = {skb_put};
    fresh identifier fn2 = fn ## "_u8";
    @@
    - *(u8 *)fn(SKB, S) = C;
    + fn2(SKB, C);

    Note that due to the "S", the spatch isn't perfect, it should
    have checked that S is 1, but there's also places that use a
    sizeof expression like sizeof(var) or sizeof(u8) etc. Turns
    out that nobody ever did something like
    *(u8 *)skb_put(skb, 2) = c;

    which would be wrong anyway since the second byte wouldn't be
    initialized.

    Suggested-by: Joe Perches
    Suggested-by: Bjørn Mork
    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • It seems like a historic accident that these return unsigned char *,
    and in many places that means casts are required, more often than not.

    Make these functions return void * and remove all the casts across
    the tree, adding a (u8 *) cast only where the unsigned char pointer
    was used directly, all done with the following spatch:

    @@
    expression SKB, LEN;
    typedef u8;
    identifier fn = { skb_push, __skb_push, skb_push_rcsum };
    @@
    - *(fn(SKB, LEN))
    + *(u8 *)fn(SKB, LEN)

    @@
    expression E, SKB, LEN;
    identifier fn = { skb_push, __skb_push, skb_push_rcsum };
    type T;
    @@
    - E = ((T *)(fn(SKB, LEN)))
    + E = fn(SKB, LEN)

    @@
    expression SKB, LEN;
    identifier fn = { skb_push, __skb_push, skb_push_rcsum };
    @@
    - fn(SKB, LEN)[0]
    + *(u8 *)fn(SKB, LEN)

    Note that the last part there converts from push(...)[0] to the
    more idiomatic *(u8 *)push(...).

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • It seems like a historic accident that these return unsigned char *,
    and in many places that means casts are required, more often than not.

    Make these functions return void * and remove all the casts across
    the tree, adding a (u8 *) cast only where the unsigned char pointer
    was used directly, all done with the following spatch:

    @@
    expression SKB, LEN;
    typedef u8;
    identifier fn = {
    skb_pull,
    __skb_pull,
    skb_pull_inline,
    __pskb_pull_tail,
    __pskb_pull,
    pskb_pull
    };
    @@
    - *(fn(SKB, LEN))
    + *(u8 *)fn(SKB, LEN)

    @@
    expression E, SKB, LEN;
    identifier fn = {
    skb_pull,
    __skb_pull,
    skb_pull_inline,
    __pskb_pull_tail,
    __pskb_pull,
    pskb_pull
    };
    type T;
    @@
    - E = ((T *)(fn(SKB, LEN)))
    + E = fn(SKB, LEN)

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • It seems like a historic accident that these return unsigned char *,
    and in many places that means casts are required, more often than not.

    Make these functions (skb_put, __skb_put and pskb_put) return void *
    and remove all the casts across the tree, adding a (u8 *) cast only
    where the unsigned char pointer was used directly, all done with the
    following spatch:

    @@
    expression SKB, LEN;
    typedef u8;
    identifier fn = { skb_put, __skb_put };
    @@
    - *(fn(SKB, LEN))
    + *(u8 *)fn(SKB, LEN)

    @@
    expression E, SKB, LEN;
    identifier fn = { skb_put, __skb_put };
    type T;
    @@
    - E = ((T *)(fn(SKB, LEN)))
    + E = fn(SKB, LEN)

    which actually doesn't cover pskb_put since there are only three
    users overall.

    A handful of stragglers were converted manually, notably a macro in
    drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many
    instances in net/bluetooth/hci_sock.c. In the former file, I also
    had to fix one whitespace problem spatch introduced.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • A common pattern with skb_put() is to just want to memcpy()
    some data into the new space, introduce skb_put_data() for
    this.

    An spatch similar to the one for skb_put_zero() converts many
    of the places using it:

    @@
    identifier p, p2;
    expression len, skb, data;
    type t, t2;
    @@
    (
    -p = skb_put(skb, len);
    +p = skb_put_data(skb, data, len);
    |
    -p = (t)skb_put(skb, len);
    +p = skb_put_data(skb, data, len);
    )
    (
    p2 = (t2)p;
    -memcpy(p2, data, len);
    |
    -memcpy(p, data, len);
    )

    @@
    type t, t2;
    identifier p, p2;
    expression skb, data;
    @@
    t *p;
    ...
    (
    -p = skb_put(skb, sizeof(t));
    +p = skb_put_data(skb, data, sizeof(t));
    |
    -p = (t *)skb_put(skb, sizeof(t));
    +p = skb_put_data(skb, data, sizeof(t));
    )
    (
    p2 = (t2)p;
    -memcpy(p2, data, sizeof(*p));
    |
    -memcpy(p, data, sizeof(*p));
    )

    @@
    expression skb, len, data;
    @@
    -memcpy(skb_put(skb, len), data, len);
    +skb_put_data(skb, data, len);

    (again, manually post-processed to retain some comments)

    Reviewed-by: Stephen Hemminger
    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg