{"id":776405,"url":"http://patchwork.ozlabs.org/api/patches/776405/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20170615185418.13980-3-javier@dowhile0.org/","project":{"id":35,"url":"http://patchwork.ozlabs.org/api/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":"<20170615185418.13980-3-javier@dowhile0.org>","list_archive_url":null,"date":"2017-06-15T18:54:04","name":"[RESEND,v5,02/16] eeprom: at24: Add OF device ID table","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"aba1613f27a1127c0836507e09f041c945fd9b24","submitter":{"id":11205,"url":"http://patchwork.ozlabs.org/api/people/11205/?format=json","name":"Javier Martinez Canillas","email":"javier@dowhile0.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20170615185418.13980-3-javier@dowhile0.org/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/776405/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/776405/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","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3wpXp72BG5z9s71\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 16 Jun 2017 04:58:23 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751980AbdFOS6L (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tThu, 15 Jun 2017 14:58:11 -0400","from mail-wr0-f194.google.com ([209.85.128.194]:36628 \"EHLO\n\tmail-wr0-f194.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751879AbdFOSyb (ORCPT\n\t<rfc822; linux-i2c@vger.kernel.org>); Thu, 15 Jun 2017 14:54:31 -0400","by mail-wr0-f194.google.com with SMTP id 77so4526612wrb.3\n\tfor <linux-i2c@vger.kernel.org>; Thu, 15 Jun 2017 11:54:30 -0700 (PDT)","from localhost.localdomain ([90.68.25.6])\n\tby smtp.gmail.com with ESMTPSA id 3sm39252wru.50.2017.06.15.11.54.28\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tThu, 15 Jun 2017 11:54:29 -0700 (PDT)"],"Authentication-Results":"ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=dowhile0-org.20150623.gappssmtp.com\n\theader.i=@dowhile0-org.20150623.gappssmtp.com\n\theader.b=\"se+cvTbM\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=dowhile0-org.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=y/S89CJh9fG1JllIepmcnjxdiC5bEXPYLwFh7eUHo84=;\n\tb=se+cvTbMTZOUFf9H+JUNNCIjD/80sQ+LKpPhJbIrNiudr85JE3HObKCCtiSfLsoZMo\n\tEJbgJ9OmWPG8aZHm+E7R6F7UmGyQOWi3qitn+OMIbxgAY1L7hMwEl4vGiTYwxQwGGiyV\n\tfyk6u2wKUJIsrYtnwl16/X1egpZPmTNnMdrJdMsJppUypL/eIwS8tC4GWxhPZ+lI1GFl\n\tyq/RnsQArBrca75xwWnofW9nKSMK4GPy69b9cLdoh83GfJQteBSfkkYfYMsngySCq6uA\n\tCSAqFVYmbrEwsjf8ZWJ+tM2jwBsEFh7nqEwBhH+zvBA5hBIGq9UPKI4dG9owN9wP5nSB\n\t9kyA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=y/S89CJh9fG1JllIepmcnjxdiC5bEXPYLwFh7eUHo84=;\n\tb=rs7Ix6xtZwwabn+2I3oF7Hymiaz/hy8wDGaP/YCogfcm/7QhN/9n2B1gO0SLkR53ps\n\tjeEWTUzXqm2g1Dq2Lbe/s7AGFg45ekm/q1GywTllo+c/dh4vFWhmFl0QKUgJRuE3Rq9D\n\ted15tRzxjcfqKhSUWx1vV8yNR0Oh5pP0SNWeEj2ACmjAKSMPn/AUulOz9zrPNA7MM0K2\n\tLNPmlFBTcNFzoKAaLdeQgOGgC111hH7PlHB/M4oXoNAK6zLfIGDM4w0Cza4y8q7TRxDg\n\t7WGIKuPsQikx0I5pxwWFar+wauLS1SlUtz6Cp76KmqUiOsrYrb0zTfVv2jLrTUWOFEd/\n\tFsvg==","X-Gm-Message-State":"AKS2vOw2K/IfLhG46GzZs3NVpleogq680FdHpWGCly9zwduMOpiulPGF\n\tOU8rHjy4suQlyzNR","X-Received":"by 10.223.171.83 with SMTP id r19mr4862369wrc.173.1497552869721; \n\tThu, 15 Jun 2017 11:54:29 -0700 (PDT)","From":"Javier Martinez Canillas <javier@dowhile0.org>","To":"linux-kernel@vger.kernel.org","Cc":"Wolfram Sang <wsa@the-dreams.de>, Rob Herring <robh@kernel.org>,\n\tJavier Martinez Canillas <javier@dowhile0.org>,\n\tSimon Horman <horms@verge.net.au>,\n\tAndy Shevchenko <andy.shevchenko@gmail.com>, linux-i2c@vger.kernel.org","Subject":"[RESEND PATCH v5 02/16] eeprom: at24: Add OF device ID table","Date":"Thu, 15 Jun 2017 20:54:04 +0200","Message-Id":"<20170615185418.13980-3-javier@dowhile0.org>","X-Mailer":"git-send-email 2.9.3","In-Reply-To":"<20170615185418.13980-1-javier@dowhile0.org>","References":"<20170615185418.13980-1-javier@dowhile0.org>","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. This is working on the assumption that a\nI2C device registered via OF will always match a legacy I2C device ID and\nthat the MODALIAS reported will always be of the form i2c:<device>.\n\nBut 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\nSuggested-by: Wolfram Sang <wsa@the-dreams.de>\nSigned-off-by: Javier Martinez Canillas <javier@dowhile0.org>\n\n---\n\nChanges in v5: None\nChanges in v4: None\nChanges in v3:\n- Fix wrong .data values for \"atmel,24c02\" and \"atmel,24c64\" entries.\n\nChanges in v2:\n- Only add a single OF device ID entry for each device type (Wolfram Sang).\n\n drivers/misc/eeprom/at24.c | 65 +++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 64 insertions(+), 1 deletion(-)","diff":"diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c\nindex 764ff5df0dbc..79c5c39be29c 100644\n--- a/drivers/misc/eeprom/at24.c\n+++ b/drivers/misc/eeprom/at24.c\n@@ -12,6 +12,7 @@\n #include <linux/kernel.h>\n #include <linux/init.h>\n #include <linux/module.h>\n+#include <linux/of_device.h>\n #include <linux/slab.h>\n #include <linux/delay.h>\n #include <linux/mutex.h>\n@@ -175,6 +176,64 @@ static const struct i2c_device_id at24_ids[] = {\n };\n MODULE_DEVICE_TABLE(i2c, at24_ids);\n \n+static const struct of_device_id at24_of_match[] = {\n+\t{\n+\t\t.compatible = \"atmel,24c00\",\n+\t\t.data = (void *)AT24_DEVICE_MAGIC(128 / 8, AT24_FLAG_TAKE8ADDR)\n+\t},\n+\t{\n+\t\t.compatible = \"atmel,24c01\",\n+\t\t.data = (void *)AT24_DEVICE_MAGIC(1024 / 8, 0)\n+\t},\n+\t{\n+\t\t.compatible = \"atmel,24c02\",\n+\t\t.data = (void *)AT24_DEVICE_MAGIC(2048 / 8, 0)\n+\t},\n+\t{\n+\t\t.compatible = \"atmel,spd\",\n+\t\t.data = (void *)AT24_DEVICE_MAGIC(2048 / 8,\n+\t\t\t\tAT24_FLAG_READONLY | AT24_FLAG_IRUGO)\n+\t},\n+\t{\n+\t\t.compatible = \"atmel,24c04\",\n+\t\t.data = (void *)AT24_DEVICE_MAGIC(4096 / 8, 0)\n+\t},\n+\t{\n+\t\t.compatible = \"atmel,24c08\",\n+\t\t.data = (void *)AT24_DEVICE_MAGIC(8192 / 8, 0)\n+\t},\n+\t{\n+\t\t.compatible = \"atmel,24c16\",\n+\t\t.data = (void *)AT24_DEVICE_MAGIC(16384 / 8, 0)\n+\t},\n+\t{\n+\t\t.compatible = \"atmel,24c32\",\n+\t\t.data = (void *)AT24_DEVICE_MAGIC(32768 / 8, AT24_FLAG_ADDR16)\n+\t},\n+\t{\n+\t\t.compatible = \"atmel,24c64\",\n+\t\t.data = (void *)AT24_DEVICE_MAGIC(65536 / 8, AT24_FLAG_ADDR16)\n+\t},\n+\t{\n+\t\t.compatible = \"atmel,24c128\",\n+\t\t.data = (void *)AT24_DEVICE_MAGIC(131072 / 8, AT24_FLAG_ADDR16)\n+\t},\n+\t{\n+\t\t.compatible = \"atmel,24c256\",\n+\t\t.data = (void *)AT24_DEVICE_MAGIC(262144 / 8, AT24_FLAG_ADDR16)\n+\t},\n+\t{\n+\t\t.compatible = \"atmel,24c512\",\n+\t\t.data = (void *)AT24_DEVICE_MAGIC(524288 / 8, AT24_FLAG_ADDR16)\n+\t},\n+\t{\n+\t\t.compatible = \"atmel,24c1024\",\n+\t\t.data = (void *)AT24_DEVICE_MAGIC(1048576 / 8, AT24_FLAG_ADDR16)\n+\t},\n+\t{ },\n+};\n+MODULE_DEVICE_TABLE(of, at24_of_match);\n+\n static const struct acpi_device_id at24_acpi_ids[] = {\n \t{ \"INT3499\", AT24_DEVICE_MAGIC(8192 / 8, 0) },\n \t{ }\n@@ -598,7 +657,10 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)\n \tif (client->dev.platform_data) {\n \t\tchip = *(struct at24_platform_data *)client->dev.platform_data;\n \t} else {\n-\t\tif (id) {\n+\t\tif (client->dev.of_node) {\n+\t\t\tmagic = (kernel_ulong_t)\n+\t\t\t\tof_device_get_match_data(&client->dev);\n+\t\t} else if (id) {\n \t\t\tmagic = id->driver_data;\n \t\t} else {\n \t\t\tconst struct acpi_device_id *aid;\n@@ -814,6 +876,7 @@ static int at24_remove(struct i2c_client *client)\n static struct i2c_driver at24_driver = {\n \t.driver = {\n \t\t.name = \"at24\",\n+\t\t.of_match_table = at24_of_match,\n \t\t.acpi_match_table = ACPI_PTR(at24_acpi_ids),\n \t},\n \t.probe = at24_probe,\n","prefixes":["RESEND","v5","02/16"]}