diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-11-21 07:10:54 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-02-12 12:32:40 -0500 |
commit | 44c5d739181886cff8e3903dfa38cd704f3d9640 (patch) | |
tree | 2fb88f5953018c20816995c6a5140cc766b782f0 /drivers | |
parent | 88d968b22fa26d5e3a8cab46fc7c3a21c89a91d3 (diff) |
ARM: PNX4008: kzalloc i2c drivers internal data
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/i2c/busses/i2c-pnx.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c index 882579e64111..1d66856a22fd 100644 --- a/drivers/i2c/busses/i2c-pnx.c +++ b/drivers/i2c/busses/i2c-pnx.c | |||
@@ -587,10 +587,16 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
587 | goto out; | 587 | goto out; |
588 | } | 588 | } |
589 | 589 | ||
590 | alg_data = kzalloc(sizeof(*alg_data), GFP_KERNEL); | ||
591 | if (!alg_data) { | ||
592 | ret = -ENOMEM; | ||
593 | goto err_kzalloc; | ||
594 | } | ||
595 | |||
590 | platform_set_drvdata(pdev, i2c_pnx); | 596 | platform_set_drvdata(pdev, i2c_pnx); |
591 | 597 | ||
592 | i2c_pnx->adapter->algo = &pnx_algorithm; | 598 | i2c_pnx->adapter->algo = &pnx_algorithm; |
593 | alg_data = i2c_pnx->adapter->algo_data; | 599 | i2c_pnx->adapter->algo_data = alg_data; |
594 | 600 | ||
595 | alg_data->clk = clk_get(&pdev->dev, NULL); | 601 | alg_data->clk = clk_get(&pdev->dev, NULL); |
596 | if (IS_ERR(alg_data->clk)) { | 602 | if (IS_ERR(alg_data->clk)) { |
@@ -603,16 +609,16 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
603 | alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter; | 609 | alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter; |
604 | 610 | ||
605 | /* Register I/O resource */ | 611 | /* Register I/O resource */ |
606 | if (!request_mem_region(alg_data->base, I2C_PNX_REGION_SIZE, | 612 | if (!request_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE, |
607 | pdev->name)) { | 613 | pdev->name)) { |
608 | dev_err(&pdev->dev, | 614 | dev_err(&pdev->dev, |
609 | "I/O region 0x%08x for I2C already in use.\n", | 615 | "I/O region 0x%08x for I2C already in use.\n", |
610 | alg_data->base); | 616 | i2c_pnx->base); |
611 | ret = -ENODEV; | 617 | ret = -ENODEV; |
612 | goto out_clkget; | 618 | goto out_clkget; |
613 | } | 619 | } |
614 | 620 | ||
615 | alg_data->ioaddr = ioremap(alg_data->base, I2C_PNX_REGION_SIZE); | 621 | alg_data->ioaddr = ioremap(i2c_pnx->base, I2C_PNX_REGION_SIZE); |
616 | if (!alg_data->ioaddr) { | 622 | if (!alg_data->ioaddr) { |
617 | dev_err(&pdev->dev, "Couldn't ioremap I2C I/O region\n"); | 623 | dev_err(&pdev->dev, "Couldn't ioremap I2C I/O region\n"); |
618 | ret = -ENOMEM; | 624 | ret = -ENOMEM; |
@@ -647,7 +653,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
647 | } | 653 | } |
648 | init_completion(&alg_data->mif.complete); | 654 | init_completion(&alg_data->mif.complete); |
649 | 655 | ||
650 | ret = request_irq(alg_data->irq, i2c_pnx_interrupt, | 656 | ret = request_irq(i2c_pnx->irq, i2c_pnx_interrupt, |
651 | 0, pdev->name, i2c_pnx->adapter); | 657 | 0, pdev->name, i2c_pnx->adapter); |
652 | if (ret) | 658 | if (ret) |
653 | goto out_clock; | 659 | goto out_clock; |
@@ -662,21 +668,23 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
662 | } | 668 | } |
663 | 669 | ||
664 | dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n", | 670 | dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n", |
665 | i2c_pnx->adapter->name, alg_data->base, alg_data->irq); | 671 | i2c_pnx->adapter->name, i2c_pnx->base, i2c_pnx->irq); |
666 | 672 | ||
667 | return 0; | 673 | return 0; |
668 | 674 | ||
669 | out_irq: | 675 | out_irq: |
670 | free_irq(alg_data->irq, i2c_pnx->adapter); | 676 | free_irq(i2c_pnx->irq, i2c_pnx->adapter); |
671 | out_clock: | 677 | out_clock: |
672 | clk_disable(alg_data->clk); | 678 | clk_disable(alg_data->clk); |
673 | out_unmap: | 679 | out_unmap: |
674 | iounmap(alg_data->ioaddr); | 680 | iounmap(alg_data->ioaddr); |
675 | out_release: | 681 | out_release: |
676 | release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE); | 682 | release_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE); |
677 | out_clkget: | 683 | out_clkget: |
678 | clk_put(alg_data->clk); | 684 | clk_put(alg_data->clk); |
679 | out_drvdata: | 685 | out_drvdata: |
686 | kfree(alg_data); | ||
687 | err_kzalloc: | ||
680 | platform_set_drvdata(pdev, NULL); | 688 | platform_set_drvdata(pdev, NULL); |
681 | out: | 689 | out: |
682 | return ret; | 690 | return ret; |
@@ -688,12 +696,13 @@ static int __devexit i2c_pnx_remove(struct platform_device *pdev) | |||
688 | struct i2c_adapter *adap = i2c_pnx->adapter; | 696 | struct i2c_adapter *adap = i2c_pnx->adapter; |
689 | struct i2c_pnx_algo_data *alg_data = adap->algo_data; | 697 | struct i2c_pnx_algo_data *alg_data = adap->algo_data; |
690 | 698 | ||
691 | free_irq(alg_data->irq, i2c_pnx->adapter); | 699 | free_irq(i2c_pnx->irq, i2c_pnx->adapter); |
692 | i2c_del_adapter(adap); | 700 | i2c_del_adapter(adap); |
693 | clk_disable(alg_data->clk); | 701 | clk_disable(alg_data->clk); |
694 | iounmap(alg_data->ioaddr); | 702 | iounmap(alg_data->ioaddr); |
695 | release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE); | 703 | release_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE); |
696 | clk_put(alg_data->clk); | 704 | clk_put(alg_data->clk); |
705 | kfree(alg_data); | ||
697 | platform_set_drvdata(pdev, NULL); | 706 | platform_set_drvdata(pdev, NULL); |
698 | 707 | ||
699 | return 0; | 708 | return 0; |