From patchwork Fri Sep 11 11:56:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 53446 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id 82C15215BF for ; Fri, 11 Sep 2015 11:59:01 +0000 (UTC) Received: by wicuu12 with SMTP id uu12sf17701831wic.2 for ; Fri, 11 Sep 2015 04:59:00 -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=qEHW7++60bjT3mfrOXAJy38EPGEDePFC06GBTMJUlU4=; b=bMOMTCm+CQOARcEnftpL+Kkg0nvPJFLZZ/76NjnxilkB9HZHMmcf0+SorUjMyUJBqe TgrsIeMyExEuDNc6SelXvMA3JeWtugGzoFzcXWI1/A0ClsedA8KVJgmZYK2bcSuq5if1 VG5cG3ehbGVJdcrvMHaMAsfCX1Av50HlrHDU40qmIKotI5Jti2PNLs06kyc6PogHvUYI msGwqVRh5bRijVkJKuy8etM0Arsct9MCYwZX6hviNvU+dEmCf5DIIRQIYaqX3wY6qapx bwSbAH2Fl1XALbGJ4V4FuLqWn3SG9a94O05yzK7fOmSAdwQuERx9fUrDDB5CAhn8NB9X M9hg== X-Gm-Message-State: ALoCoQmhRa/04c6zo7+uJOuu2t9DqDMUCbWnILCJKQXVF98ASbsKKR0BcyVYmrbXeBp7hBuG5BDv X-Received: by 10.112.135.104 with SMTP id pr8mr11397943lbb.4.1441972740507; Fri, 11 Sep 2015 04:59:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.245.140 with SMTP id xo12ls229124lac.73.gmail; Fri, 11 Sep 2015 04:59:00 -0700 (PDT) X-Received: by 10.152.8.233 with SMTP id u9mr41593085laa.8.1441972740342; Fri, 11 Sep 2015 04:59:00 -0700 (PDT) Received: from mail-la0-x22a.google.com (mail-la0-x22a.google.com. [2a00:1450:4010:c03::22a]) by mx.google.com with ESMTPS id y10si21011lal.29.2015.09.11.04.59.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2015 04:59:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22a as permitted sender) client-ip=2a00:1450:4010:c03::22a; Received: by lamp12 with SMTP id p12so45635245lam.0 for ; Fri, 11 Sep 2015 04:59:00 -0700 (PDT) X-Received: by 10.112.77.10 with SMTP id o10mr41484703lbw.73.1441972739867; Fri, 11 Sep 2015 04:58:59 -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 w3csp1542270lbq; Fri, 11 Sep 2015 04:58:58 -0700 (PDT) X-Received: by 10.50.115.36 with SMTP id jl4mr3104199igb.18.1441972738610; Fri, 11 Sep 2015 04:58:58 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n81si106683ion.206.2015.09.11.04.58.57; Fri, 11 Sep 2015 04:58:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-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 S1752935AbbIKL64 (ORCPT + 1 other); Fri, 11 Sep 2015 07:58:56 -0400 Received: from mail-wi0-f182.google.com ([209.85.212.182]:38566 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751915AbbIKL5y (ORCPT ); Fri, 11 Sep 2015 07:57:54 -0400 Received: by wiclk2 with SMTP id lk2so55548191wic.1; Fri, 11 Sep 2015 04:57:53 -0700 (PDT) X-Received: by 10.180.74.52 with SMTP id q20mr16735661wiv.94.1441972673351; Fri, 11 Sep 2015 04:57:53 -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 wj4sm25354wjb.10.2015.09.11.04.57.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Sep 2015 04:57:52 -0700 (PDT) From: Kieran Bingham To: Wolfram Sang , Samuel Ortiz , Lee Jones Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, grant.likely@linaro.org, javier@osg.samsung.com, Kieran Bingham Subject: [RESEND PATCH v4 6/8] i2c: Provide a temporary .probe2() call-back type Date: Fri, 11 Sep 2015 12:56:02 +0100 Message-Id: <1441972564-9621-7-git-send-email-kieranbingham@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1441972564-9621-1-git-send-email-kieranbingham@gmail.com> References: <1441972564-9621-1-git-send-email-kieranbingham@gmail.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-i2c@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::22a 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 787066b..bf675d5 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 *);