Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: dvbdev: fix most coding style issues

As we're doing several changes here, address coding style issues,
as reported by checkpatch.pl.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

+74 -83
+74 -83
drivers/media/dvb-core/dvbdev.c
··· 61 61 #define DVB_MAX_IDS 4 62 62 63 63 static const u8 minor_type[] = { 64 - [DVB_DEVICE_VIDEO] = 0, 65 - [DVB_DEVICE_AUDIO] = 1, 66 - [DVB_DEVICE_SEC] = 2, 67 - [DVB_DEVICE_FRONTEND] = 3, 68 - [DVB_DEVICE_DEMUX] = 4, 69 - [DVB_DEVICE_DVR] = 5, 70 - [DVB_DEVICE_CA] = 6, 71 - [DVB_DEVICE_NET] = 7, 72 - [DVB_DEVICE_OSD] = 8, 64 + [DVB_DEVICE_VIDEO] = 0, 65 + [DVB_DEVICE_AUDIO] = 1, 66 + [DVB_DEVICE_SEC] = 2, 67 + [DVB_DEVICE_FRONTEND] = 3, 68 + [DVB_DEVICE_DEMUX] = 4, 69 + [DVB_DEVICE_DVR] = 5, 70 + [DVB_DEVICE_CA] = 6, 71 + [DVB_DEVICE_NET] = 7, 72 + [DVB_DEVICE_OSD] = 8, 73 73 }; 74 74 75 75 #define nums2minor(num, type, id) \ 76 - (((num) << 6) | ((id) << 4) | minor_type[type]) 76 + (((num) << 6) | ((id) << 4) | minor_type[type]) 77 77 78 - #define MAX_DVB_MINORS (DVB_MAX_ADAPTERS*64) 78 + #define MAX_DVB_MINORS (DVB_MAX_ADAPTERS * 64) 79 79 #endif 80 80 81 81 static struct class *dvb_class; ··· 112 112 return -ENODEV; 113 113 } 114 114 115 - 116 - static const struct file_operations dvb_device_fops = 117 - { 115 + static const struct file_operations dvb_device_fops = { 118 116 .owner = THIS_MODULE, 119 117 .open = dvb_device_open, 120 118 .llseek = noop_llseek, ··· 145 147 } 146 148 EXPORT_SYMBOL(dvb_generic_open); 147 149 148 - 149 150 int dvb_generic_release(struct inode *inode, struct file *file) 150 151 { 151 152 struct dvb_device *dvbdev = file->private_data; ··· 152 155 if (!dvbdev) 153 156 return -ENODEV; 154 157 155 - if ((file->f_flags & O_ACCMODE) == O_RDONLY) { 158 + if ((file->f_flags & O_ACCMODE) == O_RDONLY) 156 159 dvbdev->readers++; 157 - } else { 160 + else 158 161 dvbdev->writers++; 159 - } 160 162 161 163 dvbdev->users++; 162 164 ··· 164 168 return 0; 165 169 } 166 170 EXPORT_SYMBOL(dvb_generic_release); 167 - 168 171 169 172 long dvb_generic_ioctl(struct file *file, 170 173 unsigned int cmd, unsigned long arg) ··· 180 185 } 181 186 EXPORT_SYMBOL(dvb_generic_ioctl); 182 187 183 - 184 - static int dvbdev_get_free_id (struct dvb_adapter *adap, int type) 188 + static int dvbdev_get_free_id(struct dvb_adapter *adap, int type) 185 189 { 186 190 u32 id = 0; 187 191 188 192 while (id < DVB_MAX_IDS) { 189 193 struct dvb_device *dev; 194 + 190 195 list_for_each_entry(dev, &adap->device_list, list_head) 191 196 if (dev->type == type && dev->id == id) 192 197 goto skip; ··· 240 245 241 246 #if defined(CONFIG_MEDIA_CONTROLLER_DVB) 242 247 static int dvb_create_tsout_entity(struct dvb_device *dvbdev, 243 - const char *name, int npads) 248 + const char *name, int npads) 244 249 { 245 250 int i; 246 251 ··· 382 387 383 388 static int dvb_register_media_device(struct dvb_device *dvbdev, 384 389 int type, int minor, 385 - unsigned demux_sink_pads) 390 + unsigned int demux_sink_pads) 386 391 { 387 392 #if defined(CONFIG_MEDIA_CONTROLLER_DVB) 388 393 struct media_link *link; ··· 457 462 458 463 mutex_lock(&dvbdev_register_lock); 459 464 460 - if ((id = dvbdev_get_free_id (adap, type)) < 0) { 465 + id = dvbdev_get_free_id(adap, type); 466 + if (id < 0) { 461 467 mutex_unlock(&dvbdev_register_lock); 462 468 *pdvbdev = NULL; 463 469 pr_err("%s: couldn't find free device id\n", __func__); ··· 466 470 } 467 471 468 472 *pdvbdev = dvbdev = kzalloc(sizeof(*dvbdev), GFP_KERNEL); 469 - if (!dvbdev){ 473 + if (!dvbdev) { 470 474 mutex_unlock(&dvbdev_register_lock); 471 475 return -ENOMEM; 472 476 } ··· 478 482 */ 479 483 list_for_each_entry(node, &dvbdevfops_list, list_head) { 480 484 if (node->fops->owner == adap->module && 481 - node->type == type && 482 - node->template == template) { 485 + node->type == type && node->template == template) { 483 486 dvbdevfops = node->fops; 484 487 break; 485 488 } 486 489 } 487 490 488 - if (dvbdevfops == NULL) { 491 + if (!dvbdevfops) { 489 492 dvbdevfops = kmemdup(template->fops, sizeof(*dvbdevfops), GFP_KERNEL); 490 493 if (!dvbdevfops) { 491 494 kfree(dvbdev); ··· 492 497 return -ENOMEM; 493 498 } 494 499 495 - new_node = kzalloc(sizeof(struct dvbdevfops_node), GFP_KERNEL); 500 + new_node = kzalloc(sizeof(*new_node), GFP_KERNEL); 496 501 if (!new_node) { 497 502 kfree(dvbdevfops); 498 503 kfree(dvbdev); ··· 503 508 new_node->fops = dvbdevfops; 504 509 new_node->type = type; 505 510 new_node->template = template; 506 - list_add_tail (&new_node->list_head, &dvbdevfops_list); 511 + list_add_tail(&new_node->list_head, &dvbdevfops_list); 507 512 } 508 513 509 514 memcpy(dvbdev, template, sizeof(struct dvb_device)); ··· 513 518 dvbdev->adapter = adap; 514 519 dvbdev->priv = priv; 515 520 dvbdev->fops = dvbdevfops; 516 - init_waitqueue_head (&dvbdev->wait_queue); 521 + init_waitqueue_head(&dvbdev->wait_queue); 517 522 dvbdevfops->owner = adap->module; 518 - list_add_tail (&dvbdev->list_head, &adap->device_list); 523 + list_add_tail(&dvbdev->list_head, &adap->device_list); 519 524 down_write(&minor_rwsem); 520 525 #ifdef CONFIG_DVB_DYNAMIC_MINORS 521 526 for (minor = 0; minor < MAX_DVB_MINORS; minor++) 522 - if (dvb_minors[minor] == NULL) 527 + if (!dvb_minors[minor]) 523 528 break; 524 529 if (minor == MAX_DVB_MINORS) { 525 530 if (new_node) { 526 - list_del (&new_node->list_head); 531 + list_del(&new_node->list_head); 527 532 kfree(dvbdevfops); 528 533 kfree(new_node); 529 534 } 530 - list_del (&dvbdev->list_head); 535 + list_del(&dvbdev->list_head); 531 536 kfree(dvbdev); 532 537 up_write(&minor_rwsem); 533 538 mutex_unlock(&dvbdev_register_lock); ··· 542 547 ret = dvb_register_media_device(dvbdev, type, minor, demux_sink_pads); 543 548 if (ret) { 544 549 pr_err("%s: dvb_register_media_device failed to create the mediagraph\n", 545 - __func__); 550 + __func__); 546 551 if (new_node) { 547 - list_del (&new_node->list_head); 552 + list_del(&new_node->list_head); 548 553 kfree(dvbdevfops); 549 554 kfree(new_node); 550 555 } 551 556 dvb_media_device_free(dvbdev); 552 - list_del (&dvbdev->list_head); 557 + list_del(&dvbdev->list_head); 553 558 kfree(dvbdev); 554 559 mutex_unlock(&dvbdev_register_lock); 555 560 return ret; ··· 562 567 pr_err("%s: failed to create device dvb%d.%s%d (%ld)\n", 563 568 __func__, adap->num, dnames[type], id, PTR_ERR(clsdev)); 564 569 if (new_node) { 565 - list_del (&new_node->list_head); 570 + list_del(&new_node->list_head); 566 571 kfree(dvbdevfops); 567 572 kfree(new_node); 568 573 } 569 574 dvb_media_device_free(dvbdev); 570 - list_del (&dvbdev->list_head); 575 + list_del(&dvbdev->list_head); 571 576 kfree(dvbdev); 572 577 mutex_unlock(&dvbdev_register_lock); 573 578 return PTR_ERR(clsdev); ··· 580 585 return 0; 581 586 } 582 587 EXPORT_SYMBOL(dvb_register_device); 583 - 584 588 585 589 void dvb_remove_device(struct dvb_device *dvbdev) 586 590 { ··· 595 601 596 602 device_destroy(dvb_class, MKDEV(DVB_MAJOR, dvbdev->minor)); 597 603 598 - list_del (&dvbdev->list_head); 604 + list_del(&dvbdev->list_head); 599 605 } 600 606 EXPORT_SYMBOL(dvb_remove_device); 601 - 602 607 603 608 static void dvb_free_device(struct kref *ref) 604 609 { 605 610 struct dvb_device *dvbdev = container_of(ref, struct dvb_device, ref); 606 611 607 - kfree (dvbdev); 612 + kfree(dvbdev); 608 613 } 609 - 610 614 611 615 struct dvb_device *dvb_device_get(struct dvb_device *dvbdev) 612 616 { ··· 613 621 } 614 622 EXPORT_SYMBOL(dvb_device_get); 615 623 616 - 617 624 void dvb_device_put(struct dvb_device *dvbdev) 618 625 { 619 626 if (dvbdev) 620 627 kref_put(&dvbdev->ref, dvb_free_device); 621 628 } 622 - 623 629 624 630 void dvb_unregister_device(struct dvb_device *dvbdev) 625 631 { ··· 625 635 dvb_device_put(dvbdev); 626 636 } 627 637 EXPORT_SYMBOL(dvb_unregister_device); 628 - 629 638 630 639 #ifdef CONFIG_MEDIA_CONTROLLER_DVB 631 640 ··· 658 669 struct media_entity *demux = NULL, *ca = NULL; 659 670 struct media_link *link; 660 671 struct media_interface *intf; 661 - unsigned demux_pad = 0; 662 - unsigned dvr_pad = 0; 663 - unsigned ntuner = 0, ndemod = 0; 672 + unsigned int demux_pad = 0; 673 + unsigned int dvr_pad = 0; 674 + unsigned int ntuner = 0, ndemod = 0; 664 675 int ret, pad_source, pad_sink; 665 676 static const char *connector_name = "Television"; 666 677 ··· 784 795 media_device_for_each_entity(entity, mdev) { 785 796 if (entity->function == MEDIA_ENT_F_IO_DTV) { 786 797 if (!strncmp(entity->name, DVR_TSOUT, 787 - strlen(DVR_TSOUT))) { 798 + strlen(DVR_TSOUT))) { 788 799 ret = media_create_pad_link(demux, 789 - ++dvr_pad, 790 - entity, 0, 0); 800 + ++dvr_pad, 801 + entity, 0, 0); 791 802 if (ret) 792 803 return ret; 793 804 } 794 805 if (!strncmp(entity->name, DEMUX_TSOUT, 795 - strlen(DEMUX_TSOUT))) { 806 + strlen(DEMUX_TSOUT))) { 796 807 ret = media_create_pad_link(demux, 797 - ++demux_pad, 798 - entity, 0, 0); 808 + ++demux_pad, 809 + entity, 0, 0); 799 810 if (ret) 800 811 return ret; 801 812 } ··· 853 864 static int dvbdev_check_free_adapter_num(int num) 854 865 { 855 866 struct list_head *entry; 867 + 856 868 list_for_each(entry, &dvb_adapter_list) { 857 869 struct dvb_adapter *adap; 870 + 858 871 adap = list_entry(entry, struct dvb_adapter, list_head); 859 872 if (adap->num == num) 860 873 return 0; ··· 864 873 return 1; 865 874 } 866 875 867 - static int dvbdev_get_free_adapter_num (void) 876 + static int dvbdev_get_free_adapter_num(void) 868 877 { 869 878 int num = 0; 870 879 ··· 876 885 877 886 return -ENFILE; 878 887 } 879 - 880 888 881 889 int dvb_register_adapter(struct dvb_adapter *adap, const char *name, 882 890 struct module *module, struct device *device, ··· 903 913 return -ENFILE; 904 914 } 905 915 906 - memset (adap, 0, sizeof(struct dvb_adapter)); 907 - INIT_LIST_HEAD (&adap->device_list); 916 + memset(adap, 0, sizeof(struct dvb_adapter)); 917 + INIT_LIST_HEAD(&adap->device_list); 908 918 909 919 pr_info("DVB: registering new adapter (%s)\n", name); 910 920 ··· 914 924 adap->device = device; 915 925 adap->mfe_shared = 0; 916 926 adap->mfe_dvbdev = NULL; 917 - mutex_init (&adap->mfe_lock); 927 + mutex_init(&adap->mfe_lock); 918 928 919 929 #ifdef CONFIG_MEDIA_CONTROLLER_DVB 920 930 mutex_init(&adap->mdev_lock); 921 931 #endif 922 932 923 - list_add_tail (&adap->list_head, &dvb_adapter_list); 933 + list_add_tail(&adap->list_head, &dvb_adapter_list); 924 934 925 935 mutex_unlock(&dvbdev_register_lock); 926 936 ··· 928 938 } 929 939 EXPORT_SYMBOL(dvb_register_adapter); 930 940 931 - 932 941 int dvb_unregister_adapter(struct dvb_adapter *adap) 933 942 { 934 943 mutex_lock(&dvbdev_register_lock); 935 - list_del (&adap->list_head); 944 + list_del(&adap->list_head); 936 945 mutex_unlock(&dvbdev_register_lock); 937 946 return 0; 938 947 } 939 948 EXPORT_SYMBOL(dvb_unregister_adapter); 940 949 941 - /* if the miracle happens and "generic_usercopy()" is included into 942 - the kernel, then this can vanish. please don't make the mistake and 943 - define this as video_usercopy(). this will introduce a dependency 944 - to the v4l "videodev.o" module, which is unnecessary for some 945 - cards (ie. the budget dvb-cards don't need the v4l module...) */ 950 + /* 951 + * if the miracle happens and "generic_usercopy()" is included into 952 + * the kernel, then this can vanish. please don't make the mistake and 953 + * define this as video_usercopy(). this will introduce a dependency 954 + * to the v4l "videodev.o" module, which is unnecessary for some 955 + * cards (ie. the budget dvb-cards don't need the v4l module...) 956 + */ 946 957 int dvb_usercopy(struct file *file, 947 - unsigned int cmd, unsigned long arg, 948 - int (*func)(struct file *file, 949 - unsigned int cmd, void *arg)) 958 + unsigned int cmd, unsigned long arg, 959 + int (*func)(struct file *file, 960 + unsigned int cmd, void *arg)) 950 961 { 951 962 char sbuf[128]; 952 963 void *mbuf = NULL; ··· 961 970 * For this command, the pointer is actually an integer 962 971 * argument. 963 972 */ 964 - parg = (void *) arg; 973 + parg = (void *)arg; 965 974 break; 966 975 case _IOC_READ: /* some v4l ioctls are marked wrong ... */ 967 976 case _IOC_WRITE: ··· 971 980 } else { 972 981 /* too big to allocate from stack */ 973 982 mbuf = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL); 974 - if (NULL == mbuf) 983 + if (!mbuf) 975 984 return -ENOMEM; 976 985 parg = mbuf; 977 986 } ··· 983 992 } 984 993 985 994 /* call driver */ 986 - if ((err = func(file, cmd, parg)) == -ENOIOCTLCMD) 995 + err = func(file, cmd, parg); 996 + if (err == -ENOIOCTLCMD) 987 997 err = -ENOTTY; 988 998 989 999 if (err < 0) 990 1000 goto out; 991 1001 992 1002 /* Copy results into user buffer */ 993 - switch (_IOC_DIR(cmd)) 994 - { 1003 + switch (_IOC_DIR(cmd)) { 995 1004 case _IOC_READ: 996 1005 case (_IOC_WRITE | _IOC_READ): 997 1006 if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd))) ··· 1071 1080 dvbdev->adapter->num, dnames[dvbdev->type], dvbdev->id); 1072 1081 } 1073 1082 1074 - 1075 1083 static int __init init_dvbdev(void) 1076 1084 { 1077 1085 int retval; 1078 1086 dev_t dev = MKDEV(DVB_MAJOR, 0); 1079 1087 1080 - if ((retval = register_chrdev_region(dev, MAX_DVB_MINORS, "DVB")) != 0) { 1088 + retval = register_chrdev_region(dev, MAX_DVB_MINORS, "DVB"); 1089 + if (retval != 0) { 1081 1090 pr_err("dvb-core: unable to get major %d\n", DVB_MAJOR); 1082 1091 return retval; 1083 1092 } 1084 1093 1085 1094 cdev_init(&dvb_device_cdev, &dvb_device_fops); 1086 - if ((retval = cdev_add(&dvb_device_cdev, dev, MAX_DVB_MINORS)) != 0) { 1095 + retval = cdev_add(&dvb_device_cdev, dev, MAX_DVB_MINORS); 1096 + if (retval != 0) { 1087 1097 pr_err("dvb-core: unable register character device\n"); 1088 1098 goto error; 1089 1099 } ··· 1104 1112 return retval; 1105 1113 } 1106 1114 1107 - 1108 1115 static void __exit exit_dvbdev(void) 1109 1116 { 1110 1117 struct dvbdevfops_node *node, *next; ··· 1113 1122 unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), MAX_DVB_MINORS); 1114 1123 1115 1124 list_for_each_entry_safe(node, next, &dvbdevfops_list, list_head) { 1116 - list_del (&node->list_head); 1125 + list_del(&node->list_head); 1117 1126 kfree(node->fops); 1118 1127 kfree(node); 1119 1128 }