[{"id":1746811,"web_url":"http://patchwork.ozlabs.org/comment/1746811/","msgid":"<de6bf483-9ef4-522b-507d-272f736bcabc@redhat.com>","list_archive_url":null,"date":"2017-08-14T20:13:23","subject":"Re: [PATCH 1/2] i2c: core: Allow the driver to override the default\n\ti2c_bus match behavior","submitter":{"id":1893,"url":"http://patchwork.ozlabs.org/api/people/1893/","name":"Hans de Goede","email":"hdegoede@redhat.com"},"content":"Hi,\n\nOn 22-07-17 20:55, Hans de Goede wrote:\n> Some ACPI devices report multiple ids for a single i2c_client, while not\n> really implementing the hw-interface asociated with some of these ids.\n> \n> For some of these devices calling probe and having probe fail with\n> -ENODEV is a problem in itself as this causes the device to be\n> powered-up and down again (causes its PS0 and PS3 ACPI methods to be\n> executed) which puts some devices in an unusable state.\n> \n> This commit adds a match callback to i2c_driver, allowing drivers to\n> override the default i2c_bus match behavior and tell the core they\n> are not the right driver for the device, avoiding i2c_bus_type.probe\n> getting called, avoiding the undesirable power up / down cycle.\n> \n> Signed-off-by: Hans de Goede <hdegoede@redhat.com>\n\nWhat is the status of this series ? I thought there was agreement\non merging this through the i2c (wsa/linux.git) tree ?\n\nRegards,\n\nHans\n\n\n> ---\n>   drivers/i2c/i2c-core-base.c | 12 +++++++++---\n>   include/linux/i2c.h         |  6 ++++++\n>   2 files changed, 15 insertions(+), 3 deletions(-)\n> \n> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c\n> index c89dac7fd2e7..2c6702f2347b 100644\n> --- a/drivers/i2c/i2c-core-base.c\n> +++ b/drivers/i2c/i2c-core-base.c\n> @@ -98,8 +98,16 @@ EXPORT_SYMBOL_GPL(i2c_match_id);\n>   static int i2c_device_match(struct device *dev, struct device_driver *drv)\n>   {\n>   \tstruct i2c_client\t*client = i2c_verify_client(dev);\n> -\tstruct i2c_driver\t*driver;\n> +\tstruct i2c_driver\t*driver = to_i2c_driver(drv);\n> +\tint ret;\n>   \n> +\tif (driver->match && client) {\n> +\t\tret = driver->match(client);\n> +\t\tif (ret < 0)\n> +\t\t\treturn 0;\n> +\t\tif (ret > 0)\n> +\t\t\treturn 1;\n> +\t}\n>   \n>   \t/* Attempt an OF style match */\n>   \tif (i2c_of_match_device(drv->of_match_table, client))\n> @@ -109,8 +117,6 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv)\n>   \tif (acpi_driver_match_device(dev, drv))\n>   \t\treturn 1;\n>   \n> -\tdriver = to_i2c_driver(drv);\n> -\n>   \t/* Finally an I2C match */\n>   \tif (i2c_match_id(driver->id_table, client))\n>   \t\treturn 1;\n> diff --git a/include/linux/i2c.h b/include/linux/i2c.h\n> index 00ca5b86a753..670577c82bc3 100644\n> --- a/include/linux/i2c.h\n> +++ b/include/linux/i2c.h\n> @@ -139,6 +139,9 @@ enum i2c_alert_protocol {\n>    * struct i2c_driver - represent an I2C device driver\n>    * @class: What kind of i2c device we instantiate (for detect)\n>    * @attach_adapter: Callback for bus addition (deprecated)\n> + * @match: Allows the driver to override the default i2c_bus match behavior\n> + *         return < 0 to fail the match, > 0 to force a match, 0 to fallback\n> + *         to default id matching\n>    * @probe: Callback for device binding - soon to be deprecated\n>    * @probe_new: New callback for device binding\n>    * @remove: Callback for device unbinding\n> @@ -180,6 +183,9 @@ struct i2c_driver {\n>   \t */\n>   \tint (*attach_adapter)(struct i2c_adapter *) __deprecated;\n>   \n> +\t/* Set this to override standard i2c_bus match behavior */\n> +\tint (*match)(struct i2c_client *);\n> +\n>   \t/* Standard driver model interfaces */\n>   \tint (*probe)(struct i2c_client *, const struct i2c_device_id *);\n>   \tint (*remove)(struct i2c_client *);\n>","headers":{"Return-Path":"<linux-i2c-owner@vger.kernel.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-i2c-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=hdegoede@redhat.com"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xWRdD10NVz9t2r\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 15 Aug 2017 06:13:36 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752120AbdHNUNe (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tMon, 14 Aug 2017 16:13:34 -0400","from mx1.redhat.com ([209.132.183.28]:46214 \"EHLO mx1.redhat.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751030AbdHNUNc (ORCPT <rfc822;linux-i2c@vger.kernel.org>);\n\tMon, 14 Aug 2017 16:13:32 -0400","from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 3A49B51455;\n\tMon, 14 Aug 2017 20:13:32 +0000 (UTC)","from shalem.localdomain (ovpn-116-222.ams2.redhat.com\n\t[10.36.116.222])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 8134161F24;\n\tMon, 14 Aug 2017 20:13:24 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 3A49B51455","Subject":"Re: [PATCH 1/2] i2c: core: Allow the driver to override the default\n\ti2c_bus match behavior","To":"Jiri Kosina <jikos@kernel.org>,\n\tBenjamin Tissoires <benjamin.tissoires@redhat.com>,\n\tWolfram Sang <wsa@the-dreams.de>","Cc":"linux-input@vger.kernel.org, linux-i2c@vger.kernel.org","References":"<20170722185537.12696-1-hdegoede@redhat.com>","From":"Hans de Goede <hdegoede@redhat.com>","Message-ID":"<de6bf483-9ef4-522b-507d-272f736bcabc@redhat.com>","Date":"Mon, 14 Aug 2017 22:13:23 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<20170722185537.12696-1-hdegoede@redhat.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.15","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.39]);\n\tMon, 14 Aug 2017 20:13:32 +0000 (UTC)","Sender":"linux-i2c-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-i2c.vger.kernel.org>","X-Mailing-List":"linux-i2c@vger.kernel.org"}},{"id":1746869,"web_url":"http://patchwork.ozlabs.org/comment/1746869/","msgid":"<20170814212115.GA5142@katana>","list_archive_url":null,"date":"2017-08-14T21:21:15","subject":"Re: [PATCH 1/2] i2c: core: Allow the driver to override the default\n\ti2c_bus match behavior","submitter":{"id":22495,"url":"http://patchwork.ozlabs.org/api/people/22495/","name":"Wolfram Sang","email":"wsa@the-dreams.de"},"content":"On Mon, Aug 14, 2017 at 10:13:23PM +0200, Hans de Goede wrote:\n> Hi,\n> \n> On 22-07-17 20:55, Hans de Goede wrote:\n> >Some ACPI devices report multiple ids for a single i2c_client, while not\n> >really implementing the hw-interface asociated with some of these ids.\n> >\n> >For some of these devices calling probe and having probe fail with\n> >-ENODEV is a problem in itself as this causes the device to be\n> >powered-up and down again (causes its PS0 and PS3 ACPI methods to be\n> >executed) which puts some devices in an unusable state.\n> >\n> >This commit adds a match callback to i2c_driver, allowing drivers to\n> >override the default i2c_bus match behavior and tell the core they\n> >are not the right driver for the device, avoiding i2c_bus_type.probe\n> >getting called, avoiding the undesirable power up / down cycle.\n> >\n> >Signed-off-by: Hans de Goede <hdegoede@redhat.com>\n> \n> What is the status of this series ? I thought there was agreement\n> on merging this through the i2c (wsa/linux.git) tree ?\n\nYes, but I need to review the I2C core changes first.","headers":{"Return-Path":"<linux-i2c-owner@vger.kernel.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-i2c-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xWT7M52bMz9t2y\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 15 Aug 2017 07:21:19 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752339AbdHNVVS (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tMon, 14 Aug 2017 17:21:18 -0400","from www.zeus03.de ([194.117.254.33]:50378 \"EHLO mail.zeus03.de\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1752133AbdHNVVR (ORCPT <rfc822;linux-i2c@vger.kernel.org>);\n\tMon, 14 Aug 2017 17:21:17 -0400","(qmail 27411 invoked from network); 14 Aug 2017 23:21:16 +0200","from p200300cf5bc2ce00021de0fffea0c865.dip0.t-ipconnect.de (HELO\n\tlocalhost) (l3s3148p1@2003:cf:5bc2:ce00:21d:e0ff:fea0:c865)\n\tby mail.zeus03.de with ESMTPSA (ECDHE-RSA-AES256-GCM-SHA384\n\tencrypted, authenticated); 14 Aug 2017 23:21:16 +0200"],"Date":"Mon, 14 Aug 2017 23:21:15 +0200","From":"Wolfram Sang <wsa@the-dreams.de>","To":"Hans de Goede <hdegoede@redhat.com>","Cc":"Jiri Kosina <jikos@kernel.org>,\n\tBenjamin Tissoires <benjamin.tissoires@redhat.com>,\n\tlinux-input@vger.kernel.org, linux-i2c@vger.kernel.org","Subject":"Re: [PATCH 1/2] i2c: core: Allow the driver to override the default\n\ti2c_bus match behavior","Message-ID":"<20170814212115.GA5142@katana>","References":"<20170722185537.12696-1-hdegoede@redhat.com>\n\t<de6bf483-9ef4-522b-507d-272f736bcabc@redhat.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"G4iJoqBmSsgzjUCe\"","Content-Disposition":"inline","In-Reply-To":"<de6bf483-9ef4-522b-507d-272f736bcabc@redhat.com>","User-Agent":"Mutt/1.5.24 (2015-08-30)","Sender":"linux-i2c-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-i2c.vger.kernel.org>","X-Mailing-List":"linux-i2c@vger.kernel.org"}}]