From patchwork Tue Oct 25 16:41:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 686605 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 3t3Jsc1g60z9vFg for ; Wed, 26 Oct 2016 03:44:52 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941746AbcJYQoN (ORCPT ); Tue, 25 Oct 2016 12:44:13 -0400 Received: from mail.kernel.org ([198.145.29.136]:41246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S941934AbcJYQm0 (ORCPT ); Tue, 25 Oct 2016 12:42:26 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 273A220251; Tue, 25 Oct 2016 16:42:19 +0000 (UTC) Received: from CookieMonster.cookiemonster.local (cpc87017-aztw30-2-0-cust65.18-1.cable.virginm.net [92.232.232.66]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E5CCD20142; Tue, 25 Oct 2016 16:42:16 +0000 (UTC) From: Kieran Bingham To: Wolfram Sang , Lee Jones , Kieran Bingham Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Martinez Canillas , sameo@linux.intel.com Subject: [PATCHv6 04/11] i2c: Make I2C ID tables non-mandatory for DT'ed devices Date: Tue, 25 Oct 2016 17:41:48 +0100 Message-Id: <1477413715-22894-5-git-send-email-kieran@bingham.xyz> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477413715-22894-1-git-send-email-kieran@bingham.xyz> References: <1477413715-22894-1-git-send-email-kieran@bingham.xyz> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Lee Jones Currently the I2C framework insists on devices supplying an I2C ID table. Many of the devices which do so unnecessarily adding quite a few wasted lines to kernel code. This patch allows drivers a means to 'not' supply the aforementioned table and match on DT match tables instead. Acked-by: Grant Likely Signed-off-by: Lee Jones Tested-by: Kieran Bingham Reviewed-by: Javier Martinez Canillas Tested-by: Javier Martinez Canillas Signed-off-by: Kieran Bingham --- drivers/i2c/i2c-core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index d5eca0dc32be..a69b47990ae7 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -607,7 +607,7 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv) /* Attempt an OF style match */ - if (of_driver_match_device(dev, drv)) + if (i2c_of_match_device(drv->of_match_table, client)) return 1; /* Then ACPI style match */ @@ -833,7 +833,15 @@ static int i2c_device_probe(struct device *dev) } driver = to_i2c_driver(dev->driver); - if (!driver->probe || !driver->id_table) + if (!driver->probe) + return -EINVAL; + + /* + * An I2C ID table is not mandatory, if and only if, a suitable Device + * Tree match table entry is supplied for the probing device. + */ + if (!driver->id_table && + !i2c_of_match_device(dev->driver->of_match_table, client)) return -ENODEV; if (client->flags & I2C_CLIENT_WAKE) {