1. 29 8月, 2013 3 次提交
  2. 28 8月, 2013 24 次提交
  3. 27 8月, 2013 7 次提交
  4. 26 8月, 2013 6 次提交
    • I
      staging: comedi: comedi_bond: use correct minor device numbers in name · 7322b320
      Ian Abbott 提交于
      The board name for "comedi_bond" is constructed from a space-separated
      list of items of the form "minor:subdevice" where "minor" is a minor
      device number and "subdevice" is a subdevice number.  Currently, all the
      "minor" device numbers are for the "comedi_bond" device itself and the
      "subdevice" numbers are for the bonded devices.  It makes makes more
      sense for the "minor" device numbers to come from the bonded devices as
      well so that the string is a list of bonded "minor:subdevice" pairs.
      Fix it.
      Signed-off-by: NIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7322b320
    • I
      staging: comedi: comedi_bond: use krealloc() and fix memory leak · a55de0f4
      Ian Abbott 提交于
      `do_dev_config()` is called from the comedi 'attach' handler,
      `bonding_attach()`.  The device private data structure contains a
      dynamically allocated array of pointers to "bonded" device structures
      which grows during the `do_dev_config()` call.  The length of this array
      is in `devpriv->ndevs`.  It currently uses a local function `realloc()`
      to allocate a new array, copy the old contents over and free the old
      array.  It should be more efficient to use `krealloc()` as it may be
      able to use slack space at the end of the previous array and avoid a
      copy.
      
      The old `realloc()` function always freed the old buffer which meant
      that if it failed to allocate the new buffer it would lose the contents
      of the old buffer.  Unfortunately, that contained pointers to more
      dynamically allocated memory, leading to a memory leak.  If `krealloc()`
      fails, keep the old buffer and avoid the memory leak.  The
      aforementioned pointers to more dynamically allocated memory will be
      cleaned up by the 'detach' handler, `bonding_detach()` which will be
      called by the comedi core as a consequence of `krealloc()` failing in
      `do_dev_config()`.
      Signed-off-by: NIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a55de0f4
    • I
      staging: comedi: comedi_bond: handle base channel for insn_bits · 0f3ce1a6
      Ian Abbott 提交于
      If a DIO subdevice has more than 32 channels, its 'insn_bits' handler is
      supposed to take account of the base channel from
      `CR_CHAN(insn->chanspec)`.  (The comedi core will adjust the base
      channel to 0 and shift the mask and data to compensate if the subdevice
      has less than or equal to 32 channels.)  The "comedi_bond" driver
      currently ignores the base channel and assumes it is 0.
      
      Replace `comedi_dio_bitfield()` in the "kcomedilib" module with
      `comedi_dio_bitfield2()` that takes account of the base channel, and
      rewrite the "comedi_bond" driver's 'insn_bits' handler
      (`bonding_dio_insn_bits()`) to take account of the base channel and use
      the new function.
      
      No other modules use `comedi_dio_bitfield()` so it is safe to replace it
      with `comedi_dio_bitfield2()`.  The name follows that of the equivalent
      function in the user-space comedilib.  If the base channel is non-zero
      and the subdevice has less than or equal to 32 channels it needs to
      adjust things in the same way as the comedi core (same as `parse_insn()`
      in "comedi_fops.c") due to most drivers ignoring the base channel.
      Signed-off-by: NIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0f3ce1a6
    • I
      staging: comedi: comedi_bond: get INSN_CONFIG_DIO_QUERY info from horse's mouth · 16d2d3cb
      Ian Abbott 提交于
      The DIO subdevice of the "comedi_bond" device attempts to remember the
      directions of DIO channels itself in the `io_bits` member of the
      subdevice, but that is only large enough for the first 32 channels and
      it might not be accurate anyway as changing the direction of one channel
      may have affected a whole group of channels and we have no idea of the
      initial directions before the "bonded" device was linked to the the
      "comedi_bond" device.  It would be better to ask the bonded device for
      this information when handling a `INSN_CONFIG_DIO_QUERY` configuration
      instruction.  Add new function `comedi_dio_get_config()` to the
      "kcomedilib" module to allow us to get the DIO direction of a channel
      and use it.
      Signed-off-by: NIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      16d2d3cb
    • I
      staging: comedi: comedi_bond: just check devprivs->devs once on detach · 7b8cbe92
      Ian Abbott 提交于
      The `while` loop in `bonding_detach()` doesn't need to check
      `devpriv->devs` each time round the loop.  Move the test outside the
      loop.  The enclosing `if (devpriv)` can be changed to `if (devpriv &&
      devpriv->devs)` as everything in this `if` statement is associated with
      `devpriv->devs` anyway.
      Signed-off-by: NIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7b8cbe92
    • I
      staging: comedi: comedi_bond: no need to free dev->private on detach · c2af5b96
      Ian Abbott 提交于
      The comedi core will free `dev->private` if it is non-NULL after calling
      the "detach" handler (`bonding_detach()`), so don't bother freeing it in
      `bonding_detach()`.
      Signed-off-by: NIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c2af5b96