From patchwork Wed Apr 16 14:44:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 28489 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f70.google.com (mail-pb0-f70.google.com [209.85.160.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1B950206A6 for ; Wed, 16 Apr 2014 14:44:55 +0000 (UTC) Received: by mail-pb0-f70.google.com with SMTP id rp16sf41246367pbb.1 for ; Wed, 16 Apr 2014 07:44:55 -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=9ii0L0kC2V6SkJj35DPt3h6xINrq37qdTYckfNbmA14=; b=OINvu7zpQnVxdZeJWHJ2EmWWhVsxu7XY1v1TUI1G+5PcnyZ7aZ1uvDA1n/PRBNT+Gx c3jfeYTplbtZVdrXFpfoZd6PEEDj66DxJ4H4MsM3hhqZurnoA8fK+kp2K8Es+ZzmvZas IUz8nyVCW+BANC6L7iu4+cGdAqiD1nOr1czjg/+yIpT3FEIsef0SHaQMhnNzS2qy8EJ5 JcBPchReBq6mFplbeIWljrehaFI9OwFGPmbE/Z3kRHskgwnZMhLrBP4X58yWcddBCk/i shmkHO3btQRWYHjYl5zheF+aWjmA1EuCYI53EMIS3ZJtBN8E31lmewU3GYTHn4tWIlf8 rKDQ== X-Gm-Message-State: ALoCoQnIRzn/S/Gp9Te/YPmtMH9zKeaJ7T8RZimrzhmvriPbSC14EZBSYqy9RTiMguaFcEJpUmrw X-Received: by 10.68.133.75 with SMTP id pa11mr4121880pbb.2.1397659495279; Wed, 16 Apr 2014 07:44:55 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.20.138 with SMTP id 10ls609127qgj.92.gmail; Wed, 16 Apr 2014 07:44:55 -0700 (PDT) X-Received: by 10.52.231.72 with SMTP id te8mr87734vdc.54.1397659495145; Wed, 16 Apr 2014 07:44:55 -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 tm8si3901034vdc.206.2014.04.16.07.44.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Apr 2014 07:44:55 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id jy13so10831676veb.16 for ; Wed, 16 Apr 2014 07:44:55 -0700 (PDT) X-Received: by 10.52.249.105 with SMTP id yt9mr1361733vdc.34.1397659495047; Wed, 16 Apr 2014 07:44:55 -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 ib8csp317869vcb; Wed, 16 Apr 2014 07:44:54 -0700 (PDT) X-Received: by 10.66.197.135 with SMTP id iu7mr8731256pac.149.1397659494054; Wed, 16 Apr 2014 07:44:54 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rb6si12853215pab.67.2014.04.16.07.44.52; Wed, 16 Apr 2014 07:44:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422640AbaDPOoq (ORCPT + 26 others); Wed, 16 Apr 2014 10:44:46 -0400 Received: from mail-wg0-f52.google.com ([74.125.82.52]:43162 "EHLO mail-wg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161145AbaDPOoo (ORCPT ); Wed, 16 Apr 2014 10:44:44 -0400 Received: by mail-wg0-f52.google.com with SMTP id k14so11106216wgh.35 for ; Wed, 16 Apr 2014 07:44:43 -0700 (PDT) X-Received: by 10.194.81.164 with SMTP id b4mr7473630wjy.2.1397659483183; Wed, 16 Apr 2014 07:44:43 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id eu7sm5398968wib.18.2014.04.16.07.44.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Apr 2014 07:44:42 -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] mfd: stmpe: prope properly from the device tree Date: Wed, 16 Apr 2014 16:44:12 +0200 Message-Id: <1397659455-13638-4-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1397659455-13638-1-git-send-email-linus.walleij@linaro.org> References: <1397659455-13638-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: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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. Signed-off-by: Linus Walleij --- drivers/mfd/stmpe-i2c.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c index 0da02e11d58e..8902a600d978 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,71 @@ static struct stmpe_client_info i2c_ci = { .write_block = i2c_block_write, }; +#ifdef CONFIG_OF +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); + +int stmpe_i2c_of_probe(struct i2c_client *i2c) +{ + const struct of_device_id *of_id; + + of_id = of_match_device(stmpe_of_match, &i2c->dev); + if (!of_id) + return -EINVAL; + return (int)of_id->data; +} +#else +int stmpe_i2c_of_probe(struct i2c_client *i2c) +{ + return -EINVAL; +} +#endif + static int stmpe_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { + int partnum; + 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); + partnum = stmpe_i2c_of_probe(i2c); + if (partnum < 0) + partnum = id->driver_data; + + return stmpe_probe(&i2c_ci, partnum); } static int stmpe_i2c_remove(struct i2c_client *i2c) @@ -89,6 +146,7 @@ static struct i2c_driver stmpe_i2c_driver = { #ifdef CONFIG_PM .pm = &stmpe_dev_pm_ops, #endif + .of_match_table = of_match_ptr(stmpe_of_match), }, .probe = stmpe_i2c_probe, .remove = stmpe_i2c_remove,