From patchwork Thu Jun 9 08:53:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9166477 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 914F6607DA for ; Thu, 9 Jun 2016 08:54:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 858102823D for ; Thu, 9 Jun 2016 08:54:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 724A428336; Thu, 9 Jun 2016 08:54:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 298032823D for ; Thu, 9 Jun 2016 08:54:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 005256EB00; Thu, 9 Jun 2016 08:54:28 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 258BA6E116 for ; Thu, 9 Jun 2016 08:54:19 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id k184so8815430wme.2 for ; Thu, 09 Jun 2016 01:54:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lXuX6RAPRXNUYYVxdxt1aW6rTtlPNWWNjUFy/wPd8fE=; b=rzqwogEHIfPyaw8/KlvXAI6M30jygAqRvVwaaF8aeHnWyl5NjjUaZIJkBhv65C3G/N NYvUxOFU+jkYBFe1nTRjSrO8sGiQ9RiMCH4XjdH6631bu0/NydQpDzAvHTXLfnTBeRGu x8sgLnOIScAGcto0Lrz2Wm6jTAO9GuSETmtutVobXbBdueNcZNR5kaB5uaBvQ7eI0+BE qeXhUwskbRuuVRee+Dx170H2kWnqrOa1fwJexX6ky3i5IY2vEbjOiXvTMtBUPpSJuRpV P3mzhdL4iDi3ay7UffUz31XyuIMP0o2sadAWGtcRh+9aYr7idnpgJEJt8l4gPwefTXiM x4Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=lXuX6RAPRXNUYYVxdxt1aW6rTtlPNWWNjUFy/wPd8fE=; b=MRYkIMITp0LV37AKWWyKstJWVc2SOjk5Bz/h4wLlJB6jsXqU0EokPv9LpWcl290jk4 WgXXGh3A8K+JxnhZ5bkC5YXqyAjuyL0ipgMjRzIQ4cyzV28+pwyO4Mb5JOPnBuBW0yj5 iWJLT3jRK2OsLSJP64FlPoKXXs9qJSItxUzSSwDfLUFnQ4q661FEB2xcYV2deKv9YM3p lkDlvkEPmgguXcMRKLUkR5lzvQaqJqV58xsQl1C+pucs5h/j5ekJt/4EdwYpbnUT6Eis mbJqK+nnHPf5FmTd1iSdwFJ17tsjDn75Oq0C1jL/KUK0iJJFcmdyKJERv8FLomARjTw+ 2JuQ== X-Gm-Message-State: ALyK8tKBhHWFZsz9EpFzrE5oDaN8sXcu9dehoUT5V3k2gWHDauHwlmTmF5dVfU6ohbPGzA== X-Received: by 10.194.91.194 with SMTP id cg2mr8973434wjb.47.1465462457299; Thu, 09 Jun 2016 01:54:17 -0700 (PDT) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id x128sm3901916wmf.6.2016.06.09.01.54.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jun 2016 01:54:16 -0700 (PDT) From: Chris Wilson To: linux-i2c@vger.kernel.org Subject: [PATCH 3/3] i2c: Export i2c_init_adapter() for use by drivers in early initialisation Date: Thu, 9 Jun 2016 09:53:55 +0100 Message-Id: <1465462435-5240-3-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1465462435-5240-1-git-send-email-chris@chris-wilson.co.uk> References: <1465462435-5240-1-git-send-email-chris@chris-wilson.co.uk> MIME-Version: 1.0 Cc: dri-devel@lists.freedesktop.org, Wolfram Sang , linux-kernel@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Some drivers require use of their i2c adapter long before they can add the adapter to userspace (i.e. before they establish and expose their objects in the sysfs kobject tree). Currently i2c_add_adapter() registers the adapter with userspace, which causes a conflict in the ordering of the driver's initialisation. Exporting i2c_init_adapter() allows for the i2c adapter to be used early in the initialisation in order to detect whether the device the adapter is attached to is even present. The drivers still need to call i2c_add_adapter() (or i2c_add_number_adapter()) as per normal to complete their registration. Signed-off-by: Chris Wilson Cc: Ville Syrjälä Cc: Wolfram Sang Cc: linux-i2c@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org --- drivers/i2c/i2c-core.c | 16 +++++++++++++++- include/linux/i2c.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 91ff70d31ec8..0a3bdb048d65 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1511,7 +1511,20 @@ static int __process_new_adapter(struct device_driver *d, void *data) return i2c_do_add_adapter(to_i2c_driver(d), data); } -static int i2c_init_adapter(struct i2c_adapter *adap) +/** + * i2c_init_adapter - initialise i2c adapter for internal use + * @adapter: the adapter to initialise + * Context: any + * + * This routine is used to initialise an I2C adapter for internal use + * prior to registering it with third parties (including userspace). The + * driver should still call i2c_add_adapter() or i2c_add_numbered_adapter() + * when it is ready to expose the adapter to userspace. + * + * Returns: 0 on success, or a negative error value if the adapter is not + * fully specified for use. + */ +int i2c_init_adapter(struct i2c_adapter *adap) { /* Only initialise the adapter once. */ if (list_empty(&adap->userspace_clients)) @@ -1546,6 +1559,7 @@ static int i2c_init_adapter(struct i2c_adapter *adap) return 0; } +EXPORT_SYMBOL(i2c_init_adapter); static int i2c_register_adapter(struct i2c_adapter *adap) { diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 96a25ae14494..72c76c5efba5 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -639,6 +639,7 @@ i2c_unlock_adapter(struct i2c_adapter *adapter) /* administration... */ #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) +extern int i2c_init_adapter(struct i2c_adapter *); extern int i2c_add_adapter(struct i2c_adapter *); extern void i2c_del_adapter(struct i2c_adapter *); extern int i2c_add_numbered_adapter(struct i2c_adapter *);