From patchwork Thu May 8 21:16:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 29863 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AEC3120534 for ; Thu, 8 May 2014 21:17:28 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id va2sf15293672obc.9 for ; Thu, 08 May 2014 14:17:28 -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:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=MKqfwZRiDkxLJPMFsbX6dNyiGwEhlYVlIncb7JWB9SU=; b=GzsIHAR2W7U2pn+EKMg4QWlhWciPc1J3N4sDwKUBWKMgm3DF7OTOZouLj99kMJMxuw VF7a3KaVzc/y78YcjfdNkDPWcUrVe3AO1p4vNW90DJNM4tFH5VUX7BILS5UMb+NWrV1Q A4WCxwUcFTL6NRZfqd+u5om8Erqr+DFGL8wrQbHs0k9m4PuRx18Af0RpcYoqkYoYJMCB IIxIP7jkoRYjEuwjYzMCpLumBo/hFvDqrhUjMrrH28eQRNWogn8iwoNCbzha2GPap6BL /tk9Td/6jMRxpcnSrkVj+yQxw4g6VA2UnBvrX4WdUGg7MjweCwbXSWCjIrno11f3GhD1 WTww== X-Gm-Message-State: ALoCoQmD+TOd9ayfGmC/NQM3DgS6QI52Al05Kg6UIqFEis92jCT6ErPd/6lwTa/99tTYIYSuftaL X-Received: by 10.50.254.1 with SMTP id ae1mr170118igd.6.1399583848141; Thu, 08 May 2014 14:17:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.133 with SMTP id t5ls36845qgt.43.gmail; Thu, 08 May 2014 14:17:28 -0700 (PDT) X-Received: by 10.52.13.41 with SMTP id e9mr3946073vdc.21.1399583848013; Thu, 08 May 2014 14:17:28 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id ge9si381785veb.44.2014.05.08.14.17.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 May 2014 14:17:28 -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.220.170; Received: by mail-vc0-f170.google.com with SMTP id lf12so4115818vcb.29 for ; Thu, 08 May 2014 14:17:27 -0700 (PDT) X-Received: by 10.220.81.194 with SMTP id y2mr4665537vck.29.1399583847933; Thu, 08 May 2014 14:17:27 -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 ib8csp25889vcb; Thu, 8 May 2014 14:17:27 -0700 (PDT) X-Received: by 10.66.164.70 with SMTP id yo6mr11940669pab.85.1399583846394; Thu, 08 May 2014 14:17:26 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fm5si1093040pbc.34.2014.05.08.14.17.25; Thu, 08 May 2014 14:17:25 -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 S1755873AbaEHVRH (ORCPT + 27 others); Thu, 8 May 2014 17:17:07 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:50012 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755735AbaEHVRC (ORCPT ); Thu, 8 May 2014 17:17:02 -0400 Received: by mail-wi0-f171.google.com with SMTP id hm4so379147wib.4 for ; Thu, 08 May 2014 14:17:01 -0700 (PDT) X-Received: by 10.180.11.137 with SMTP id q9mr57566wib.13.1399583821393; Thu, 08 May 2014 14:17:01 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id gd5sm2726629wjb.40.2014.05.08.14.16.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 May 2014 14:17:00 -0700 (PDT) From: Linus Walleij To: Samuel Ortiz , Lee Jones , linux-kernel@vger.kernel.org Cc: Linus Walleij Subject: [RESEND PATCH 3/6] mfd: stmpe: probe properly from the device tree Date: Thu, 8 May 2014 23:16:36 +0200 Message-Id: <1399583799-23517-3-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1399583799-23517-1-git-send-email-linus.walleij@linaro.org> References: <1399583799-23517-1-git-send-email-linus.walleij@linaro.org> 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 v2->v3: - Fix a stupid error where I left a dangling return statement in the probe path. - Fix up subject prope->probe 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 | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 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..a45f9c0a330a 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,41 @@ 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; + } else + partnum = (int)of_id->data; + + return stmpe_probe(&i2c_ci, partnum); } static int stmpe_i2c_remove(struct i2c_client *i2c) @@ -89,6 +116,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,