aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/misc/atmel-ssc.c47
1 files changed, 15 insertions, 32 deletions
diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
index 5bb187781074..23dcb76abdaf 100644
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -70,37 +70,33 @@ EXPORT_SYMBOL(ssc_free);
70 70
71static int __init ssc_probe(struct platform_device *pdev) 71static int __init ssc_probe(struct platform_device *pdev)
72{ 72{
73 int retval = 0;
74 struct resource *regs; 73 struct resource *regs;
75 struct ssc_device *ssc; 74 struct ssc_device *ssc;
76 75
77 ssc = kzalloc(sizeof(struct ssc_device), GFP_KERNEL); 76 ssc = devm_kzalloc(&pdev->dev, sizeof(struct ssc_device), GFP_KERNEL);
78 if (!ssc) { 77 if (!ssc) {
79 dev_dbg(&pdev->dev, "out of memory\n"); 78 dev_dbg(&pdev->dev, "out of memory\n");
80 retval = -ENOMEM; 79 return -ENOMEM;
81 goto out;
82 } 80 }
83 81
82 ssc->pdev = pdev;
83
84 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 84 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
85 if (!regs) { 85 if (!regs) {
86 dev_dbg(&pdev->dev, "no mmio resource defined\n"); 86 dev_dbg(&pdev->dev, "no mmio resource defined\n");
87 retval = -ENXIO; 87 return -ENXIO;
88 goto out_free;
89 } 88 }
90 89
91 ssc->clk = clk_get(&pdev->dev, "pclk"); 90 ssc->regs = devm_request_and_ioremap(&pdev->dev, regs);
92 if (IS_ERR(ssc->clk)) {
93 dev_dbg(&pdev->dev, "no pclk clock defined\n");
94 retval = -ENXIO;
95 goto out_free;
96 }
97
98 ssc->pdev = pdev;
99 ssc->regs = ioremap(regs->start, resource_size(regs));
100 if (!ssc->regs) { 91 if (!ssc->regs) {
101 dev_dbg(&pdev->dev, "ioremap failed\n"); 92 dev_dbg(&pdev->dev, "ioremap failed\n");
102 retval = -EINVAL; 93 return -EINVAL;
103 goto out_clk; 94 }
95
96 ssc->clk = devm_clk_get(&pdev->dev, "pclk");
97 if (IS_ERR(ssc->clk)) {
98 dev_dbg(&pdev->dev, "no pclk clock defined\n");
99 return -ENXIO;
104 } 100 }
105 101
106 /* disable all interrupts */ 102 /* disable all interrupts */
@@ -112,8 +108,7 @@ static int __init ssc_probe(struct platform_device *pdev)
112 ssc->irq = platform_get_irq(pdev, 0); 108 ssc->irq = platform_get_irq(pdev, 0);
113 if (!ssc->irq) { 109 if (!ssc->irq) {
114 dev_dbg(&pdev->dev, "could not get irq\n"); 110 dev_dbg(&pdev->dev, "could not get irq\n");
115 retval = -ENXIO; 111 return -ENXIO;
116 goto out_unmap;
117 } 112 }
118 113
119 spin_lock(&user_lock); 114 spin_lock(&user_lock);
@@ -125,16 +120,7 @@ static int __init ssc_probe(struct platform_device *pdev)
125 dev_info(&pdev->dev, "Atmel SSC device at 0x%p (irq %d)\n", 120 dev_info(&pdev->dev, "Atmel SSC device at 0x%p (irq %d)\n",
126 ssc->regs, ssc->irq); 121 ssc->regs, ssc->irq);
127 122
128 goto out; 123 return 0;
129
130out_unmap:
131 iounmap(ssc->regs);
132out_clk:
133 clk_put(ssc->clk);
134out_free:
135 kfree(ssc);
136out:
137 return retval;
138} 124}
139 125
140static int __devexit ssc_remove(struct platform_device *pdev) 126static int __devexit ssc_remove(struct platform_device *pdev)
@@ -142,10 +128,7 @@ static int __devexit ssc_remove(struct platform_device *pdev)
142 struct ssc_device *ssc = platform_get_drvdata(pdev); 128 struct ssc_device *ssc = platform_get_drvdata(pdev);
143 129
144 spin_lock(&user_lock); 130 spin_lock(&user_lock);
145 iounmap(ssc->regs);
146 clk_put(ssc->clk);
147 list_del(&ssc->list); 131 list_del(&ssc->list);
148 kfree(ssc);
149 spin_unlock(&user_lock); 132 spin_unlock(&user_lock);
150 133
151 return 0; 134 return 0;