Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 186325
b: refs/heads/master
c: b4877d2
h: refs/heads/master
i:
  186323: 6cc4eb3
v: v3
  • Loading branch information
H Hartley Sweeten authored and Linus Torvalds committed Mar 6, 2010
1 parent 2ceca3d commit 0bd0f08
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 44 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 49908e739e23e2672d3efb9b1a35f877f8e86342
refs/heads/master: b4877d2b3678f4455f2b8b0211868ac57c3b1ff6
71 changes: 28 additions & 43 deletions trunk/drivers/rtc/rtc-ep93xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ static ssize_t ep93xx_rtc_show_comp_delete(struct device *dev,
}
static DEVICE_ATTR(comp_delete, S_IRUGO, ep93xx_rtc_show_comp_delete, NULL);

static struct attribute *ep93xx_rtc_attrs[] = {
&dev_attr_comp_preload.attr,
&dev_attr_comp_delete.attr,
NULL
};

static const struct attribute_group ep93xx_rtc_sysfs_files = {
.attrs = ep93xx_rtc_attrs,
};

static int __init ep93xx_rtc_probe(struct platform_device *pdev)
{
Expand All @@ -123,81 +132,57 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev)
struct rtc_device *rtc;
int err;

ep93xx_rtc = kzalloc(sizeof(struct ep93xx_rtc), GFP_KERNEL);
if (ep93xx_rtc == NULL)
ep93xx_rtc = devm_kzalloc(&pdev->dev, sizeof(*ep93xx_rtc), GFP_KERNEL);
if (!ep93xx_rtc)
return -ENOMEM;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) {
err = -ENXIO;
goto fail_free;
}
if (!res)
return -ENXIO;

res = request_mem_region(res->start, resource_size(res), pdev->name);
if (res == NULL) {
err = -EBUSY;
goto fail_free;
}
if (!devm_request_mem_region(&pdev->dev, res->start,
resource_size(res), pdev->name))
return -EBUSY;

ep93xx_rtc->mmio_base = ioremap(res->start, resource_size(res));
if (ep93xx_rtc->mmio_base == NULL) {
err = -ENXIO;
goto fail;
}
ep93xx_rtc->mmio_base = devm_ioremap(&pdev->dev, res->start,
resource_size(res));
if (!ep93xx_rtc->mmio_base)
return -ENXIO;

pdev->dev.platform_data = ep93xx_rtc;

rtc = rtc_device_register(pdev->name,
&pdev->dev, &ep93xx_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) {
err = PTR_ERR(rtc);
goto fail;
goto exit;
}

platform_set_drvdata(pdev, rtc);

err = device_create_file(&pdev->dev, &dev_attr_comp_preload);
err = sysfs_create_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files);
if (err)
goto fail;
err = device_create_file(&pdev->dev, &dev_attr_comp_delete);
if (err) {
device_remove_file(&pdev->dev, &dev_attr_comp_preload);
goto fail;
}

return 0;

fail:
if (ep93xx_rtc->mmio_base) {
iounmap(ep93xx_rtc->mmio_base);
pdev->dev.platform_data = NULL;
}
release_mem_region(res->start, resource_size(res));
fail_free:
kfree(ep93xx_rtc);
platform_set_drvdata(pdev, NULL);
rtc_device_unregister(rtc);
exit:
pdev->dev.platform_data = NULL;
return err;
}

static int __exit ep93xx_rtc_remove(struct platform_device *pdev)
{
struct rtc_device *rtc = platform_get_drvdata(pdev);
struct ep93xx_rtc *ep93xx_rtc = pdev->dev.platform_data;
struct resource *res;

/* cleanup sysfs */
device_remove_file(&pdev->dev, &dev_attr_comp_delete);
device_remove_file(&pdev->dev, &dev_attr_comp_preload);

sysfs_remove_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files);
platform_set_drvdata(pdev, NULL);
rtc_device_unregister(rtc);

iounmap(ep93xx_rtc->mmio_base);
pdev->dev.platform_data = NULL;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res->start, resource_size(res));

platform_set_drvdata(pdev, NULL);

return 0;
}

Expand Down

0 comments on commit 0bd0f08

Please sign in to comment.