From patchwork Thu Dec 18 02:15:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 5510051 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5ED9E9F1D4 for ; Thu, 18 Dec 2014 02:15:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8932D209E3 for ; Thu, 18 Dec 2014 02:15:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 653FA20997 for ; Thu, 18 Dec 2014 02:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751727AbaLRCP1 (ORCPT ); Wed, 17 Dec 2014 21:15:27 -0500 Received: from galahad.ideasonboard.com ([185.26.127.97]:50362 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751615AbaLRCP0 (ORCPT ); Wed, 17 Dec 2014 21:15:26 -0500 Received: from avalon.ideasonboard.com (dsl-hkibrasgw3-50ddcc-40.dhcp.inet.fi [80.221.204.40]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 9721B20B64; Thu, 18 Dec 2014 03:12:05 +0100 (CET) From: Laurent Pinchart To: linux-input@vger.kernel.org Cc: linux-sh@vger.kernel.org, linux-i2c@vger.kernel.org, Geert Uytterhoeven , Wolfram Sang Subject: [PATCH] input: adxl34x: Add OF match support Date: Thu, 18 Dec 2014 04:15:23 +0200 Message-Id: <1418868923-13411-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.0.4 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, 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 The I2C subsystem can match devices without explicit OF support based on the part of their compatible property after the comma. However, this mechanism uses the first compatible value only. For adxl34x OF device nodes the compatible property should list the more specific "adi,adxl345" or "adi,adxl346" value first and the "adi,adxl34x" fallback value second. This prevents the device node from being matched with the adxl34x driver. Fix this by adding an OF match table with an "adi,adxl34x" compatible entry. Signed-off-by: Laurent Pinchart --- drivers/input/misc/adxl34x-i2c.c | 11 +++++++++++ 1 file changed, 11 insertions(+) Another option would have been to add "adxl325" and "adxl326" entries to the adxl34x_id I2C match table, but it would have had the drawback of requiring a driver update for every new device. diff --git a/drivers/input/misc/adxl34x-i2c.c b/drivers/input/misc/adxl34x-i2c.c index 416f47ddcc90..22687b738811 100644 --- a/drivers/input/misc/adxl34x-i2c.c +++ b/drivers/input/misc/adxl34x-i2c.c @@ -10,6 +10,7 @@ #include /* BUS_I2C */ #include #include +#include #include #include #include "adxl34x.h" @@ -137,11 +138,21 @@ static const struct i2c_device_id adxl34x_id[] = { MODULE_DEVICE_TABLE(i2c, adxl34x_id); +#ifdef CONFIG_OF +static const struct of_device_id adxl34x_of_id[] = { + { .compatible = "adi,adxl34x", }, + { } +}; + +MODULE_DEVICE_TABLE(of, adxl34x_of_id); +#endif + static struct i2c_driver adxl34x_driver = { .driver = { .name = "adxl34x", .owner = THIS_MODULE, .pm = &adxl34x_i2c_pm, + .of_match_table = of_match_ptr(adxl34x_of_id), }, .probe = adxl34x_i2c_probe, .remove = adxl34x_i2c_remove,