From patchwork Wed May 4 15:14:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 67151 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp240647qge; Wed, 4 May 2016 08:16:26 -0700 (PDT) X-Received: by 10.98.43.7 with SMTP id r7mr12893911pfr.24.1462374986567; Wed, 04 May 2016 08:16:26 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r5si5415364pac.152.2016.05.04.08.16.26; Wed, 04 May 2016 08:16:26 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753790AbcEDPQV (ORCPT + 29 others); Wed, 4 May 2016 11:16:21 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35101 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753383AbcEDPPP (ORCPT ); Wed, 4 May 2016 11:15:15 -0400 Received: by mail-wm0-f67.google.com with SMTP id e201so10855142wme.2; Wed, 04 May 2016 08:15:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+/zhoTLv9+/nXtH1o4KPEQzXa8a10ldpscsQPiQmeXk=; b=at9O4xL/+j1+td5xtN2JKZIUBOiyy2U+40P6xOw7QzoHlW83qs0dA8GAcwHACafYZH S2B7ejZ66AAKQj/YqU9mIuh8r7/5lvKfdIXaSXC8c8RpOJgYxHS1atVXAB2dSSPnUZs7 +Pnq+QrnPFMhz1JI40pAJnjEnj6C1b4JWE3SYS159+vW2XgkaWsY2Wev4ljlZl/umvz2 dZ0JKs2Nkfqy4Fe+ndtpZN2hA6vJuGu4r09EP2oB61RT7FsOssZ/GhwFx1p5O3bO2CGk ZjlS/iSxXAdxeFVBkt7ba04iekyT2GsJZbAEddgPxgZLi5FjgHRj4O2hjGotT6zvN7Db I1Tg== X-Gm-Message-State: AOPr4FXb3FeClsDiS/Dmr896uJS7Zf0NkhiGyHhW9LXZsMID2OCX0X/JW1ZUnfdHZYI4Gg== X-Received: by 10.28.147.135 with SMTP id v129mr29777215wmd.65.1462374913506; Wed, 04 May 2016 08:15:13 -0700 (PDT) Received: from CookieMonster.cookiemonster.local (cpc87017-aztw30-2-0-cust65.18-1.cable.virginm.net. [92.232.232.66]) by smtp.gmail.com with ESMTPSA id u187sm5497613wmu.21.2016.05.04.08.15.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 May 2016 08:15:12 -0700 (PDT) From: Kieran Bingham To: Wolfram Sang , Lee Jones , javier@osg.samsung.com Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, grant.likely@linaro.org, sameo@linux.intel.com, Kieran Bingham Subject: [PATCHv5 6/8] i2c: Provide a temporary .probe_new() call-back type Date: Wed, 4 May 2016 16:14:46 +0100 Message-Id: <1462374888-22888-7-git-send-email-kieran@bingham.xyz> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1462374888-22888-1-git-send-email-kieran@bingham.xyz> References: <1462374888-22888-1-git-send-email-kieran@bingham.xyz> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Tested-by: Kieran Bingham --- Changes since v4 [Kieran] - Rename .probe2 to probe_new - Checkpatch warnings fixed --- drivers/i2c/i2c-core.c | 15 ++++++++++++--- include/linux/i2c.h | 8 +++++++- 2 files changed, 19 insertions(+), 4 deletions(-) -- 2.5.0 diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 64d543b041b1..268fec3b6931 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -697,8 +697,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 @@ -740,7 +738,18 @@ static int i2c_device_probe(struct device *dev) if (status == -EPROBE_DEFER) goto err_clear_wakeup_irq; - status = driver->probe(client, i2c_match_id(driver->id_table, client)); + /* + * When there are no more users of probe(), + * rename probe_new to probe. + */ + if (driver->probe_new) + status = driver->probe_new(client); + else if (driver->probe) + status = driver->probe(client, + i2c_match_id(driver->id_table, client)); + else + status = -EINVAL; + if (status) goto err_detach_pm_domain; diff --git a/include/linux/i2c.h b/include/linux/i2c.h index e3aa3f5e59a8..c8f73b9f51fe 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -130,7 +130,8 @@ i2c_smbus_read_i2c_block_data_or_emulated(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 + * @probe_new: 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 @@ -173,6 +174,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 (*probe_new)(struct i2c_client *); + /* driver model interfaces that don't relate to enumeration */ void (*shutdown)(struct i2c_client *);