From patchwork Thu Aug 28 14:35:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 36232 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B8B39202DD for ; Thu, 28 Aug 2014 14:37:23 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf8313825oag.4 for ; Thu, 28 Aug 2014 07:37:23 -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=HeATPW5jjQxBI3K88zcKCaUOe3h+rwTbSFJVAZuiI5c=; b=c9SL2te7rKhQ/9bR+WwRqrd4Go208Ods6H/KZ/mFH29DkJyHytTQxqDAz8hPy5Q8cv v16hvG474EpQoxfDAitCqD2hVYxrEqlNUNH8y3vUYGlFYJTIQX6WshOauwl8+1kSNM57 HRTciNhPTk6fY3zlIwaq+E7mCs4epH8k21eCxvsO/6qU1SfXqnsQQhxU+ubuhJBY6pHc BfTf0gl8ZdpbXAOT6Y9pZwXwS1UHn54RoGcQjTtjeSb7yVbCmZT3tB8FDRgu0Ga59Z0t uWHyBqDrje91EtNtFOtkve+h5olX8jHyBDkUSgrOIhAzhWV6VIXn1LNpyTCHMbmJMLI0 hKZA== X-Gm-Message-State: ALoCoQld6FYSNg0awlK8SKN0fviHxv94Eyjm9FDOJNOh3W4QbPSJ4xyCwctN97IYR6eCjqPC7zOf X-Received: by 10.69.29.234 with SMTP id jz10mr2305942pbd.1.1409236642325; Thu, 28 Aug 2014 07:37:22 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.97.134 with SMTP id m6ls583691qge.8.gmail; Thu, 28 Aug 2014 07:37:22 -0700 (PDT) X-Received: by 10.220.49.10 with SMTP id t10mr1329266vcf.34.1409236642220; Thu, 28 Aug 2014 07:37:22 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id cr2si3695583vcb.8.2014.08.28.07.37.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Aug 2014 07:37:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id hy4so904459vcb.38 for ; Thu, 28 Aug 2014 07:37:22 -0700 (PDT) X-Received: by 10.220.118.136 with SMTP id v8mr1125167vcq.50.1409236642120; Thu, 28 Aug 2014 07:37:22 -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.221.45.67 with SMTP id uj3csp246779vcb; Thu, 28 Aug 2014 07:37:21 -0700 (PDT) X-Received: by 10.70.36.4 with SMTP id m4mr6595522pdj.88.1409236640697; Thu, 28 Aug 2014 07:37:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id so2si6871082pab.132.2014.08.28.07.37.20 for ; Thu, 28 Aug 2014 07:37:20 -0700 (PDT) Received-SPF: none (google.com: linux-i2c-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 S1751117AbaH1Ogs (ORCPT + 1 other); Thu, 28 Aug 2014 10:36:48 -0400 Received: from mail-qa0-f47.google.com ([209.85.216.47]:44399 "EHLO mail-qa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751823AbaH1OgF (ORCPT ); Thu, 28 Aug 2014 10:36:05 -0400 Received: by mail-qa0-f47.google.com with SMTP id x12so790838qac.34 for ; Thu, 28 Aug 2014 07:36:05 -0700 (PDT) X-Received: by 10.229.236.8 with SMTP id ki8mr7351417qcb.12.1409236565192; Thu, 28 Aug 2014 07:36:05 -0700 (PDT) Received: from localhost.localdomain (host86-152-0-170.range86-152.btcentralplus.com. [86.152.0.170]) by mx.google.com with ESMTPSA id o2sm5797541qgo.17.2014.08.28.07.36.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Aug 2014 07:36:04 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, kernel@stlinux.com, wsa@the-dreams.de, grant.likely@linaro.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linus.walleij@linaro.org Subject: [PATCH 6/8] i2c: Provide a temporary .probe2() call-back type Date: Thu, 28 Aug 2014 15:35:36 +0100 Message-Id: <1409236538-21274-7-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1409236538-21274-1-git-send-email-lee.jones@linaro.org> References: <1409236538-21274-1-git-send-email-lee.jones@linaro.org> Sender: linux-i2c-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-i2c@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) 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: , 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 --- drivers/i2c/i2c-core.c | 12 +++++++++--- include/linux/i2c.h | 8 +++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 7c21f49..5c74bd0 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -270,8 +270,6 @@ static int i2c_device_probe(struct device *dev) return 0; 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 @@ -291,7 +289,15 @@ static int i2c_device_probe(struct device *dev) return status; acpi_dev_pm_attach(&client->dev, true); - status = driver->probe(client, i2c_match_id(driver->id_table, client)); + + /* 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 + return -EINVAL; if (status) acpi_dev_pm_detach(&client->dev, true); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 79b674d..c8240e5 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -125,7 +125,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 * @suspend: Callback for device suspend @@ -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 *); int (*suspend)(struct i2c_client *, pm_message_t mesg);