mtd: nand: diskonchip: Request memory region prior ioremap()
Subsystems (2)
PATCH RESEND 1/1 mtd: nand: diskonchip: Request memory region prior ioremap()
This patch adds request_mem_region() prior ioremap() for diskonchip driver. This will allow to check if memory region is occupied by any other device, for example in case if we have memory region for several optional devices and only one device can be used at once.
Signed-off-by Alexander Shiyan <[email protected]>
--- drivers/mtd/nand/diskonchip.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/mtd/nand/diskonchip.c +5 -0
@@ -1440,8 +1440,11 @@ static int __init doc_probe(unsigned long physadr)int reg, len, numchips;int ret =0 ; +if (!request_mem_region (physadr,DOC_IOREMAP_LEN ,NULL )) +return -EBUSY ; virtadr =ioremap (physadr,DOC_IOREMAP_LEN );if (!virtadr) { +release_mem_region (physadr,DOC_IOREMAP_LEN );printk (KERN_ERR "Diskonchip ioremap failed: 0x%x bytes at 0x%lx\n" ,DOC_IOREMAP_LEN , physadr);return -EIO ; }
@@ -1629,6 +1632,7 @@ static int __init doc_probe(unsigned long physadr)WriteDOC (save_control, virtadr, DOCControl); fail:iounmap (virtadr); +release_mem_region (physadr,DOC_IOREMAP_LEN );return ret; }
@@ -1645,6 +1649,7 @@ static void release_nanddoc(void) nextmtd = doc->nextdoc;nand_release (mtd);iounmap (doc->virtadr); +release_mem_region (doc->physadr,DOC_IOREMAP_LEN );kfree (mtd); } }
Signature · 1 line
1.8.1.5
PATCH v3 2/4 mtd: nand: gpio: Use devm_gpio_request_one() where possible
Signed-off-by Alexander Shiyan <[email protected]>
--- drivers/mtd/nand/gpio.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-)
drivers/mtd/nand/gpio.c +20 -17
@@ -190,14 +190,20 @@ gpio_nand_get_io_sync(struct platform_device *pdev)return platform_get_resource (pdev,IORESOURCE_MEM ,1 ); } +static void gpio_nand_set_wp (struct gpiomtd *gpiomtd,int val) +{ +if (gpio_is_valid (gpiomtd->plat.gpio_nwp)) +gpio_set_value (gpiomtd->plat.gpio_nwp, val); +} +static int gpio_nand_remove (struct platform_device *pdev) {struct gpiomtd *gpiomtd =platform_get_drvdata (pdev);nand_release (&gpiomtd->mtd_info); -if (gpio_is_valid (gpiomtd->plat.gpio_nwp)) -gpio_set_value (gpiomtd->plat.gpio_nwp,0 ); +gpio_nand_set_wp (gpiomtd,0 ); +gpio_set_value (gpiomtd->plat.gpio_nce,1 );return 0 ;
@@ -242,34 +248,33 @@ static int gpio_nand_probe(struct platform_device *pdev)return PTR_ERR (gpiomtd->io_sync); } - ret =devm_gpio_request (&pdev->dev, gpiomtd->plat.gpio_nce,"NAND NCE" ); + ret =devm_gpio_request_one (&pdev->dev, gpiomtd->plat.gpio_nce, +GPIOF_OUT_INIT_HIGH ,"NAND NCE" );if (ret)return ret; -gpio_direction_output (gpiomtd->plat.gpio_nce,1 );if (gpio_is_valid (gpiomtd->plat.gpio_nwp)) { - ret =devm_gpio_request (&pdev->dev, gpiomtd->plat.gpio_nwp, -"NAND NWP" ); + ret =devm_gpio_request_one (&pdev->dev, gpiomtd->plat.gpio_nwp, +GPIOF_OUT_INIT_LOW ,"NAND NWP" );if (ret)return ret; } - ret =devm_gpio_request (&pdev->dev, gpiomtd->plat.gpio_ale,"NAND ALE" ); + ret =devm_gpio_request_one (&pdev->dev, gpiomtd->plat.gpio_ale, +GPIOF_OUT_INIT_LOW ,"NAND ALE" );if (ret)return ret; -gpio_direction_output (gpiomtd->plat.gpio_ale,0 ); - ret =devm_gpio_request (&pdev->dev, gpiomtd->plat.gpio_cle,"NAND CLE" ); + ret =devm_gpio_request_one (&pdev->dev, gpiomtd->plat.gpio_cle, +GPIOF_OUT_INIT_LOW ,"NAND CLE" );if (ret)return ret; -gpio_direction_output (gpiomtd->plat.gpio_cle,0 );if (gpio_is_valid (gpiomtd->plat.gpio_rdy)) { - ret =devm_gpio_request (&pdev->dev, gpiomtd->plat.gpio_rdy, -"NAND RDY" ); + ret =devm_gpio_request_one (&pdev->dev, gpiomtd->plat.gpio_rdy, +GPIOF_IN ,"NAND RDY" );if (ret)return ret; -gpio_direction_input (gpiomtd->plat.gpio_rdy); chip->dev_ready = gpio_nand_devready; }
@@ -284,8 +289,7 @@ static int gpio_nand_probe(struct platform_device *pdev)platform_set_drvdata (pdev, gpiomtd); -if (gpio_is_valid (gpiomtd->plat.gpio_nwp)) -gpio_direction_output (gpiomtd->plat.gpio_nwp,1 ); +gpio_nand_set_wp (gpiomtd,1 );if (nand_scan (&gpiomtd->mtd_info,1 )) { ret = -ENXIO ;
@@ -304,8 +308,7 @@ static int gpio_nand_probe(struct platform_device *pdev)return 0 ; err_wp: -if (gpio_is_valid (gpiomtd->plat.gpio_nwp)) -gpio_set_value (gpiomtd->plat.gpio_nwp,0 ); +gpio_nand_set_wp (gpiomtd,0 );return ret; }
Signature · 1 line
1.8.1.5
PATCH v3 3/4 mtd: nand: gpio: Return real nand_scan() error code on fail
In reply to Alexander ShiyanSigned-off-by Alexander Shiyan <[email protected]>
--- drivers/mtd/nand/gpio.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/mtd/nand/gpio.c +3 -4
@@ -215,7 +215,7 @@ static int gpio_nand_probe(struct platform_device *pdev)struct nand_chip *chip;struct resource *res;struct mtd_part_parser_data ppdata = {}; -int ret =0 ; +int ret;if (!pdev->dev.of_node && !pdev->dev.platform_data)return -EINVAL ;
@@ -291,10 +291,9 @@ static int gpio_nand_probe(struct platform_device *pdev)gpio_nand_set_wp (gpiomtd,1 ); -if (nand_scan (&gpiomtd->mtd_info,1 )) { - ret = -ENXIO ; + ret =nand_scan (&gpiomtd->mtd_info,1 ); +if (ret) goto err_wp; - }if (gpiomtd->plat.adjust_parts) gpiomtd->plat.adjust_parts(&gpiomtd->plat,
Signature · 1 line
1.8.1.5