diff options
-rw-r--r-- | arch/sparc/include/asm/termbits.h | 11 | ||||
-rw-r--r-- | arch/sparc/kernel/of_device.c | 4 | ||||
-rw-r--r-- | drivers/rtc/rtc-sun4v.c | 69 |
3 files changed, 26 insertions, 58 deletions
diff --git a/arch/sparc/include/asm/termbits.h b/arch/sparc/include/asm/termbits.h index d6ca3e2754f5..d72dfed1f9d7 100644 --- a/arch/sparc/include/asm/termbits.h +++ b/arch/sparc/include/asm/termbits.h | |||
@@ -29,10 +29,11 @@ struct termios { | |||
29 | tcflag_t c_cflag; /* control mode flags */ | 29 | tcflag_t c_cflag; /* control mode flags */ |
30 | tcflag_t c_lflag; /* local mode flags */ | 30 | tcflag_t c_lflag; /* local mode flags */ |
31 | cc_t c_line; /* line discipline */ | 31 | cc_t c_line; /* line discipline */ |
32 | #ifndef __KERNEL__ | ||
32 | cc_t c_cc[NCCS]; /* control characters */ | 33 | cc_t c_cc[NCCS]; /* control characters */ |
33 | #ifdef __KERNEL__ | 34 | #else |
35 | cc_t c_cc[NCCS+2]; /* kernel needs 2 more to hold vmin/vtime */ | ||
34 | #define SIZEOF_USER_TERMIOS sizeof (struct termios) - (2*sizeof (cc_t)) | 36 | #define SIZEOF_USER_TERMIOS sizeof (struct termios) - (2*sizeof (cc_t)) |
35 | cc_t _x_cc[2]; /* We need them to hold vmin/vtime */ | ||
36 | #endif | 37 | #endif |
37 | }; | 38 | }; |
38 | 39 | ||
@@ -42,8 +43,7 @@ struct termios2 { | |||
42 | tcflag_t c_cflag; /* control mode flags */ | 43 | tcflag_t c_cflag; /* control mode flags */ |
43 | tcflag_t c_lflag; /* local mode flags */ | 44 | tcflag_t c_lflag; /* local mode flags */ |
44 | cc_t c_line; /* line discipline */ | 45 | cc_t c_line; /* line discipline */ |
45 | cc_t c_cc[NCCS]; /* control characters */ | 46 | cc_t c_cc[NCCS+2]; /* control characters */ |
46 | cc_t _x_cc[2]; /* padding to match ktermios */ | ||
47 | speed_t c_ispeed; /* input speed */ | 47 | speed_t c_ispeed; /* input speed */ |
48 | speed_t c_ospeed; /* output speed */ | 48 | speed_t c_ospeed; /* output speed */ |
49 | }; | 49 | }; |
@@ -54,8 +54,7 @@ struct ktermios { | |||
54 | tcflag_t c_cflag; /* control mode flags */ | 54 | tcflag_t c_cflag; /* control mode flags */ |
55 | tcflag_t c_lflag; /* local mode flags */ | 55 | tcflag_t c_lflag; /* local mode flags */ |
56 | cc_t c_line; /* line discipline */ | 56 | cc_t c_line; /* line discipline */ |
57 | cc_t c_cc[NCCS]; /* control characters */ | 57 | cc_t c_cc[NCCS+2]; /* control characters */ |
58 | cc_t _x_cc[2]; /* We need them to hold vmin/vtime */ | ||
59 | speed_t c_ispeed; /* input speed */ | 58 | speed_t c_ispeed; /* input speed */ |
60 | speed_t c_ospeed; /* output speed */ | 59 | speed_t c_ospeed; /* output speed */ |
61 | }; | 60 | }; |
diff --git a/arch/sparc/kernel/of_device.c b/arch/sparc/kernel/of_device.c index 0837bd52e28f..0a83bd737654 100644 --- a/arch/sparc/kernel/of_device.c +++ b/arch/sparc/kernel/of_device.c | |||
@@ -563,9 +563,9 @@ build_resources: | |||
563 | op->dev.parent = parent; | 563 | op->dev.parent = parent; |
564 | op->dev.bus = &of_platform_bus_type; | 564 | op->dev.bus = &of_platform_bus_type; |
565 | if (!parent) | 565 | if (!parent) |
566 | strcpy(op->dev.bus_id, "root"); | 566 | dev_set_name(&op->dev, "root"); |
567 | else | 567 | else |
568 | sprintf(op->dev.bus_id, "%08x", dp->node); | 568 | dev_set_name(&op->dev, "%08x", dp->node); |
569 | 569 | ||
570 | if (of_device_register(op)) { | 570 | if (of_device_register(op)) { |
571 | printk("%s: Could not register of device.\n", | 571 | printk("%s: Could not register of device.\n", |
diff --git a/drivers/rtc/rtc-sun4v.c b/drivers/rtc/rtc-sun4v.c index 2012ccbb4a53..5b2261052a65 100644 --- a/drivers/rtc/rtc-sun4v.c +++ b/drivers/rtc/rtc-sun4v.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* rtc-sun4c.c: Hypervisor based RTC for SUN4V systems. | 1 | /* rtc-sun4v.c: Hypervisor based RTC for SUN4V systems. |
2 | * | 2 | * |
3 | * Copyright (C) 2008 David S. Miller <davem@davemloft.net> | 3 | * Copyright (C) 2008 David S. Miller <davem@davemloft.net> |
4 | */ | 4 | */ |
@@ -7,21 +7,11 @@ | |||
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/delay.h> | 8 | #include <linux/delay.h> |
9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
10 | #include <linux/time.h> | ||
11 | #include <linux/rtc.h> | 10 | #include <linux/rtc.h> |
12 | #include <linux/platform_device.h> | 11 | #include <linux/platform_device.h> |
13 | 12 | ||
14 | #include <asm/hypervisor.h> | 13 | #include <asm/hypervisor.h> |
15 | 14 | ||
16 | MODULE_AUTHOR("David S. Miller <davem@davemloft.net>"); | ||
17 | MODULE_DESCRIPTION("SUN4V RTC driver"); | ||
18 | MODULE_LICENSE("GPL"); | ||
19 | |||
20 | struct sun4v_rtc { | ||
21 | struct rtc_device *rtc; | ||
22 | spinlock_t lock; | ||
23 | }; | ||
24 | |||
25 | static unsigned long hypervisor_get_time(void) | 15 | static unsigned long hypervisor_get_time(void) |
26 | { | 16 | { |
27 | unsigned long ret, time; | 17 | unsigned long ret, time; |
@@ -45,15 +35,7 @@ retry: | |||
45 | 35 | ||
46 | static int sun4v_read_time(struct device *dev, struct rtc_time *tm) | 36 | static int sun4v_read_time(struct device *dev, struct rtc_time *tm) |
47 | { | 37 | { |
48 | struct sun4v_rtc *p = dev_get_drvdata(dev); | 38 | rtc_time_to_tm(hypervisor_get_time(), tm); |
49 | unsigned long flags, secs; | ||
50 | |||
51 | spin_lock_irqsave(&p->lock, flags); | ||
52 | secs = hypervisor_get_time(); | ||
53 | spin_unlock_irqrestore(&p->lock, flags); | ||
54 | |||
55 | rtc_time_to_tm(secs, tm); | ||
56 | |||
57 | return 0; | 39 | return 0; |
58 | } | 40 | } |
59 | 41 | ||
@@ -80,19 +62,14 @@ retry: | |||
80 | 62 | ||
81 | static int sun4v_set_time(struct device *dev, struct rtc_time *tm) | 63 | static int sun4v_set_time(struct device *dev, struct rtc_time *tm) |
82 | { | 64 | { |
83 | struct sun4v_rtc *p = dev_get_drvdata(dev); | 65 | unsigned long secs; |
84 | unsigned long flags, secs; | ||
85 | int err; | 66 | int err; |
86 | 67 | ||
87 | err = rtc_tm_to_time(tm, &secs); | 68 | err = rtc_tm_to_time(tm, &secs); |
88 | if (err) | 69 | if (err) |
89 | return err; | 70 | return err; |
90 | 71 | ||
91 | spin_lock_irqsave(&p->lock, flags); | 72 | return hypervisor_set_time(secs); |
92 | err = hypervisor_set_time(secs); | ||
93 | spin_unlock_irqrestore(&p->lock, flags); | ||
94 | |||
95 | return err; | ||
96 | } | 73 | } |
97 | 74 | ||
98 | static const struct rtc_class_ops sun4v_rtc_ops = { | 75 | static const struct rtc_class_ops sun4v_rtc_ops = { |
@@ -100,33 +77,22 @@ static const struct rtc_class_ops sun4v_rtc_ops = { | |||
100 | .set_time = sun4v_set_time, | 77 | .set_time = sun4v_set_time, |
101 | }; | 78 | }; |
102 | 79 | ||
103 | static int __devinit sun4v_rtc_probe(struct platform_device *pdev) | 80 | static int __init sun4v_rtc_probe(struct platform_device *pdev) |
104 | { | 81 | { |
105 | struct sun4v_rtc *p = kzalloc(sizeof(*p), GFP_KERNEL); | 82 | struct rtc_device *rtc = rtc_device_register("sun4v", &pdev->dev, |
106 | |||
107 | if (!p) | ||
108 | return -ENOMEM; | ||
109 | |||
110 | spin_lock_init(&p->lock); | ||
111 | |||
112 | p->rtc = rtc_device_register("sun4v", &pdev->dev, | ||
113 | &sun4v_rtc_ops, THIS_MODULE); | 83 | &sun4v_rtc_ops, THIS_MODULE); |
114 | if (IS_ERR(p->rtc)) { | 84 | if (IS_ERR(rtc)) |
115 | int err = PTR_ERR(p->rtc); | 85 | return PTR_ERR(rtc); |
116 | kfree(p); | 86 | |
117 | return err; | 87 | platform_set_drvdata(pdev, rtc); |
118 | } | ||
119 | platform_set_drvdata(pdev, p); | ||
120 | return 0; | 88 | return 0; |
121 | } | 89 | } |
122 | 90 | ||
123 | static int __devexit sun4v_rtc_remove(struct platform_device *pdev) | 91 | static int __exit sun4v_rtc_remove(struct platform_device *pdev) |
124 | { | 92 | { |
125 | struct sun4v_rtc *p = platform_get_drvdata(pdev); | 93 | struct rtc_device *rtc = platform_get_drvdata(pdev); |
126 | |||
127 | rtc_device_unregister(p->rtc); | ||
128 | kfree(p); | ||
129 | 94 | ||
95 | rtc_device_unregister(rtc); | ||
130 | return 0; | 96 | return 0; |
131 | } | 97 | } |
132 | 98 | ||
@@ -135,13 +101,12 @@ static struct platform_driver sun4v_rtc_driver = { | |||
135 | .name = "rtc-sun4v", | 101 | .name = "rtc-sun4v", |
136 | .owner = THIS_MODULE, | 102 | .owner = THIS_MODULE, |
137 | }, | 103 | }, |
138 | .probe = sun4v_rtc_probe, | 104 | .remove = __exit_p(sun4v_rtc_remove), |
139 | .remove = __devexit_p(sun4v_rtc_remove), | ||
140 | }; | 105 | }; |
141 | 106 | ||
142 | static int __init sun4v_rtc_init(void) | 107 | static int __init sun4v_rtc_init(void) |
143 | { | 108 | { |
144 | return platform_driver_register(&sun4v_rtc_driver); | 109 | return platform_driver_probe(&sun4v_rtc_driver, sun4v_rtc_probe); |
145 | } | 110 | } |
146 | 111 | ||
147 | static void __exit sun4v_rtc_exit(void) | 112 | static void __exit sun4v_rtc_exit(void) |
@@ -151,3 +116,7 @@ static void __exit sun4v_rtc_exit(void) | |||
151 | 116 | ||
152 | module_init(sun4v_rtc_init); | 117 | module_init(sun4v_rtc_init); |
153 | module_exit(sun4v_rtc_exit); | 118 | module_exit(sun4v_rtc_exit); |
119 | |||
120 | MODULE_AUTHOR("David S. Miller <davem@davemloft.net>"); | ||
121 | MODULE_DESCRIPTION("SUN4V RTC driver"); | ||
122 | MODULE_LICENSE("GPL"); | ||