aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/um/drivers/ubd_kern.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index d863482cdd27..da0badcd7551 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -131,7 +131,6 @@ static struct block_device_operations ubd_blops = {
131 131
132/* Protected by ubd_lock */ 132/* Protected by ubd_lock */
133static int fake_major = MAJOR_NR; 133static int fake_major = MAJOR_NR;
134
135static struct gendisk *ubd_gendisk[MAX_DEV]; 134static struct gendisk *ubd_gendisk[MAX_DEV];
136static struct gendisk *fake_gendisk[MAX_DEV]; 135static struct gendisk *fake_gendisk[MAX_DEV];
137 136
@@ -142,10 +141,6 @@ static struct gendisk *fake_gendisk[MAX_DEV];
142#define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 0, .c = 0, \ 141#define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 0, .c = 0, \
143 .cl = 1 }) 142 .cl = 1 })
144#endif 143#endif
145
146/* Not protected - changed only in ubd_setup_common and then only to
147 * to enable O_SYNC.
148 */
149static struct openflags global_openflags = OPEN_FLAGS; 144static struct openflags global_openflags = OPEN_FLAGS;
150 145
151struct cow { 146struct cow {
@@ -197,6 +192,7 @@ struct ubd {
197 .lock = SPIN_LOCK_UNLOCKED, \ 192 .lock = SPIN_LOCK_UNLOCKED, \
198} 193}
199 194
195/* Protected by ubd_lock */
200struct ubd ubd_devs[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_UBD }; 196struct ubd ubd_devs[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_UBD };
201 197
202/* Only changed by fake_ide_setup which is a setup */ 198/* Only changed by fake_ide_setup which is a setup */
@@ -288,7 +284,7 @@ static int ubd_setup_common(char *str, int *index_out, char **error_out)
288 struct ubd *ubd_dev; 284 struct ubd *ubd_dev;
289 struct openflags flags = global_openflags; 285 struct openflags flags = global_openflags;
290 char *backing_file; 286 char *backing_file;
291 int n, err, i; 287 int n, err = 0, i;
292 288
293 if(index_out) *index_out = -1; 289 if(index_out) *index_out = -1;
294 n = *str; 290 n = *str;
@@ -299,15 +295,16 @@ static int ubd_setup_common(char *str, int *index_out, char **error_out)
299 str++; 295 str++;
300 if(!strcmp(str, "sync")){ 296 if(!strcmp(str, "sync")){
301 global_openflags = of_sync(global_openflags); 297 global_openflags = of_sync(global_openflags);
302 return 0; 298 goto out1;
303 } 299 }
300
301 err = -EINVAL;
304 major = simple_strtoul(str, &end, 0); 302 major = simple_strtoul(str, &end, 0);
305 if((*end != '\0') || (end == str)){ 303 if((*end != '\0') || (end == str)){
306 *error_out = "Didn't parse major number"; 304 *error_out = "Didn't parse major number";
307 return -EINVAL; 305 goto out1;
308 } 306 }
309 307
310 err = -EINVAL;
311 mutex_lock(&ubd_lock); 308 mutex_lock(&ubd_lock);
312 if(fake_major != MAJOR_NR){ 309 if(fake_major != MAJOR_NR){
313 *error_out = "Can't assign a fake major twice"; 310 *error_out = "Can't assign a fake major twice";
@@ -473,12 +470,6 @@ static void do_ubd_request(request_queue_t * q);
473/* Only changed by ubd_init, which is an initcall. */ 470/* Only changed by ubd_init, which is an initcall. */
474int thread_fd = -1; 471int thread_fd = -1;
475 472
476/* Changed by ubd_handler, which is serialized because interrupts only
477 * happen on CPU 0.
478 * XXX: currently unused.
479 */
480static int intr_count = 0;
481
482/* call ubd_finish if you need to serialize */ 473/* call ubd_finish if you need to serialize */
483static void __ubd_finish(struct request *req, int error) 474static void __ubd_finish(struct request *req, int error)
484{ 475{
@@ -518,7 +509,6 @@ static void ubd_handler(void)
518 int n; 509 int n;
519 510
520 do_ubd = 0; 511 do_ubd = 0;
521 intr_count++;
522 n = os_read_file(thread_fd, &req, sizeof(req)); 512 n = os_read_file(thread_fd, &req, sizeof(req));
523 if(n != sizeof(req)){ 513 if(n != sizeof(req)){
524 printk(KERN_ERR "Pid %d - spurious interrupt in ubd_handler, " 514 printk(KERN_ERR "Pid %d - spurious interrupt in ubd_handler, "
@@ -637,8 +627,7 @@ static int ubd_open_dev(struct ubd *ubd_dev)
637} 627}
638 628
639static int ubd_disk_register(int major, u64 size, int unit, 629static int ubd_disk_register(int major, u64 size, int unit,
640 struct gendisk **disk_out) 630 struct gendisk **disk_out)
641
642{ 631{
643 struct gendisk *disk; 632 struct gendisk *disk;
644 633
@@ -840,7 +829,7 @@ out:
840} 829}
841 830
842/* All these are called by mconsole in process context and without 831/* All these are called by mconsole in process context and without
843 * ubd-specific locks. 832 * ubd-specific locks. The structure itself is const except for .list.
844 */ 833 */
845static struct mc_device ubd_mc = { 834static struct mc_device ubd_mc = {
846 .list = LIST_HEAD_INIT(ubd_mc.list), 835 .list = LIST_HEAD_INIT(ubd_mc.list),
@@ -863,13 +852,17 @@ static int __init ubd0_init(void)
863{ 852{
864 struct ubd *ubd_dev = &ubd_devs[0]; 853 struct ubd *ubd_dev = &ubd_devs[0];
865 854
855 mutex_lock(&ubd_lock);
866 if(ubd_dev->file == NULL) 856 if(ubd_dev->file == NULL)
867 ubd_dev->file = "root_fs"; 857 ubd_dev->file = "root_fs";
858 mutex_unlock(&ubd_lock);
859
868 return(0); 860 return(0);
869} 861}
870 862
871__initcall(ubd0_init); 863__initcall(ubd0_init);
872 864
865/* Used in ubd_init, which is an initcall */
873static struct platform_driver ubd_driver = { 866static struct platform_driver ubd_driver = {
874 .driver = { 867 .driver = {
875 .name = DRIVER_NAME, 868 .name = DRIVER_NAME,
@@ -892,12 +885,14 @@ static int __init ubd_init(void)
892 return -1; 885 return -1;
893 } 886 }
894 platform_driver_register(&ubd_driver); 887 platform_driver_register(&ubd_driver);
888 mutex_lock(&ubd_lock);
895 for (i = 0; i < MAX_DEV; i++){ 889 for (i = 0; i < MAX_DEV; i++){
896 err = ubd_add(i, &error); 890 err = ubd_add(i, &error);
897 if(err) 891 if(err)
898 printk(KERN_ERR "Failed to initialize ubd device %d :" 892 printk(KERN_ERR "Failed to initialize ubd device %d :"
899 "%s\n", i, error); 893 "%s\n", i, error);
900 } 894 }
895 mutex_unlock(&ubd_lock);
901 return 0; 896 return 0;
902} 897}
903 898
@@ -1129,7 +1124,7 @@ static int ubd_ioctl(struct inode * inode, struct file * file,
1129 sizeof(ubd_id))) 1124 sizeof(ubd_id)))
1130 return(-EFAULT); 1125 return(-EFAULT);
1131 return(0); 1126 return(0);
1132 1127
1133 case CDROMVOLREAD: 1128 case CDROMVOLREAD:
1134 if(copy_from_user(&volume, (char __user *) arg, sizeof(volume))) 1129 if(copy_from_user(&volume, (char __user *) arg, sizeof(volume)))
1135 return(-EFAULT); 1130 return(-EFAULT);