From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752679AbbEHKOm (ORCPT ); Fri, 8 May 2015 06:14:42 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:34215 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751236AbbEHKOl (ORCPT ); Fri, 8 May 2015 06:14:41 -0400 MIME-Version: 1.0 In-Reply-To: <1431001910-4004-1-git-send-email-bert@biot.com> References: <1431001910-4004-1-git-send-email-bert@biot.com> Date: Fri, 8 May 2015 12:14:40 +0200 Message-ID: Subject: Re: [PATCH v2] nand: Add NAND driver for Mikrotik RB4xx series boards From: Frans Klaver To: Bert Vermeulen Cc: David Woodhouse , Brian Norris , linux-mtd@lists.infradead.org, "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 7, 2015 at 2:31 PM, Bert Vermeulen wrote: > +static int rb4xx_nand_probe(struct platform_device *pdev) > +{ > + struct device *spi_dev; > + struct rb4xx_nand_info *info; > + struct rb4xx_cpld_platform_data *pdata; > + int ret; > + > + /* > + * NAND chip is behind the CPLD on SPI bus 0 CS 1. Allow this > + * to silently fail the second time around. > + */ > + spi_register_driver(&rb4xx_cpld_driver); > + > + /* > + * Getting a handle on the SPI device above will fail the first time, > + * but should succeed whenever that driver gets probed. > + */ > + spi_dev = bus_find_device_by_name(&spi_bus_type, NULL, "spi0.1"); > + if (!spi_dev) > + return -EPROBE_DEFER; > + > + pdata = dev_get_platdata(spi_dev); > + if (!pdata) > + return -ENODATA; > + > + info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); > + if (!info) > + return -ENOMEM; > + > + info->gpio_ale = devm_gpiod_get(&pdev->dev, "NAND ALE", GPIOD_OUT_LOW); > + if (IS_ERR(info->gpio_ale)) { > + dev_err(&pdev->dev, "unable to request gpio NAND ALE: %ld\n", > + PTR_ERR(info->gpio_ale)); > + return -ENOENT; > + } > + > + info->gpio_cle = devm_gpiod_get(&pdev->dev, "NAND CLE", GPIOD_OUT_LOW); > + if (IS_ERR(info->gpio_cle)) { > + dev_err(&pdev->dev, "unable to request gpio NAND CLE: %ld\n", > + PTR_ERR(info->gpio_cle)); > + return -ENOENT; > + } > + > + info->gpio_nce = devm_gpiod_get(&pdev->dev, "NAND NCE", GPIOD_OUT_LOW); > + if (IS_ERR(info->gpio_nce)) { > + dev_err(&pdev->dev, "unable to request gpio NAND NCE: %ld\n", > + PTR_ERR(info->gpio_nce)); > + return -ENOENT; > + } > + > + /* Platform GPIO, has no device to manage it. */ > + info->gpio_rdy = gpiod_get(NULL, "NAND RDY", GPIOD_IN); > + if (IS_ERR(info->gpio_rdy)) { > + dev_err(&pdev->dev, "unable to request gpio RDY: %ld\n", > + PTR_ERR(info->gpio_rdy)); > + return -ENOENT; > + } > + > + info->spi_dev = container_of(spi_dev, struct spi_device, dev); > + > + info->chip.priv = info; > + info->mtd.priv = &info->chip; > + info->mtd.owner = THIS_MODULE; If you should respin, could you add info->mtd.dev.parent = &pdev->dev; This will have a symlink to the parent device show up in sysfs. Seems some people feel rather strongly about that. Thanks, Frans