Date:2013-12-17 09:52:23 (8 months 3 days ago)
Author:Lars C.
Commit:ee7dcbabdd9c5a7933cdae40f26361bd362572c1
Message:usb: musb-jz4740: Don't manually free device managed resources

Devices managed resources are freed automatically, no need to do this by hand.
Also give a bit more descriptive names to the error labels.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Files: drivers/usb/musb/jz4740.c (3 diffs)

Change Details

drivers/usb/musb/jz4740.c
123123    struct platform_device *musb;
124124    struct jz4740_glue *glue;
125125    struct clk *clk;
126
127    int ret = -ENOMEM;
126    int ret;
128127
129128    if (!pdata) {
130129        dev_err(&pdev->dev, "failed to allocate platform data\n");
131        goto err0;
130        return -EINVAL;
132131    }
133132
134133    glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
135    if (!glue) {
136        dev_err(&pdev->dev, "failed to allocate glue context\n");
137        goto err0;
138    }
134    if (!glue)
135        return -ENOMEM;
139136
140137    musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
141138    if (!musb) {
142139        dev_err(&pdev->dev, "failed to allocate musb device\n");
143        goto err1;
140        return -ENOMEM;
144141    }
145142
146143    clk = devm_clk_get(&pdev->dev, "udc");
147144    if (IS_ERR(clk)) {
148145        dev_err(&pdev->dev, "failed to get clock\n");
149146        ret = PTR_ERR(clk);
150        goto err2;
147        goto err_platform_device_put;
151148    }
152149
153150    ret = clk_prepare_enable(clk);
154151    if (ret) {
155152        dev_err(&pdev->dev, "failed to enable clock\n");
156        goto err3;
153        goto err_platform_device_put;
157154    }
158155
159156    musb->dev.parent = &pdev->dev;
...... 
170167                        pdev->num_resources);
171168    if (ret) {
172169        dev_err(&pdev->dev, "failed to add resources\n");
173        goto err4;
170        goto err_clk_disable;
174171    }
175172
176173    ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
177174    if (ret) {
178175        dev_err(&pdev->dev, "failed to add platform_data\n");
179        goto err4;
176        goto err_clk_disable;
180177    }
181178
182179    ret = platform_device_add(musb);
183180    if (ret) {
184181        dev_err(&pdev->dev, "failed to register musb device\n");
185        goto err4;
182        goto err_clk_disable;
186183    }
187184
188185    return 0;
189186
190err4:
187err_clk_disable:
191188    clk_disable_unprepare(clk);
192
193err3:
194    devm_clk_put(&pdev->dev, clk);
195
196err2:
189err_platform_device_put:
197190    platform_device_put(musb);
198
199err1:
200    devm_kfree(&pdev->dev, glue);
201
202err0:
203191    return ret;
204192}
205193
...... 
209197
210198    platform_device_unregister(glue->musb);
211199    clk_disable_unprepare(glue->clk);
212    clk_put(glue->clk);
213    devm_kfree(&pdev->dev, glue);
214200
215201    return 0;
216202}

Archive Download the corresponding diff file



interactive