aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers/ubd_kern.c
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-05-06 17:51:41 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-07 15:13:03 -0400
commitdc764e5087bceeb26714bb7975b711062b39d804 (patch)
treef777ee4533f398754e9779f9d2505387eb074307 /arch/um/drivers/ubd_kern.c
parentfda83a99b2b49016b9d7ed562745969db25c4ef9 (diff)
uml: formatting fixes around os_{read_write}_file callers
Formatting fixes ahead of renaming os_{read_write}_file_k to os_{read_write}_file and fixing all the callers. Signed-off-by: Jeff Dike <jdike@linux.intel.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/drivers/ubd_kern.c')
-rw-r--r--arch/um/drivers/ubd_kern.c124
1 files changed, 62 insertions, 62 deletions
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 2a00203e1017..614fe25a31bd 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -89,7 +89,7 @@ static inline int ubd_test_bit(__u64 bit, unsigned char *data)
89 bits = sizeof(data[0]) * 8; 89 bits = sizeof(data[0]) * 8;
90 n = bit / bits; 90 n = bit / bits;
91 off = bit % bits; 91 off = bit % bits;
92 return((data[n] & (1 << off)) != 0); 92 return (data[n] & (1 << off)) != 0;
93} 93}
94 94
95static inline void ubd_set_bit(__u64 bit, unsigned char *data) 95static inline void ubd_set_bit(__u64 bit, unsigned char *data)
@@ -146,7 +146,7 @@ struct cow {
146 unsigned long *bitmap; 146 unsigned long *bitmap;
147 unsigned long bitmap_len; 147 unsigned long bitmap_len;
148 int bitmap_offset; 148 int bitmap_offset;
149 int data_offset; 149 int data_offset;
150}; 150};
151 151
152#define MAX_SG 64 152#define MAX_SG 64
@@ -174,10 +174,10 @@ struct ubd {
174 174
175#define DEFAULT_COW { \ 175#define DEFAULT_COW { \
176 .file = NULL, \ 176 .file = NULL, \
177 .fd = -1, \ 177 .fd = -1, \
178 .bitmap = NULL, \ 178 .bitmap = NULL, \
179 .bitmap_offset = 0, \ 179 .bitmap_offset = 0, \
180 .data_offset = 0, \ 180 .data_offset = 0, \
181} 181}
182 182
183#define DEFAULT_UBD { \ 183#define DEFAULT_UBD { \
@@ -187,9 +187,9 @@ struct ubd {
187 .size = -1, \ 187 .size = -1, \
188 .boot_openflags = OPEN_FLAGS, \ 188 .boot_openflags = OPEN_FLAGS, \
189 .openflags = OPEN_FLAGS, \ 189 .openflags = OPEN_FLAGS, \
190 .no_cow = 0, \ 190 .no_cow = 0, \
191 .shared = 0, \ 191 .shared = 0, \
192 .cow = DEFAULT_COW, \ 192 .cow = DEFAULT_COW, \
193 .lock = SPIN_LOCK_UNLOCKED, \ 193 .lock = SPIN_LOCK_UNLOCKED, \
194 .request = NULL, \ 194 .request = NULL, \
195 .start_sg = 0, \ 195 .start_sg = 0, \
@@ -249,7 +249,7 @@ static void make_ide_entries(char *dev_name)
249static int fake_ide_setup(char *str) 249static int fake_ide_setup(char *str)
250{ 250{
251 fake_ide = 1; 251 fake_ide = 1;
252 return(1); 252 return 1;
253} 253}
254 254
255__setup("fake_ide", fake_ide_setup); 255__setup("fake_ide", fake_ide_setup);
@@ -267,7 +267,7 @@ static int parse_unit(char **ptr)
267 if(isdigit(*str)) { 267 if(isdigit(*str)) {
268 n = simple_strtoul(str, &end, 0); 268 n = simple_strtoul(str, &end, 0);
269 if(end == str) 269 if(end == str)
270 return(-1); 270 return -1;
271 *ptr = end; 271 *ptr = end;
272 } 272 }
273 else if (('a' <= *str) && (*str <= 'z')) { 273 else if (('a' <= *str) && (*str <= 'z')) {
@@ -275,7 +275,7 @@ static int parse_unit(char **ptr)
275 str++; 275 str++;
276 *ptr = str; 276 *ptr = str;
277 } 277 }
278 return(n); 278 return n;
279} 279}
280 280
281/* If *index_out == -1 at exit, the passed option was a general one; 281/* If *index_out == -1 at exit, the passed option was a general one;
@@ -442,7 +442,7 @@ static int udb_setup(char *str)
442{ 442{
443 printk("udb%s specified on command line is almost certainly a ubd -> " 443 printk("udb%s specified on command line is almost certainly a ubd -> "
444 "udb TYPO\n", str); 444 "udb TYPO\n", str);
445 return(1); 445 return 1;
446} 446}
447 447
448__setup("udb", udb_setup); 448__setup("udb", udb_setup);
@@ -541,7 +541,7 @@ static void ubd_handler(void)
541static irqreturn_t ubd_intr(int irq, void *dev) 541static irqreturn_t ubd_intr(int irq, void *dev)
542{ 542{
543 ubd_handler(); 543 ubd_handler();
544 return(IRQ_HANDLED); 544 return IRQ_HANDLED;
545} 545}
546 546
547/* Only changed by ubd_init, which is an initcall. */ 547/* Only changed by ubd_init, which is an initcall. */
@@ -560,7 +560,7 @@ static inline int ubd_file_size(struct ubd *ubd_dev, __u64 *size_out)
560 char *file; 560 char *file;
561 561
562 file = ubd_dev->cow.file ? ubd_dev->cow.file : ubd_dev->file; 562 file = ubd_dev->cow.file ? ubd_dev->cow.file : ubd_dev->file;
563 return(os_file_size(file, size_out)); 563 return os_file_size(file, size_out);
564} 564}
565 565
566static void ubd_close_dev(struct ubd *ubd_dev) 566static void ubd_close_dev(struct ubd *ubd_dev)
@@ -632,10 +632,10 @@ static int ubd_open_dev(struct ubd *ubd_dev)
632 if(err < 0) goto error; 632 if(err < 0) goto error;
633 ubd_dev->cow.fd = err; 633 ubd_dev->cow.fd = err;
634 } 634 }
635 return(0); 635 return 0;
636 error: 636 error:
637 os_close_file(ubd_dev->fd); 637 os_close_file(ubd_dev->fd);
638 return(err); 638 return err;
639} 639}
640 640
641static void ubd_device_release(struct device *dev) 641static void ubd_device_release(struct device *dev)
@@ -653,7 +653,7 @@ static int ubd_disk_register(int major, u64 size, int unit,
653 653
654 disk = alloc_disk(1 << UBD_SHIFT); 654 disk = alloc_disk(1 << UBD_SHIFT);
655 if(disk == NULL) 655 if(disk == NULL)
656 return(-ENOMEM); 656 return -ENOMEM;
657 657
658 disk->major = major; 658 disk->major = major;
659 disk->first_minor = unit << UBD_SHIFT; 659 disk->first_minor = unit << UBD_SHIFT;
@@ -758,14 +758,14 @@ static int ubd_config(char *str, char **error_out)
758 goto err_free; 758 goto err_free;
759 } 759 }
760 760
761 mutex_lock(&ubd_lock); 761 mutex_lock(&ubd_lock);
762 ret = ubd_add(n, error_out); 762 ret = ubd_add(n, error_out);
763 if (ret) 763 if (ret)
764 ubd_devs[n].file = NULL; 764 ubd_devs[n].file = NULL;
765 mutex_unlock(&ubd_lock); 765 mutex_unlock(&ubd_lock);
766 766
767out: 767out:
768 return ret; 768 return ret;
769 769
770err_free: 770err_free:
771 kfree(str); 771 kfree(str);
@@ -780,7 +780,7 @@ static int ubd_get_config(char *name, char *str, int size, char **error_out)
780 n = parse_unit(&name); 780 n = parse_unit(&name);
781 if((n >= MAX_DEV) || (n < 0)){ 781 if((n >= MAX_DEV) || (n < 0)){
782 *error_out = "ubd_get_config : device number out of range"; 782 *error_out = "ubd_get_config : device number out of range";
783 return(-1); 783 return -1;
784 } 784 }
785 785
786 ubd_dev = &ubd_devs[n]; 786 ubd_dev = &ubd_devs[n];
@@ -801,17 +801,17 @@ static int ubd_get_config(char *name, char *str, int size, char **error_out)
801 801
802 out: 802 out:
803 mutex_unlock(&ubd_lock); 803 mutex_unlock(&ubd_lock);
804 return(len); 804 return len;
805} 805}
806 806
807static int ubd_id(char **str, int *start_out, int *end_out) 807static int ubd_id(char **str, int *start_out, int *end_out)
808{ 808{
809 int n; 809 int n;
810 810
811 n = parse_unit(str); 811 n = parse_unit(str);
812 *start_out = 0; 812 *start_out = 0;
813 *end_out = MAX_DEV - 1; 813 *end_out = MAX_DEV - 1;
814 return n; 814 return n;
815} 815}
816 816
817static int ubd_remove(int n, char **error_out) 817static int ubd_remove(int n, char **error_out)
@@ -832,7 +832,7 @@ static int ubd_remove(int n, char **error_out)
832 if(ubd_dev->count > 0) 832 if(ubd_dev->count > 0)
833 goto out; 833 goto out;
834 834
835 ubd_gendisk[n] = NULL; 835 ubd_gendisk[n] = NULL;
836 if(disk != NULL){ 836 if(disk != NULL){
837 del_gendisk(disk); 837 del_gendisk(disk);
838 put_disk(disk); 838 put_disk(disk);
@@ -858,7 +858,7 @@ static struct mc_device ubd_mc = {
858 .list = LIST_HEAD_INIT(ubd_mc.list), 858 .list = LIST_HEAD_INIT(ubd_mc.list),
859 .name = "ubd", 859 .name = "ubd",
860 .config = ubd_config, 860 .config = ubd_config,
861 .get_config = ubd_get_config, 861 .get_config = ubd_get_config,
862 .id = ubd_id, 862 .id = ubd_id,
863 .remove = ubd_remove, 863 .remove = ubd_remove,
864}; 864};
@@ -880,7 +880,7 @@ static int __init ubd0_init(void)
880 ubd_dev->file = "root_fs"; 880 ubd_dev->file = "root_fs";
881 mutex_unlock(&ubd_lock); 881 mutex_unlock(&ubd_lock);
882 882
883 return(0); 883 return 0;
884} 884}
885 885
886__initcall(ubd0_init); 886__initcall(ubd0_init);
@@ -908,14 +908,14 @@ static int __init ubd_init(void)
908 return -1; 908 return -1;
909 } 909 }
910 platform_driver_register(&ubd_driver); 910 platform_driver_register(&ubd_driver);
911 mutex_lock(&ubd_lock); 911 mutex_lock(&ubd_lock);
912 for (i = 0; i < MAX_DEV; i++){ 912 for (i = 0; i < MAX_DEV; i++){
913 err = ubd_add(i, &error); 913 err = ubd_add(i, &error);
914 if(err) 914 if(err)
915 printk(KERN_ERR "Failed to initialize ubd device %d :" 915 printk(KERN_ERR "Failed to initialize ubd device %d :"
916 "%s\n", i, error); 916 "%s\n", i, error);
917 } 917 }
918 mutex_unlock(&ubd_lock); 918 mutex_unlock(&ubd_lock);
919 return 0; 919 return 0;
920} 920}
921 921
@@ -939,7 +939,7 @@ static int __init ubd_driver_init(void){
939 "ubd : Failed to start I/O thread (errno = %d) - " 939 "ubd : Failed to start I/O thread (errno = %d) - "
940 "falling back to synchronous I/O\n", -io_pid); 940 "falling back to synchronous I/O\n", -io_pid);
941 io_pid = -1; 941 io_pid = -1;
942 return(0); 942 return 0;
943 } 943 }
944 err = um_request_irq(UBD_IRQ, thread_fd, IRQ_READ, ubd_intr, 944 err = um_request_irq(UBD_IRQ, thread_fd, IRQ_READ, ubd_intr,
945 IRQF_DISABLED, "ubd", ubd_devs); 945 IRQF_DISABLED, "ubd", ubd_devs);
@@ -974,7 +974,7 @@ static int ubd_open(struct inode *inode, struct file *filp)
974 err = -EROFS; 974 err = -EROFS;
975 }*/ 975 }*/
976 out: 976 out:
977 return(err); 977 return err;
978} 978}
979 979
980static int ubd_release(struct inode * inode, struct file * file) 980static int ubd_release(struct inode * inode, struct file * file)
@@ -984,7 +984,7 @@ static int ubd_release(struct inode * inode, struct file * file)
984 984
985 if(--ubd_dev->count == 0) 985 if(--ubd_dev->count == 0)
986 ubd_close_dev(ubd_dev); 986 ubd_close_dev(ubd_dev);
987 return(0); 987 return 0;
988} 988}
989 989
990static void cowify_bitmap(__u64 io_offset, int length, unsigned long *cow_mask, 990static void cowify_bitmap(__u64 io_offset, int length, unsigned long *cow_mask,
@@ -1040,7 +1040,7 @@ static void cowify_req(struct io_thread_req *req, unsigned long *bitmap,
1040 if(ubd_test_bit(sector + i, (unsigned char *) bitmap)) 1040 if(ubd_test_bit(sector + i, (unsigned char *) bitmap))
1041 ubd_set_bit(i, (unsigned char *) 1041 ubd_set_bit(i, (unsigned char *)
1042 &req->sector_mask); 1042 &req->sector_mask);
1043 } 1043 }
1044 } 1044 }
1045 else cowify_bitmap(req->offset, req->length, &req->sector_mask, 1045 else cowify_bitmap(req->offset, req->length, &req->sector_mask,
1046 &req->cow_offset, bitmap, bitmap_offset, 1046 &req->cow_offset, bitmap, bitmap_offset,
@@ -1157,21 +1157,21 @@ static int ubd_ioctl(struct inode * inode, struct file * file,
1157 ubd_id.cyls = ubd_dev->size / (128 * 32 * 512); 1157 ubd_id.cyls = ubd_dev->size / (128 * 32 * 512);
1158 if(copy_to_user((char __user *) arg, (char *) &ubd_id, 1158 if(copy_to_user((char __user *) arg, (char *) &ubd_id,
1159 sizeof(ubd_id))) 1159 sizeof(ubd_id)))
1160 return(-EFAULT); 1160 return -EFAULT;
1161 return(0); 1161 return 0;
1162 1162
1163 case CDROMVOLREAD: 1163 case CDROMVOLREAD:
1164 if(copy_from_user(&volume, (char __user *) arg, sizeof(volume))) 1164 if(copy_from_user(&volume, (char __user *) arg, sizeof(volume)))
1165 return(-EFAULT); 1165 return -EFAULT;
1166 volume.channel0 = 255; 1166 volume.channel0 = 255;
1167 volume.channel1 = 255; 1167 volume.channel1 = 255;
1168 volume.channel2 = 255; 1168 volume.channel2 = 255;
1169 volume.channel3 = 255; 1169 volume.channel3 = 255;
1170 if(copy_to_user((char __user *) arg, &volume, sizeof(volume))) 1170 if(copy_to_user((char __user *) arg, &volume, sizeof(volume)))
1171 return(-EFAULT); 1171 return -EFAULT;
1172 return(0); 1172 return 0;
1173 } 1173 }
1174 return(-EINVAL); 1174 return -EINVAL;
1175} 1175}
1176 1176
1177static int path_requires_switch(char *from_cmdline, char *from_cow, char *cow) 1177static int path_requires_switch(char *from_cmdline, char *from_cow, char *cow)
@@ -1213,29 +1213,29 @@ static int backing_file_mismatch(char *file, __u64 size, time_t mtime)
1213 if(err < 0){ 1213 if(err < 0){
1214 printk("Failed to get modification time of backing file " 1214 printk("Failed to get modification time of backing file "
1215 "\"%s\", err = %d\n", file, -err); 1215 "\"%s\", err = %d\n", file, -err);
1216 return(err); 1216 return err;
1217 } 1217 }
1218 1218
1219 err = os_file_size(file, &actual); 1219 err = os_file_size(file, &actual);
1220 if(err < 0){ 1220 if(err < 0){
1221 printk("Failed to get size of backing file \"%s\", " 1221 printk("Failed to get size of backing file \"%s\", "
1222 "err = %d\n", file, -err); 1222 "err = %d\n", file, -err);
1223 return(err); 1223 return err;
1224 } 1224 }
1225 1225
1226 if(actual != size){ 1226 if(actual != size){
1227 /*__u64 can be a long on AMD64 and with %lu GCC complains; so 1227 /*__u64 can be a long on AMD64 and with %lu GCC complains; so
1228 * the typecast.*/ 1228 * the typecast.*/
1229 printk("Size mismatch (%llu vs %llu) of COW header vs backing " 1229 printk("Size mismatch (%llu vs %llu) of COW header vs backing "
1230 "file\n", (unsigned long long) size, actual); 1230 "file\n", (unsigned long long) size, actual);
1231 return(-EINVAL); 1231 return -EINVAL;
1232 } 1232 }
1233 if(modtime != mtime){ 1233 if(modtime != mtime){
1234 printk("mtime mismatch (%ld vs %ld) of COW header vs backing " 1234 printk("mtime mismatch (%ld vs %ld) of COW header vs backing "
1235 "file\n", mtime, modtime); 1235 "file\n", mtime, modtime);
1236 return(-EINVAL); 1236 return -EINVAL;
1237 } 1237 }
1238 return(0); 1238 return 0;
1239} 1239}
1240 1240
1241int read_cow_bitmap(int fd, void *buf, int offset, int len) 1241int read_cow_bitmap(int fd, void *buf, int offset, int len)
@@ -1244,13 +1244,13 @@ int read_cow_bitmap(int fd, void *buf, int offset, int len)
1244 1244
1245 err = os_seek_file(fd, offset); 1245 err = os_seek_file(fd, offset);
1246 if(err < 0) 1246 if(err < 0)
1247 return(err); 1247 return err;
1248 1248
1249 err = os_read_file_k(fd, buf, len); 1249 err = os_read_file(fd, buf, len);
1250 if(err < 0) 1250 if(err < 0)
1251 return(err); 1251 return err;
1252 1252
1253 return(0); 1253 return 0;
1254} 1254}
1255 1255
1256int open_ubd_file(char *file, struct openflags *openflags, int shared, 1256int open_ubd_file(char *file, struct openflags *openflags, int shared,
@@ -1268,14 +1268,14 @@ int open_ubd_file(char *file, struct openflags *openflags, int shared,
1268 if (fd < 0) { 1268 if (fd < 0) {
1269 if ((fd == -ENOENT) && (create_cow_out != NULL)) 1269 if ((fd == -ENOENT) && (create_cow_out != NULL))
1270 *create_cow_out = 1; 1270 *create_cow_out = 1;
1271 if (!openflags->w || 1271 if (!openflags->w ||
1272 ((fd != -EROFS) && (fd != -EACCES))) 1272 ((fd != -EROFS) && (fd != -EACCES)))
1273 return fd; 1273 return fd;
1274 openflags->w = 0; 1274 openflags->w = 0;
1275 fd = os_open_file(file, *openflags, mode); 1275 fd = os_open_file(file, *openflags, mode);
1276 if (fd < 0) 1276 if (fd < 0)
1277 return fd; 1277 return fd;
1278 } 1278 }
1279 1279
1280 if(shared) 1280 if(shared)
1281 printk("Not locking \"%s\" on the host\n", file); 1281 printk("Not locking \"%s\" on the host\n", file);
@@ -1289,7 +1289,7 @@ int open_ubd_file(char *file, struct openflags *openflags, int shared,
1289 1289
1290 /* Successful return case! */ 1290 /* Successful return case! */
1291 if(backing_file_out == NULL) 1291 if(backing_file_out == NULL)
1292 return(fd); 1292 return fd;
1293 1293
1294 err = read_cow_header(file_reader, &fd, &version, &backing_file, &mtime, 1294 err = read_cow_header(file_reader, &fd, &version, &backing_file, &mtime,
1295 &size, &sectorsize, &align, bitmap_offset_out); 1295 &size, &sectorsize, &align, bitmap_offset_out);
@@ -1299,7 +1299,7 @@ int open_ubd_file(char *file, struct openflags *openflags, int shared,
1299 goto out_close; 1299 goto out_close;
1300 } 1300 }
1301 if(err) 1301 if(err)
1302 return(fd); 1302 return fd;
1303 1303
1304 asked_switch = path_requires_switch(*backing_file_out, backing_file, file); 1304 asked_switch = path_requires_switch(*backing_file_out, backing_file, file);
1305 1305
@@ -1322,7 +1322,7 @@ int open_ubd_file(char *file, struct openflags *openflags, int shared,
1322 cow_sizes(version, size, sectorsize, align, *bitmap_offset_out, 1322 cow_sizes(version, size, sectorsize, align, *bitmap_offset_out,
1323 bitmap_len_out, data_offset_out); 1323 bitmap_len_out, data_offset_out);
1324 1324
1325 return fd; 1325 return fd;
1326 out_close: 1326 out_close:
1327 os_close_file(fd); 1327 os_close_file(fd);
1328 return err; 1328 return err;
@@ -1347,10 +1347,10 @@ int create_cow_file(char *cow_file, char *backing_file, struct openflags flags,
1347 bitmap_offset_out, bitmap_len_out, 1347 bitmap_offset_out, bitmap_len_out,
1348 data_offset_out); 1348 data_offset_out);
1349 if(!err) 1349 if(!err)
1350 return(fd); 1350 return fd;
1351 os_close_file(fd); 1351 os_close_file(fd);
1352 out: 1352 out:
1353 return(err); 1353 return err;
1354} 1354}
1355 1355
1356static int update_bitmap(struct io_thread_req *req) 1356static int update_bitmap(struct io_thread_req *req)
@@ -1358,12 +1358,12 @@ static int update_bitmap(struct io_thread_req *req)
1358 int n; 1358 int n;
1359 1359
1360 if(req->cow_offset == -1) 1360 if(req->cow_offset == -1)
1361 return(0); 1361 return 0;
1362 1362
1363 n = os_seek_file(req->fds[1], req->cow_offset); 1363 n = os_seek_file(req->fds[1], req->cow_offset);
1364 if(n < 0){ 1364 if(n < 0){
1365 printk("do_io - bitmap lseek failed : err = %d\n", -n); 1365 printk("do_io - bitmap lseek failed : err = %d\n", -n);
1366 return(1); 1366 return 1;
1367 } 1367 }
1368 1368
1369 n = os_write_file_k(req->fds[1], &req->bitmap_words, 1369 n = os_write_file_k(req->fds[1], &req->bitmap_words,
@@ -1371,10 +1371,10 @@ static int update_bitmap(struct io_thread_req *req)
1371 if(n != sizeof(req->bitmap_words)){ 1371 if(n != sizeof(req->bitmap_words)){
1372 printk("do_io - bitmap update failed, err = %d fd = %d\n", -n, 1372 printk("do_io - bitmap update failed, err = %d fd = %d\n", -n,
1373 req->fds[1]); 1373 req->fds[1]);
1374 return(1); 1374 return 1;
1375 } 1375 }
1376 1376
1377 return(0); 1377 return 0;
1378} 1378}
1379 1379
1380void do_io(struct io_thread_req *req) 1380void do_io(struct io_thread_req *req)