From patchwork Fri Jun 20 12:02:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 32269 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E0638203C2 for ; Fri, 20 Jun 2014 12:03:33 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id oy12sf12129095veb.6 for ; Fri, 20 Jun 2014 05:03:33 -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=WmPDBZQADYQgPWDLClxHrkfhWFaBsPbvohm744m6vWg=; b=YEMJYYpWLI82WA6J1GnOEKi4Y1HXfzX9m2EnqICSvgEsQU19jANeGcdbRKqMvhzFnz pYuOqBYG9FGO/0uMHMQrNKDxpRm9SI2Ml+ZtfKBPfwH7IMqSTLGjpH5kYAvw7+bTx+Mt Aw7NOVXhXLQggT220kXGp4OUZemE+wJt2LlyF2BmMdMln01SjAq93/RqqONWFZCgBVQO VsDcp03ICjOfRGIt3ghkwR+4qBLFd7Lp3hJWJssBT5rFtT1SWlN32LuBdPmUqvksevFj yY8vMZr7I5a/3nHRDv7IaBXoV4k6DKlrhQsXcHhAfqViulInx6W+e7zrVh+TnKavXVU2 kkVg== X-Gm-Message-State: ALoCoQlT8rGyK58VNv+wbmmkpgOKIO5QOsfWtKZ5Xc1DwAIp5MHHe1RgIjf7IMyz18SAhufUhAXe X-Received: by 10.58.94.197 with SMTP id de5mr1190872veb.19.1403265813725; Fri, 20 Jun 2014 05:03:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.27.131 with SMTP id 3ls930650qgx.9.gmail; Fri, 20 Jun 2014 05:03:33 -0700 (PDT) X-Received: by 10.58.132.70 with SMTP id os6mr830711veb.36.1403265813633; Fri, 20 Jun 2014 05:03:33 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id mt8si413816vec.72.2014.06.20.05.03.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Jun 2014 05:03:33 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id hy4so3337965vcb.20 for ; Fri, 20 Jun 2014 05:03:33 -0700 (PDT) X-Received: by 10.58.228.74 with SMTP id sg10mr1557913vec.6.1403265813570; Fri, 20 Jun 2014 05:03:33 -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.37.5 with SMTP id tc5csp16609vcb; Fri, 20 Jun 2014 05:03:33 -0700 (PDT) X-Received: by 10.42.186.2 with SMTP id cq2mr3153954icb.25.1403265812951; Fri, 20 Jun 2014 05:03:32 -0700 (PDT) Received: from mail-ig0-f174.google.com (mail-ig0-f174.google.com [209.85.213.174]) by mx.google.com with ESMTPS id do6si14473322icc.40.2014.06.20.05.03.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Jun 2014 05:03:32 -0700 (PDT) Received-SPF: pass (google.com: domain of lee.jones@linaro.org designates 209.85.213.174 as permitted sender) client-ip=209.85.213.174; Received: by mail-ig0-f174.google.com with SMTP id l13so424774iga.13 for ; Fri, 20 Jun 2014 05:03:32 -0700 (PDT) X-Received: by 10.50.13.41 with SMTP id e9mr3725000igc.23.1403265812700; Fri, 20 Jun 2014 05:03:32 -0700 (PDT) Received: from localhost.localdomain (host109-148-235-194.range109-148.btcentralplus.com. [109.148.235.194]) by mx.google.com with ESMTPSA id qn5sm3890078igb.7.2014.06.20.05.03.30 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Jun 2014 05:03:32 -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, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linus.walleij@linaro.org, Lee Jones Subject: [PATCH 7/9] i2c: Provide a temporary .probe2() call-back type Date: Fri, 20 Jun 2014 13:02:31 +0100 Message-Id: <1403265753-25851-9-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1403265753-25851-1-git-send-email-lee.jones@linaro.org> References: <1403265753-25851-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.220.175 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 b8962e4..d8daf24 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 370905d..9414b16 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);