From patchwork Thu Jun 15 18:54:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 776405 Return-Path: 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]) by ozlabs.org (Postfix) with ESMTP id 3wpXp72BG5z9s71 for ; Fri, 16 Jun 2017 04:58:23 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=dowhile0-org.20150623.gappssmtp.com header.i=@dowhile0-org.20150623.gappssmtp.com header.b="se+cvTbM"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751980AbdFOS6L (ORCPT ); Thu, 15 Jun 2017 14:58:11 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:36628 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751879AbdFOSyb (ORCPT ); Thu, 15 Jun 2017 14:54:31 -0400 Received: by mail-wr0-f194.google.com with SMTP id 77so4526612wrb.3 for ; Thu, 15 Jun 2017 11:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dowhile0-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=y/S89CJh9fG1JllIepmcnjxdiC5bEXPYLwFh7eUHo84=; b=se+cvTbMTZOUFf9H+JUNNCIjD/80sQ+LKpPhJbIrNiudr85JE3HObKCCtiSfLsoZMo EJbgJ9OmWPG8aZHm+E7R6F7UmGyQOWi3qitn+OMIbxgAY1L7hMwEl4vGiTYwxQwGGiyV fyk6u2wKUJIsrYtnwl16/X1egpZPmTNnMdrJdMsJppUypL/eIwS8tC4GWxhPZ+lI1GFl yq/RnsQArBrca75xwWnofW9nKSMK4GPy69b9cLdoh83GfJQteBSfkkYfYMsngySCq6uA CSAqFVYmbrEwsjf8ZWJ+tM2jwBsEFh7nqEwBhH+zvBA5hBIGq9UPKI4dG9owN9wP5nSB 9kyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=y/S89CJh9fG1JllIepmcnjxdiC5bEXPYLwFh7eUHo84=; b=rs7Ix6xtZwwabn+2I3oF7Hymiaz/hy8wDGaP/YCogfcm/7QhN/9n2B1gO0SLkR53ps jeEWTUzXqm2g1Dq2Lbe/s7AGFg45ekm/q1GywTllo+c/dh4vFWhmFl0QKUgJRuE3Rq9D ed15tRzxjcfqKhSUWx1vV8yNR0Oh5pP0SNWeEj2ACmjAKSMPn/AUulOz9zrPNA7MM0K2 LNPmlFBTcNFzoKAaLdeQgOGgC111hH7PlHB/M4oXoNAK6zLfIGDM4w0Cza4y8q7TRxDg 7WGIKuPsQikx0I5pxwWFar+wauLS1SlUtz6Cp76KmqUiOsrYrb0zTfVv2jLrTUWOFEd/ Fsvg== X-Gm-Message-State: AKS2vOw2K/IfLhG46GzZs3NVpleogq680FdHpWGCly9zwduMOpiulPGF OU8rHjy4suQlyzNR X-Received: by 10.223.171.83 with SMTP id r19mr4862369wrc.173.1497552869721; Thu, 15 Jun 2017 11:54:29 -0700 (PDT) Received: from localhost.localdomain ([90.68.25.6]) by smtp.gmail.com with ESMTPSA id 3sm39252wru.50.2017.06.15.11.54.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Jun 2017 11:54:29 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Rob Herring , Javier Martinez Canillas , Simon Horman , Andy Shevchenko , 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: X-Mailing-List: linux-i2c@vger.kernel.org The driver doesn't have a struct of_device_id table but supported devices are registered via Device Trees. This is working on the assumption that a I2C device registered via OF will always match a legacy I2C device ID and that the MODALIAS reported will always be of the form i2c:. But this could change in the future so the correct approach is to have an OF device ID table if the devices are registered via OF. Suggested-by: Wolfram Sang Signed-off-by: Javier Martinez Canillas --- Changes in v5: None Changes in v4: None Changes in v3: - Fix wrong .data values for "atmel,24c02" and "atmel,24c64" entries. Changes in v2: - Only add a single OF device ID entry for each device type (Wolfram Sang). drivers/misc/eeprom/at24.c | 65 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 764ff5df0dbc..79c5c39be29c 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -175,6 +176,64 @@ static const struct i2c_device_id at24_ids[] = { }; MODULE_DEVICE_TABLE(i2c, at24_ids); +static const struct of_device_id at24_of_match[] = { + { + .compatible = "atmel,24c00", + .data = (void *)AT24_DEVICE_MAGIC(128 / 8, AT24_FLAG_TAKE8ADDR) + }, + { + .compatible = "atmel,24c01", + .data = (void *)AT24_DEVICE_MAGIC(1024 / 8, 0) + }, + { + .compatible = "atmel,24c02", + .data = (void *)AT24_DEVICE_MAGIC(2048 / 8, 0) + }, + { + .compatible = "atmel,spd", + .data = (void *)AT24_DEVICE_MAGIC(2048 / 8, + AT24_FLAG_READONLY | AT24_FLAG_IRUGO) + }, + { + .compatible = "atmel,24c04", + .data = (void *)AT24_DEVICE_MAGIC(4096 / 8, 0) + }, + { + .compatible = "atmel,24c08", + .data = (void *)AT24_DEVICE_MAGIC(8192 / 8, 0) + }, + { + .compatible = "atmel,24c16", + .data = (void *)AT24_DEVICE_MAGIC(16384 / 8, 0) + }, + { + .compatible = "atmel,24c32", + .data = (void *)AT24_DEVICE_MAGIC(32768 / 8, AT24_FLAG_ADDR16) + }, + { + .compatible = "atmel,24c64", + .data = (void *)AT24_DEVICE_MAGIC(65536 / 8, AT24_FLAG_ADDR16) + }, + { + .compatible = "atmel,24c128", + .data = (void *)AT24_DEVICE_MAGIC(131072 / 8, AT24_FLAG_ADDR16) + }, + { + .compatible = "atmel,24c256", + .data = (void *)AT24_DEVICE_MAGIC(262144 / 8, AT24_FLAG_ADDR16) + }, + { + .compatible = "atmel,24c512", + .data = (void *)AT24_DEVICE_MAGIC(524288 / 8, AT24_FLAG_ADDR16) + }, + { + .compatible = "atmel,24c1024", + .data = (void *)AT24_DEVICE_MAGIC(1048576 / 8, AT24_FLAG_ADDR16) + }, + { }, +}; +MODULE_DEVICE_TABLE(of, at24_of_match); + static const struct acpi_device_id at24_acpi_ids[] = { { "INT3499", AT24_DEVICE_MAGIC(8192 / 8, 0) }, { } @@ -598,7 +657,10 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) if (client->dev.platform_data) { chip = *(struct at24_platform_data *)client->dev.platform_data; } else { - if (id) { + if (client->dev.of_node) { + magic = (kernel_ulong_t) + of_device_get_match_data(&client->dev); + } else if (id) { magic = id->driver_data; } else { const struct acpi_device_id *aid; @@ -814,6 +876,7 @@ static int at24_remove(struct i2c_client *client) static struct i2c_driver at24_driver = { .driver = { .name = "at24", + .of_match_table = at24_of_match, .acpi_match_table = ACPI_PTR(at24_acpi_ids), }, .probe = at24_probe,