hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/media/dvb-frontends/mt312.c
....@@ -1,23 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 Driver for Zarlink VP310/MT312/ZL10313 Satellite Channel Decoder
34
45 Copyright (C) 2003 Andreas Oberritter <obi@linuxtv.org>
56 Copyright (C) 2008 Matthias Schwarzott <zzam@gentoo.org>
67
7
- This program is free software; you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation; either version 2 of the License, or
10
- (at your option) any later version.
11
-
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
-
16
- GNU General Public License for more details.
17
-
18
- You should have received a copy of the GNU General Public License
19
- along with this program; if not, write to the Free Software
20
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
218
229 References:
2310 http://products.zarlink.com/product_profiles/MT312.htm
....@@ -148,11 +135,6 @@
148135 return mt312_write(state, reg, &tmp, 1);
149136 }
150137
151
-static inline u32 mt312_div(u32 a, u32 b)
152
-{
153
- return (a + (b / 2)) / b;
154
-}
155
-
156138 static int mt312_reset(struct mt312_state *state, const u8 full)
157139 {
158140 return mt312_writereg(state, RESET, full ? 0x80 : 0x40);
....@@ -200,7 +182,7 @@
200182 monitor = (buf[0] << 8) | buf[1];
201183
202184 dprintk("sr(auto) = %u\n",
203
- mt312_div(monitor * 15625, 4));
185
+ DIV_ROUND_CLOSEST(monitor * 15625, 4));
204186 } else {
205187 ret = mt312_writereg(state, MON_CTRL, 0x05);
206188 if (ret < 0)
....@@ -304,10 +286,10 @@
304286 }
305287
306288 /* SYS_CLK */
307
- buf[0] = mt312_div(state->xtal * state->freq_mult * 2, 1000000);
289
+ buf[0] = DIV_ROUND_CLOSEST(state->xtal * state->freq_mult * 2, 1000000);
308290
309291 /* DISEQC_RATIO */
310
- buf[1] = mt312_div(state->xtal, 22000 * 4);
292
+ buf[1] = DIV_ROUND_CLOSEST(state->xtal, 22000 * 4);
311293
312294 ret = mt312_write(state, SYS_CLK, buf, sizeof(buf));
313295 if (ret < 0)
....@@ -623,7 +605,7 @@
623605 }
624606
625607 /* sr = (u16)(sr * 256.0 / 1000000.0) */
626
- sr = mt312_div(p->symbol_rate * 4, 15625);
608
+ sr = DIV_ROUND_CLOSEST(p->symbol_rate * 4, 15625);
627609
628610 /* SYM_RATE */
629611 buf[0] = (sr >> 8) & 0x3f;
....@@ -645,7 +627,9 @@
645627 if (ret < 0)
646628 return ret;
647629
648
- mt312_reset(state, 0);
630
+ ret = mt312_reset(state, 0);
631
+ if (ret < 0)
632
+ return ret;
649633
650634 return 0;
651635 }
....@@ -815,17 +799,20 @@
815799
816800 switch (state->id) {
817801 case ID_VP310:
818
- strcpy(state->frontend.ops.info.name, "Zarlink VP310 DVB-S");
802
+ strscpy(state->frontend.ops.info.name, "Zarlink VP310 DVB-S",
803
+ sizeof(state->frontend.ops.info.name));
819804 state->xtal = MT312_PLL_CLK;
820805 state->freq_mult = 9;
821806 break;
822807 case ID_MT312:
823
- strcpy(state->frontend.ops.info.name, "Zarlink MT312 DVB-S");
808
+ strscpy(state->frontend.ops.info.name, "Zarlink MT312 DVB-S",
809
+ sizeof(state->frontend.ops.info.name));
824810 state->xtal = MT312_PLL_CLK;
825811 state->freq_mult = 6;
826812 break;
827813 case ID_ZL10313:
828
- strcpy(state->frontend.ops.info.name, "Zarlink ZL10313 DVB-S");
814
+ strscpy(state->frontend.ops.info.name, "Zarlink ZL10313 DVB-S",
815
+ sizeof(state->frontend.ops.info.name));
829816 state->xtal = MT312_PLL_CLK_10_111;
830817 state->freq_mult = 9;
831818 break;
....@@ -840,7 +827,7 @@
840827 kfree(state);
841828 return NULL;
842829 }
843
-EXPORT_SYMBOL(mt312_attach);
830
+EXPORT_SYMBOL_GPL(mt312_attach);
844831
845832 module_param(debug, int, 0644);
846833 MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");