From patchwork Fri Jun 6 15:52:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 31497 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 66107202DA for ; Fri, 6 Jun 2014 15:53:03 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id r20sf1366603wiv.3 for ; Fri, 06 Jun 2014 08:53:02 -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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=LuKN+WeqQyEoR5Xi8/aDuHNFTMAq0Rz3wQlpx5qLntM=; b=fR2L+PqPU/uPpKtPbnB75eu3ieZfQH3o5x2JJ/scQRsdNEyuPUFb/4IXpeYSU2CtBl 8v3zL04HyAA3OCmOspqYMBlI4q38GfAuC374VW3skY/SZRFYB9miABtfw9DIGE/baYVh O/pApO5XIUrnAK98Z7BW5QGB95uvQKGSnvAm2unRInC2Po4drMRwcuAwmwdUH+CTYtQZ XmeYr/atMkde0MdPOr9+O023ZYoCSPDH0Jc1Wx6l7Q1mlmGKJJ50ZTCA/vWp788VSz31 uOH96YNW42DNLGwnP5DrJPsz1SnjmnJaG0gXA6nZ1vaxfw9NPXyVVg6S5J5Ngqld7v/1 7m3g== X-Gm-Message-State: ALoCoQkbFAntR5I/mzHlomhX2x5Tfqi+S45S0HUzhrV8hF6DIRcYVtyI4AeqGaGipOen31Qld1FD X-Received: by 10.152.203.226 with SMTP id kt2mr1561958lac.2.1402069982433; Fri, 06 Jun 2014 08:53:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.36.14 with SMTP id o14ls773727qgo.63.gmail; Fri, 06 Jun 2014 08:53:02 -0700 (PDT) X-Received: by 10.58.198.46 with SMTP id iz14mr4784017vec.53.1402069982219; Fri, 06 Jun 2014 08:53:02 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id lt1si6687305vec.15.2014.06.06.08.53.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 06 Jun 2014 08:53:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.182 as permitted sender) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id sa20so3384495veb.41 for ; Fri, 06 Jun 2014 08:53:02 -0700 (PDT) X-Received: by 10.221.26.10 with SMTP id rk10mr6726654vcb.0.1402069982130; Fri, 06 Jun 2014 08:53:02 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp115259vcb; Fri, 6 Jun 2014 08:53:01 -0700 (PDT) X-Received: by 10.43.164.136 with SMTP id ms8mr6978938icc.93.1402069981557; Fri, 06 Jun 2014 08:53:01 -0700 (PDT) Received: from mail-ie0-f175.google.com (mail-ie0-f175.google.com [209.85.223.175]) by mx.google.com with ESMTPS id u7si23340792igh.44.2014.06.06.08.53.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 06 Jun 2014 08:53:01 -0700 (PDT) Received-SPF: pass (google.com: domain of lee.jones@linaro.org designates 209.85.223.175 as permitted sender) client-ip=209.85.223.175; Received: by mail-ie0-f175.google.com with SMTP id tp5so1056427ieb.34 for ; Fri, 06 Jun 2014 08:53:01 -0700 (PDT) X-Received: by 10.50.28.51 with SMTP id y19mr32575358igg.5.1402069981199; Fri, 06 Jun 2014 08:53:01 -0700 (PDT) Received: from localhost.localdomain (host86-181-29-77.range86-181.btcentralplus.com. [86.181.29.77]) by mx.google.com with ESMTPSA id j1sm27388094ige.0.2014.06.06.08.52.58 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 06 Jun 2014 08:53:00 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: wsa@the-dreams.de, grant.likely@linaro.org, linus.walleij@linaro.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, Lee Jones Subject: [PATCH 6/9] i2c: Provide a temporary .probe2() call-back type Date: Fri, 6 Jun 2014 16:52:29 +0100 Message-Id: <1402069952-28022-7-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1402069952-28022-1-git-send-email-lee.jones@linaro.org> References: <1402069952-28022-1-git-send-email-lee.jones@linaro.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.128.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: 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 3fe8232..7047ea9 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -269,8 +269,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 @@ -286,7 +284,15 @@ static int i2c_device_probe(struct device *dev) dev_dbg(dev, "probe\n"); 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 9d36f86..0a470ea 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);