1. 18 9月, 2020 1 次提交
    • C
      regmap: debugfs: Fix handling of name string for debugfs init delays · 94cc89eb
      Charles Keepax 提交于
      In regmap_debugfs_init the initialisation of the debugfs is delayed
      if the root node isn't ready yet. Most callers of regmap_debugfs_init
      pass the name from the regmap_config, which is considered temporary
      ie. may be unallocated after the regmap_init call returns. This leads
      to a potential use after free, where config->name has been freed by
      the time it is used in regmap_debugfs_initcall.
      
      This situation can be seen on Zynq, where the architecture init_irq
      callback registers a syscon device, using a local variable for the
      regmap_config. As init_irq is very early in the platform bring up the
      regmap debugfs root isn't ready yet. Although this doesn't crash it
      does result in the debugfs entry not having the correct name.
      
      Regmap already sets map->name from config->name on the regmap_init
      path and the fact that a separate field is used to pass the name
      to regmap_debugfs_init appears to be an artifact of the debugfs
      name being added before the map name. As such this patch updates
      regmap_debugfs_init to use map->name, which is already duplicated from
      the config avoiding the issue.
      
      This does however leave two lose ends, both regmap_attach_dev and
      regmap_reinit_cache can be called after a regmap is registered and
      would have had the effect of applying a new name to the debugfs
      entries. In both of these cases it was chosen to update the map
      name. In the case of regmap_attach_dev there are 3 users that
      currently use this function to update the name, thus doing so avoids
      changes for those users and it seems reasonable that attaching
      a device would want to set the name of the map. In the case of
      regmap_reinit_cache the primary use-case appears to be devices that
      need some register access to identify the device (for example devices
      in the same family) and then update the cache to match the exact
      hardware. Whilst no users do currently update the name here, given the
      use-case it seemed reasonable the name might want to be updated once
      the device is better identified.
      Signed-off-by: NCharles Keepax <ckeepax@opensource.cirrus.com>
      Link: https://lore.kernel.org/r/20200917120828.12987-1-ckeepax@opensource.cirrus.comSigned-off-by: NMark Brown <broonie@kernel.org>
      94cc89eb
  2. 10 7月, 2020 1 次提交
  3. 03 7月, 2020 1 次提交
  4. 18 6月, 2020 1 次提交
  5. 16 6月, 2020 1 次提交
  6. 08 6月, 2020 1 次提交
  7. 02 6月, 2020 1 次提交
  8. 01 6月, 2020 1 次提交
  9. 29 5月, 2020 1 次提交
  10. 14 4月, 2020 1 次提交
  11. 22 1月, 2020 1 次提交
  12. 12 6月, 2019 1 次提交
    • S
      regmap: fix bulk writes on paged registers · db057679
      Srinivas Kandagatla 提交于
      On buses like SlimBus and SoundWire which does not support
      gather_writes yet in regmap, A bulk write on paged register
      would be silently ignored after programming page.
      This is because local variable 'ret' value in regmap_raw_write_impl()
      gets reset to 0 once page register is written successfully and the
      code below checks for 'ret' value to be -ENOTSUPP before linearising
      the write buffer to send to bus->write().
      
      Fix this by resetting the 'ret' value to -ENOTSUPP in cases where
      gather_writes() is not supported or single register write is
      not possible.
      Signed-off-by: NSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      db057679
  13. 26 4月, 2019 1 次提交
  14. 03 4月, 2019 1 次提交
    • H
      regmap: verify if register is writeable before writing operations · 8b9f9d4d
      Han Nandor 提交于
      regmap provides a couple of ways to validate the register range used.
      a) maxim allowed register, b) writable/readable register tables,
      c) callback function that can be provided by the driver to validate
      a register. regmap framework should verify if registers
      are writeable before every write operation. However this doesn't
      seems to happen in every situation.
      
      The method `_regmap_raw_write_impl` is only using the `writeable_reg`
      callback to verify if register is writeable, ignoring the other two.
      This can lead to undefined behaviour since this allows to write to
      registers that could be declared un-writeable by using any other
      option.
      
      Change `_regmap_raw_write_impl` to use the `regmap_writeable` method
      to verify if registers are writable before the write operation.
      Signed-off-by: NNandor Han <nandor.han@vaisala.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      8b9f9d4d
  15. 19 10月, 2018 2 次提交
  16. 07 9月, 2018 1 次提交
    • D
      regmap: split up regmap_config.use_single_rw · 1c96a2f6
      David Frey 提交于
      Split regmap_config.use_single_rw into use_single_read and
      use_single_write. This change enables drivers of devices which only
      support bulk operations in one direction to use the regmap_bulk_*()
      functions for both directions and have their bulk operation split into
      single operations only when necessary.
      
      Update all struct regmap_config instances where use_single_rw==true to
      instead set both use_single_read and use_single_write. No attempt was
      made to evaluate whether it is possible to set only one of
      use_single_read or use_single_write.
      Signed-off-by: NDavid Frey <dpfrey@gmail.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      1c96a2f6
  17. 09 8月, 2018 1 次提交
    • C
      regmap: Add regmap_noinc_read API · 74fe7b55
      Crestez Dan Leonard 提交于
      The regmap API usually assumes that bulk read operations will read a
      range of registers but some I2C/SPI devices have certain registers for
      which a such a read operation will return data from an internal FIFO
      instead. Add an explicit API to support bulk read without range semantics.
      
      Some linux drivers use regmap_bulk_read or regmap_raw_read for such
      registers, for example mpu6050 or bmi150 from IIO. This only happens to
      work because when caching is disabled a single regmap read op will map
      to a single bus read op (as desired). This breaks if caching is enabled and
      reg+1 happens to be a cacheable register.
      
      Without regmap support refactoring a driver to enable regmap caching
      requires separate I2C and SPI paths. This is exactly what regmap is
      supposed to help avoid.
      Suggested-by: NJonathan Cameron <jic23@kernel.org>
      Signed-off-by: NCrestez Dan Leonard <leonard.crestez@intel.com>
      Signed-off-by: NStefan Popa <stefan.popa@analog.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      74fe7b55
  18. 26 2月, 2018 5 次提交
  19. 20 2月, 2018 1 次提交
  20. 16 2月, 2018 3 次提交
  21. 13 2月, 2018 4 次提交
  22. 08 2月, 2018 1 次提交
    • D
      regmap: Fix reversed bounds check in regmap_raw_write() · f00e7109
      Dan Carpenter 提交于
      We're supposed to be checking that "val_len" is not too large but
      instead we check if it is smaller than the max.
      
      The only function affected would be regmap_i2c_smbus_i2c_write() in
      drivers/base/regmap/regmap-i2c.c.  Strangely that function has its own
      limit check which returns an error if (count >= I2C_SMBUS_BLOCK_MAX) so
      it doesn't look like it has ever been able to do anything except return
      an error.
      
      Fixes: c335931e ("regmap: Add raw_write/read checks for max_raw_write/read sizes")
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Cc: stable@vger.kernel.org
      f00e7109
  23. 08 1月, 2018 1 次提交
    • A
      regmap: Allow empty read/write_flag_mask · 9bf485c9
      Andrew F. Davis 提交于
      All zero read and write masks in the regmap config are used to signal no
      special mask is needed and the bus defaults are used. In some devices
      all zero read/write masks are the special mask and bus defaults should
      not be used. To signal this a new variable is added.
      
      For example SPI often sets bit 7 in address to signal to the device a
      read is requested. On TI AFE44xx parts with SPI interfaces no bit
      needs to be set as registers are either read or write only and the
      operation can be determined from the address only. For this case both
      masks must be zero to not effect the address.
      Signed-off-by: NAndrew F. Davis <afd@ti.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      9bf485c9
  24. 27 12月, 2017 1 次提交
  25. 19 12月, 2017 1 次提交
    • K
      regmap: use proper part of work_buf for storing val · 4c90f297
      Krzysztof Adamski 提交于
      The map->work_buf is a buffer preallocated in __regmap_init() with size
      allowing it to store all 3 parts of a buffer - reg, pad and val. While
      reg and val parts are always properly setup before each transaction, the
      pad part is left at its default value (zeros). Until it is overwritten,
      that is.
      
      _regmap_bus_read(), when calling _regmap_raw_read() uses beginning of
      work_buf as a place to store data read. Usually that is fine but if
      val_bits > reg_bits && pad_bits > 0, padding area of work_buf() may get
      overwritten. Since padding is not zeroed before each transaction,
      garbage will be used on next calls.
      
      This patch moves the val pointer used for _regmap_raw_read() to point
      to a part of work_buf intended for storing value read.
      Signed-off-by: NKrzysztof Adamski <krzysztof.adamski@nokia.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      4c90f297
  26. 14 12月, 2017 2 次提交
  27. 13 12月, 2017 1 次提交
  28. 06 12月, 2017 1 次提交
    • B
      regmap: allow to disable all locking mechanisms · c9b41fcf
      Bartosz Golaszewski 提交于
      We have a use case in the at24 EEPROM driver (recently converted to
      using regmap instead of raw i2c/smbus calls) where we read from/write
      to the regmap in a loop, while protecting the entire loop with
      a mutex.
      
      Currently this implicitly makes us use two mutexes - one in the driver
      and one in regmap. While browsing the code for similar use cases I
      noticed a significant number of places where locking *seems* redundant.
      
      Allow users to completely disable any locking mechanisms in regmap
      config.
      Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      c9b41fcf
  29. 29 11月, 2017 1 次提交