From patchwork Thu Jun 9 08:53:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 632683 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3rQJyS5TlFz9sBf for ; Thu, 9 Jun 2016 18:54:24 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=XP35umCQ; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422628AbcFIIyW (ORCPT ); Thu, 9 Jun 2016 04:54:22 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35756 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161280AbcFIIyQ (ORCPT ); Thu, 9 Jun 2016 04:54:16 -0400 Received: by mail-wm0-f68.google.com with SMTP id k184so8815094wme.2; Thu, 09 Jun 2016 01:54:15 -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:mime-version :content-transfer-encoding; bh=L+4iybI/RsxjDjOAD92JM/pZpyRt94d6X/tMzZ9Yxhw=; b=XP35umCQK+r0odt3vmYf01D97AlGhAdIaN0y4EdmflSPNgG7qxNUJCBGTi0XJ5T7Q1 gZM8geOPJykfMm1BlGGAE36fC48yKQbg6/KoGqi1M1BR483GYx94mpq7CLJIM3S+LTg0 v1xgODoX3XtxoylVwLoXFZ/YvXN1lCMPDtsOW+q2mL0ilN+7Lw58NJzwEhsw2CMihEV+ AK+tkG0E/9daTBYTTdAWPovI5IDGKvLegldSvpbNWpYmXpHpUqPD9RJ4/tJ51YS8bCNL AUa8LJ0BgY5ByO7etH4j5lykXZC7SAdZdcKCvyu0VJCR9+OIJ+MsG8NNToZUJbm7bfGN Hf3g== 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 :mime-version:content-transfer-encoding; bh=L+4iybI/RsxjDjOAD92JM/pZpyRt94d6X/tMzZ9Yxhw=; b=kpOm1W/VDnmDp3al39b2yRybTEllixK6bIp1q7dTfsnucMgGe6dZglsMNWKkee/9Za BMLICu5y1yh+dvsxCJ46lyl/sNumYF3yCbKdRGGGvd/aa5vTZHODgMJ8pgpblm5xx6Ze tBPzS8N4OWT/ctBeJIFdu50kwqT3hKHxdti2QAzNSjIXTXvfGQo5id+CPGPvFISSwsUD eYg550KGuOMPL54i35cHzlHpZeWXZL4ifuiFy3DvDA6C2KgL85TY06RKhk1WXhQIdHa0 MvBSqhGRppMibIMEX18zz02kUPOJcX1Ije7VjQCniV1x0xpIye+7zwNCCfTVjq6A0Hqu CGlg== X-Gm-Message-State: ALyK8tLJrG6TXrbNuAkUSAKXYo0GtF51r8XvpZ8QbzJLtbkek891Tf2PyBXBIQCSpv3xiA== X-Received: by 10.28.126.72 with SMTP id z69mr12315239wmc.22.1465462454756; Thu, 09 Jun 2016 01:54:14 -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.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jun 2016 01:54:13 -0700 (PDT) From: Chris Wilson To: linux-i2c@vger.kernel.org Cc: Chris Wilson , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Wolfram Sang , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 1/3] i2c: Split adapter initialisation from registers Date: Thu, 9 Jun 2016 09:53:53 +0100 Message-Id: <1465462435-5240-1-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org In order to handle devices that need to use the adapter prior to it being registered with the system, we first need to split out the initialisation of the adapter out of i2c_register_adapter. 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 | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index af11b658984d..743c38a63da1 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1511,16 +1511,8 @@ static int __process_new_adapter(struct device_driver *d, void *data) return i2c_do_add_adapter(to_i2c_driver(d), data); } -static int i2c_register_adapter(struct i2c_adapter *adap) +static int i2c_init_adapter(struct i2c_adapter *adap) { - int res = 0; - - /* Can't register until after driver model init */ - if (WARN_ON(!is_registered)) { - res = -EAGAIN; - goto out_list; - } - /* Sanity checks */ if (unlikely(adap->name[0] == '\0')) { pr_err("i2c-core: Attempt to register an adapter with " @@ -1548,6 +1540,23 @@ static int i2c_register_adapter(struct i2c_adapter *adap) if (adap->timeout == 0) adap->timeout = HZ; + return 0; +} + +static int i2c_register_adapter(struct i2c_adapter *adap) +{ + int res = 0; + + /* Can't register until after driver model init */ + if (WARN_ON(!is_registered)) { + res = -EAGAIN; + goto out_list; + } + + res = i2c_init_adapter(adap); + if (res) + goto out_list; + dev_set_name(&adap->dev, "i2c-%d", adap->nr); adap->dev.bus = &i2c_bus_type; adap->dev.type = &i2c_adapter_type;