From patchwork Wed Sep 9 18:33:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 53327 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id 5855F22B05 for ; Wed, 9 Sep 2015 18:34:57 +0000 (UTC) Received: by lbbti1 with SMTP id ti1sf6409188lbb.3 for ; Wed, 09 Sep 2015 11:34:56 -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=OiYYHr7TzuP399M0KfXhrQMazoLEn4XhYQmChfiMTlE=; b=Dquu0QmYA2zH+EbwjGPAK1u0CrcBPks/dkIaQPHp1ztq+I8ZVkU+ldPHldWO8PAbyb zn4Tn0m7drIMODtGw4cjpjpHC90qO97PZnFtOC+gQ9mLqQjMTo/dnPu/ZDK1EMu2l3v7 SglK7SbrNYkdKO/P3p2dm+KdeyJ8PE9OwX4/4O6VOxhslMooceFrw/CixUwQvVOMIs7r lWsCr5DUEH6mhU4V9TqeNBDk2rOYKwqsQg7ZySHYWwWiNLt+NfNlIQ0Ws6z0v8JpiHg+ v9anCzqauWvL4Cw+ufDsB2cMQCImfcbPJz0Mv7KrFbv7lj9/nQ6mNtf4a+xeuuPd42Sp teyg== X-Gm-Message-State: ALoCoQniCCmgt4ParFF6spE5eNZAjPRFYGOHM05NdB37KxS3Phezbe7RfqbB8ImHtFB0BSjeb8iZ X-Received: by 10.112.144.99 with SMTP id sl3mr8386936lbb.12.1441823696268; Wed, 09 Sep 2015 11:34:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.163 with SMTP id w3ls106921lae.21.gmail; Wed, 09 Sep 2015 11:34:55 -0700 (PDT) X-Received: by 10.153.7.75 with SMTP id da11mr15033966lad.103.1441823695960; Wed, 09 Sep 2015 11:34:55 -0700 (PDT) Received: from mail-la0-x230.google.com (mail-la0-x230.google.com. [2a00:1450:4010:c03::230]) by mx.google.com with ESMTPS id s12si7478797lbp.106.2015.09.09.11.34.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2015 11:34:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::230 as permitted sender) client-ip=2a00:1450:4010:c03::230; Received: by lamp12 with SMTP id p12so12546457lam.0 for ; Wed, 09 Sep 2015 11:34:55 -0700 (PDT) X-Received: by 10.152.5.133 with SMTP id s5mr8427291las.19.1441823695805; Wed, 09 Sep 2015 11:34: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.112.59.35 with SMTP id w3csp492167lbq; Wed, 9 Sep 2015 11:34:54 -0700 (PDT) X-Received: by 10.50.225.66 with SMTP id ri2mr20950099igc.5.1441823694759; Wed, 09 Sep 2015 11:34:54 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qu10si2304353pbb.181.2015.09.09.11.34.53; Wed, 09 Sep 2015 11:34:54 -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 S1754989AbbIISel (ORCPT + 28 others); Wed, 9 Sep 2015 14:34:41 -0400 Received: from mail-wi0-f196.google.com ([209.85.212.196]:36241 "EHLO mail-wi0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754783AbbIISee (ORCPT ); Wed, 9 Sep 2015 14:34:34 -0400 Received: by wicmn1 with SMTP id mn1so5348161wic.3; Wed, 09 Sep 2015 11:34:32 -0700 (PDT) X-Received: by 10.180.99.232 with SMTP id et8mr55743344wib.80.1441823672183; Wed, 09 Sep 2015 11:34:32 -0700 (PDT) Received: from localhost.localdomain (cpc17-aztw24-2-0-cust759.aztw.cable.virginm.net. [92.237.134.248]) by smtp.gmail.com with ESMTPSA id u1sm5155141wiz.22.2015.09.09.11.34.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Sep 2015 11:34:30 -0700 (PDT) From: Kieran Bingham To: Wolfram Sang , Samuel Ortiz , Lee Jones Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linus.walleij@linaro.org, grant.likely@linaro.org, Kieran Bingham Subject: [PATCH v4 6/8] i2c: Provide a temporary .probe2() call-back type Date: Wed, 9 Sep 2015 19:33:45 +0100 Message-Id: <1441823627-6227-7-git-send-email-kieranbingham@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1441823627-6227-1-git-send-email-kieranbingham@gmail.com> References: <1441823627-6227-1-git-send-email-kieranbingham@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: kieranbingham@gmail.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::230 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@gmail.com; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com 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: , From: Lee Jones This will aid the seamless removal of the current probe()'s, more commonly unused than used second parameter. Most I2C drivers can simply switch over to the new interface, others which have DT support can use its own matching instead and others can call i2c_match_id() themselves. This brings I2C's device probe method into line with other similar interfaces in the kernel and prevents the requirement to pass an i2c_device_id table. Suggested-by: Grant Likely Signed-off-by: Lee Jones [Kieran: fix rebase conflicts and adapt for dev_pm_domain_{attach,detach}] Signed-off-by: Kieran Bingham --- drivers/i2c/i2c-core.c | 22 ++++++++++++++-------- include/linux/i2c.h | 8 +++++++- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 0e40136..a28b423 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -658,8 +658,6 @@ static int i2c_device_probe(struct device *dev) } driver = to_i2c_driver(dev->driver); - if (!driver->probe) - return -EINVAL; /* * An I2C ID table is not mandatory, if and only if, a suitable Device @@ -679,12 +677,20 @@ static int i2c_device_probe(struct device *dev) return status; status = dev_pm_domain_attach(&client->dev, true); - if (status != -EPROBE_DEFER) { - status = driver->probe(client, i2c_match_id(driver->id_table, - client)); - if (status) - dev_pm_domain_detach(&client->dev, true); - } + if (status == -EPROBE_DEFER) + return status; + + /* When there are no more users of probe(), rename probe2 to probe. */ + if (driver->probe2) + status = driver->probe2(client); + else if (driver->probe) + status = driver->probe(client, + i2c_match_id(driver->id_table, client)); + else + status = -EINVAL; + + if (status) + dev_pm_domain_detach(&client->dev, true); return status; } diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 126585c..cb25ae0 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -127,7 +127,8 @@ extern s32 i2c_smbus_write_i2c_block_data(const struct i2c_client *client, * struct i2c_driver - represent an I2C device driver * @class: What kind of i2c device we instantiate (for detect) * @attach_adapter: Callback for bus addition (deprecated) - * @probe: Callback for device binding + * @probe: Callback for device binding - soon to be deprecated + * @probe2: New callback for device binding * @remove: Callback for device unbinding * @shutdown: Callback for device shutdown * @alert: Alert callback, for example for the SMBus alert protocol @@ -170,6 +171,11 @@ struct i2c_driver { int (*probe)(struct i2c_client *, const struct i2c_device_id *); int (*remove)(struct i2c_client *); + /* New driver model interface to aid the seamless removal of the + * current probe()'s, more commonly unused than used second parameter. + */ + int (*probe2)(struct i2c_client *); + /* driver model interfaces that don't relate to enumeration */ void (*shutdown)(struct i2c_client *);