aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
diff options
context:
space:
mode:
authorPantelis Koukousoulas <pakt223@freemail.gr>2006-12-27 21:07:58 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-02-21 10:34:22 -0500
commit2fdf3d9c94f7f752dacbebb75bbecda3c1b082a0 (patch)
tree24d9c155095a642806cb3fee4210843936f220fe /drivers/media/video/pvrusb2/pvrusb2-sysfs.c
parent6fcb5b3ef758ca78461d390dc07bed5a4667c521 (diff)
V4L/DVB (5037): Pvrusb2: Implement multiple minor device number handling
This is the first patch in preparation of the V4L2/IVTV radio interface. It does away with the assumption of only one minor per device. It also adds a file to show the radio minor as well. This can be useful for a program like pvr-radio.c (when it grows up), since this way it can search for the minor of the /dev/radioX device it opened and use the video minor of the same driver instance to get to the actual stream. The implementation looks kinda ugly. Feel free to improve (that is the reason behind separate patches anyway). Signed-off-by: Pantelis Koukousoulas <pakt223@freemail.gr> Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-sysfs.c')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-sysfs.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index c294f46db9b9..d583c9777b6d 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -40,8 +40,10 @@ struct pvr2_sysfs {
40 struct pvr2_sysfs_ctl_item *item_first; 40 struct pvr2_sysfs_ctl_item *item_first;
41 struct pvr2_sysfs_ctl_item *item_last; 41 struct pvr2_sysfs_ctl_item *item_last;
42 struct class_device_attribute attr_v4l_minor_number; 42 struct class_device_attribute attr_v4l_minor_number;
43 struct class_device_attribute attr_v4l_radio_minor_number;
43 struct class_device_attribute attr_unit_number; 44 struct class_device_attribute attr_unit_number;
44 int v4l_minor_number_created_ok; 45 int v4l_minor_number_created_ok;
46 int v4l_radio_minor_number_created_ok;
45 int unit_number_created_ok; 47 int unit_number_created_ok;
46}; 48};
47 49
@@ -709,6 +711,10 @@ static void class_dev_destroy(struct pvr2_sysfs *sfp)
709 class_device_remove_file(sfp->class_dev, 711 class_device_remove_file(sfp->class_dev,
710 &sfp->attr_v4l_minor_number); 712 &sfp->attr_v4l_minor_number);
711 } 713 }
714 if (sfp->v4l_radio_minor_number_created_ok) {
715 class_device_remove_file(sfp->class_dev,
716 &sfp->attr_v4l_radio_minor_number);
717 }
712 if (sfp->unit_number_created_ok) { 718 if (sfp->unit_number_created_ok) {
713 class_device_remove_file(sfp->class_dev, 719 class_device_remove_file(sfp->class_dev,
714 &sfp->attr_unit_number); 720 &sfp->attr_unit_number);
@@ -726,7 +732,18 @@ static ssize_t v4l_minor_number_show(struct class_device *class_dev,char *buf)
726 sfp = (struct pvr2_sysfs *)class_dev->class_data; 732 sfp = (struct pvr2_sysfs *)class_dev->class_data;
727 if (!sfp) return -EINVAL; 733 if (!sfp) return -EINVAL;
728 return scnprintf(buf,PAGE_SIZE,"%d\n", 734 return scnprintf(buf,PAGE_SIZE,"%d\n",
729 pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw)); 735 pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,0));
736}
737
738
739static ssize_t v4l_radio_minor_number_show(struct class_device *class_dev,
740 char *buf)
741{
742 struct pvr2_sysfs *sfp;
743 sfp = (struct pvr2_sysfs *)class_dev->class_data;
744 if (!sfp) return -EINVAL;
745 return scnprintf(buf,PAGE_SIZE,"%d\n",
746 pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,2));
730} 747}
731 748
732 749
@@ -793,6 +810,20 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
793 sfp->v4l_minor_number_created_ok = !0; 810 sfp->v4l_minor_number_created_ok = !0;
794 } 811 }
795 812
813 sfp->attr_v4l_radio_minor_number.attr.owner = THIS_MODULE;
814 sfp->attr_v4l_radio_minor_number.attr.name = "v4l_radio_minor_number";
815 sfp->attr_v4l_radio_minor_number.attr.mode = S_IRUGO;
816 sfp->attr_v4l_radio_minor_number.show = v4l_radio_minor_number_show;
817 sfp->attr_v4l_radio_minor_number.store = NULL;
818 ret = class_device_create_file(sfp->class_dev,
819 &sfp->attr_v4l_radio_minor_number);
820 if (ret < 0) {
821 printk(KERN_WARNING "%s: class_device_create_file error: %d\n",
822 __FUNCTION__, ret);
823 } else {
824 sfp->v4l_radio_minor_number_created_ok = !0;
825 }
826
796 sfp->attr_unit_number.attr.owner = THIS_MODULE; 827 sfp->attr_unit_number.attr.owner = THIS_MODULE;
797 sfp->attr_unit_number.attr.name = "unit_number"; 828 sfp->attr_unit_number.attr.name = "unit_number";
798 sfp->attr_unit_number.attr.mode = S_IRUGO; 829 sfp->attr_unit_number.attr.mode = S_IRUGO;