.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | Driver for Zarlink VP310/MT312/ZL10313 Satellite Channel Decoder |
---|
3 | 4 | |
---|
4 | 5 | Copyright (C) 2003 Andreas Oberritter <obi@linuxtv.org> |
---|
5 | 6 | Copyright (C) 2008 Matthias Schwarzott <zzam@gentoo.org> |
---|
6 | 7 | |
---|
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. |
---|
21 | 8 | |
---|
22 | 9 | References: |
---|
23 | 10 | http://products.zarlink.com/product_profiles/MT312.htm |
---|
.. | .. |
---|
148 | 135 | return mt312_write(state, reg, &tmp, 1); |
---|
149 | 136 | } |
---|
150 | 137 | |
---|
151 | | -static inline u32 mt312_div(u32 a, u32 b) |
---|
152 | | -{ |
---|
153 | | - return (a + (b / 2)) / b; |
---|
154 | | -} |
---|
155 | | - |
---|
156 | 138 | static int mt312_reset(struct mt312_state *state, const u8 full) |
---|
157 | 139 | { |
---|
158 | 140 | return mt312_writereg(state, RESET, full ? 0x80 : 0x40); |
---|
.. | .. |
---|
200 | 182 | monitor = (buf[0] << 8) | buf[1]; |
---|
201 | 183 | |
---|
202 | 184 | dprintk("sr(auto) = %u\n", |
---|
203 | | - mt312_div(monitor * 15625, 4)); |
---|
| 185 | + DIV_ROUND_CLOSEST(monitor * 15625, 4)); |
---|
204 | 186 | } else { |
---|
205 | 187 | ret = mt312_writereg(state, MON_CTRL, 0x05); |
---|
206 | 188 | if (ret < 0) |
---|
.. | .. |
---|
304 | 286 | } |
---|
305 | 287 | |
---|
306 | 288 | /* 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); |
---|
308 | 290 | |
---|
309 | 291 | /* DISEQC_RATIO */ |
---|
310 | | - buf[1] = mt312_div(state->xtal, 22000 * 4); |
---|
| 292 | + buf[1] = DIV_ROUND_CLOSEST(state->xtal, 22000 * 4); |
---|
311 | 293 | |
---|
312 | 294 | ret = mt312_write(state, SYS_CLK, buf, sizeof(buf)); |
---|
313 | 295 | if (ret < 0) |
---|
.. | .. |
---|
623 | 605 | } |
---|
624 | 606 | |
---|
625 | 607 | /* 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); |
---|
627 | 609 | |
---|
628 | 610 | /* SYM_RATE */ |
---|
629 | 611 | buf[0] = (sr >> 8) & 0x3f; |
---|
.. | .. |
---|
645 | 627 | if (ret < 0) |
---|
646 | 628 | return ret; |
---|
647 | 629 | |
---|
648 | | - mt312_reset(state, 0); |
---|
| 630 | + ret = mt312_reset(state, 0); |
---|
| 631 | + if (ret < 0) |
---|
| 632 | + return ret; |
---|
649 | 633 | |
---|
650 | 634 | return 0; |
---|
651 | 635 | } |
---|
.. | .. |
---|
815 | 799 | |
---|
816 | 800 | switch (state->id) { |
---|
817 | 801 | 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)); |
---|
819 | 804 | state->xtal = MT312_PLL_CLK; |
---|
820 | 805 | state->freq_mult = 9; |
---|
821 | 806 | break; |
---|
822 | 807 | 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)); |
---|
824 | 810 | state->xtal = MT312_PLL_CLK; |
---|
825 | 811 | state->freq_mult = 6; |
---|
826 | 812 | break; |
---|
827 | 813 | 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)); |
---|
829 | 816 | state->xtal = MT312_PLL_CLK_10_111; |
---|
830 | 817 | state->freq_mult = 9; |
---|
831 | 818 | break; |
---|
.. | .. |
---|
840 | 827 | kfree(state); |
---|
841 | 828 | return NULL; |
---|
842 | 829 | } |
---|
843 | | -EXPORT_SYMBOL(mt312_attach); |
---|
| 830 | +EXPORT_SYMBOL_GPL(mt312_attach); |
---|
844 | 831 | |
---|
845 | 832 | module_param(debug, int, 0644); |
---|
846 | 833 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); |
---|