diff options
Diffstat (limited to 'drivers/staging/media/bcm2048/radio-bcm2048.c')
-rw-r--r-- | drivers/staging/media/bcm2048/radio-bcm2048.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c index d605c41..38f72d0 100644 --- a/drivers/staging/media/bcm2048/radio-bcm2048.c +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c @@ -177,12 +177,12 @@ #define BCM2048_FREQDEV_UNIT 10000 #define BCM2048_FREQV4L2_MULTI 625 -#define dev_to_v4l2(f) ((f * BCM2048_FREQDEV_UNIT) / BCM2048_FREQV4L2_MULTI) -#define v4l2_to_dev(f) ((f * BCM2048_FREQV4L2_MULTI) / BCM2048_FREQDEV_UNIT) +#define dev_to_v4l2(f) (((f) * BCM2048_FREQDEV_UNIT) / BCM2048_FREQV4L2_MULTI) +#define v4l2_to_dev(f) (((f) * BCM2048_FREQV4L2_MULTI) / BCM2048_FREQDEV_UNIT) -#define msb(x) ((u8)((u16)x >> 8)) -#define lsb(x) ((u8)((u16)x & 0x00FF)) -#define compose_u16(msb, lsb) (((u16)msb << 8) | lsb) +#define msb(x) ((u8)((u16)(x) >> 8)) +#define lsb(x) ((u8)((u16)(x) & 0x00FF)) +#define compose_u16(msb, lsb) (((u16)(msb) << 8) | (lsb)) #define BCM2048_DEFAULT_POWERING_DELAY 20 #define BCM2048_DEFAULT_REGION 0x02 @@ -1534,7 +1534,11 @@ static int bcm2048_parse_rt_match_c(struct bcm2048_device *bdev, int i, if (crc == BCM2048_RDS_CRC_UNRECOVARABLE) return 0; - BUG_ON((index+2) >= BCM2048_MAX_RDS_RT); + if ((index + 2) >= BCM2048_MAX_RDS_RT) { + dev_err(&bdev->client->dev, + "Incorrect index = %d\n", index); + return 0; + } if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) == BCM2048_RDS_BLOCK_C) { @@ -1557,7 +1561,11 @@ static void bcm2048_parse_rt_match_d(struct bcm2048_device *bdev, int i, if (crc == BCM2048_RDS_CRC_UNRECOVARABLE) return; - BUG_ON((index+4) >= BCM2048_MAX_RDS_RT); + if ((index + 4) >= BCM2048_MAX_RDS_RT) { + dev_err(&bdev->client->dev, + "Incorrect index = %d\n", index); + return; + } if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) == BCM2048_RDS_BLOCK_D) @@ -2008,7 +2016,7 @@ static ssize_t bcm2048_##prop##_read(struct device *dev, \ if (!bdev) \ return -ENODEV; \ \ - out = kzalloc(size + 1, GFP_KERNEL); \ + out = kzalloc((size) + 1, GFP_KERNEL); \ if (!out) \ return -ENOMEM; \ \ @@ -2634,7 +2642,7 @@ exit: return err; } -static int __exit bcm2048_i2c_driver_remove(struct i2c_client *client) +static int bcm2048_i2c_driver_remove(struct i2c_client *client) { struct bcm2048_device *bdev = i2c_get_clientdata(client); @@ -2673,7 +2681,7 @@ static struct i2c_driver bcm2048_i2c_driver = { .name = BCM2048_DRIVER_NAME, }, .probe = bcm2048_i2c_driver_probe, - .remove = __exit_p(bcm2048_i2c_driver_remove), + .remove = bcm2048_i2c_driver_remove, .id_table = bcm2048_id, }; |