1. 02 4月, 2013 3 次提交
    • L
      i2c: Make return type of i2c_del_adapter() void · 71546300
      Lars-Peter Clausen 提交于
      i2c_del_adapter() is usually called from a drivers remove callback. The Linux
      device driver model does not allow the remove callback to fail and all resources
      allocated in the probe callback need to be freed, as well as all resources which
      have been provided to the rest of the kernel(for example a I2C adapter) need to
      be revoked. So any function revoking such resources isn't allowed to fail
      either. i2c_del_adapter() adheres to this requirement and will never fail. But
      i2c_del_adapter()'s return type is int, which may cause driver authors to think
      that it can fail. This led to code constructs like:
      
      	ret = i2c_del_adapter(...);
      	BUG_ON(ret);
      
      Since i2c_del_adapter() always returns 0 the BUG_ON is never hit and essentially
      becomes dead code, which means it can be removed. Making the return type of
      i2c_del_adapter() void makes it explicit that the function will never fail and
      should prevent constructs like the above from re-appearing in the kernel code.
      
      All callers of i2c_del_adapter() have already been updated in a previous patch
      to ignore the return value, so the conversion of the return type from int to
      void can be done without causing any build failures.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Reviewed-by: NJean Delvare <khali@linux-fr.org>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      71546300
    • L
      i2c: i2c_del_adapter: Don't treat removing a non-registered adapter as error · f5fb0822
      Lars-Peter Clausen 提交于
      Currently i2c_del_adapter() returns -EINVAL when it gets an adapter which is not
      registered. But none of the users of i2c_del_adapter() depend on this behavior,
      so for the sake of being able to sanitize the return type of i2c_del_adapter
      argue, that the purpose of i2c_del_adapter() is to remove an I2C adapter from
      the system. If the adapter is not registered in the first place this becomes a
      no-op. So we can return success without having to do anything.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Reviewed-by: NJean Delvare <khali@linux-fr.org>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      f5fb0822
    • L
      i2c: Remove detach_adapter · 19baba4c
      Lars-Peter Clausen 提交于
      The detach_adapter callback has been deprecated for quite some time and has no
      user left. Keeping it alive blocks other cleanups, so remove it.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Reviewed-by: NJean Delvare <khali@linux-fr.org>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      19baba4c
  2. 24 3月, 2013 2 次提交
    • V
      i2c: Add bus recovery infrastructure · 5f9296ba
      Viresh Kumar 提交于
      Add i2c bus recovery infrastructure to i2c adapters as specified in the i2c
      protocol Rev. 03 section 3.1.16 titled "Bus clear".
      
      http://www.nxp.com/documents/user_manual/UM10204.pdf
      
      Sometimes during operation i2c bus hangs and we need to give dummy clocks to
      slave device to start the transfer again. Now we may have capability in the bus
      controller to generate these clocks or platform may have gpio pins which can be
      toggled to generate dummy clocks. This patch supports both.
      
      This patch also adds in generic bus recovery routines gpio or scl line based
      which can be used by bus controller. In addition controller driver may provide
      its own version of the bus recovery routine.
      
      This doesn't support multi-master recovery for now.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      [wsa: changed gpio type to int and minor reformatting]
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      5f9296ba
    • D
      i2c: core: Pick i2c bus number from dt alias if present · ee5c2744
      Doug Anderson 提交于
      This allows you to get the equivalent functionality of
      i2c_add_numbered_adapter() with all data in the device tree and no
      special case code in your driver.  This is a common device tree
      technique.
      
      For quick reference, the FDT syntax for using an alias to provide an
      ID looks like:
        aliases {
          i2c0 = &i2c_0;
          i2c1 = &i2c_1;
        };
      Signed-off-by: NDoug Anderson <dianders@chromium.org>
      [wsa: removed one check from static function. We know our callers]
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      ee5c2744
  3. 28 2月, 2013 2 次提交
    • T
      idr: remove MAX_IDR_MASK and move left MAX_IDR_* into idr.c · e8c8d1bc
      Tejun Heo 提交于
      MAX_IDR_MASK is another weirdness in the idr interface.  As idr covers
      whole positive integer range, it's defined as 0x7fffffff or INT_MAX.
      
      Its usage in idr_find(), idr_replace() and idr_remove() is bizarre.
      They basically mask off the sign bit and operate on the rest, so if
      the caller, by accident, passes in a negative number, the sign bit
      will be masked off and the remaining part will be used as if that was
      the input, which is worse than crashing.
      
      The constant is visible in idr.h and there are several users in the
      kernel.
      
      * drivers/i2c/i2c-core.c:i2c_add_numbered_adapter()
      
        Basically used to test if adap->nr is a negative number which isn't
        -1 and returns -EINVAL if so.  idr_alloc() already has negative
        @start checking (w/ WARN_ON_ONCE), so this can go away.
      
      * drivers/infiniband/core/cm.c:cm_alloc_id()
        drivers/infiniband/hw/mlx4/cm.c:id_map_alloc()
      
        Used to wrap cyclic @start.  Can be replaced with max(next, 0).
        Note that this type of cyclic allocation using idr is buggy.  These
        are prone to spurious -ENOSPC failure after the first wraparound.
      
      * fs/super.c:get_anon_bdev()
      
        The ID allocated from ida is masked off before being tested whether
        it's inside valid range.  ida allocated ID can never be a negative
        number and the masking is unnecessary.
      
      Update idr_*() functions to fail with -EINVAL when negative @id is
      specified and update other MAX_IDR_MASK users as described above.
      
      This leaves MAX_IDR_MASK without any user, remove it and relocate
      other MAX_IDR_* constants to lib/idr.c.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Jean Delvare <khali@linux-fr.org>
      Cc: Roland Dreier <roland@kernel.org>
      Cc: Sean Hefty <sean.hefty@intel.com>
      Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
      Cc: "Marciniszyn, Mike" <mike.marciniszyn@intel.com>
      Cc: Jack Morgenstein <jackm@dev.mellanox.co.il>
      Cc: Or Gerlitz <ogerlitz@mellanox.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Acked-by: NWolfram Sang <wolfram@the-dreams.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e8c8d1bc
    • T
      i2c: convert to idr_alloc() · 4ae42b0f
      Tejun Heo 提交于
      Convert to the much saner new idr interface.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Jean Delvare <khali@linux-fr.org>
      Cc: Wolfram Sang <wolfram@the-dreams.de>
      Tested-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4ae42b0f
  4. 28 1月, 2013 1 次提交
  5. 23 11月, 2012 1 次提交
  6. 06 10月, 2012 2 次提交
  7. 10 9月, 2012 1 次提交
    • J
      i2c-core: Fix for lockdep validator · 390946b1
      Jean Delvare 提交于
      If kernel is compiled with CONFIG_PROVE_LOCKING the
      validator raises an error when a multiplexer is removed
      via sysfs and sub-clients are connected to it. This is a
      false positive.
      Documentation/lockdep-design.txt recommends to handle this
      via calls to mutex_lock_nested().
      
      Based on an earlier fix from Michael Lawnick.
      
      Note that the extra code resolves to nothing unless
      CONFIG_DEBUG_LOCK_ALLOC=y.
      Signed-off-by: NJean Delvare <khali@linux-fr.org>
      Cc: Michael Lawnick <ml.lawnick@gmx.de>
      390946b1
  8. 24 7月, 2012 2 次提交
  9. 30 6月, 2012 1 次提交
    • J
      [media] i2c: Export an unlocked flavor of i2c_transfer · b37d2a3a
      Jean Delvare 提交于
      Some drivers (in particular for TV cards) need exclusive access to
      their I2C buses for specific operations. Export an unlocked flavor
      of i2c_transfer to give them full control.
      
      The unlocked flavor has the following limitations:
      * Obviously, caller must hold the i2c adapter lock.
      * No debug messages are logged. We don't want to log messages while
        holding a rt_mutex.
      * No check is done on the existence of adap->algo->master_xfer. It
        is thus the caller's responsibility to ensure that the function is
        OK to call.
      Signed-off-by: NJean Delvare <khali@linux-fr.org>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
      b37d2a3a
  10. 12 5月, 2012 1 次提交
  11. 27 3月, 2012 1 次提交
  12. 16 3月, 2012 1 次提交
  13. 23 11月, 2011 1 次提交
  14. 25 7月, 2011 1 次提交
  15. 17 4月, 2011 1 次提交
  16. 31 3月, 2011 1 次提交
  17. 20 3月, 2011 3 次提交
  18. 22 1月, 2011 1 次提交
  19. 15 1月, 2011 3 次提交
  20. 11 1月, 2011 1 次提交
  21. 16 11月, 2010 1 次提交
  22. 25 10月, 2010 3 次提交
  23. 30 9月, 2010 3 次提交
    • G
      of/i2c: Fix module load order issue caused by of_i2c.c · 925bb9c6
      Grant Likely 提交于
      Commit 959e85f7, "i2c: add OF-style registration and binding" caused a
      module dependency loop where of_i2c.c calls functions in i2c-core, and
      i2c-core calls of_i2c_register_devices() in of_i2c.  This means that
      when i2c support is built as a module when CONFIG_OF is set, then
      neither i2c_core nor of_i2c are able to be loaded.
      
      This patch fixes the problem by moving the of_i2c_register_devices()
      calls back into the device drivers.  Device drivers already
      specifically request the core code to parse the device tree for
      devices anyway by setting the of_node pointer, so it isn't a big
      deal to also call the registration function.  The drivers just become
      slightly more verbose.
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      Signed-off-by: NJean Delvare <khali@linux-fr.org>
      925bb9c6
    • R
      i2c: Fix checks which cause legacy suspend to never get called · 64b4782f
      Rajendra Nayak 提交于
      For devices which are not adapted to runtime PM a call to
      pm_runtime_suspended always returns true.
      
      Hence the pm_runtime_suspended checks below prevent legacy
      suspend from getting called.
      
      So do a pm_runtime_suspended check only for devices with a
      dev_pm_ops populated (which hence do not rely on the legacy
      suspend.)
      Signed-off-by: NRajendra Nayak <rnayak@ti.com>
      Acked-by: NRafael J. Wysocki <rjw@sisk.pl>
      Cc: Ben Dooks <ben-linux@fluff.org>
      Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
      Cc: Kevin Hilman <khilman@deeprootsystems.com>
      Signed-off-by: NJean Delvare <khali@linux-fr.org>
      64b4782f
    • V
      i2c: Fix for suspend/resume issue · 753419f5
      Vishwanath BS 提交于
      In current i2c core driver, call to pm_runtime_set_active from
      i2c_device_pm_resume will unconditionally enable i2c module and
      increment child count of the parent. Because of this, in CPU Idle
      path, i2c does not idle, preventing Core to enter retention. Also i2c
      module will not be suspended upon system suspend as
      pm_runtime_set_suspended is not called from i2c_device_pm_suspend.
      
      This issue is fixed by removing pm_runtime_set_active call from resume
      path which is not necessary.
      This fix has been tested on OMAP4430.
      Signed-off-by: NPartha Basak <p-basak2@ti.com>
      Signed-off-by: NVishwanath BS <vishwanath.bs@ti.com>
      Acked-by: NRafael J. Wysocki <rjw@sisk.pl>
      Cc: Kevin Hilman <khilman@deeprootsystems.com>
      Cc: Ben Dooks <ben-linux@fluff.org>
      Signed-off-by: NJean Delvare <khali@linux-fr.org>
      753419f5
  24. 12 8月, 2010 3 次提交