1. 16 6月, 2017 4 次提交
    • J
      networking: add and use skb_put_u8() · 634fef61
      Johannes Berg 提交于
      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: NJoe Perches <joe@perches.com>
      Suggested-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      634fef61
    • J
      networking: make skb_push & __skb_push return void pointers · d58ff351
      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: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d58ff351
    • J
      networking: make skb_put & friends return void pointers · 4df864c1
      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: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4df864c1
    • J
      networking: introduce and use skb_put_data() · 59ae1d12
      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: NStephen Hemminger <stephen@networkplumber.org>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      59ae1d12
  2. 05 4月, 2017 5 次提交
  3. 02 4月, 2017 1 次提交
  4. 04 5月, 2016 4 次提交
    • C
      NFC: st21nfca: Drop two useless checks in ACPI probe path · 070718a4
      Christophe Ricard 提交于
      When st21nfca_hci_i2c_acpi_request_resources() gets called we
      already know that the entries in ->acpi_match_table have matched
      ACPI ID of the device.
      In addition I2C client pointer cannot be NULL in any case
      (otherwise I2C core would not call ->probe() for the driver in
      the first place).
      
      Drop the two useless checks from the driver.
      Signed-off-by: NChristophe Ricard <christophe-h.ricard@st.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      070718a4
    • C
      nfc: st21nfca: set is_ese_present and is_uicc_present properly · bd9d5232
      Christophe Ricard 提交于
      When they're present, set is_ese_present and set is_uicc_present
      to the value describe in their package description.
      
      So far is_ese_present and is_uicc_present was set to true if their
      property was present.
      Signed-off-by: NChristophe Ricard <christophe-h.ricard@st.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      bd9d5232
    • C
      nfc: st21nfca: i2c: Change ST21NFCA_GPIO_NAME_RESET to match DT · 2a196975
      Christophe Ricard 提交于
      Since
      commit 10cf4899 ("gpiolib: tighten up ACPI legacy gpio lookups")
      
      If _DSD properties are available in an ACPI node, we are not
      allowed to fallback to _CRS data to retrieve gpio properties.
      This was causing us to fail if uicc-present and/or ese-present
      are defined.
      
      To be consistent with devicetree change ST_NCI_GPIO_NAME_RESET
      content to reset so that acpi_find_gpio in drivers/gpio/gpiolib.c
      will look for reset-gpios. In the mean time the ACPI table needs
      to be fixed as follow:
      
      Device (NFC1)
      {
          Name (_ADR, Zero)  // _ADR: Address
          Name (_HID, "SMO2100")  // _HID: Hardware ID
          Name (_CID, "SMO2100")  // _CID: Compatible ID
          Name (_DDN, "SMO NFC")  // _DDN: DOS Device Name
          Name (_UID, One)  // _UID: Unique ID
          Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
          {
              Name (SBUF, ResourceTemplate ()
              {
                   I2cSerialBus (0x0008, ControllerInitiated, 400000,
                                 AddressingMode7Bit, "\\_SB.I2C7",
                                 0x00, ResourceConsumer, ,)
                   GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullNone, 0x0000,
                            "\\_SB.GPO2", 0x00, ResourceConsumer, ,)
                   {   // Pin list
                       0x0001
                   }
                   GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
                           "\\_SB.GPO2", 0x00, ResourceConsumer, ,)
                   {   // Pin list
                       0x0002,
                   }
              })
              Name (_DSD, Package (0x02)
              {
                   ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */,
                   Package (0x03)
                   {
                       Package (0x02) { "uicc-present", 1 },
                       Package (0x02) { "ese-present", 1 },
                       Package (0x02) { "enable-gpios", Package(0x04) { ^NFC1, 1, 0, 0} },
                   }
              })
              Return (SBUF) /* \_SB_.I2C7.NFC1._CRS.SBUF */
          }
          Method (_STA, 0, NotSerialized)  // _STA: Status
          {
              Return (0x0F)
          }
      }
      Signed-off-by: NChristophe Ricard <christophe-h.ricard@st.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      2a196975
    • C
      nfc: st21nfca: Fix static checker warning · b58afe6d
      Christophe Ricard 提交于
      Fix static checker warning:
      drivers/nfc/st21nfca/i2c.c:530 st21nfca_hci_i2c_acpi_request_resources()
      error: 'gpiod_ena' dereferencing possible ERR_PTR()
      
      Fix so that if no enable gpio can be retrieved an -ENODEV is returned.
      Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
      Fixes: dfa8070d ("nfc: st21nfca: Add support for acpi probing for i2c device.")
      Cc: stable@vger.kernel.org
      Signed-off-by: NChristophe Ricard <christophe-h.ricard@st.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      b58afe6d
  5. 02 5月, 2016 1 次提交
  6. 30 12月, 2015 6 次提交
  7. 27 10月, 2015 1 次提交
  8. 28 1月, 2015 1 次提交
    • C
      NFC: st21nfca: Adding support for secure element · 2130fb97
      Christophe Ricard 提交于
      st21nfca has 1 physical SWP line and can support up to 2 secure elements
      (UICC & eSE) thanks to an external switch managed with a gpio.
      
      The platform integrator needs to specify thanks to 2 initialization
      properties, uicc-present and ese-present, if it is suppose to have uicc
      and/or ese. Of course if the platform does not have an external switch,
      only one kind of secure element can be supported. Those parameters are
      under platform integrator responsibilities.
      
      During initialization, the white_list will be set according to those
      parameters.
      
      The discovery_se function will assume a secure element is physically
      present according to uicc-present and ese-present values and will add it
      to the secure element list. On ese activation, the atr is retrieved to
      calculate a command exchange timeout based on the first atr(TB) value.
      
      The se_io will allow to transfer data over SWP. 2 kind of events may appear
      after a data is sent over:
      - ST21NFCA_EVT_TRANSMIT_DATA when receiving an apdu answer
      - ST21NFCA_EVT_WTX_REQUEST when the secure element needs more time than
      expected to compute a command. If this timeout expired, a first recovery
      tentative consist to send a simple software reset proprietary command.
      If this tentative still fail, a second recovery tentative consist to send
      a hardware reset proprietary command.
      This function is only relevant for eSE like secure element.
      
      This patch also change the way a pipe is referenced. There can be
      different pipe connected to the same gate with different host destination
      (ex: CONNECTIVITY). In order to keep host information every pipe are
      reference with a tuple (gate, host). In order to reduce changes, we are
      keeping unchanged the way a gate is addressed on the Terminal Host.
      However, this is working because we consider the apdu reader gate is only
      present on the eSE slot also the connectivity gate cannot give a reliable
      value; it will give the latest stored pipe value.
      Signed-off-by: NChristophe Ricard <christophe-h.ricard@st.com>
      Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
      2130fb97
  9. 27 1月, 2015 1 次提交
  10. 26 1月, 2015 1 次提交
  11. 03 12月, 2014 1 次提交
  12. 02 12月, 2014 2 次提交
  13. 28 11月, 2014 1 次提交
  14. 08 9月, 2014 4 次提交
  15. 23 7月, 2014 3 次提交
  16. 20 5月, 2014 1 次提交
  17. 05 5月, 2014 3 次提交