Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp200529pxa; Wed, 26 Aug 2020 08:21:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeWOUvLI3c3+R5s0atnwQjISG/SxSdLmfb9gvd/i6H6cISRa2lQCMUD3TvEKS8PKWDUyrO X-Received: by 2002:a05:6402:b1b:: with SMTP id bm27mr9855720edb.288.1598455270363; Wed, 26 Aug 2020 08:21:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598455270; cv=none; d=google.com; s=arc-20160816; b=YUKNOI7leH/zx1z8+MlliNrZfRCfO/P1d7PLZdYIur5Atb4nc7GtaAMG4tUBMvMu3f lHK4jb5UmgUmJbWXrrwW531fflQAYbTeBgN2TqKKqKTLUIQes3cgqOoGWAy8ans/ZpPn iAI9Rs6PvGOf2kXk8/yoaajGlnvpHieoSxY86EnFQQenm3VuUVAjNcpNwIdZH+KlYWI/ 8GKnuWLSuy5d1AQHE3rNgopyR/ldJeVCV4zhsy4wnbLtW+IY9IsBGS/Q5hOykGstdyYi 0a4oYSDiXjv0FWXAH9cfo/LjnA9spUGU0F92oDgbb0SguuPZL8P6hfTbUlgSVv54f5ol MTyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=ebHjc6ttDUsxBLgR9vRoD9T1kE8x6pmCgEyNvTByGRE=; b=tzCuth3xciUppSMHtunbBxnxBJRKdoFTTT1achjKSv9fKwasj8MwFfOkM3TwBzAR+h GW4EsFs66A+2ySu6BJpFU/NWnCGixj+jb2MXpAoexh64YSrXIrMBxOy6ptF1R1jJapyK J7grTLbmfW51ciOMQN4wR6mp9HnEkC8oSPb16hNEQsGnWC7mECyuO64YxP3hW7WSmAL8 dm+GAQktdq43YUM1ol5828YxWcoa0AnerCMItljNpWIxuC22U7uMupY9BlMZm3tpzeXG psUTRVKYl6Uw4vjlqOjcx12c+lBBjB790vgfOFvAgfcLeOknlizKoaUZgXpay0ciuK7i uxOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b23si1753790ejv.299.2020.08.26.08.20.47; Wed, 26 Aug 2020 08:21:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726947AbgHZPSs (ORCPT + 99 others); Wed, 26 Aug 2020 11:18:48 -0400 Received: from mga04.intel.com ([192.55.52.120]:10523 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727883AbgHZPSp (ORCPT ); Wed, 26 Aug 2020 11:18:45 -0400 IronPort-SDR: sJR3OabF68OF93kicsNQIkyGv+qfkzmTQu234eocC/w8tKCQezOxiMXFnB0pdeV+TvTmaMvvgT P8RPsjwpJqNQ== X-IronPort-AV: E=McAfee;i="6000,8403,9725"; a="153731861" X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="153731861" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2020 08:18:44 -0700 IronPort-SDR: LFOOq02faltDs2sF7gkQT/rBXsdGjaw5I+KcUpzLmZZ7XJ90mijCpdb1DfxpTxWkqP1M2jymH8 or4UJgSKhp6Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="329260583" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga008.jf.intel.com with ESMTP; 26 Aug 2020 08:18:42 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1kAxA5-00BatB-CF; Wed, 26 Aug 2020 18:16:29 +0300 Date: Wed, 26 Aug 2020 18:16:29 +0300 From: Andy Shevchenko To: Sergey Senozhatsky Cc: Wolfram Sang , Jean Delvare , Mika Westerberg , linux-i2c@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] i2c: do not acpi/of match device in i2c_device_probe() Message-ID: <20200826151629.GR1891694@smile.fi.intel.com> References: <20200826144920.110605-1-sergey.senozhatsky@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200826144920.110605-1-sergey.senozhatsky@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 26, 2020 at 11:49:20PM +0900, Sergey Senozhatsky wrote: > i2c, apparently, can match the same device twice - the first > time in ->match bus hook (i2c_device_match()), and the second > one in ->probe (i2c_device_probe()) bus hook. > > To make things more complicated, the second matching does not > do exactly same checks as the first one. Namely, i2c_device_match() > calls acpi_driver_match_device() which considers devices that > provide of_match_table and performs of_compatible() matching for > such devices. One important thing to note here is that ACPI > of_compatible() matching (acpi_of_match_device()) is part of ACPI > and does not depend on CONFIG_OF. > > i2c_device_probe(), on the other hand, calls acpi_match_device() > which does not perform of_compatible() matching, but instead > i2c_device_probe() relies on CONFIG_OF API to perform of_match_table > matching, IOW ->probe matching, unlike ->match matching, depends on > CONFIG_OF. This can break i2c device probing on !CONFIG_OF systems > if the device does not provide .id_table. > > i2c_device_probe() > ... > if (!driver->id_table && > !i2c_acpi_match_device(dev->driver->acpi_match_table, client) && > !i2c_of_match_device(dev->driver->of_match_table, client)) { > status = -ENODEV; > goto put_sync_adapter; > } > > i2c_of_match_device() on !CONFIG_OF systems is always false, so we never > perform of_match_table matching. i2c_acpi_match_device() does ACPI match > only, no of_compatible() matching takes place, even though the device > provides .of_match_table and ACPI is capable of matching such device. > > It is not entirely clear why the device is matched again in bus > ->probe after successful and proper matching in bus ->match. Let's > remove ->probe matching. Reviewed-by: Andy Shevchenko (assuming it's okay to go) > Signed-off-by: Sergey Senozhatsky > Suggested-by: Andy Shevchenko > --- > drivers/i2c/i2c-core-base.c | 11 ----------- > 1 file changed, 11 deletions(-) > > diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c > index 5ec082e2039d..77eea5c0bc71 100644 > --- a/drivers/i2c/i2c-core-base.c > +++ b/drivers/i2c/i2c-core-base.c > @@ -475,17 +475,6 @@ static int i2c_device_probe(struct device *dev) > > driver = to_i2c_driver(dev->driver); > > - /* > - * An I2C ID table is not mandatory, if and only if, a suitable OF > - * or ACPI ID table is supplied for the probing device. > - */ > - if (!driver->id_table && > - !acpi_driver_match_device(dev, dev->driver) && > - !i2c_of_match_device(dev->driver->of_match_table, client)) { > - status = -ENODEV; > - goto put_sync_adapter; > - } > - > if (client->flags & I2C_CLIENT_WAKE) { > int wakeirq; > > -- > 2.28.0 > -- With Best Regards, Andy Shevchenko