ivtv: Some general fixes
PATCH 1/2 ivtv: Some general fixes
Fix "warning: Using plain integer as NULL pointer". Remove a gcc-2.95 requirement.
Convert 'x < y ? x : y' to use min() instead.
---
Compile-tested on i386 with "allyesconfig" and "allmodconfig".
ivtv-driver.c | 2 +- ivtv-driver.h | 4 +--- ivtv-ioctl.c | 2 +- ivtv-irq.c | 4 ++-- ivtv-streams.c | 4 ++-- ivtvfb.c | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-)
drivers/media/video/ivtv/ivtv-driver.c +1 -1
@@ -979,7 +979,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev, } itv =kzalloc (sizeof (struct ivtv ),GFP_ATOMIC ); -if (itv ==0 ) { +if (itv ==NULL ) {spin_unlock (&ivtv_cards_lock);return -ENOMEM ; }
drivers/media/video/ivtv/ivtv-driver.h +1 -3
@@ -132,12 +132,10 @@ extern int ivtv_debug;/* Flag to turn on high volume debugging */ #define IVTV_DBGFLG_HIGHVOL (1 << 10) -/* NOTE: extra space before comma in 'itv->num , ## args' is required for -gcc-2.95, otherwise it won't compile. */ #define IVTV_DEBUG(x, type, fmt, args...) \ do { \ if ((x) & ivtv_debug) \ - printk(KERN_INFO "ivtv%d " type ": " fmt, itv->num , ## args); \ + printk(KERN_INFO "ivtv%d " type ": " fmt, itv->num, ## args); \ } while (0) #define IVTV_DEBUG_WARN(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_WARN, "warn", fmt , ## args) #define IVTV_DEBUG_INFO(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_INFO, "info", fmt , ## args)
drivers/media/video/ivtv/ivtv-ioctl.c +1 -1
@@ -688,7 +688,7 @@ static int ivtv_debug_ioctls(struct file *filp, unsigned int cmd, void *arg)ivtv_reset_ir_gpio (itv); }if (val &0x02 ) { - itv->video_dec_func (itv, cmd,0 ); + itv->video_dec_func (itv, cmd,NULL ); }break ; }
drivers/media/video/ivtv/ivtv-irq.c +2 -2
@@ -204,7 +204,7 @@ static int stream_enc_dma_append(struct ivtv_stream *s, u32 data[CX2341X_MBOX_MA s->sg_pending[idx].dst = buf->dma_handle; s->sg_pending[idx].src = offset; s->sg_pending[idx].size = s->buf_size; - buf->bytesused = (size < s->buf_size) ? size : s->buf_size; + buf->bytesused =min (size, s->buf_size); buf->dma_xfer_cnt = s->dma_xfer_cnt; s->q_predma.bytesused += buf->bytesused;
@@ -705,7 +705,7 @@ static void ivtv_irq_dec_data_req(struct ivtv *itv) s = &itv->streams[IVTV_DEC_STREAM_TYPE_YUV ]; }else { - itv->dma_data_req_size = data[2 ] >=0x10000 ?0x10000 : data[2 ]; + itv->dma_data_req_size =min_t (u32, data[2 ],0x10000 ); itv->dma_data_req_offset = data[1 ]; s = &itv->streams[IVTV_DEC_STREAM_TYPE_MPG ]; }
drivers/media/video/ivtv/ivtv-streams.c +2 -2
@@ -572,10 +572,10 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)clear_bit (IVTV_F_I_EOS , &itv->i_flags);/* Initialize Digitizer for Capture */ - itv->video_dec_func (itv,VIDIOC_STREAMOFF ,0 ); + itv->video_dec_func (itv,VIDIOC_STREAMOFF ,NULL );ivtv_msleep_timeout (300 ,1 );ivtv_vapi (itv,CX2341X_ENC_INITIALIZE_INPUT ,0 ); - itv->video_dec_func (itv,VIDIOC_STREAMON ,0 ); + itv->video_dec_func (itv,VIDIOC_STREAMON ,NULL ); }/* begin_capture */
drivers/media/video/ivtv/ivtvfb.c +1 -1
@@ -1053,7 +1053,7 @@ static int ivtvfb_init_card(struct ivtv *itv) } itv->osd_info =kzalloc (sizeof (struct osd_info ),GFP_ATOMIC ); -if (itv->osd_info ==0 ) { +if (itv->osd_info ==NULL ) {IVTVFB_ERR ("Failed to allocate memory for osd_info\n" );return -ENOMEM ; }
PATCH 2/2 ivtv: Remove a invalid shadow-variable
Remove the shadowing 'struct v4l2_chip_ident *chip', since it already exists and makes the if-statement useless.
---
Compile-tested on i386 with "allyesconfig" and "allmodconfig".
drivers/media/video/ivtv/ivtv-ioctl.c +1 -4
@@ -660,11 +660,8 @@ static int ivtv_debug_ioctls(struct file *filp, unsigned int cmd, void *arg) chip->ident =V4L2_IDENT_NONE ; chip->revision =0 ;if (reg->match_type ==V4L2_CHIP_MATCH_HOST ) { -if (v4l2_chip_match_host (reg->match_type, reg->match_chip)) { -struct v4l2_chip_ident *chip = arg; - +if (v4l2_chip_match_host (reg->match_type, reg->match_chip)) chip->ident = itv->has_cx23415 ?V4L2_IDENT_CX23415 :V4L2_IDENT_CX23416 ; - }return 0 ; }if (reg->match_type ==V4L2_CHIP_MATCH_I2C_DRIVER )
Re: [v4l-dvb-maintainer] [PATCH 2/2] ivtv: Remove a invalid shadow-variable
Quoted 4 lines · Richard Knutsson
Remove the shadowing 'struct
v4l2_chip_ident*chip', since it already exists and makes the if-statement useless.Signed-off-by Richard Knutsson <[email protected]>
Thanks,
Hans
Quoted 26 lines
---
Compile-tested on i386 with "allyesconfig" and "allmodconfig".(quoted diff) +0
-0
b/drivers/media/video/ivtv/ivtv-ioctl.cindex fd6826f..874aa22 100644drivers/media/video/ivtv/ivtv-ioctl.c +1
-3@@ -660,11 +660,8 @@ static int ivtv_debug_ioctls(struct file *filp, unsigned int cmd, void *arg) chip->ident = V4L2_IDENT_NONE; chip->revision =0 ;if (reg->match_type ==V4L2_CHIP_MATCH_HOST ) { -if (v4l2_chip_match_host (reg->match_type, reg->match_chip)) { -struct v4l2_chip_ident *chip = arg; - +if (v4l2_chip_match_host (reg->match_type, reg->match_chip)) chip->ident = itv->has_cx23415 ?V4L2_IDENT_CX23415 : V4L2_IDENT_CX23416; - }return 0 ; }if (reg->match_type ==V4L2_CHIP_MATCH_I2C_DRIVER )_______________________________________________
v4l-dvb-maintainer mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/v4l-dvb-maintainer
Quoted 1 line · Richard Knutsson
Fix "warning: Using plain integer as NULL pointer".
Quoted 1 line
Remove a gcc-2.95 requirement.
NACK! The main v4l-dvb repository that contains this driver can also be compiled on older systems. I'd like to keep the option that the driver can be compiled with an older gcc version, unless Mauro thinks otherwise. Other than the removal of one comment and one space there are no other benefits of this change, so I'd prefer to keep it.
Quoted 1 line
Convert 'x < y ? x : y' to use
min()instead.
Thanks,
Hans
Quoted 120 lines
Signed-off-by Richard Knutsson <[email protected]>---
Compile-tested on i386 with "allyesconfig" and "allmodconfig".ivtv-driver.c | 2 +- ivtv-driver.h | 4 +--- ivtv-ioctl.c | 2 +- ivtv-irq.c | 4 ++-- ivtv-streams.c | 4 ++-- ivtvfb.c | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-)(quoted diff) +0
-0
b/drivers/media/video/ivtv/ivtv-driver.cindex 6d2dd87..96f340c 100644drivers/media/video/ivtv/ivtv-driver.c +1
-1@@ -979,7 +979,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev, } itv =kzalloc (sizeof (struct ivtv ),GFP_ATOMIC ); -if (itv ==0 ) { +if (itv ==NULL ) {spin_unlock (&ivtv_cards_lock);return -ENOMEM ; }(quoted diff) +0
-0
b/drivers/media/video/ivtv/ivtv-driver.hindex 49ce14d..5c4956c 100644drivers/media/video/ivtv/ivtv-driver.h +0
-1@@ -132,12 +132,10 @@ extern int ivtv_debug;/* Flag to turn on high volume debugging */ #define IVTV_DBGFLG_HIGHVOL (1 << 10) -/* NOTE: extra space before comma in 'itv->num , ## args' is required for - gcc-2.95, otherwise it won't compile. */
#defineIVTV_DEBUG(x, type, fmt, args...)\drivers/media/video/ivtv/ivtv-driver.h +1
-1do { \if ((x) & ivtv_debug) \ - printk(KERN_INFO "ivtv%d " type ": " fmt, itv->num , ## args); \ + printk(KERN_INFO "ivtv%d " type ": " fmt, itv->num, ## args); \ } while (0) #define IVTV_DEBUG_WARN(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_WARN,"warn", fmt , ## args) #define
IVTV_DEBUG_INFO(fmt, args...)IVTV_DEBUG(IVTV_DBGFLG_INFO, "info", fmt , ## args)diff --gita/drivers/media/video/ivtv/ivtv-ioctl.cb/drivers/media/video/ivtv/ivtv-ioctl.cindex fd6826f..24270de 100644drivers/media/video/ivtv/ivtv-ioctl.c +1
-1@@ -688,7 +688,7 @@ static int ivtv_debug_ioctls(struct file *filp, unsigned int cmd, void *arg) ivtv_reset_ir_gpio(itv); }if (val &0x02 ) { - itv->video_dec_func (itv, cmd,0 ); + itv->video_dec_func (itv, cmd,NULL ); }break ; }(quoted diff) +0
-0
b/drivers/media/video/ivtv/ivtv-irq.cindex fd1688e..1384615 100644drivers/media/video/ivtv/ivtv-irq.c +0
-0@@ -204,7 +204,7 @@ static int stream_enc_dma_append(struct
ivtv_stream*s, u32 data[CX2341X_MBOX_MA s->sg_pending[idx].dst =buf->dma_handle;drivers/media/video/ivtv/ivtv-irq.c +2
-2s->sg_pending[idx].src = offset; s->sg_pending[idx].size = s->buf_size; - buf->bytesused = (size < s->buf_size) ? size : s->buf_size; + buf->bytesused =min (size, s->buf_size); buf->dma_xfer_cnt = s->dma_xfer_cnt; s->q_predma.bytesused += buf->bytesused;@@ -705,7 +705,7 @@ static void ivtv_irq_dec_data_req(struct ivtv *itv) s = &itv->streams[IVTV_DEC_STREAM_TYPE_YUV]; }else { - itv->dma_data_req_size = data[2 ] >=0x10000 ?0x10000 : data[2 ]; + itv->dma_data_req_size =min_t (u32, data[2 ],0x10000 ); itv->dma_data_req_offset = data[1 ]; s = &itv->streams[IVTV_DEC_STREAM_TYPE_MPG ]; }(quoted diff) +0
-0
b/drivers/media/video/ivtv/ivtv-streams.cindex aa03e61..0e9e7d0 100644drivers/media/video/ivtv/ivtv-streams.c +2
-2@@ -572,10 +572,10 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s) clear_bit(IVTV_F_I_EOS, &itv->i_flags);/* Initialize Digitizer for Capture */ - itv->video_dec_func (itv,VIDIOC_STREAMOFF ,0 ); + itv->video_dec_func (itv,VIDIOC_STREAMOFF ,NULL );ivtv_msleep_timeout (300 ,1 );ivtv_vapi (itv,CX2341X_ENC_INITIALIZE_INPUT ,0 ); - itv->video_dec_func (itv,VIDIOC_STREAMON ,0 ); + itv->video_dec_func (itv,VIDIOC_STREAMON ,NULL ); }/* begin_capture */ (quoted diff) +0
-0
b/drivers/media/video/ivtv/ivtvfb.cindex 52ffd15..f73ce98 100644drivers/media/video/ivtv/ivtvfb.c +1
-1@@ -1053,7 +1053,7 @@ static int ivtvfb_init_card(struct ivtv *itv) } itv->osd_info =kzalloc (sizeof (struct osd_info ),GFP_ATOMIC ); -if (itv->osd_info ==0 ) { +if (itv->osd_info ==NULL ) {IVTVFB_ERR ("Failed to allocate memory for osd_info\n" );return -ENOMEM ; }_______________________________________________
v4l-dvb-maintainer mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/v4l-dvb-maintainer
Quoted 5 lines · Hans Verkuil
Quoted 2 lines · Richard Knutsson
Fix "warning: Using plain integer as NULL pointer".
Quoted 9 lines
Signed-off-by Hans Verkuil <[email protected]>Quoted 2 lines
Remove a gcc-2.95 requirement.
NACK! The main v4l-dvb repository that contains this driver can also be compiled on older systems. I'd like to keep the option that the driver can be compiled with an older gcc version, unless Mauro thinks otherwise. Other than the removal of one comment and one space there are no other benefits of this change, so I'd prefer to keep it.
Oh alright, thought it was just a leftover since the support for the 2.95 ended.
Maybe add something to the text to let others know the status? (Since I found it by doing a 'grep' for "gcc 2.95"'s...)
Quoted 10 lines
Quoted 2 lines
Convert 'x < y ? x : y' to use
min()instead.Signed-off-by Hans Verkuil <[email protected]>Thanks,
Hans
Thanks for the fast turnaround
Richard
Em Dom, 2007-12-02 às 20:49 +0100, Hans Verkuil escreveu:
Quoted 7 lines · Richard Knutsson
Quoted 1 line
Fix "warning: Using plain integer as NULL pointer".
Signed-off-by Hans Verkuil <[email protected]>Quoted 1 line
Remove a gcc-2.95 requirement.
Quoted 7 lines
NACK! The main v4l-dvb repository that contains this driver can also be compiled on older systems. I'd like to keep the option that the driver can be compiled with an older gcc version, unless Mauro thinks otherwise. Other than the removal of one comment and one space there are no other benefits of this change, so I'd prefer to keep it.
From my POV, I don't see any reason to remove the required space to keep
gcc-2.95 compatibility.
The required extra whitespace is a small CodingStyle violation, but may help to use the same driver code for systems that still use gcc-2.95. So, it seems valid to keep this whitespace. Besides that, it is properly commented.
Cheers,
Mauro