]> err.no Git - linux-2.6/commitdiff
V4L/DVB (5040): Pvrusb2: Use enumeration for minor number get / store code
authorMike Isely <isely@pobox.com>
Thu, 28 Dec 2006 02:11:22 +0000 (23:11 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 21 Feb 2007 15:34:23 +0000 (13:34 -0200)
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
drivers/media/video/pvrusb2/pvrusb2-hdw.c
drivers/media/video/pvrusb2/pvrusb2-hdw.h
drivers/media/video/pvrusb2/pvrusb2-sysfs.c
drivers/media/video/pvrusb2/pvrusb2-v4l2.c

index 4f69431a8f4ee5c2b5a0d86012f0851c8c54f28f..e6d546f56d311aa2432996d7af92f4210838bc9a 100644 (file)
@@ -283,7 +283,8 @@ struct pvr2_hdw {
 
        /* Minor numbers used by v4l logic (yes, this is a hack, as there
           should be no v4l junk here).  Probably a better way to do this. */
-       int v4l_minor_number[3];
+       int v4l_minor_number_mpeg;
+       int v4l_minor_number_radio;
 
        /* Location of eeprom or a negative number if none */
        int eeprom_addr;
index 4b45299e187d2dc3a6bfc75fd8b7aa2bc2cfb97f..6acd73ca9ed34a83792247cc80f30419f1791fda 100644 (file)
@@ -1898,9 +1898,8 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
 
        hdw->eeprom_addr = -1;
        hdw->unit_number = -1;
-       hdw->v4l_minor_number[0] = -1;
-       hdw->v4l_minor_number[1] = -1;
-       hdw->v4l_minor_number[2] = -1;
+       hdw->v4l_minor_number_mpeg = -1;
+       hdw->v4l_minor_number_radio = -1;
        hdw->ctl_write_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL);
        if (!hdw->ctl_write_buffer) goto fail;
        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,
 }
 
 
-int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *hdw,int index)
+int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *hdw,
+                                 enum pvr2_config index)
 {
-       return hdw->v4l_minor_number[index];
+       switch (index) {
+       case pvr2_config_mpeg: return hdw->v4l_minor_number_mpeg;
+       case pvr2_config_radio: return hdw->v4l_minor_number_radio;
+       default: return -1;
+       }
 }
 
 
 /* Store a v4l minor device number */
-void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,int index,int v)
+void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,
+                                    enum pvr2_config index,int v)
 {
-       hdw->v4l_minor_number[index] = v;
+       switch (index) {
+       case pvr2_config_mpeg: hdw->v4l_minor_number_mpeg = v;
+       case pvr2_config_radio: hdw->v4l_minor_number_radio = v;
+       default: break;
+       }
 }
 
 
index b1d80bd2678cb6eebea5c199e5780a34bf624651..fa3769a244a1a238fed4be8332f5bc154c769df3 100644 (file)
@@ -206,10 +206,11 @@ int pvr2_hdw_cpufw_get(struct pvr2_hdw *,unsigned int offs,
                       char *buf,unsigned int cnt);
 
 /* Retrieve a previously stored v4l minor device number */
-int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *,int);
+int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *,enum pvr2_config index);
 
 /* Store a v4l minor device number */
-void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int,int);
+void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,
+                                    enum pvr2_config index,int);
 
 /* Direct read/write access to chip's registers:
    chip_id - unique id of chip (e.g. I2C_DRIVERD_xxxx)
index d583c9777b6deb0537a8777ff0413ab6b9da5aab..0f8021e2dd068d1078bd71dd4403c66d662cd804 100644 (file)
@@ -732,7 +732,8 @@ static ssize_t v4l_minor_number_show(struct class_device *class_dev,char *buf)
        sfp = (struct pvr2_sysfs *)class_dev->class_data;
        if (!sfp) return -EINVAL;
        return scnprintf(buf,PAGE_SIZE,"%d\n",
-                        pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,0));
+                        pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,
+                                                      pvr2_config_mpeg));
 }
 
 
@@ -743,7 +744,8 @@ static ssize_t v4l_radio_minor_number_show(struct class_device *class_dev,
        sfp = (struct pvr2_sysfs *)class_dev->class_data;
        if (!sfp) return -EINVAL;
        return scnprintf(buf,PAGE_SIZE,"%d\n",
-                        pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,2));
+                        pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,
+                                                      pvr2_config_radio));
 }
 
 
index 3cea6101e9f0a74b7deda97104f54ce67ac51ca6..4acbbc71f7e00cc6e84da2ac1cbd5de482698f2d 100644 (file)
@@ -725,11 +725,9 @@ static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
 static void pvr2_v4l2_destroy_no_lock(struct pvr2_v4l2 *vp)
 {
        pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
-                                       pvr2_config_mpeg-1,-1);
+                                       pvr2_config_mpeg,-1);
        pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
-                                       pvr2_config_vbi-1,-1);
-       pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
-                                       pvr2_config_radio-1,-1);
+                                       pvr2_config_radio,-1);
        pvr2_v4l2_dev_destroy(vp->vdev);
 
        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,
        }
 
        pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
-                                       cfg-1,dip->devbase.minor);
+                                       cfg,dip->devbase.minor);
 }