From patchwork Wed Sep 23 14:41:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 521722 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 6E9B31401DA for ; Thu, 24 Sep 2015 00:41:24 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755006AbbIWOlX (ORCPT ); Wed, 23 Sep 2015 10:41:23 -0400 Received: from ducie-dc1.codethink.co.uk ([185.25.241.215]:44356 "EHLO ducie-dc1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754978AbbIWOlW (ORCPT ); Wed, 23 Sep 2015 10:41:22 -0400 Received: from localhost (localhost [127.0.0.1]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTP id C7260461D34; Wed, 23 Sep 2015 15:41:20 +0100 (BST) 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 CUQYYy9Tf8dM; Wed, 23 Sep 2015 15:41:19 +0100 (BST) Received: from rainbowdash.ducie.codethink.co.uk (unknown [10.24.1.119]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTPS id 369B9461C95; Wed, 23 Sep 2015 15:41:19 +0100 (BST) Received: from ben by rainbowdash.ducie.codethink.co.uk with local (Exim 4.86) (envelope-from ) id 1ZelEU-0003KK-Te; Wed, 23 Sep 2015 15:41:18 +0100 From: Ben Dooks To: linux-i2c@vger.kernel.org, wsa@the-dreams.de Cc: linux-kernel@lists.codethink.co.uk, Ben Dooks Subject: [PATCH] i2c-core: allow either old or of_matching of devices Date: Wed, 23 Sep 2015 15:41:15 +0100 Message-Id: <1443019275-12753-1-git-send-email-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.5.1 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org If an i2c-driver does not have an Linux specific id_table, but does have an of_match_table available then allow that to be probed by the i2c core code. Signed-off-by: Ben Dooks --- drivers/i2c/i2c-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 5f89f1e..073c130 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -455,6 +455,9 @@ static inline int acpi_i2c_install_space_handler(struct i2c_adapter *adapter) static const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id, const struct i2c_client *client) { + if (!id) + return NULL; + while (id->name[0]) { if (strcmp(client->name, id->name) == 0) return id; @@ -662,7 +665,7 @@ static int i2c_device_probe(struct device *dev) } driver = to_i2c_driver(dev->driver); - if (!driver->probe || !driver->id_table) + if (!driver->probe || !(driver->id_table || dev->driver->of_match_table)) return -ENODEV; if (client->flags & I2C_CLIENT_WAKE) {