Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 365815
b: refs/heads/master
c: 0529bf4
h: refs/heads/master
i:
  365813: 4de0e70
  365811: 9a80afa
  365807: 4362cf4
v: v3
  • Loading branch information
Sachin Kamat authored and Linus Torvalds committed Apr 30, 2013
1 parent 627e961 commit 687add6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 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: d64132ac0083d97f0a8b63f3c1759b2e9b5ed7b1
refs/heads/master: 0529bf4673a05ca688fa42a14917069278d88103
35 changes: 12 additions & 23 deletions trunk/drivers/rtc/rtc-ds1305.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ static int ds1305_probe(struct spi_device *spi)
return -EINVAL;

/* set up driver data */
ds1305 = kzalloc(sizeof *ds1305, GFP_KERNEL);
ds1305 = devm_kzalloc(&spi->dev, sizeof(*ds1305), GFP_KERNEL);
if (!ds1305)
return -ENOMEM;
ds1305->spi = spi;
Expand All @@ -632,7 +632,7 @@ static int ds1305_probe(struct spi_device *spi)
if (status < 0) {
dev_dbg(&spi->dev, "can't %s, %d\n",
"read", status);
goto fail0;
return status;
}

dev_dbg(&spi->dev, "ctrl %s: %3ph\n", "read", ds1305->ctrl);
Expand All @@ -644,8 +644,7 @@ static int ds1305_probe(struct spi_device *spi)
*/
if ((ds1305->ctrl[0] & 0x38) != 0 || (ds1305->ctrl[1] & 0xfc) != 0) {
dev_dbg(&spi->dev, "RTC chip is not present\n");
status = -ENODEV;
goto fail0;
return -ENODEV;
}
if (ds1305->ctrl[2] == 0)
dev_dbg(&spi->dev, "chip may not be present\n");
Expand All @@ -664,7 +663,7 @@ static int ds1305_probe(struct spi_device *spi)

dev_dbg(&spi->dev, "clear WP --> %d\n", status);
if (status < 0)
goto fail0;
return status;
}

/* on DS1305, maybe start oscillator; like most low power
Expand Down Expand Up @@ -718,7 +717,7 @@ static int ds1305_probe(struct spi_device *spi)
if (status < 0) {
dev_dbg(&spi->dev, "can't %s, %d\n",
"write", status);
goto fail0;
return status;
}

dev_dbg(&spi->dev, "ctrl %s: %3ph\n", "write", ds1305->ctrl);
Expand All @@ -730,20 +729,20 @@ static int ds1305_probe(struct spi_device *spi)
&value, sizeof value);
if (status < 0) {
dev_dbg(&spi->dev, "read HOUR --> %d\n", status);
goto fail0;
return status;
}

ds1305->hr12 = (DS1305_HR_12 & value) != 0;
if (ds1305->hr12)
dev_dbg(&spi->dev, "AM/PM\n");

/* register RTC ... from here on, ds1305->ctrl needs locking */
ds1305->rtc = rtc_device_register("ds1305", &spi->dev,
ds1305->rtc = devm_rtc_device_register(&spi->dev, "ds1305",
&ds1305_ops, THIS_MODULE);
if (IS_ERR(ds1305->rtc)) {
status = PTR_ERR(ds1305->rtc);
dev_dbg(&spi->dev, "register rtc --> %d\n", status);
goto fail0;
return status;
}

/* Maybe set up alarm IRQ; be ready to handle it triggering right
Expand All @@ -754,12 +753,12 @@ static int ds1305_probe(struct spi_device *spi)
*/
if (spi->irq) {
INIT_WORK(&ds1305->work, ds1305_work);
status = request_irq(spi->irq, ds1305_irq,
status = devm_request_irq(&spi->dev, spi->irq, ds1305_irq,
0, dev_name(&ds1305->rtc->dev), ds1305);
if (status < 0) {
dev_dbg(&spi->dev, "request_irq %d --> %d\n",
spi->irq, status);
goto fail1;
return status;
}

device_set_wakeup_capable(&spi->dev, 1);
Expand All @@ -769,18 +768,10 @@ static int ds1305_probe(struct spi_device *spi)
status = sysfs_create_bin_file(&spi->dev.kobj, &nvram);
if (status < 0) {
dev_dbg(&spi->dev, "register nvram --> %d\n", status);
goto fail2;
return status;
}

return 0;

fail2:
free_irq(spi->irq, ds1305);
fail1:
rtc_device_unregister(ds1305->rtc);
fail0:
kfree(ds1305);
return status;
}

static int ds1305_remove(struct spi_device *spi)
Expand All @@ -792,13 +783,11 @@ static int ds1305_remove(struct spi_device *spi)
/* carefully shut down irq and workqueue, if present */
if (spi->irq) {
set_bit(FLAG_EXITING, &ds1305->flags);
free_irq(spi->irq, ds1305);
devm_free_irq(&spi->dev, spi->irq, ds1305);
cancel_work_sync(&ds1305->work);
}

rtc_device_unregister(ds1305->rtc);
spi_set_drvdata(spi, NULL);
kfree(ds1305);
return 0;
}

Expand Down

0 comments on commit 687add6

Please sign in to comment.