1. 25 Aug, 2014 11 commits
    • David Herrmann's avatar
      HID: uhid: report to user-space whether reports are numbered · c2b2f16c
      David Herrmann authored
      This makes UHID_START include a "dev_flags" field that describes details
      of the hid-device in the kernel. The first flags we introduce describe
      whether a given report-type uses numbered reports. This is useful for
      transport layers that force report-numbers and therefore might have to
      prefix kernel-provided HID-messages with the report-number.
      
      Currently, only HoG needs this and the spec only talks about "global
      report numbers". That is, it's a global boolean not a per-type boolean.
      However, given the quirks we already have in kernel-space, a per-type
      value seems much more appropriate.
      Signed-off-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      c2b2f16c
    • David Herrmann's avatar
      HID: uhid: implement SET_REPORT · 11c22155
      David Herrmann authored
      We so far lacked support for hid_hw_raw_request(..., HID_REQ_SET_REPORT);
      Add support for it and simply forward the request to user-space. Note that
      SET_REPORT is synchronous, just like GET_REPORT, even though it does not
      provide any data back besides an error code.
      
      If a transport layer does SET_REPORT asynchronously, they can just ACK it
      immediately by writing an uhid_set_report_reply to uhid.
      
      This patch re-uses the synchronous uhid-report infrastructure to query
      user-space. Note that this means you cannot run SET_REPORT and GET_REPORT
      in parallel. However, that has always been a restriction of HID and due to
      its blocking nature, this is just fine. Maybe some future transport layer
      supports parallel requests (very unlikely), however, until then lets not
      over-complicate things and avoid request-lookup-tables.
      Signed-off-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      11c22155
    • David Herrmann's avatar
      HID: uhid: rename uhid_raw_request to uhid_hid_raw_request · 7c4003bc
      David Herrmann authored
      We use strict prefixed in uhid.c:
        uhid_char_*: implement char-dev callbacks
        uhid_dev_*: implement uhid device management and runtime
        uhid_hid_*: implement hid-dev callbacks
      
      uhid_raw_request is an hid callback, so rename it to uhid_hid_raw_request.
      
      While at it, move it closer to it's extracted helpers and keep the same
      order as in "struct hid_driver".
      Signed-off-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      7c4003bc
    • David Herrmann's avatar
      HID: uhid: keep legacy definitions at the bottom of uhid.h · 50598e70
      David Herrmann authored
      Instead of inlining the legacy definitions into the main part of uhid.h,
      keep them at the bottom now. This way, the API is much easier to read and
      legacy requests can be looked up at a separate place.
      Signed-off-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      50598e70
    • David Herrmann's avatar
      HID: uhid: add ABI compatible UHID_GET_REPORT replacing UHID_FEATURE · fa71f32b
      David Herrmann authored
      The old hdev->hid_get_raw_report() was broken by design. It was never
      clear what kind of HW request it should trigger. Benjamin fixed that with
      the core HID cleanup, though we never really adjusted uhid.
      
      Unfortunately, our old UHID_FEATURE command was modelled around the broken
      hid_get_raw_report(). We converted it silently to the new GET_REPORT and
      nothing broke. Make this explicit by renaming UHID_FEATURE to
      UHID_GET_REPORT and UHID_FEATURE_ANSWER to UHID_GET_REPORT_REPLY.
      
      Note that this is 100% ABI compatible to UHID_FEATURE. This is just a
      rename. But we have to keep the old definitions around to not break API.
      
      >From now on, UHID_GET_REPORT must trigger a GET_REPORT request on the
      user-space hardware layer. All the ambiguity due to the weird "feature"
      name should be gone now.
      Signed-off-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      fa71f32b
    • David Herrmann's avatar
      HID: uhid: invert report_done and make non-atomic · 5942b849
      David Herrmann authored
      All accesses to @report_done are protected by qlock (or report-contexts).
      No need to use an atomic.
      
      While at it, invert the logic and call it "report_running". This is
      similar to the uhid->running field and easier to read.
      Signed-off-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      5942b849
    • David Herrmann's avatar
      HID: uhid: turn report_id into u32 · 8cad5b01
      David Herrmann authored
      All accesses to @report_id are protected by @qlock. No need to use an
      atomic.
      Signed-off-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      8cad5b01
    • David Herrmann's avatar
      HID: uhid: avoid magic-numbers when setting strings · 25be7fe2
      David Herrmann authored
      Avoid hard-coding the target buffer sizes and use sizeof() instead. This
      also makes us future-proof to buffer-extensions later on.
      Signed-off-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      25be7fe2
    • David Herrmann's avatar
      HID: uhid: avoid dangling pointers in uhid context · 41c4a464
      David Herrmann authored
      Avoid keeping uhid->rd_data and uhid->rd_size set in case
      uhid_dev_create2() fails. This is non-critical as we never flip
      uhid->running and thus never enter uhid_dev_destroy(). However, it's much
      nicer for debugging if pointers are only set if they point to valid data.
      Signed-off-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      41c4a464
    • David Herrmann's avatar
      HID: uhid: forward create_req to create2_req · 56c47754
      David Herrmann authored
      Instead of hard-coding the uhid_dev_create() function twice, copy any
      create_req into a create2_req structure and forward it.
      
      We allocate uhid_create_req on the stack here, but that should be fine.
      Unlike uhid_create2_req it is fairly small (<1KB) and it's only used
      temporarily to swap entries. uhid_dev_create2() doesn't access it.
      Signed-off-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      56c47754
    • David Herrmann's avatar
      HID: uhid: simplify report-cb shutdown · 0e0d7520
      David Herrmann authored
      The report-query is blocking, so when user-space destroys a device we have
      to wake up any blocking kernel context that is currently in the report-cb.
      We used some broken correlation between @report_done and @running so far.
      Replace it by a much more obvious use.
      
      We now wake up the report-cb if either @report_done or @running is set.
      wake_up() and wait_event() serve as implicit barriers (as they always do)
      so no need to use smp_rmb/wmb directly.
      
      Note that @report_done is never reset by anyone but the report-cb, thus
      it cannot flip twice while we wait for it. And whenever we set @running,
      we afterwards synchronously remove the HID device. Therefore, we wait for
      all report-cbs to finish before we return. This way, @running can never
      flip to true while we wait for it.
      Signed-off-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      0e0d7520
  2. 21 Aug, 2014 11 commits
  3. 20 Aug, 2014 6 commits
  4. 19 Aug, 2014 12 commits