--- zzzz-none-000/linux-3.10.107/drivers/media/radio/wl128x/fmdrv_common.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/media/radio/wl128x/fmdrv_common.c 2021-02-04 17:41:59.000000000 +0000 @@ -175,7 +175,7 @@ fm_irq_handle_intmsk_cmd_resp }; -long (*g_st_write) (struct sk_buff *skb); +static long (*g_st_write) (struct sk_buff *skb); static struct completion wait_for_fmdrv_reg_comp; static inline void fm_irq_call(struct fmdev *fmdev) @@ -440,7 +440,7 @@ * command with u16 payload - convert to be16 */ if (payload != NULL) - *(u16 *)payload = cpu_to_be16(*(u16 *)payload); + *(__be16 *)payload = cpu_to_be16(*(u16 *)payload); } else if (payload != NULL) { fm_cb(skb)->fm_op = *((u8 *)payload + 2); @@ -595,7 +595,7 @@ skb_pull(skb, sizeof(struct fm_event_msg_hdr)); memcpy(&fmdev->irq_info.flag, skb->data, fm_evt_hdr->dlen); - fmdev->irq_info.flag = be16_to_cpu(fmdev->irq_info.flag); + fmdev->irq_info.flag = be16_to_cpu((__force __be16)fmdev->irq_info.flag); fmdbg("irq: flag register(0x%x)\n", fmdev->irq_info.flag); /* Continue next function in interrupt handler table */ @@ -689,7 +689,6 @@ static void fm_rdsparse_swapbytes(struct fmdev *fmdev, struct fm_rdsdata_format *rds_format) { - u8 byte1; u8 index = 0; u8 *rds_buff; @@ -701,9 +700,7 @@ if (fmdev->asci_id != 0x6350) { rds_buff = &rds_format->data.groupdatabuff.buff[0]; while (index + 1 < FM_RX_RDS_INFO_FIELD_MAX) { - byte1 = rds_buff[index]; - rds_buff[index] = rds_buff[index + 1]; - rds_buff[index + 1] = byte1; + swap(rds_buff[index], rds_buff[index + 1]); index += 2; } } @@ -715,7 +712,7 @@ struct fm_rdsdata_format rds_fmt; struct fm_rds *rds = &fmdev->rx.rds; unsigned long group_idx, flags; - u8 *rds_data, meta_data, tmpbuf[3]; + u8 *rds_data, meta_data, tmpbuf[FM_RDS_BLK_SIZE]; u8 type, blk_idx; u16 cur_picode; u32 rds_len; @@ -764,7 +761,7 @@ * Extract PI code and store in local cache. * We need this during AF switch processing. */ - cur_picode = be16_to_cpu(rds_fmt.data.groupgeneral.pidata); + cur_picode = be16_to_cpu((__force __be16)rds_fmt.data.groupgeneral.pidata); if (fmdev->rx.stat_info.picode != cur_picode) fmdev->rx.stat_info.picode = cur_picode; @@ -989,7 +986,7 @@ /* Skip header info and copy only response data */ skb_pull(skb, sizeof(struct fm_event_msg_hdr)); memcpy(&read_freq, skb->data, sizeof(read_freq)); - read_freq = be16_to_cpu(read_freq); + read_freq = be16_to_cpu((__force __be16)read_freq); curr_freq = fmdev->rx.region.bot_freq + ((u32)read_freq * FM_FREQ_MUL); jumped_freq = fmdev->rx.stat_info.af_cache[fmdev->rx.afjump_idx]; @@ -1073,6 +1070,7 @@ u8 __user *buf, size_t count) { u32 block_count; + u8 tmpbuf[FM_RDS_BLK_SIZE]; unsigned long flags; int ret; @@ -1087,29 +1085,32 @@ } /* Calculate block count from byte count */ - count /= 3; + count /= FM_RDS_BLK_SIZE; block_count = 0; ret = 0; - spin_lock_irqsave(&fmdev->rds_buff_lock, flags); - while (block_count < count) { - if (fmdev->rx.rds.wr_idx == fmdev->rx.rds.rd_idx) - break; + spin_lock_irqsave(&fmdev->rds_buff_lock, flags); - if (copy_to_user(buf, &fmdev->rx.rds.buff[fmdev->rx.rds.rd_idx], - FM_RDS_BLK_SIZE)) + if (fmdev->rx.rds.wr_idx == fmdev->rx.rds.rd_idx) { + spin_unlock_irqrestore(&fmdev->rds_buff_lock, flags); break; - + } + memcpy(tmpbuf, &fmdev->rx.rds.buff[fmdev->rx.rds.rd_idx], + FM_RDS_BLK_SIZE); fmdev->rx.rds.rd_idx += FM_RDS_BLK_SIZE; if (fmdev->rx.rds.rd_idx >= fmdev->rx.rds.buf_size) fmdev->rx.rds.rd_idx = 0; + spin_unlock_irqrestore(&fmdev->rds_buff_lock, flags); + + if (copy_to_user(buf, tmpbuf, FM_RDS_BLK_SIZE)) + break; + block_count++; buf += FM_RDS_BLK_SIZE; ret += FM_RDS_BLK_SIZE; } - spin_unlock_irqrestore(&fmdev->rds_buff_lock, flags); return ret; } @@ -1252,7 +1253,7 @@ fmerr("Unable to read firmware(%s) content\n", fw_name); return ret; } - fmdbg("Firmware(%s) length : %d bytes\n", fw_name, fw_entry->size); + fmdbg("Firmware(%s) length : %zu bytes\n", fw_name, fw_entry->size); fw_data = (void *)fw_entry->data; fw_len = fw_entry->size; @@ -1313,7 +1314,8 @@ /* Does FM power on sequence */ static int fm_power_up(struct fmdev *fmdev, u8 mode) { - u16 payload, asic_id, asic_ver; + u16 payload; + __be16 asic_id, asic_ver; int resp_len, ret; u8 fw_name[50];