All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c-gpio: add board_info to pdata
@ 2015-03-17 12:14 Ben Dooks
       [not found] ` <1426594495-31844-1-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Dooks @ 2015-03-17 12:14 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-4yDnlxn2s6sWdaTGBSpHTA, Ben Dooks

Add board_info so that the i2c-gpio driver can probe devices on probe
so that i2c_register_board_info() does not need to be used. This is
preferable for devices that get hotplugged as otherwise we need to do
i2c_unregister_board_info() which would be more code.

Signed-off-by: Ben Dooks <ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
---
 drivers/i2c/busses/i2c-gpio.c | 8 ++++++++
 include/linux/i2c-gpio.h      | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index 34cfc0e..d1050bd 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -232,6 +232,14 @@ static int i2c_gpio_probe(struct platform_device *pdev)
 		 pdata->scl_is_output_only
 		 ? ", no clock stretching" : "");
 
+	if (pdata->board_info) {
+		struct i2c_board_info const *info = pdata->board_info;
+		int nr;
+
+		for (nr = 0; nr <  pdata->board_size; info++, nr++)
+			i2c_new_device(adap, info);
+	}
+
 	return 0;
 }
 
diff --git a/include/linux/i2c-gpio.h b/include/linux/i2c-gpio.h
index c1bcb1f..b4d2505 100644
--- a/include/linux/i2c-gpio.h
+++ b/include/linux/i2c-gpio.h
@@ -17,6 +17,8 @@
  * @udelay: signal toggle delay. SCL frequency is (500 / udelay) kHz
  * @timeout: clock stretching timeout in jiffies. If the slave keeps
  *	SCL low for longer than this, the transfer will time out.
+ * @board_size: The number of entries in the board_info field.
+ * @board_info: List of devices to be added by this i2c bus at probe time.
  * @sda_is_open_drain: SDA is configured as open drain, i.e. the pin
  *	isn't actively driven high when setting the output value high.
  *	gpio_get_value() must return the actual pin state even if the
@@ -30,6 +32,8 @@ struct i2c_gpio_platform_data {
 	unsigned int	scl_pin;
 	int		udelay;
 	int		timeout;
+	int		board_size;
+	struct i2c_board_info *board_info;
 	unsigned int	sda_is_open_drain:1;
 	unsigned int	scl_is_open_drain:1;
 	unsigned int	scl_is_output_only:1;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c-gpio: add board_info to pdata
       [not found] ` <1426594495-31844-1-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
@ 2015-03-27 15:48   ` Wolfram Sang
  2015-04-22  8:42     ` Ben Dooks
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfram Sang @ 2015-03-27 15:48 UTC (permalink / raw)
  To: Ben Dooks
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, linux-kernel-4yDnlxn2s6sWdaTGBSpHTA

[-- Attachment #1: Type: text/plain, Size: 494 bytes --]

On Tue, Mar 17, 2015 at 12:14:55PM +0000, Ben Dooks wrote:
> Add board_info so that the i2c-gpio driver can probe devices on probe
> so that i2c_register_board_info() does not need to be used. This is
> preferable for devices that get hotplugged as otherwise we need to do
> i2c_unregister_board_info() which would be more code.
> 
> Signed-off-by: Ben Dooks <ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>

Why can't you use static bus numbers? Or instantiating from userspace?


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c-gpio: add board_info to pdata
  2015-03-27 15:48   ` Wolfram Sang
@ 2015-04-22  8:42     ` Ben Dooks
  0 siblings, 0 replies; 3+ messages in thread
From: Ben Dooks @ 2015-04-22  8:42 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, linux-kernel-4yDnlxn2s6sWdaTGBSpHTA

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 27/03/15 17:48, Wolfram Sang wrote:
> On Tue, Mar 17, 2015 at 12:14:55PM +0000, Ben Dooks wrote:
>> Add board_info so that the i2c-gpio driver can probe devices on
>> probe so that i2c_register_board_info() does not need to be used.
>> This is preferable for devices that get hotplugged as otherwise
>> we need to do i2c_unregister_board_info() which would be more
>> code.
>> 
>> Signed-off-by: Ben Dooks <ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
> 
> Why can't you use static bus numbers? Or instantiating from
> userspace?

the static bus numbers where a pain on a system with dynamically
added i2c busses such as the i2c-mux instatiations.


- -- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJVN17dAAoJEMuhVOkVU3uz/GoIANcu1JAbx0OEDzyhXCLkkS/3
60E/S6n6bitIRBWtxLGbCeKcPGzavSPHUQHxF/9C9m1Ekr4HIkihsTdmTwnOYgh6
HzBbxlx0nJCGE8gBvKeCZ9UVosazPSMELsU/+MlkZh9waTIQ7bTF84USj5LPr0Y6
XuOt1XOtrTNiJGLyoN2SHVfDdwWd2SKfN3zlRGZMaC6OJ5g3zzaelE0UA7jj+2/N
e6vMnDCfcD/99lGnzKVqNEN3zhGy0zRjgft4deLCY6in6bKIUi+NFw2Nky/aUJWT
yKjf3ltvmj/5SbL+AF3l6ONv+NvVBLEHJlDgxLzKmbKFp7EoclhpP1RiL919Ej8=
=7Geh
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-22  8:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-17 12:14 [PATCH] i2c-gpio: add board_info to pdata Ben Dooks
     [not found] ` <1426594495-31844-1-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
2015-03-27 15:48   ` Wolfram Sang
2015-04-22  8:42     ` Ben Dooks

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.