Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752907AbbETKtZ (ORCPT ); Wed, 20 May 2015 06:49:25 -0400 Received: from mail-wg0-f43.google.com ([74.125.82.43]:33921 "EHLO mail-wg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751818AbbETKtY (ORCPT ); Wed, 20 May 2015 06:49:24 -0400 MIME-Version: 1.0 In-Reply-To: <20150520094829.GS1490@lahna.fi.intel.com> References: <1432044209-27858-1-git-send-email-robert.dolca@intel.com> <20150520074708.GQ1490@lahna.fi.intel.com> <20150520094829.GS1490@lahna.fi.intel.com> From: Robert Dolca Date: Wed, 20 May 2015 13:49:02 +0300 Message-ID: Subject: Re: [PATCH RFC] i2c: Use ID table to detect ACPI I2C devices To: Mika Westerberg Cc: Robert Dolca , linux-i2c@vger.kernel.org, linux-acpi@vger.kernel.org, "linux-kernel@vger.kernel.org" , Wolfram Sang , "Rafael J. Wysocki" , Len Brown , Daniel Baluta Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2182 Lines: 58 On Wed, May 20, 2015 at 12:48 PM, Mika Westerberg wrote: > On Wed, May 20, 2015 at 12:39:22PM +0300, Robert Dolca wrote: >> Currently, if the name used for DT (in dts) matches one of the names >> specified in the id table you will have a match. Isn't that an >> intended behavior? > > I thought one needs to put IDs to the driver .of_match_table. This is > also what i2c_device_match() is expecting, if I read it right. If you put the DT id in of_match_table it will match here: i2c_device_match /* Attempt an OF style match */ if (of_driver_match_device(dev, drv)) return 1; If you don't specify of_match_table and you put the same ID in i2c_device_id table it wil match here: i2c_device_match driver = to_i2c_driver(drv); /* match on an id table if there is one */ if (driver->id_table) return i2c_match_id(driver->id_table, client) != NULL; This is happening because the name from dts is used for client->name. i2c_match_id does the matching based on the client name. > BTW, how modules are supposed to be matched if we allow putting ACPI > identifiers to i2c_device_id table? My aproach was like this: if the driver specifies .acpi_match table it will work like before. i2c_device_match /* Then ACPI style match */ if (acpi_driver_match_device(dev, drv)) return 1; If the driver does not specify .acpi_match table the i2c core will atempt to match against the i2c_match_id table (the same way it does for DT). In the ACPI case the client->name has that :nn suffix and what the patch does is to ignore that when i2c_match_id is called. i2c_device_match driver = to_i2c_driver(drv); /* match on an id table if there is one */ if (driver->id_table) return i2c_match_id(driver->id_table, client) != NULL; The final goal is to simplify the driver and remove redundant code. Robert -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/