Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1059890pxb; Wed, 6 Apr 2022 07:48:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAINXO1XsiQqibHtQDWSHxDanCoiFclQc0lHNcbVXtzQFYf31c4Hl+n45tz6RJ40/bL3FE X-Received: by 2002:a05:6a00:3018:b0:4fa:d533:45e5 with SMTP id ay24-20020a056a00301800b004fad53345e5mr9101287pfb.13.1649256508478; Wed, 06 Apr 2022 07:48:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649256508; cv=none; d=google.com; s=arc-20160816; b=HA8gUWWVMSrzi6u43zGzS6r/1x9Qrm2S4l/LZtJ7P0tPgYbx0f0lAo4SMUQ6KXLcyd vkEvsZwQ8rD5uqkuQH7D8yVkCIYdSulVpqqCYpqkSX9xZKImyKzueB7V58Q89FtKVIeC /B9zJGU4IpUCkwNj7mJJkhWrud9BIhMRKDq6ZvKRjmd2HN9cKx5qelxQc3/4tMtautg+ FNuQ6SusA9IRAX2h6Xi192kCwTc7MoBl+V9IdKppcClSAzKd0XGz6sz3PF71Opldvcjy RV1wi9hU5avmcOHXJyDBc+Xu6BgPlR46COlKHN3ynCJ9CRBfiJ6CnV+8rajKfqH6pidT XCiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=x4YcHLziIrEggw9HG5I5fbaW8iCdF7u9wJBMUjziEm8=; b=j/xTAq/0kS3Q4QJcYZFax/ewvINlwP+M3Y9q4cQoSzaikVbp+ErYhIwd97gfInznZi jbIqtzq6u3XEVUp5xo3Z5725/Yn0YnJfo3MexD/gOMWaT7cEL1rvImCEBhfRKD/NTa8/ OOnHRoLMTNd6Y9hU/mIkL2ZjbEZHdRfw1y8yXmmFGOItpw8HESsWfgcO2F7xgKiUYBnY vyGCqNJ1+F5mffj2LFJb0YJhY6QR+85zDchr6BFBYG8C+Vt8SNXS51Ay/fPnxRZorH2w wOH+JsIfxhJ84wRuHktLI4R4Q9qCk1JJMmcmQBQlJxMT8ePDJOKJ4zD4wglrkNIKEEIy EhRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=meQxV9f1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id nl12-20020a17090b384c00b001bd14e0302dsi5672829pjb.5.2022.04.06.07.48.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 07:48:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=meQxV9f1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C975E586302; Wed, 6 Apr 2022 05:38:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1839069AbiDFA6M (ORCPT + 99 others); Tue, 5 Apr 2022 20:58:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380317AbiDENOB (ORCPT ); Tue, 5 Apr 2022 09:14:01 -0400 Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54880123BE5; Tue, 5 Apr 2022 05:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1649161001; x=1680697001; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x4YcHLziIrEggw9HG5I5fbaW8iCdF7u9wJBMUjziEm8=; b=meQxV9f1p1HxnA3LmMRvs8ovRZ0drYp0I+KKJAUcs7eP7q68kAO9jRvG 5xgBBynyHeSrU7SC+XYDy/gOfaOKCoOMUwNmTum1YmqLNFA/tDU1wNG0Z fKawQ0pdr4asecovTbrHWQE7JdFkJUI8dpn60dfWZXB5pY789qCwPJxbZ ctjRS89ABOnJilYZeMhLr4HxnA1XPBXRDCJS+lZF6iyuCH6nP8Cn+qkBD ONmlhg8GdVyC8ip3m1a5cQfJf+j7yBDSyKxykIETTWeFKKkXiOaXC98cF BWAO6Sr1S1y0r2wLxBnfjegIeqJXA4gA+j6MctVnwViaHh7A0LoFMPJU4 w==; From: Vincent Whitchurch To: CC: , Vincent Whitchurch , , , , , Subject: [PATCH 2/2] i2c: core: support no-detect property Date: Tue, 5 Apr 2022 14:16:27 +0200 Message-ID: <20220405121627.1560949-3-vincent.whitchurch@axis.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220405121627.1560949-1-vincent.whitchurch@axis.com> References: <20220405121627.1560949-1-vincent.whitchurch@axis.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the devicetree specifies the no-detect property, we can avoid calling drivers' detect callback and wasting time probing for devices which do not exist. Signed-off-by: Vincent Whitchurch --- drivers/i2c/i2c-core-base.c | 8 +++++++- include/linux/i2c.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index d43db2c3876e..d43025b84546 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1341,7 +1341,8 @@ static int i2c_do_add_adapter(struct i2c_driver *driver, struct i2c_adapter *adap) { /* Detect supported devices on that bus, and instantiate them */ - i2c_detect(adap, driver); + if (adap->detect) + i2c_detect(adap, driver); return 0; } @@ -1432,6 +1433,7 @@ EXPORT_SYMBOL_GPL(i2c_handle_smbus_host_notify); static int i2c_register_adapter(struct i2c_adapter *adap) { + struct device_node *np = adap->dev.of_node; int res = -EINVAL; /* Can't register until after driver model init */ @@ -1502,6 +1504,10 @@ static int i2c_register_adapter(struct i2c_adapter *adap) "Failed to create compatibility class link\n"); #endif + adap->detect = true; + if (np && of_property_read_bool(np, "no-detect")) + adap->detect = false; + /* create pre-declared device nodes */ of_i2c_register_devices(adap); i2c_acpi_install_space_handler(adap); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index fbda5ada2afc..8fad5fe85685 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -728,6 +728,7 @@ struct i2c_adapter { struct rt_mutex bus_lock; struct rt_mutex mux_lock; + bool detect; int timeout; /* in jiffies */ int retries; struct device dev; /* the adapter device */ -- 2.34.1