| .. | .. |
|---|
| 515 | 515 | static int plgpio_probe(struct platform_device *pdev) |
|---|
| 516 | 516 | { |
|---|
| 517 | 517 | struct plgpio *plgpio; |
|---|
| 518 | | - struct resource *res; |
|---|
| 519 | 518 | int ret, irq; |
|---|
| 520 | 519 | |
|---|
| 521 | 520 | plgpio = devm_kzalloc(&pdev->dev, sizeof(*plgpio), GFP_KERNEL); |
|---|
| 522 | 521 | if (!plgpio) |
|---|
| 523 | 522 | return -ENOMEM; |
|---|
| 524 | 523 | |
|---|
| 525 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 526 | | - plgpio->base = devm_ioremap_resource(&pdev->dev, res); |
|---|
| 524 | + plgpio->base = devm_platform_ioremap_resource(pdev, 0); |
|---|
| 527 | 525 | if (IS_ERR(plgpio->base)) |
|---|
| 528 | 526 | return PTR_ERR(plgpio->base); |
|---|
| 529 | 527 | |
|---|
| .. | .. |
|---|
| 569 | 567 | } |
|---|
| 570 | 568 | } |
|---|
| 571 | 569 | |
|---|
| 570 | + irq = platform_get_irq(pdev, 0); |
|---|
| 571 | + if (irq > 0) { |
|---|
| 572 | + struct gpio_irq_chip *girq; |
|---|
| 573 | + |
|---|
| 574 | + girq = &plgpio->chip.irq; |
|---|
| 575 | + girq->chip = &plgpio_irqchip; |
|---|
| 576 | + girq->parent_handler = plgpio_irq_handler; |
|---|
| 577 | + girq->num_parents = 1; |
|---|
| 578 | + girq->parents = devm_kcalloc(&pdev->dev, 1, |
|---|
| 579 | + sizeof(*girq->parents), |
|---|
| 580 | + GFP_KERNEL); |
|---|
| 581 | + if (!girq->parents) |
|---|
| 582 | + return -ENOMEM; |
|---|
| 583 | + girq->parents[0] = irq; |
|---|
| 584 | + girq->default_type = IRQ_TYPE_NONE; |
|---|
| 585 | + girq->handler = handle_simple_irq; |
|---|
| 586 | + dev_info(&pdev->dev, "PLGPIO registering with IRQs\n"); |
|---|
| 587 | + } else { |
|---|
| 588 | + dev_info(&pdev->dev, "PLGPIO registering without IRQs\n"); |
|---|
| 589 | + } |
|---|
| 590 | + |
|---|
| 572 | 591 | ret = gpiochip_add_data(&plgpio->chip, plgpio); |
|---|
| 573 | 592 | if (ret) { |
|---|
| 574 | 593 | dev_err(&pdev->dev, "unable to add gpio chip\n"); |
|---|
| 575 | 594 | goto unprepare_clk; |
|---|
| 576 | 595 | } |
|---|
| 577 | 596 | |
|---|
| 578 | | - irq = platform_get_irq(pdev, 0); |
|---|
| 579 | | - if (irq < 0) { |
|---|
| 580 | | - dev_info(&pdev->dev, "PLGPIO registered without IRQs\n"); |
|---|
| 581 | | - return 0; |
|---|
| 582 | | - } |
|---|
| 583 | | - |
|---|
| 584 | | - ret = gpiochip_irqchip_add(&plgpio->chip, |
|---|
| 585 | | - &plgpio_irqchip, |
|---|
| 586 | | - 0, |
|---|
| 587 | | - handle_simple_irq, |
|---|
| 588 | | - IRQ_TYPE_NONE); |
|---|
| 589 | | - if (ret) { |
|---|
| 590 | | - dev_err(&pdev->dev, "failed to add irqchip to gpiochip\n"); |
|---|
| 591 | | - goto remove_gpiochip; |
|---|
| 592 | | - } |
|---|
| 593 | | - |
|---|
| 594 | | - gpiochip_set_chained_irqchip(&plgpio->chip, |
|---|
| 595 | | - &plgpio_irqchip, |
|---|
| 596 | | - irq, |
|---|
| 597 | | - plgpio_irq_handler); |
|---|
| 598 | | - |
|---|
| 599 | | - dev_info(&pdev->dev, "PLGPIO registered with IRQs\n"); |
|---|
| 600 | | - |
|---|
| 601 | 597 | return 0; |
|---|
| 602 | 598 | |
|---|
| 603 | | -remove_gpiochip: |
|---|
| 604 | | - dev_info(&pdev->dev, "Remove gpiochip\n"); |
|---|
| 605 | | - gpiochip_remove(&plgpio->chip); |
|---|
| 606 | 599 | unprepare_clk: |
|---|
| 607 | 600 | if (!IS_ERR(plgpio->clk)) |
|---|
| 608 | 601 | clk_unprepare(plgpio->clk); |
|---|