aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2006-12-27 21:11:22 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-02-21 10:34:23 -0500
commitfd5a75fe00ec13311289928c2cb17d8676f8db45 (patch)
tree478dcf0445fc17e64df4036e391106522b54bdea /drivers
parentae2b9e25fdfb63efed3659b19c5cc8778fd981ba (diff)
V4L/DVB (5040): Pvrusb2: Use enumeration for minor number get / store code
Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h3
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c23
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.h5
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-sysfs.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c8
5 files changed, 28 insertions, 17 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
index 4f69431a8f4e..e6d546f56d31 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
@@ -283,7 +283,8 @@ struct pvr2_hdw {
283 283
284 /* Minor numbers used by v4l logic (yes, this is a hack, as there 284 /* Minor numbers used by v4l logic (yes, this is a hack, as there
285 should be no v4l junk here). Probably a better way to do this. */ 285 should be no v4l junk here). Probably a better way to do this. */
286 int v4l_minor_number[3]; 286 int v4l_minor_number_mpeg;
287 int v4l_minor_number_radio;
287 288
288 /* Location of eeprom or a negative number if none */ 289 /* Location of eeprom or a negative number if none */
289 int eeprom_addr; 290 int eeprom_addr;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 4b45299e187d..6acd73ca9ed3 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -1898,9 +1898,8 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
1898 1898
1899 hdw->eeprom_addr = -1; 1899 hdw->eeprom_addr = -1;
1900 hdw->unit_number = -1; 1900 hdw->unit_number = -1;
1901 hdw->v4l_minor_number[0] = -1; 1901 hdw->v4l_minor_number_mpeg = -1;
1902 hdw->v4l_minor_number[1] = -1; 1902 hdw->v4l_minor_number_radio = -1;
1903 hdw->v4l_minor_number[2] = -1;
1904 hdw->ctl_write_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL); 1903 hdw->ctl_write_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL);
1905 if (!hdw->ctl_write_buffer) goto fail; 1904 if (!hdw->ctl_write_buffer) goto fail;
1906 hdw->ctl_read_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL); 1905 hdw->ctl_read_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL);
@@ -2548,16 +2547,26 @@ int pvr2_hdw_cpufw_get(struct pvr2_hdw *hdw,unsigned int offs,
2548} 2547}
2549 2548
2550 2549
2551int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *hdw,int index) 2550int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *hdw,
2551 enum pvr2_config index)
2552{ 2552{
2553 return hdw->v4l_minor_number[index]; 2553 switch (index) {
2554 case pvr2_config_mpeg: return hdw->v4l_minor_number_mpeg;
2555 case pvr2_config_radio: return hdw->v4l_minor_number_radio;
2556 default: return -1;
2557 }
2554} 2558}
2555 2559
2556 2560
2557/* Store a v4l minor device number */ 2561/* Store a v4l minor device number */
2558void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,int index,int v) 2562void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,
2563 enum pvr2_config index,int v)
2559{ 2564{
2560 hdw->v4l_minor_number[index] = v; 2565 switch (index) {
2566 case pvr2_config_mpeg: hdw->v4l_minor_number_mpeg = v;
2567 case pvr2_config_radio: hdw->v4l_minor_number_radio = v;
2568 default: break;
2569 }
2561} 2570}
2562 2571
2563 2572
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
index b1d80bd2678c..fa3769a244a1 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -206,10 +206,11 @@ int pvr2_hdw_cpufw_get(struct pvr2_hdw *,unsigned int offs,
206 char *buf,unsigned int cnt); 206 char *buf,unsigned int cnt);
207 207
208/* Retrieve a previously stored v4l minor device number */ 208/* Retrieve a previously stored v4l minor device number */
209int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *,int); 209int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *,enum pvr2_config index);
210 210
211/* Store a v4l minor device number */ 211/* Store a v4l minor device number */
212void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int,int); 212void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,
213 enum pvr2_config index,int);
213 214
214/* Direct read/write access to chip's registers: 215/* Direct read/write access to chip's registers:
215 chip_id - unique id of chip (e.g. I2C_DRIVERD_xxxx) 216 chip_id - unique id of chip (e.g. I2C_DRIVERD_xxxx)
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index d583c9777b6d..0f8021e2dd06 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -732,7 +732,8 @@ static ssize_t v4l_minor_number_show(struct class_device *class_dev,char *buf)
732 sfp = (struct pvr2_sysfs *)class_dev->class_data; 732 sfp = (struct pvr2_sysfs *)class_dev->class_data;
733 if (!sfp) return -EINVAL; 733 if (!sfp) return -EINVAL;
734 return scnprintf(buf,PAGE_SIZE,"%d\n", 734 return scnprintf(buf,PAGE_SIZE,"%d\n",
735 pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,0)); 735 pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,
736 pvr2_config_mpeg));
736} 737}
737 738
738 739
@@ -743,7 +744,8 @@ static ssize_t v4l_radio_minor_number_show(struct class_device *class_dev,
743 sfp = (struct pvr2_sysfs *)class_dev->class_data; 744 sfp = (struct pvr2_sysfs *)class_dev->class_data;
744 if (!sfp) return -EINVAL; 745 if (!sfp) return -EINVAL;
745 return scnprintf(buf,PAGE_SIZE,"%d\n", 746 return scnprintf(buf,PAGE_SIZE,"%d\n",
746 pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,2)); 747 pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,
748 pvr2_config_radio));
747} 749}
748 750
749 751
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 3cea6101e9f0..4acbbc71f7e0 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -725,11 +725,9 @@ static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
725static void pvr2_v4l2_destroy_no_lock(struct pvr2_v4l2 *vp) 725static void pvr2_v4l2_destroy_no_lock(struct pvr2_v4l2 *vp)
726{ 726{
727 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw, 727 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
728 pvr2_config_mpeg-1,-1); 728 pvr2_config_mpeg,-1);
729 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw, 729 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
730 pvr2_config_vbi-1,-1); 730 pvr2_config_radio,-1);
731 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
732 pvr2_config_radio-1,-1);
733 pvr2_v4l2_dev_destroy(vp->vdev); 731 pvr2_v4l2_dev_destroy(vp->vdev);
734 732
735 pvr2_trace(PVR2_TRACE_STRUCT,"Destroying pvr2_v4l2 id=%p",vp); 733 pvr2_trace(PVR2_TRACE_STRUCT,"Destroying pvr2_v4l2 id=%p",vp);
@@ -1135,7 +1133,7 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
1135 } 1133 }
1136 1134
1137 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw, 1135 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
1138 cfg-1,dip->devbase.minor); 1136 cfg,dip->devbase.minor);
1139} 1137}
1140 1138
1141 1139