{"id":799629,"url":"http://patchwork.ozlabs.org/api/1.2/patches/799629/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20170809101256.31204-1-javierm@redhat.com/","project":{"id":35,"url":"http://patchwork.ozlabs.org/api/1.2/projects/35/?format=json","name":"Linux I2C development","link_name":"linux-i2c","list_id":"linux-i2c.vger.kernel.org","list_email":"linux-i2c@vger.kernel.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170809101256.31204-1-javierm@redhat.com>","list_archive_url":null,"date":"2017-08-09T10:12:56","name":"i2c: slave-eeprom: Add an OF device ID table","commit_ref":null,"pull_url":null,"state":"rejected","archived":false,"hash":"d2e2938c8cfbfd731912ed3fd6074f36facf007a","submitter":{"id":72132,"url":"http://patchwork.ozlabs.org/api/1.2/people/72132/?format=json","name":"Javier Martinez Canillas","email":"javierm@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20170809101256.31204-1-javierm@redhat.com/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/799629/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/799629/checks/","tags":{},"related":[],"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-mx05.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=javierm@redhat.com"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xS6YR3BkLz9s76\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed,  9 Aug 2017 20:13:47 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1753046AbdHIKNb (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tWed, 9 Aug 2017 06:13:31 -0400","from mx1.redhat.com ([209.132.183.28]:52108 \"EHLO mx1.redhat.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1753077AbdHIKND (ORCPT <rfc822;linux-i2c@vger.kernel.org>);\n\tWed, 9 Aug 2017 06:13:03 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\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 03B273A92E3;\n\tWed,  9 Aug 2017 10:13:03 +0000 (UTC)","from minerva.redhat.com (ovpn-116-235.ams2.redhat.com\n\t[10.36.116.235])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 0091018B85;\n\tWed,  9 Aug 2017 10:12:58 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 03B273A92E3","From":"Javier Martinez Canillas <javierm@redhat.com>","To":"linux-kernel@vger.kernel.org","Cc":"Luis Oliveira <Luis.Oliveira@synopsys.com>,\n\tJavier Martinez Canillas <javierm@redhat.com>,\n\tWolfram Sang <wsa@the-dreams.de>, linux-i2c@vger.kernel.org","Subject":"[PATCH] i2c: slave-eeprom: Add an OF device ID table","Date":"Wed,  9 Aug 2017 12:12:56 +0200","Message-Id":"<20170809101256.31204-1-javierm@redhat.com>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.14","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.29]);\n\tWed, 09 Aug 2017 10:13:03 +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"},"content":"The driver doesn't have a struct of_device_id table but supported devices\nare registered via Device Trees as shown in the following DT binding doc:\n\nDocumentation/devicetree/bindings/i2c/i2c-designware.txt\n\nBut this works on the assumption that a I2C device registered via OF will\nalways match a legacy I2C device ID and that the MODALIAS reported will\nalways be of the form i2c:<device>.\n\nAnd this could change in the future so the correct approach is to have an\nOF device ID table if the devices are registered via OF.\n\nSigned-off-by: Javier Martinez Canillas <javierm@redhat.com>\n\n---\n\n drivers/i2c/i2c-slave-eeprom.c | 15 ++++++++++++++-\n 1 file changed, 14 insertions(+), 1 deletion(-)","diff":"diff --git a/drivers/i2c/i2c-slave-eeprom.c b/drivers/i2c/i2c-slave-eeprom.c\nindex b2039f94c9d8..20226860cfe7 100644\n--- a/drivers/i2c/i2c-slave-eeprom.c\n+++ b/drivers/i2c/i2c-slave-eeprom.c\n@@ -17,6 +17,7 @@\n #include <linux/i2c.h>\n #include <linux/init.h>\n #include <linux/module.h>\n+#include <linux/of_device.h>\n #include <linux/of.h>\n #include <linux/slab.h>\n #include <linux/spinlock.h>\n@@ -108,7 +109,12 @@ static int i2c_slave_eeprom_probe(struct i2c_client *client, const struct i2c_de\n {\n \tstruct eeprom_data *eeprom;\n \tint ret;\n-\tunsigned size = id->driver_data;\n+\tunsigned size;\n+\n+\tif (client->dev.of_node)\n+\t\tsize = (kernel_ulong_t)of_device_get_match_data(&client->dev);\n+\telse\n+\t\tsize = id->driver_data;\n \n \teeprom = devm_kzalloc(&client->dev, sizeof(struct eeprom_data) + size, GFP_KERNEL);\n \tif (!eeprom)\n@@ -154,9 +160,16 @@ static const struct i2c_device_id i2c_slave_eeprom_id[] = {\n };\n MODULE_DEVICE_TABLE(i2c, i2c_slave_eeprom_id);\n \n+static const struct of_device_id i2c_slave_eeprom_of_match[] = {\n+\t{ .compatible = \"linux,slave-24c02\", .data = (void *)(2048 / 8) },\n+\t{ }\n+};\n+MODULE_DEVICE_TABLE(of, i2c_slave_eeprom_of_match);\n+\n static struct i2c_driver i2c_slave_eeprom_driver = {\n \t.driver = {\n \t\t.name = \"i2c-slave-eeprom\",\n+\t\t.of_match_table = i2c_slave_eeprom_of_match,\n \t},\n \t.probe = i2c_slave_eeprom_probe,\n \t.remove = i2c_slave_eeprom_remove,\n","prefixes":[]}