fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / rtc / rtc-test.c
index e1fa5fe..f50a1b8 100644 (file)
@@ -75,7 +75,7 @@ static int test_rtc_ioctl(struct device *dev, unsigned int cmd,
        }
 }
 
-static struct rtc_class_ops test_rtc_ops = {
+static const struct rtc_class_ops test_rtc_ops = {
        .proc = test_rtc_proc,
        .read_time = test_rtc_read_time,
        .set_time = test_rtc_set_time,
@@ -99,6 +99,7 @@ static ssize_t test_irq_store(struct device *dev,
        struct rtc_device *rtc = platform_get_drvdata(plat_dev);
 
        retval = count;
+       local_irq_disable();
        if (strncmp(buf, "tick", 4) == 0)
                rtc_update_irq(&rtc->class_dev, 1, RTC_PF | RTC_IRQF);
        else if (strncmp(buf, "alarm", 5) == 0)
@@ -107,6 +108,7 @@ static ssize_t test_irq_store(struct device *dev,
                rtc_update_irq(&rtc->class_dev, 1, RTC_UF | RTC_IRQF);
        else
                retval = -EINVAL;
+       local_irq_enable();
 
        return retval;
 }
@@ -121,11 +123,18 @@ static int test_probe(struct platform_device *plat_dev)
                err = PTR_ERR(rtc);
                return err;
        }
-       device_create_file(&plat_dev->dev, &dev_attr_irq);
+
+       err = device_create_file(&plat_dev->dev, &dev_attr_irq);
+       if (err)
+               goto err;
 
        platform_set_drvdata(plat_dev, rtc);
 
        return 0;
+
+err:
+       rtc_device_unregister(rtc);
+       return err;
 }
 
 static int __devexit test_remove(struct platform_device *plat_dev)