These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / staging / media / bcm2048 / radio-bcm2048.c
index e9d0691..b10d601 100644 (file)
 #define BCM2048_FREQ_ERROR_FLOOR       -20
 #define BCM2048_FREQ_ERROR_ROOF                20
 
-/* -60 dB is reported as full signal strenght */
+/* -60 dB is reported as full signal strength */
 #define BCM2048_RSSI_LEVEL_BASE                -60
 #define BCM2048_RSSI_LEVEL_ROOF                -100
 #define BCM2048_RSSI_LEVEL_ROOF_NEG    100
@@ -342,14 +342,6 @@ static struct region_info region_configs[] = {
                .deemphasis             = 50,
                .region                 = 3,
        },
-       /* Japan wide band */
-       {
-               .channel_spacing        = 10,
-               .bottom_frequency       = 76000,
-               .top_frequency          = 108000,
-               .deemphasis             = 50,
-               .region                 = 4,
-       },
 };
 
 /*
@@ -621,7 +613,7 @@ static int bcm2048_set_fm_frequency(struct bcm2048_device *bdev, u32 frequency)
 static int bcm2048_get_fm_frequency(struct bcm2048_device *bdev)
 {
        int err;
-       u8 lsb, msb;
+       u8 lsb = 0, msb = 0;
 
        mutex_lock(&bdev->mutex);
 
@@ -666,7 +658,7 @@ static int bcm2048_set_fm_af_frequency(struct bcm2048_device *bdev,
 static int bcm2048_get_fm_af_frequency(struct bcm2048_device *bdev)
 {
        int err;
-       u8 lsb, msb;
+       u8 lsb = 0, msb = 0;
 
        mutex_lock(&bdev->mutex);
 
@@ -741,6 +733,18 @@ static int bcm2048_set_region(struct bcm2048_device *bdev, u8 region)
 
        mutex_lock(&bdev->mutex);
        bdev->region_info = region_configs[region];
+
+       if (region_configs[region].bottom_frequency < 87500)
+               bdev->cache_fm_ctrl |= BCM2048_BAND_SELECT;
+       else
+               bdev->cache_fm_ctrl &= ~BCM2048_BAND_SELECT;
+
+       err = bcm2048_send_command(bdev, BCM2048_I2C_FM_CTRL,
+                                       bdev->cache_fm_ctrl);
+       if (err) {
+               mutex_unlock(&bdev->mutex);
+               goto done;
+       }
        mutex_unlock(&bdev->mutex);
 
        if (bdev->frequency < region_configs[region].bottom_frequency ||
@@ -1048,7 +1052,7 @@ static int bcm2048_set_rds_b_block_mask(struct bcm2048_device *bdev, u16 mask)
 static int bcm2048_get_rds_b_block_mask(struct bcm2048_device *bdev)
 {
        int err;
-       u8 lsb, msb;
+       u8 lsb = 0, msb = 0;
 
        mutex_lock(&bdev->mutex);
 
@@ -1084,7 +1088,7 @@ static int bcm2048_set_rds_b_block_match(struct bcm2048_device *bdev,
 static int bcm2048_get_rds_b_block_match(struct bcm2048_device *bdev)
 {
        int err;
-       u8 lsb, msb;
+       u8 lsb = 0, msb = 0;
 
        mutex_lock(&bdev->mutex);
 
@@ -1119,7 +1123,7 @@ static int bcm2048_set_rds_pi_mask(struct bcm2048_device *bdev, u16 mask)
 static int bcm2048_get_rds_pi_mask(struct bcm2048_device *bdev)
 {
        int err;
-       u8 lsb, msb;
+       u8 lsb = 0, msb = 0;
 
        mutex_lock(&bdev->mutex);
 
@@ -1154,7 +1158,7 @@ static int bcm2048_set_rds_pi_match(struct bcm2048_device *bdev, u16 match)
 static int bcm2048_get_rds_pi_match(struct bcm2048_device *bdev)
 {
        int err;
-       u8 lsb, msb;
+       u8 lsb = 0, msb = 0;
 
        mutex_lock(&bdev->mutex);
 
@@ -1189,7 +1193,7 @@ static int bcm2048_set_fm_rds_mask(struct bcm2048_device *bdev, u16 mask)
 static int bcm2048_get_fm_rds_mask(struct bcm2048_device *bdev)
 {
        int err;
-       u8 value0, value1;
+       u8 value0 = 0, value1 = 0;
 
        mutex_lock(&bdev->mutex);
 
@@ -1207,7 +1211,7 @@ static int bcm2048_get_fm_rds_mask(struct bcm2048_device *bdev)
 static int bcm2048_get_fm_rds_flags(struct bcm2048_device *bdev)
 {
        int err;
-       u8 value0, value1;
+       u8 value0 = 0, value1 = 0;
 
        mutex_lock(&bdev->mutex);
 
@@ -1235,7 +1239,7 @@ static int bcm2048_get_region_top_frequency(struct bcm2048_device *bdev)
 static int bcm2048_set_fm_best_tune_mode(struct bcm2048_device *bdev, u8 mode)
 {
        int err;
-       u8 value;
+       u8 value = 0;
 
        mutex_lock(&bdev->mutex);
 
@@ -1909,7 +1913,7 @@ unlock:
 static void bcm2048_work(struct work_struct *work)
 {
        struct bcm2048_device *bdev;
-       u8 flag_lsb, flag_msb, flags;
+       u8 flag_lsb = 0, flag_msb = 0, flags;
 
        bdev = container_of(work, struct bcm2048_device, work);
        bcm2048_recv_command(bdev, BCM2048_I2C_FM_RDS_FLAG0, &flag_lsb);
@@ -2468,7 +2472,7 @@ static int bcm2048_vidioc_g_tuner(struct file *file, void *priv,
                } else {
                        /*
                         * RSSI level -60 dB is defined to report full
-                        * signal strenght
+                        * signal strength
                         */
                        rssi = bcm2048_get_fm_rssi(bdev);
                        if (rssi >= BCM2048_RSSI_LEVEL_BASE) {
@@ -2593,7 +2597,7 @@ static int bcm2048_i2c_driver_probe(struct i2c_client *client,
                                        const struct i2c_device_id *id)
 {
        struct bcm2048_device *bdev;
-       int err, skip_release = 0;
+       int err;
 
        bdev = kzalloc(sizeof(*bdev), GFP_KERNEL);
        if (!bdev) {
@@ -2646,7 +2650,6 @@ free_sysfs:
        bcm2048_sysfs_unregister_properties(bdev, ARRAY_SIZE(attrs));
 free_registration:
        video_unregister_device(&bdev->videodev);
-       skip_release = 1;
 free_irq:
        if (client->irq)
                free_irq(client->irq, bdev);