From patchwork Wed Apr 23 11:37:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 28871 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 220412057C for ; Wed, 23 Apr 2014 11:38:53 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id hw13sf2566261qab.7 for ; Wed, 23 Apr 2014 04:38:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=vIrhoFbMZtNEYPJFr8KNtZH2tZkHchl8cp9Yixrqr6M=; b=Br/FCQ3SJraQfPPkfSe3EXOyxMXVi/U0RVshQO3XommDXd1jdZsO+ws3BW09I84Ydi 4gBRB/4785XI7VVXRqvZB4p5hp3GSBkGufdv2Aq+tQsfA/BH6Ugy7T6BaC/bT2Cwtbea xzQs8QmHwxVP/G1gqYA8hm5XBUe7q4mqITURV4vSOmvqgufOh+Ba/779uCvreW7hiku/ ADdvqw1gZz1Q4WrShVYa30jLTGMyZDKRhtNJsE3wTnCdNFMLka8cGurBNqzMPzK3VoLA Keu0n2iSHJ+7Xv5fRAnUi6j9UOuyBhBO+S0LqAKu0CT6bFFbmOQrbrdxehrk0JBPmia+ 7eUQ== X-Gm-Message-State: ALoCoQmRw4JzjUl8IPDGdNlvqeYhprj6z9pa1NrjoT6A9+aAF4BvQs0dIgEhOCH2ESlavczrIqOp X-Received: by 10.52.165.179 with SMTP id yz19mr20198300vdb.1.1398253132675; Wed, 23 Apr 2014 04:38:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.41.212 with SMTP id z78ls576738qgz.93.gmail; Wed, 23 Apr 2014 04:38:52 -0700 (PDT) X-Received: by 10.58.219.233 with SMTP id pr9mr46579085vec.10.1398253132574; Wed, 23 Apr 2014 04:38:52 -0700 (PDT) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id de9si114885vcb.105.2014.04.23.04.38.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Apr 2014 04:38:52 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id jy13so939312veb.2 for ; Wed, 23 Apr 2014 04:38:52 -0700 (PDT) X-Received: by 10.220.105.130 with SMTP id t2mr5306938vco.18.1398253132497; Wed, 23 Apr 2014 04:38:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp96638vcb; Wed, 23 Apr 2014 04:38:52 -0700 (PDT) X-Received: by 10.68.178.162 with SMTP id cz2mr53650188pbc.51.1398253131486; Wed, 23 Apr 2014 04:38:51 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vv4si455984pbc.408.2014.04.23.04.38.50; Wed, 23 Apr 2014 04:38:50 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753557AbaDWLio (ORCPT + 27 others); Wed, 23 Apr 2014 07:38:44 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:61343 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753243AbaDWLiP (ORCPT ); Wed, 23 Apr 2014 07:38:15 -0400 Received: by mail-wi0-f178.google.com with SMTP id bs8so980790wib.5 for ; Wed, 23 Apr 2014 04:38:13 -0700 (PDT) X-Received: by 10.180.98.232 with SMTP id el8mr1398821wib.27.1398253093278; Wed, 23 Apr 2014 04:38:13 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id pm5sm1148729wjc.11.2014.04.23.04.38.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Apr 2014 04:38:12 -0700 (PDT) From: Linus Walleij To: Samuel Ortiz , Lee Jones , linux-kernel@vger.kernel.org Cc: Silvio F , Philipp Zabel , Sascha Hauer , Shawn Guo , Viresh Kumar , Shiraz Hashim , spear-devel@list.st.com, Linus Walleij Subject: [PATCH 3/6 v2] mfd: stmpe: prope properly from the device tree Date: Wed, 23 Apr 2014 13:37:48 +0200 Message-Id: <1398253068-20984-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The current STMPE I2C probing code does not really match the compatible strings - it matches node names happening to give the right device name. Instead, let's introduce some real compatible matching, more complex, more accurate. Make the driver depend on OF since all platforms using it are DT-only. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Make driver depend on OF and remove some ifdeffery that way. - Squash OF match table to single lines. - Merge of-specific probe function into probe(). - Print a small nag if DT is using the node name trick to make the driver probe. --- drivers/mfd/Kconfig | 1 + drivers/mfd/stmpe-i2c.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 33834120d057..29be025d5835 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -675,6 +675,7 @@ config MFD_DB8500_PRCMU config MFD_STMPE bool "STMicroelectronics STMPE" depends on (I2C=y || SPI_MASTER=y) + depends on OF select MFD_CORE help Support for the STMPE family of I/O Expanders from diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c index 0da02e11d58e..da15dda04df9 100644 --- a/drivers/mfd/stmpe-i2c.c +++ b/drivers/mfd/stmpe-i2c.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "stmpe.h" static int i2c_reg_read(struct stmpe *stmpe, u8 reg) @@ -52,15 +53,42 @@ static struct stmpe_client_info i2c_ci = { .write_block = i2c_block_write, }; +static const struct of_device_id stmpe_of_match[] = { + { .compatible = "st,stmpe610", .data = (void *)STMPE610, }, + { .compatible = "st,stmpe801", .data = (void *)STMPE801, }, + { .compatible = "st,stmpe811", .data = (void *)STMPE811, }, + { .compatible = "st,stmpe1601", .data = (void *)STMPE1601, }, + { .compatible = "st,stmpe1801", .data = (void *)STMPE1801, }, + { .compatible = "st,stmpe2401", .data = (void *)STMPE2401, }, + { .compatible = "st,stmpe2403", .data = (void *)STMPE2403, }, + {}, +}; +MODULE_DEVICE_TABLE(of, stmpe_of_match); + static int stmpe_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { + int partnum; + const struct of_device_id *of_id; + i2c_ci.data = (void *)id; i2c_ci.irq = i2c->irq; i2c_ci.client = i2c; i2c_ci.dev = &i2c->dev; - return stmpe_probe(&i2c_ci, id->driver_data); + of_id = of_match_device(stmpe_of_match, &i2c->dev); + if (!of_id) { + /* + * This happens when the I2C ID matches the node name + * but no real compatible string has been given. + */ + dev_info(&i2c->dev, "matching on node name, compatible is preferred\n"); + partnum = id->driver_data; + return -ENODEV; + } else + partnum = (int)of_id->data; + + return stmpe_probe(&i2c_ci, partnum); } static int stmpe_i2c_remove(struct i2c_client *i2c) @@ -89,6 +117,7 @@ static struct i2c_driver stmpe_i2c_driver = { #ifdef CONFIG_PM .pm = &stmpe_dev_pm_ops, #endif + .of_match_table = stmpe_of_match, }, .probe = stmpe_i2c_probe, .remove = stmpe_i2c_remove,