hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/media/radio/wl128x/fmdrv_common.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * FM Driver for Connectivity chip of Texas Instruments.
34 *
....@@ -16,21 +17,13 @@
1617 * Copyright (C) 2011 Texas Instruments
1718 * Author: Raja Mani <raja_mani@ti.com>
1819 * Author: Manjunatha Halli <manjunatha_halli@ti.com>
19
- *
20
- * This program is free software; you can redistribute it and/or modify
21
- * it under the terms of the GNU General Public License version 2 as
22
- * published by the Free Software Foundation.
23
- *
24
- * This program is distributed in the hope that it will be useful,
25
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- * GNU General Public License for more details.
28
- *
2920 */
3021
31
-#include <linux/module.h>
32
-#include <linux/firmware.h>
3322 #include <linux/delay.h>
23
+#include <linux/firmware.h>
24
+#include <linux/module.h>
25
+#include <linux/nospec.h>
26
+
3427 #include "fmdrv.h"
3528 #include "fmdrv_v4l2.h"
3629 #include "fmdrv_common.h"
....@@ -253,7 +246,7 @@
253246 * FM common sub-module will schedule this tasklet whenever it receives
254247 * FM packet from ST driver.
255248 */
256
-static void recv_tasklet(unsigned long arg)
249
+static void recv_tasklet(struct tasklet_struct *t)
257250 {
258251 struct fmdev *fmdev;
259252 struct fm_irq *irq_info;
....@@ -262,7 +255,7 @@
262255 u8 num_fm_hci_cmds;
263256 unsigned long flags;
264257
265
- fmdev = (struct fmdev *)arg;
258
+ fmdev = from_tasklet(fmdev, t, tx_task);
266259 irq_info = &fmdev->irq_info;
267260 /* Process all packets in the RX queue */
268261 while ((skb = skb_dequeue(&fmdev->rx_q))) {
....@@ -337,13 +330,13 @@
337330 }
338331
339332 /* FM send tasklet: is scheduled when FM packet has to be sent to chip */
340
-static void send_tasklet(unsigned long arg)
333
+static void send_tasklet(struct tasklet_struct *t)
341334 {
342335 struct fmdev *fmdev;
343336 struct sk_buff *skb;
344337 int len;
345338
346
- fmdev = (struct fmdev *)arg;
339
+ fmdev = from_tasklet(fmdev, t, tx_task);
347340
348341 if (!atomic_read(&fmdev->tx_cnt))
349342 return;
....@@ -709,7 +702,7 @@
709702 struct fm_rds *rds = &fmdev->rx.rds;
710703 unsigned long group_idx, flags;
711704 u8 *rds_data, meta_data, tmpbuf[FM_RDS_BLK_SIZE];
712
- u8 type, blk_idx;
705
+ u8 type, blk_idx, idx;
713706 u16 cur_picode;
714707 u32 rds_len;
715708
....@@ -742,9 +735,11 @@
742735 }
743736
744737 /* Skip checkword (control) byte and copy only data byte */
745
- memcpy(&rds_fmt.data.groupdatabuff.
746
- buff[blk_idx * (FM_RDS_BLK_SIZE - 1)],
747
- rds_data, (FM_RDS_BLK_SIZE - 1));
738
+ idx = array_index_nospec(blk_idx * (FM_RDS_BLK_SIZE - 1),
739
+ FM_RX_RDS_INFO_FIELD_MAX - (FM_RDS_BLK_SIZE - 1));
740
+
741
+ memcpy(&rds_fmt.data.groupdatabuff.buff[idx], rds_data,
742
+ FM_RDS_BLK_SIZE - 1);
748743
749744 rds->last_blk_idx = blk_idx;
750745
....@@ -911,7 +906,7 @@
911906 u16 frq_index;
912907 u16 payload;
913908
914
- fmdbg("Swtich to %d KHz\n", fmdev->rx.stat_info.af_cache[fmdev->rx.afjump_idx]);
909
+ fmdbg("Switch to %d KHz\n", fmdev->rx.stat_info.af_cache[fmdev->rx.afjump_idx]);
915910 frq_index = (fmdev->rx.stat_info.af_cache[fmdev->rx.afjump_idx] -
916911 fmdev->rx.region.bot_freq) / FM_FREQ_MUL;
917912
....@@ -1050,7 +1045,7 @@
10501045 clear_bit(FM_INTTASK_RUNNING, &fmdev->flag);
10511046 }
10521047
1053
-/* Returns availability of RDS data in internel buffer */
1048
+/* Returns availability of RDS data in internal buffer */
10541049 int fmc_is_rds_data_available(struct fmdev *fmdev, struct file *file,
10551050 struct poll_table_struct *pts)
10561051 {
....@@ -1524,7 +1519,7 @@
15241519 }
15251520
15261521 ret = 0;
1527
- } else if (ret == -1) {
1522
+ } else if (ret < 0) {
15281523 fmerr("st_register failed %d\n", ret);
15291524 return -EAGAIN;
15301525 }
....@@ -1544,11 +1539,11 @@
15441539
15451540 /* Initialize TX queue and TX tasklet */
15461541 skb_queue_head_init(&fmdev->tx_q);
1547
- tasklet_init(&fmdev->tx_task, send_tasklet, (unsigned long)fmdev);
1542
+ tasklet_setup(&fmdev->tx_task, send_tasklet);
15481543
15491544 /* Initialize RX Queue and RX tasklet */
15501545 skb_queue_head_init(&fmdev->rx_q);
1551
- tasklet_init(&fmdev->rx_task, recv_tasklet, (unsigned long)fmdev);
1546
+ tasklet_setup(&fmdev->rx_task, recv_tasklet);
15521547
15531548 fmdev->irq_info.stage = 0;
15541549 atomic_set(&fmdev->tx_cnt, 1);