aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2012-02-17 00:44:10 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-03-08 08:39:56 -0500
commit3b2a63061ed69465cf851f93b7028ee8badb9d9c (patch)
treec96fffa5d0681069db9915dae088ed2d4035a8f0
parent6c61ac635535bbabf4f374df171372d012b0e822 (diff)
[media] s2255drv: fix some endian bugs
I don't have this hardware and I don't know the subsystem very well. So please review this patch carefully. The original code definitely looks buggy though. Sparse complains about some endian bugs where little endian bugs are treated as cpu endian. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Dean Anderson <linux-dev@sensoray.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/s2255drv.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index 350524246ce0..4894cbb1c547 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -134,7 +134,7 @@
134 134
135/* usb config commands */ 135/* usb config commands */
136#define IN_DATA_TOKEN cpu_to_le32(0x2255c0de) 136#define IN_DATA_TOKEN cpu_to_le32(0x2255c0de)
137#define CMD_2255 cpu_to_le32(0xc2255000) 137#define CMD_2255 0xc2255000
138#define CMD_SET_MODE cpu_to_le32((CMD_2255 | 0x10)) 138#define CMD_SET_MODE cpu_to_le32((CMD_2255 | 0x10))
139#define CMD_START cpu_to_le32((CMD_2255 | 0x20)) 139#define CMD_START cpu_to_le32((CMD_2255 | 0x20))
140#define CMD_STOP cpu_to_le32((CMD_2255 | 0x30)) 140#define CMD_STOP cpu_to_le32((CMD_2255 | 0x30))
@@ -2025,7 +2025,7 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
2025 pdata[1]); 2025 pdata[1]);
2026 offset = jj + PREFIX_SIZE; 2026 offset = jj + PREFIX_SIZE;
2027 bframe = 1; 2027 bframe = 1;
2028 cc = pdword[1]; 2028 cc = le32_to_cpu(pdword[1]);
2029 if (cc >= MAX_CHANNELS) { 2029 if (cc >= MAX_CHANNELS) {
2030 printk(KERN_ERR 2030 printk(KERN_ERR
2031 "bad channel\n"); 2031 "bad channel\n");
@@ -2034,22 +2034,22 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
2034 /* reverse it */ 2034 /* reverse it */
2035 dev->cc = G_chnmap[cc]; 2035 dev->cc = G_chnmap[cc];
2036 channel = &dev->channel[dev->cc]; 2036 channel = &dev->channel[dev->cc];
2037 payload = pdword[3]; 2037 payload = le32_to_cpu(pdword[3]);
2038 if (payload > channel->req_image_size) { 2038 if (payload > channel->req_image_size) {
2039 channel->bad_payload++; 2039 channel->bad_payload++;
2040 /* discard the bad frame */ 2040 /* discard the bad frame */
2041 return -EINVAL; 2041 return -EINVAL;
2042 } 2042 }
2043 channel->pkt_size = payload; 2043 channel->pkt_size = payload;
2044 channel->jpg_size = pdword[4]; 2044 channel->jpg_size = le32_to_cpu(pdword[4]);
2045 break; 2045 break;
2046 case S2255_MARKER_RESPONSE: 2046 case S2255_MARKER_RESPONSE:
2047 2047
2048 pdata += DEF_USB_BLOCK; 2048 pdata += DEF_USB_BLOCK;
2049 jj += DEF_USB_BLOCK; 2049 jj += DEF_USB_BLOCK;
2050 if (pdword[1] >= MAX_CHANNELS) 2050 if (le32_to_cpu(pdword[1]) >= MAX_CHANNELS)
2051 break; 2051 break;
2052 cc = G_chnmap[pdword[1]]; 2052 cc = G_chnmap[le32_to_cpu(pdword[1])];
2053 if (cc >= MAX_CHANNELS) 2053 if (cc >= MAX_CHANNELS)
2054 break; 2054 break;
2055 channel = &dev->channel[cc]; 2055 channel = &dev->channel[cc];
@@ -2072,11 +2072,11 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
2072 wake_up(&dev->fw_data->wait_fw); 2072 wake_up(&dev->fw_data->wait_fw);
2073 break; 2073 break;
2074 case S2255_RESPONSE_STATUS: 2074 case S2255_RESPONSE_STATUS:
2075 channel->vidstatus = pdword[3]; 2075 channel->vidstatus = le32_to_cpu(pdword[3]);
2076 channel->vidstatus_ready = 1; 2076 channel->vidstatus_ready = 1;
2077 wake_up(&channel->wait_vidstatus); 2077 wake_up(&channel->wait_vidstatus);
2078 dprintk(5, "got vidstatus %x chan %d\n", 2078 dprintk(5, "got vidstatus %x chan %d\n",
2079 pdword[3], cc); 2079 le32_to_cpu(pdword[3]), cc);
2080 break; 2080 break;
2081 default: 2081 default:
2082 printk(KERN_INFO "s2255 unknown resp\n"); 2082 printk(KERN_INFO "s2255 unknown resp\n");
@@ -2603,10 +2603,11 @@ static int s2255_probe(struct usb_interface *interface,
2603 __le32 *pRel; 2603 __le32 *pRel;
2604 pRel = (__le32 *) &dev->fw_data->fw->data[fw_size - 4]; 2604 pRel = (__le32 *) &dev->fw_data->fw->data[fw_size - 4];
2605 printk(KERN_INFO "s2255 dsp fw version %x\n", *pRel); 2605 printk(KERN_INFO "s2255 dsp fw version %x\n", *pRel);
2606 dev->dsp_fw_ver = *pRel; 2606 dev->dsp_fw_ver = le32_to_cpu(*pRel);
2607 if (*pRel < S2255_CUR_DSP_FWVER) 2607 if (dev->dsp_fw_ver < S2255_CUR_DSP_FWVER)
2608 printk(KERN_INFO "s2255: f2255usb.bin out of date.\n"); 2608 printk(KERN_INFO "s2255: f2255usb.bin out of date.\n");
2609 if (dev->pid == 0x2257 && *pRel < S2255_MIN_DSP_COLORFILTER) 2609 if (dev->pid == 0x2257 &&
2610 dev->dsp_fw_ver < S2255_MIN_DSP_COLORFILTER)
2610 printk(KERN_WARNING "s2255: 2257 requires firmware %d" 2611 printk(KERN_WARNING "s2255: 2257 requires firmware %d"
2611 " or above.\n", S2255_MIN_DSP_COLORFILTER); 2612 " or above.\n", S2255_MIN_DSP_COLORFILTER);
2612 } 2613 }