cbus-retu-wdt: Some fixes
[openwrt/staging/dedeckeh.git] / target / linux / omap24xx / patches-2.6.38 / 535-cbus-retu-wdt-cleanup.patch
1 Index: linux-2.6.38-rc6/drivers/cbus/retu-wdt.c
2 ===================================================================
3 --- linux-2.6.38-rc6.orig/drivers/cbus/retu-wdt.c 2011-03-02 16:49:51.231863891 +0100
4 +++ linux-2.6.38-rc6/drivers/cbus/retu-wdt.c 2011-03-02 16:53:47.189454637 +0100
5 @@ -52,7 +52,6 @@ static DEFINE_MUTEX(retu_wdt_mutex);
6
7 /* Current period of watchdog */
8 static unsigned int period_val = RETU_WDT_DEFAULT_TIMER;
9 -static int counter_param = RETU_WDT_MAX_TIMER;
10
11 struct retu_wdt_dev {
12 struct device *dev;
13 @@ -109,56 +108,6 @@ static void retu_wdt_ping_work(struct wo
14 retu_wdt_ping_enable(wdev);
15 }
16
17 -static ssize_t retu_wdt_period_show(struct device *dev,
18 - struct device_attribute *attr, char *buf)
19 -{
20 - /* Show current max counter */
21 - return sprintf(buf, "%u\n", (u16)period_val);
22 -}
23 -
24 -/*
25 - * Note: This inteface is non-standard and likely to disappear!
26 - * Use /dev/watchdog instead, that's the standard.
27 - */
28 -static ssize_t retu_wdt_period_store(struct device *dev,
29 - struct device_attribute *attr,
30 - const char *buf, size_t count)
31 -{
32 - unsigned int new_period;
33 - int ret;
34 -
35 -#ifdef CONFIG_WATCHDOG_NOWAYOUT
36 - retu_wdt_ping_disable(retu_wdt);
37 -#endif
38 -
39 - if (sscanf(buf, "%u", &new_period) != 1) {
40 - printk(KERN_ALERT "retu_wdt_period_store: Invalid input\n");
41 - return -EINVAL;
42 - }
43 -
44 - ret = retu_modify_counter(new_period);
45 - if (ret < 0)
46 - return ret;
47 -
48 - return strnlen(buf, count);
49 -}
50 -
51 -static ssize_t retu_wdt_counter_show(struct device *dev,
52 - struct device_attribute *attr, char *buf)
53 -{
54 - u16 counter;
55 -
56 - /* Show current value in watchdog counter */
57 - counter = retu_read_reg(dev, RETU_REG_WATCHDOG);
58 -
59 - /* Only the 5 LSB are important */
60 - return snprintf(buf, PAGE_SIZE, "%u\n", (counter & 0x3F));
61 -}
62 -
63 -static DEVICE_ATTR(period, S_IRUGO | S_IWUSR, retu_wdt_period_show, \
64 - retu_wdt_period_store);
65 -static DEVICE_ATTR(counter, S_IRUGO, retu_wdt_counter_show, NULL);
66 -
67 static int retu_wdt_open(struct inode *inode, struct file *file)
68 {
69 if (test_and_set_bit(0, &retu_wdt->users))
70 @@ -175,9 +124,9 @@ static int retu_wdt_release(struct inode
71 struct retu_wdt_dev *wdev = file->private_data;
72
73 #ifndef CONFIG_WATCHDOG_NOWAYOUT
74 - retu_wdt_ping_enable(retu_wdt);
75 + retu_wdt_ping_enable(wdev);
76 #endif
77 - clear_bit(0, &retu_wdt->users);
78 + clear_bit(0, &wdev->users);
79
80 return 0;
81 }
82 @@ -232,18 +181,6 @@ static long retu_wdt_ioctl(struct file *
83 return 0;
84 }
85
86 -/* Start kicking retu watchdog until user space starts doing the kicking */
87 -static int __devinit retu_wdt_ping(void)
88 -{
89 -#ifdef CONFIG_WATCHDOG_NOWAYOUT
90 - retu_modify_counter(RETU_WDT_MAX_TIMER);
91 -#else
92 - retu_wdt_ping_enable(retu_wdt);
93 -#endif
94 -
95 - return 0;
96 -}
97 -
98 static const struct file_operations retu_wdt_fops = {
99 .owner = THIS_MODULE,
100 .write = retu_wdt_write,
101 @@ -252,8 +189,6 @@ static const struct file_operations retu
102 .release = retu_wdt_release,
103 };
104
105 -/*----------------------------------------------------------------------------*/
106 -
107 static int __init retu_wdt_probe(struct platform_device *pdev)
108 {
109 struct retu_wdt_dev *wdev;
110 @@ -265,18 +200,6 @@ static int __init retu_wdt_probe(struct
111
112 wdev->dev = &pdev->dev;
113
114 - ret = device_create_file(&pdev->dev, &dev_attr_period);
115 - if (ret) {
116 - dev_err(&pdev->dev, "Error creating sysfs period\n");
117 - goto free1;
118 - }
119 -
120 - ret = device_create_file(&pdev->dev, &dev_attr_counter);
121 - if (ret) {
122 - dev_err(&pdev->dev, "Error creating sysfs counter\n");
123 - goto free2;
124 - }
125 -
126 platform_set_drvdata(pdev, wdev);
127 retu_wdt = wdev;
128 wdev->retu_wdt_miscdev.parent = &pdev->dev;
129 @@ -286,38 +209,21 @@ static int __init retu_wdt_probe(struct
130
131 ret = misc_register(&(wdev->retu_wdt_miscdev));
132 if (ret)
133 - goto free3;
134 + goto err_free_wdev;
135
136 INIT_DELAYED_WORK(&wdev->ping_work, retu_wdt_ping_work);
137
138 - /* passed as module parameter? */
139 - ret = retu_modify_counter(counter_param);
140 - if (ret == -EINVAL) {
141 - ret = retu_modify_counter(RETU_WDT_DEFAULT_TIMER);
142 - dev_dbg(&pdev->dev, "Initializing to default value\n");
143 - }
144 -
145 - /* Kick the watchdog for kernel booting to finish */
146 + /* Kick the watchdog for kernel booting to finish.
147 + * If nowayout is not set, we start the ping work. */
148 +#ifdef CONFIG_WATCHDOG_NOWAYOUT
149 retu_modify_counter(RETU_WDT_MAX_TIMER);
150 -
151 - ret = retu_wdt_ping();
152 - if (ret < 0) {
153 - dev_err(&pdev->dev, "Failed to ping\n");
154 - goto free4;
155 - }
156 +#else
157 + retu_wdt_ping_enable(retu_wdt);
158 +#endif
159
160 return 0;
161
162 -free4:
163 - misc_deregister(&wdev->retu_wdt_miscdev);
164 -
165 -free3:
166 - device_remove_file(&pdev->dev, &dev_attr_counter);
167 -
168 -free2:
169 - device_remove_file(&pdev->dev, &dev_attr_period);
170 -
171 -free1:
172 +err_free_wdev:
173 kfree(wdev);
174
175 return ret;
176 @@ -329,8 +235,6 @@ static int __devexit retu_wdt_remove(str
177
178 wdev = platform_get_drvdata(pdev);
179 misc_deregister(&wdev->retu_wdt_miscdev);
180 - device_remove_file(&pdev->dev, &dev_attr_period);
181 - device_remove_file(&pdev->dev, &dev_attr_counter);
182 cancel_delayed_work_sync(&wdev->ping_work);
183 kfree(wdev);
184
185 @@ -356,9 +260,7 @@ static void __exit retu_wdt_exit(void)
186
187 module_init(retu_wdt_init);
188 module_exit(retu_wdt_exit);
189 -module_param(counter_param, int, 0);
190
191 MODULE_DESCRIPTION("Retu WatchDog");
192 MODULE_AUTHOR("Amit Kucheria");
193 MODULE_LICENSE("GPL");
194 -