1. 08 11月, 2014 2 次提交
  2. 30 9月, 2014 1 次提交
  3. 25 9月, 2014 2 次提交
  4. 22 9月, 2014 1 次提交
  5. 26 7月, 2014 1 次提交
  6. 17 7月, 2014 1 次提交
    • W
      i2c: add debug info when class instantiation was dropped · 45552272
      Wolfram Sang 提交于
      We have a warning already when support for old-fashioned class based
      instantiation is about to be dropped somewhen soon from a driver. Let's
      have another one when it was actually dropped. This allows to remove the
      cruft a little earlier and still let users know what happened in the
      rare case they are missing devices after the change. However, there is
      enough interest to get rid of class based instantiation rather sooner
      than later because it improves boot up time.
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      45552272
  7. 27 6月, 2014 2 次提交
    • L
      I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config · da3c6647
      Lan Tianyu 提交于
      Clean up ACPI related code in the i2c core and add CONFIG_I2C_ACPI
      to enable I2C ACPI code.
      
      Current there is a race between removing I2C ACPI operation region
      and ACPI AML code accessing. So make i2c core built-in if CONFIG_I2C_ACPI
      is set.
      Reviewed-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NLan Tianyu <tianyu.lan@intel.com>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      da3c6647
    • L
      I2C/ACPI: Add i2c ACPI operation region support · 5d98e61d
      Lan Tianyu 提交于
      ACPI 5.0 spec(5.5.2.4.5) defines GenericSerialBus(i2c, spi, uart) operation region.
      It allows ACPI aml code able to access such kind of devices to implement
      some ACPI standard method.
      
      ACPI Spec defines some access attribute to associate with i2c protocol.
      AttribQuick 	       	       		Read/Write Quick Protocol
      AttribSendReceive			Send/Receive Byte Protocol
      AttribByte 			 	Read/Write Byte Protocol
      AttribWord				Read/Write Word Protocol
      AttribBlock				Read/Write Block Protocol
      AttribBytes				Read/Write N-Bytes Protocol
      AttribProcessCall			Process Call Protocol
      AttribBlockProcessCall			Write Block-Read Block Process Call Protocol
      AttribRawBytes 				Raw Read/Write N-BytesProtocol
      AttribRawProcessBytes			Raw Process Call Protocol
      
      On the Asus T100TA, Bios use GenericSerialBus operation region to access
      i2c device to get battery info.
      
      Sample code From Asus T100TA
      
          Scope (_SB.I2C1)
          {
              Name (UMPC, ResourceTemplate ()
              {
                  I2cSerialBus (0x0066, ControllerInitiated, 0x00061A80,
                      AddressingMode7Bit, "\\_SB.I2C1",
                      0x00, ResourceConsumer, ,
                      )
              })
      
      	...
      
              OperationRegion (DVUM, GenericSerialBus, Zero, 0x0100)
              Field (DVUM, BufferAcc, NoLock, Preserve)
              {
                  Connection (UMPC),
                  Offset (0x81),
                  AccessAs (BufferAcc, AttribBytes (0x3E)),
                  FGC0,   8
              }
      	...
           }
      
           Device (BATC)
           {
               Name (_HID, EisaId ("PNP0C0A"))  // _HID: Hardware ID
               Name (_UID, One)  // _UID: Unique ID
      	 ...
      
                  Method (_BST, 0, NotSerialized)  // _BST: Battery Status
                  {
                      If (LEqual (AVBL, One))
                      {
                          Store (FGC0, BFFG)
                          If (LNotEqual (STAT, One))
                          {
                              ShiftRight (CHST, 0x04, Local0)
                              And (Local0, 0x03, Local0)
                              If (LOr (LEqual (Local0, One), LEqual (Local0, 0x02)))
                              {
                                  Store (0x02, Local1)
                              }
      	...
      
          }
      
      The i2c operation region is defined under I2C1 scope. _BST method under
      battery device BATC read battery status from the field "FCG0". The request
      would be sent to i2c operation region handler.
      
      This patch is to add i2c ACPI operation region support. Due to there are
      only "Byte" and "Bytes" protocol access on the Asus T100TA, other protocols
      have not been tested.
      
      About RawBytes and RawProcessBytes protocol, they needs specific drivers to interpret
      reference data from AML code according ACPI 5.0 SPEC(5.5.2.4.5.3.9 and 5.5.2.4.5.3.10).
      So far, not found such case and will add when find real case.
      Signed-off-by: NLan Tianyu <tianyu.lan@intel.com>
      Reviewed-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      5d98e61d
  8. 14 3月, 2014 2 次提交
    • D
      i2c: Add message transfer tracepoints for SMBUS [ver #2] · 8a325997
      David Howells 提交于
      The SMBUS tracepoints can be enabled thusly:
      
      	echo 1 >/sys/kernel/debug/tracing/events/i2c/enable
      
      and will dump messages that can be viewed in /sys/kernel/debug/tracing/trace
      that look like:
      
               ... smbus_read: i2c-0 a=051 f=0000 c=fa BYTE_DATA
               ... smbus_reply: i2c-0 a=051 f=0000 c=fa BYTE_DATA l=1 [39]
               ... smbus_result: i2c-0 a=051 f=0000 c=fa BYTE_DATA rd res=0
      
      formatted as:
      
      	i2c-<adapter-nr>
      	a=<addr>
      	f=<flags>
      	c=<command>
      	<protocol-name>
      	<rd|wr>
      	res=<result>
      	l=<data-len>
      	[<data-block>]
      
      The adapters to be traced can be selected by something like:
      
      	echo adapter_nr==1 >/sys/kernel/debug/tracing/events/i2c/filter
      
      Note that this shares the same filter and enablement as i2c.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Reviewed-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      8a325997
    • D
      i2c: Add message transfer tracepoints for I2C · d9a83d62
      David Howells 提交于
      Add tracepoints into the I2C message transfer function to retrieve the message
      sent or received.  The following config options must be turned on to make use
      of the facility:
      
      	CONFIG_FTRACE
      	CONFIG_ENABLE_DEFAULT_TRACERS
      
      The I2C tracepoint can be enabled thusly:
      
      	echo 1 >/sys/kernel/debug/tracing/events/i2c/enable
      
      and will dump messages that can be viewed in /sys/kernel/debug/tracing/trace
      that look like:
      
      	... i2c_write: i2c-5 #0 a=044 f=0000 l=2 [02-14]
      	... i2c_read: i2c-5 #1 a=044 f=0001 l=4
      	... i2c_reply: i2c-5 #1 a=044 f=0001 l=4 [33-00-00-00]
      	... i2c_result: i2c-5 n=2 ret=2
      
      formatted as:
      
      	i2c-<adapter-nr>
      	#<message-array-index>
      	a=<addr>
      	f=<flags>
      	l=<datalen>
      	n=<message-array-size>
      	ret=<result>
      	[<data>]
      
      The operation is done between the i2c_write/i2c_read lines and the i2c_reply
      and i2c_result lines so that if the hardware hangs, the trace buffer can be
      consulted to determine the problematic operation.
      
      The adapters to be traced can be selected by something like:
      
      	echo adapter_nr==1 >/sys/kernel/debug/tracing/events/i2c/filter
      
      These changes are based on code from Steven Rostedt.
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Reviewed-by: NSteven Rostedt <rostedt@goodmis.org>
      [wsa: adapted path for 'enable' in the commit msg]
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      d9a83d62
  9. 06 3月, 2014 1 次提交
    • W
      i2c: add deprecation warning for class based instantiation · 0c176170
      Wolfram Sang 提交于
      Class based instantiation can cause noticeable delays when booting. This
      mechanism is used when it is not possible to describe slaves on I2C
      busses. As we do have other mechanisms, most embedded I2C will not need
      classes and for embedded it is explicitly not recommended to use them. Add
      a deprecation warning for drivers which want to disable class based
      instantiation in the near future to gain boot-up time, so users relying
      on this technique can switch to something better. They really should.
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      0c176170
  10. 30 1月, 2014 1 次提交
  11. 25 1月, 2014 1 次提交
  12. 17 1月, 2014 1 次提交
    • Z
      ACPI: fix module autoloading for ACPI enumerated devices · 8c4ff6d0
      Zhang Rui 提交于
      ACPI enumerated devices has ACPI style _HID and _CID strings,
      all of these strings can be used for both driver loading and matching.
      
      Currently, in Platform, I2C and SPI bus, the ACPI style driver matching
      is supported by invoking acpi_driver_match_device() in bus .match() callback.
      But, the module autoloading is still broken.
      
      For example, there is any ACPI device with _HID "INTABCD" that is
      enumerated to platform bus, and we have a driver that can probe it.
      
      The driver exports its module_alias as "acpi:INTABCD" use the following code
      static const struct acpi_device_id xxx_acpi_match[] = {
              { "INTABCD", 0 },
              { }
      };
      MODULE_DEVICE_TABLE(acpi, xxx_acpi_match);
      
      But, unfortunately, the device' modalias is shown as "platform:INTABCD:00",
      please refer to modalias_show() and platform_uevent() in
      drivers/base/platform.c.
      This results in that the driver will not be loaded automatically when the
      device node is created, because their modalias do not match.
      
      This also applies to I2C and SPI bus.
      
      With this patch, the device' modalias will be shown as "acpi:INTABCD" as well.
      Signed-off-by: NZhang Rui <rui.zhang@intel.com>
      Acked-by: NMark Brown <broonie@linaro.org>
      Acked-by: NWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      8c4ff6d0
  13. 15 11月, 2013 2 次提交
    • J
      i2c: Use stable dev_name for ACPI enumerated I2C slaves · 70762abb
      Jarkko Nikula 提交于
      Current I2C adapter id - client address "x-00yy" based device naming scheme
      is not always stable enough to be used in name based matching, for instance
      within ALSA SoC subsystem.
      
      This is problematic in PC kind of platforms where I2C adapter numbers can
      change due variable amount of bus controllers, probe order, add-on cards or
      just because of BIOS settings.
      
      This patch addresses the problem by using the ACPI device name with
      "i2c-" prefix for ACPI enumerated I2C slaves. For them device name
      "x-00yz" becomes "i2c-INTABCD:ij" after this patch.
      Signed-off-by: NJarkko Nikula <jarkko.nikula@linux.intel.com>
      Acked-by: NWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      70762abb
    • R
      ACPI / driver core: Store an ACPI device pointer in struct acpi_dev_node · 7b199811
      Rafael J. Wysocki 提交于
      Modify struct acpi_dev_node to contain a pointer to struct acpi_device
      associated with the given device object (that is, its ACPI companion
      device) instead of an ACPI handle corresponding to it.  Introduce two
      new macros for manipulating that pointer in a CONFIG_ACPI-safe way,
      ACPI_COMPANION() and ACPI_COMPANION_SET(), and rework the
      ACPI_HANDLE() macro to take the above changes into account.
      Drop the ACPI_HANDLE_SET() macro entirely and rework its users to
      use ACPI_COMPANION_SET() instead.  For some of them who used to
      pass the result of acpi_get_child() directly to ACPI_HANDLE_SET()
      introduce a helper routine acpi_preset_companion() doing an
      equivalent thing.
      
      The main motivation for doing this is that there are things
      represented by struct acpi_device objects that don't have valid
      ACPI handles (so called fixed ACPI hardware features, such as
      power and sleep buttons) and we would like to create platform
      device objects for them and "glue" them to their ACPI companions
      in the usual way (which currently is impossible due to the
      lack of valid ACPI handles).  However, there are more reasons
      why it may be useful.
      
      First, struct acpi_device pointers allow of much better type checking
      than void pointers which are ACPI handles, so it should be more
      difficult to write buggy code using modified struct acpi_dev_node
      and the new macros.  Second, the change should help to reduce (over
      time) the number of places in which the result of ACPI_HANDLE() is
      passed to acpi_bus_get_device() in order to obtain a pointer to the
      struct acpi_device associated with the given "physical" device,
      because now that pointer is returned by ACPI_COMPANION() directly.
      Finally, the change should make it easier to write generic code that
      will build both for CONFIG_ACPI set and unset without adding explicit
      compiler directives to it.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com> # on Haswell
      Reviewed-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Reviewed-by: Aaron Lu <aaron.lu@intel.com> # for ATA and SDIO part
      7b199811
  14. 11 10月, 2013 1 次提交
  15. 10 10月, 2013 1 次提交
  16. 04 10月, 2013 1 次提交
    • L
      i2c: Remove redundant 'driver' field from the i2c_client struct · 0acc2b32
      Lars-Peter Clausen 提交于
      The 'driver' field of the i2c_client struct is redundant. The same data can be
      accessed through to_i2c_driver(client->dev.driver). The generated code for both
      approaches in more or less the same.
      
      E.g. on ARM the expression client->driver->command(...) generates
      
      		...
      		ldr     r3, [r0, #28]
      		ldr     r3, [r3, #32]
      		blx     r3
      		...
      
      and the expression to_i2c_driver(client->dev.driver)->command(...) generates
      
      		...
      		ldr     r3, [r0, #160]
          	ldr     r3, [r3, #-4]
          	blx     r3
      		...
      
      Other architectures will generate similar code.
      
      All users of the 'driver' field outside of the I2C core have already been
      converted. So this only leaves the core itself. This patch converts the
      remaining few users in the I2C core and then removes the 'driver' field from the
      i2c_client struct.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      0acc2b32
  17. 23 8月, 2013 2 次提交
  18. 15 8月, 2013 1 次提交
  19. 07 8月, 2013 1 次提交
  20. 19 6月, 2013 1 次提交
  21. 13 6月, 2013 1 次提交
    • L
      i2c: core: make it possible to match a pure device tree driver · c80f5284
      Linus Walleij 提交于
      This tries to address an issue found when writing an MFD driver
      for the Nomadik STw481x PMICs: as the platform is using device
      tree exclusively I want to specify the driver matching like
      this:
      
      static const struct of_device_id stw481x_match[] = {
      	{ .compatible = "st,stw4810", },
      	{ .compatible = "st,stw4811", },
      	{},
      };
      
      static struct i2c_driver stw481x_driver = {
      	.driver = {
      		.name	= "stw481x",
      		.of_match_table = stw481x_match,
      	},
      	.probe		= stw481x_probe,
      	.remove		= stw481x_remove,
      };
      
      However that turns out not to be possible: the I2C probe code
      is written so that the probe() call is always passed a match
      from i2c_match_id() using non-devicetree matches.
      
      This is probably why most devices using device tree for I2C
      clients currently will pass no .of_match_table *at all* but
      instead just use .id_table from struct i2c_driver to match
      the device. As you realize that means that the whole idea with
      compatible strings is discarded, and that is why we find strange
      device tree I2C device compatible strings like "product" instead
      of "vendor,product" as you could expect.
      
      Let's figure out how to fix this before the mess spreads. This
      patch will allow probeing devices with only an of_match_table
      as per above, and will pass NULL as the second argument to the
      probe() function. If the driver wants to deduce secondary info
      from the struct of_device_id .data field, it has to call
      of_match_device() on its own match table in the probe function
      device tree probe path.
      
      If drivers define both an .of_match_table *AND* a i2c_driver
      .id_table, the .of_match_table will take precedence, just
      as is done in the i2c_device_match() function in i2c-core.c.
      
      I2C devices probed from device tree should subsequently be
      fixed to handle the case where of_match_table() is
      used (I think none of them do that today), and platforms should
      fix their device trees to use compatible strings for I2C devices
      instead of setting the name to Linux device driver names as is
      done in multiple cases today.
      
      Cc: Rob Herring <rob.herring@calxeda.com>
      Cc: Grant Likely <grant.likely@linaro.org>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      c80f5284
  22. 04 6月, 2013 1 次提交
  23. 18 5月, 2013 1 次提交
    • A
      i2c: suppress lockdep warning on delete_device · e9b526fe
      Alexander Sverdlin 提交于
      i2c: suppress lockdep warning on delete_device
      
      Since commit 846f9974 the following lockdep
      warning is thrown in case i2c device is removed (via delete_device sysfs
      attribute) which contains subdevices (e.g. i2c multiplexer):
      
      =============================================
      [ INFO: possible recursive locking detected ]
      3.8.7-0-sampleversion-fct #8 Tainted: G           O
      ---------------------------------------------
      bash/3743 is trying to acquire lock:
        (s_active#110){++++.+}, at: [<ffffffff802b3048>] sysfs_hash_and_remove+0x58/0xc8
      
      but task is already holding lock:
        (s_active#110){++++.+}, at: [<ffffffff802b3cb8>] sysfs_write_file+0xc8/0x208
      
      other info that might help us debug this:
        Possible unsafe locking scenario:
      
              CPU0
              ----
         lock(s_active#110);
         lock(s_active#110);
      
        *** DEADLOCK ***
      
        May be due to missing lock nesting notation
      
      4 locks held by bash/3743:
        #0:  (&buffer->mutex){+.+.+.}, at: [<ffffffff802b3c3c>] sysfs_write_file+0x4c/0x208
        #1:  (s_active#110){++++.+}, at: [<ffffffff802b3cb8>] sysfs_write_file+0xc8/0x208
        #2:  (&adap->userspace_clients_lock/1){+.+.+.}, at: [<ffffffff80454a18>] i2c_sysfs_delete_device+0x90/0x238
        #3:  (&__lockdep_no_validate__){......}, at: [<ffffffff803dcc24>] device_release_driver+0x24/0x48
      
      stack backtrace:
      Call Trace:
      [<ffffffff80575cc8>] dump_stack+0x8/0x34
      [<ffffffff801b50fc>] __lock_acquire+0x161c/0x2110
      [<ffffffff801b5c3c>] lock_acquire+0x4c/0x70
      [<ffffffff802b60cc>] sysfs_addrm_finish+0x19c/0x1e0
      [<ffffffff802b3048>] sysfs_hash_and_remove+0x58/0xc8
      [<ffffffff802b7d8c>] sysfs_remove_group+0x64/0x148
      [<ffffffff803d990c>] device_remove_attrs+0x9c/0x1a8
      [<ffffffff803d9b1c>] device_del+0x104/0x1d8
      [<ffffffff803d9c18>] device_unregister+0x28/0x70
      [<ffffffff8045505c>] i2c_del_adapter+0x1cc/0x328
      [<ffffffff8045802c>] i2c_del_mux_adapter+0x14/0x38
      [<ffffffffc025c108>] pca954x_remove+0x90/0xe0 [pca954x]
      [<ffffffff804542f8>] i2c_device_remove+0x80/0xe8
      [<ffffffff803dca9c>] __device_release_driver+0x74/0xf8
      [<ffffffff803dcc2c>] device_release_driver+0x2c/0x48
      [<ffffffff803dbc14>] bus_remove_device+0x13c/0x1d8
      [<ffffffff803d9b24>] device_del+0x10c/0x1d8
      [<ffffffff803d9c18>] device_unregister+0x28/0x70
      [<ffffffff80454b08>] i2c_sysfs_delete_device+0x180/0x238
      [<ffffffff802b3cd4>] sysfs_write_file+0xe4/0x208
      [<ffffffff8023ddc4>] vfs_write+0xbc/0x160
      [<ffffffff8023df6c>] SyS_write+0x54/0xd8
      [<ffffffff8013d424>] handle_sys64+0x44/0x64
      
      The problem is already known for USB and PCI subsystems. The reason is that
      delete_device attribute is defined statically in i2c-core.c and used for all
      devices in i2c subsystem.
      
      Discussion of original USB problem:
      http://lkml.indiana.edu/hypermail/linux/kernel/1204.3/01160.html
      
      Commit 356c05d5 introduced new macro to suppress
      lockdep warnings for this special case and included workaround for USB code.
      
      LKML discussion of the workaround:
      http://lkml.indiana.edu/hypermail/linux/kernel/1205.1/03634.html
      
      As i2c case is in principle the same, the same workaround could be used here.
      Signed-off-by: NAlexander Sverdlin <alexander.sverdlin@nsn.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
      e9b526fe
  24. 09 4月, 2013 1 次提交
  25. 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
  26. 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
  27. 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
  28. 28 1月, 2013 1 次提交
  29. 23 11月, 2012 1 次提交
  30. 06 10月, 2012 1 次提交