aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/w1/masters/mxc_w1.c49
1 files changed, 10 insertions, 39 deletions
diff --git a/drivers/w1/masters/mxc_w1.c b/drivers/w1/masters/mxc_w1.c
index 708a25fc9961..372c8c0d54a0 100644
--- a/drivers/w1/masters/mxc_w1.c
+++ b/drivers/w1/masters/mxc_w1.c
@@ -109,34 +109,21 @@ static int mxc_w1_probe(struct platform_device *pdev)
109 struct resource *res; 109 struct resource *res;
110 int err = 0; 110 int err = 0;
111 111
112 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 112 mdev = devm_kzalloc(&pdev->dev, sizeof(struct mxc_w1_device),
113 if (!res) 113 GFP_KERNEL);
114 return -ENODEV;
115
116 mdev = kzalloc(sizeof(struct mxc_w1_device), GFP_KERNEL);
117 if (!mdev) 114 if (!mdev)
118 return -ENOMEM; 115 return -ENOMEM;
119 116
120 mdev->clk = clk_get(&pdev->dev, NULL); 117 mdev->clk = devm_clk_get(&pdev->dev, NULL);
121 if (IS_ERR(mdev->clk)) { 118 if (IS_ERR(mdev->clk))
122 err = PTR_ERR(mdev->clk); 119 return PTR_ERR(mdev->clk);
123 goto failed_clk;
124 }
125 120
126 mdev->clkdiv = (clk_get_rate(mdev->clk) / 1000000) - 1; 121 mdev->clkdiv = (clk_get_rate(mdev->clk) / 1000000) - 1;
127 122
128 res = request_mem_region(res->start, resource_size(res), 123 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
129 "mxc_w1"); 124 mdev->regs = devm_request_and_ioremap(&pdev->dev, res);
130 if (!res) { 125 if (!mdev->regs)
131 err = -EBUSY; 126 return -EBUSY;
132 goto failed_req;
133 }
134
135 mdev->regs = ioremap(res->start, resource_size(res));
136 if (!mdev->regs) {
137 dev_err(&pdev->dev, "Cannot map mxc_w1 registers\n");
138 goto failed_ioremap;
139 }
140 127
141 clk_prepare_enable(mdev->clk); 128 clk_prepare_enable(mdev->clk);
142 __raw_writeb(mdev->clkdiv, mdev->regs + MXC_W1_TIME_DIVIDER); 129 __raw_writeb(mdev->clkdiv, mdev->regs + MXC_W1_TIME_DIVIDER);
@@ -148,20 +135,10 @@ static int mxc_w1_probe(struct platform_device *pdev)
148 err = w1_add_master_device(&mdev->bus_master); 135 err = w1_add_master_device(&mdev->bus_master);
149 136
150 if (err) 137 if (err)
151 goto failed_add; 138 return err;
152 139
153 platform_set_drvdata(pdev, mdev); 140 platform_set_drvdata(pdev, mdev);
154 return 0; 141 return 0;
155
156failed_add:
157 iounmap(mdev->regs);
158failed_ioremap:
159 release_mem_region(res->start, resource_size(res));
160failed_req:
161 clk_put(mdev->clk);
162failed_clk:
163 kfree(mdev);
164 return err;
165} 142}
166 143
167/* 144/*
@@ -170,16 +147,10 @@ failed_clk:
170static int mxc_w1_remove(struct platform_device *pdev) 147static int mxc_w1_remove(struct platform_device *pdev)
171{ 148{
172 struct mxc_w1_device *mdev = platform_get_drvdata(pdev); 149 struct mxc_w1_device *mdev = platform_get_drvdata(pdev);
173 struct resource *res;
174
175 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
176 150
177 w1_remove_master_device(&mdev->bus_master); 151 w1_remove_master_device(&mdev->bus_master);
178 152
179 iounmap(mdev->regs);
180 release_mem_region(res->start, resource_size(res));
181 clk_disable_unprepare(mdev->clk); 153 clk_disable_unprepare(mdev->clk);
182 clk_put(mdev->clk);
183 154
184 platform_set_drvdata(pdev, NULL); 155 platform_set_drvdata(pdev, NULL);
185 156