Commit 32d019265d1f0c334f2f86407abf295d46bd2f4d
Committed by
Marek Vasut
1 parent
3f78a28037
Exists in
v2017.01-smarct4x
and in
37 other branches
stdio: Add force parameter to stdio_deregister
In some cases we really want to move forward with a deregister, add a force parameter to allow this, and replace the dev with a nulldev in this case. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Showing 4 changed files with 14 additions and 7 deletions Side-by-side Diff
common/stdio.c
... | ... | @@ -34,6 +34,9 @@ |
34 | 34 | #define CONFIG_SYS_DEVICE_NULLDEV 1 |
35 | 35 | #endif |
36 | 36 | |
37 | +#ifdef CONFIG_SYS_STDIO_DEREGISTER | |
38 | +#define CONFIG_SYS_DEVICE_NULLDEV 1 | |
39 | +#endif | |
37 | 40 | |
38 | 41 | #ifdef CONFIG_SYS_DEVICE_NULLDEV |
39 | 42 | void nulldev_putc(struct stdio_dev *dev, const char c) |
... | ... | @@ -172,7 +175,7 @@ |
172 | 175 | * returns 0 if success, -1 if device is assigned and 1 if devname not found |
173 | 176 | */ |
174 | 177 | #ifdef CONFIG_SYS_STDIO_DEREGISTER |
175 | -int stdio_deregister_dev(struct stdio_dev *dev) | |
178 | +int stdio_deregister_dev(struct stdio_dev *dev, int force) | |
176 | 179 | { |
177 | 180 | int l; |
178 | 181 | struct list_head *pos; |
... | ... | @@ -181,6 +184,10 @@ |
181 | 184 | /* get stdio devices (ListRemoveItem changes the dev list) */ |
182 | 185 | for (l=0 ; l< MAX_FILES; l++) { |
183 | 186 | if (stdio_devices[l] == dev) { |
187 | + if (force) { | |
188 | + strcpy(temp_names[l], "nulldev"); | |
189 | + continue; | |
190 | + } | |
184 | 191 | /* Device is assigned -> report error */ |
185 | 192 | return -1; |
186 | 193 | } |
... | ... | @@ -202,7 +209,7 @@ |
202 | 209 | return 0; |
203 | 210 | } |
204 | 211 | |
205 | -int stdio_deregister(const char *devname) | |
212 | +int stdio_deregister(const char *devname, int force) | |
206 | 213 | { |
207 | 214 | struct stdio_dev *dev; |
208 | 215 | |
... | ... | @@ -211,7 +218,7 @@ |
211 | 218 | if (!dev) /* device not found */ |
212 | 219 | return -ENODEV; |
213 | 220 | |
214 | - return stdio_deregister_dev(dev); | |
221 | + return stdio_deregister_dev(dev, force); | |
215 | 222 | } |
216 | 223 | #endif /* CONFIG_SYS_STDIO_DEREGISTER */ |
217 | 224 |
common/usb_kbd.c
drivers/serial/serial-uclass.c
include/stdio_dev.h
... | ... | @@ -103,8 +103,8 @@ |
103 | 103 | |
104 | 104 | void stdio_print_current_devices(void); |
105 | 105 | #ifdef CONFIG_SYS_STDIO_DEREGISTER |
106 | -int stdio_deregister(const char *devname); | |
107 | -int stdio_deregister_dev(struct stdio_dev *dev); | |
106 | +int stdio_deregister(const char *devname, int force); | |
107 | +int stdio_deregister_dev(struct stdio_dev *dev, int force); | |
108 | 108 | #endif |
109 | 109 | struct list_head* stdio_get_list(void); |
110 | 110 | struct stdio_dev* stdio_get_by_name(const char* name); |