@@ -846,7 +846,7 @@ static int cafe_nand_probe(struct pci_dev *pdev,
pci_set_master(pdev);
- cafe = kzalloc(sizeof(*cafe), GFP_KERNEL);
+ cafe = devm_kzalloc(&pdev->dev, sizeof(*cafe), GFP_KERNEL);
if (!cafe)
return -ENOMEM;
@@ -858,8 +858,7 @@ static int cafe_nand_probe(struct pci_dev *pdev,
cafe->mmio = pci_iomap(pdev, 0, 0);
if (!cafe->mmio) {
dev_warn(&pdev->dev, "failed to iomap\n");
- err = -ENOMEM;
- goto out_free_mtd;
+ return -ENOMEM;
}
cafe->rs = init_rs_non_canonical(12, &cafe_mul, 0, 1, 8);
@@ -908,8 +907,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
cafe_nand_init(cafe);
- err = request_irq(pdev->irq, &cafe_nand_interrupt, IRQF_SHARED,
- "CAFE NAND", mtd);
+ err = devm_request_irq(&pdev->dev, pdev->irq, cafe_nand_interrupt,
+ IRQF_SHARED, "CAFE NAND", mtd);
if (err) {
dev_warn(&pdev->dev, "Could not register IRQ %d\n", pdev->irq);
goto out_ior;
@@ -940,11 +939,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
cafe_writel(cafe,
cafe_readl(cafe, GLOBAL_IRQ_MASK) & ~CAFE_GLOBAL_IRQ_NAND,
GLOBAL_IRQ_MASK);
- free_irq(pdev->irq, mtd);
out_ior:
pci_iounmap(pdev, cafe->mmio);
- out_free_mtd:
- kfree(cafe);
out:
return err;
}
@@ -959,12 +955,10 @@ static void cafe_nand_remove(struct pci_dev *pdev)
cafe_writel(cafe,
cafe_readl(cafe, GLOBAL_IRQ_MASK) & ~CAFE_GLOBAL_IRQ_NAND,
GLOBAL_IRQ_MASK);
- free_irq(pdev->irq, mtd);
nand_release(chip);
free_rs(cafe->rs);
pci_iounmap(pdev, cafe->mmio);
dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr);
- kfree(cafe);
}
static const struct pci_device_id cafe_nand_tbl[] = {