From patchwork Tue Mar 17 12:14:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 450967 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4590114009B for ; Tue, 17 Mar 2015 23:15:14 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752299AbbCQMPM (ORCPT ); Tue, 17 Mar 2015 08:15:12 -0400 Received: from ducie-dc1.codethink.co.uk ([185.25.241.215]:47102 "EHLO ducie-dc1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752062AbbCQMPM (ORCPT ); Tue, 17 Mar 2015 08:15:12 -0400 Received: from localhost (localhost [127.0.0.1]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTP id 9988C460809; Tue, 17 Mar 2015 12:15:10 +0000 (GMT) X-Virus-Scanned: Debian amavisd-new at ducie-dc1.codethink.co.uk Received: from ducie-dc1.codethink.co.uk ([127.0.0.1]) by localhost (ducie-dc1.codethink.co.uk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lFCptr91-Gho; Tue, 17 Mar 2015 12:15:05 +0000 (GMT) Received: from rainbowdash.ducie.codethink.co.uk (rainbowdash.dyn.ducie.codethink.co.uk [10.24.2.99]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTPS id 1FB5746087E; Tue, 17 Mar 2015 12:15:05 +0000 (GMT) Received: from ben by rainbowdash.ducie.codethink.co.uk with local (Exim 4.84) (envelope-from ) id 1YXqOm-0008IC-Rm; Tue, 17 Mar 2015 12:15:04 +0000 From: Ben Dooks To: linux-i2c@vger.kernel.org Cc: linux-kernel@codethink.co.uk, Ben Dooks Subject: [PATCH] i2c-gpio: add board_info to pdata Date: Tue, 17 Mar 2015 12:14:55 +0000 Message-Id: <1426594495-31844-1-git-send-email-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.1.4 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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 --- 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;