From patchwork Fri Aug 2 06:49:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Poddar, Sourav" X-Patchwork-Id: 2837540 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A39A5BF535 for ; Fri, 2 Aug 2013 06:50:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C835201DD for ; Fri, 2 Aug 2013 06:50:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4AE2F201DE for ; Fri, 2 Aug 2013 06:50:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755138Ab3HBGuF (ORCPT ); Fri, 2 Aug 2013 02:50:05 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:43434 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754466Ab3HBGuE (ORCPT ); Fri, 2 Aug 2013 02:50:04 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r726nYeE028191; Fri, 2 Aug 2013 01:49:35 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r726nYfM018408; Fri, 2 Aug 2013 01:49:34 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Fri, 2 Aug 2013 01:49:34 -0500 Received: from a0131647.apr.dhcp.ti.com (a0131647.apr.dhcp.ti.com [172.24.145.168]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r726nVe6023329; Fri, 2 Aug 2013 01:49:32 -0500 From: Sourav Poddar To: , , , CC: , , , Sourav Poddar Subject: [PATCH] drivers: mtd: devices: make m25p80 dt adapted. Date: Fri, 2 Aug 2013 12:19:30 +0530 Message-ID: <1375426170-31609-1-git-send-email-sourav.poddar@ti.com> X-Mailer: git-send-email 1.7.1 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch helps gettimg m25p80 probed through dt. To get the id of the exact flash type supported for dt case, data->type is getting parsed from dt entry. Signed-off-by: Sourav Poddar --- drivers/mtd/devices/m25p80.c | 22 +++++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 33098bf..cbfb9b3 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -855,6 +855,13 @@ static const struct spi_device_id m25p_ids[] = { }; MODULE_DEVICE_TABLE(spi, m25p_ids); +#ifdef CONFIG_OF +static const struct of_device_id m25p_dt_ids[] = { + { .compatible = "m25p80", }, + { /* sentinel */ } +}; +#endif + static const struct spi_device_id *jedec_probe(struct spi_device *spi) { int tmp; @@ -909,6 +916,7 @@ static int m25p_probe(struct spi_device *spi) unsigned i; struct mtd_part_parser_data ppdata; struct device_node __maybe_unused *np = spi->dev.of_node; + int len; #ifdef CONFIG_MTD_OF_PARTS if (!of_device_is_available(np)) @@ -920,7 +928,18 @@ static int m25p_probe(struct spi_device *spi) * a chip ID, try the JEDEC id commands; they'll work for most * newer chips, even if we don't recognize the particular chip. */ - data = spi->dev.platform_data; + if (!np) { + data = spi->dev.platform_data; + } else { + data = devm_kzalloc(&spi->dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->type = (char *) of_get_property(np, "type", &len); + if (!data->type || strlen(data->type) > len) + return -ENODEV; + } + if (data && data->type) { const struct spi_device_id *plat_id; @@ -1098,6 +1117,7 @@ static struct spi_driver m25p80_driver = { .driver = { .name = "m25p80", .owner = THIS_MODULE, + .of_match_table = of_match_ptr(m25p_dt_ids), }, .id_table = m25p_ids, .probe = m25p_probe,