}
        if (host->ncfg->wp_gpio == -EPROBE_DEFER)
                return -EPROBE_DEFER;
-       if (gpio_is_valid(host->ncfg->wp_gpio) &&
-                       gpio_request(host->ncfg->wp_gpio, "NAND WP")) {
+       if (gpio_is_valid(host->ncfg->wp_gpio) && devm_gpio_request(&pdev->dev,
+                       host->ncfg->wp_gpio, "NAND WP")) {
                dev_err(&pdev->dev, "GPIO not available\n");
                return -EBUSY;
        }
        mtd->dev.parent = &pdev->dev;
 
        /* Get NAND clock */
-       host->clk = clk_get(&pdev->dev, NULL);
+       host->clk = devm_clk_get(&pdev->dev, NULL);
        if (IS_ERR(host->clk)) {
                dev_err(&pdev->dev, "Clock failure\n");
                res = -ENOENT;
        dma_release_channel(host->dma_chan);
 err_exit2:
        clk_disable(host->clk);
-       clk_put(host->clk);
 err_exit1:
        lpc32xx_wp_enable(host);
-       gpio_free(host->ncfg->wp_gpio);
 
        return res;
 }
        writel(tmp, SLC_CTRL(host->io_base));
 
        clk_disable(host->clk);
-       clk_put(host->clk);
        lpc32xx_wp_enable(host);
-       gpio_free(host->ncfg->wp_gpio);
 
        return 0;
 }