media: si2165: Make checkpatch happy

Fix almost all of checkpatch --strict warnings.

The remaining warnings are about:
* macro REG16 (should be enclosed in parentheses)
* macro REG16 (Macro argument reuse)

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
Matthias Schwarzott 2017-11-05 09:24:59 -05:00 committed by Mauro Carvalho Chehab
parent 1b54da77f3
commit 7dbbb4bf1e
5 changed files with 86 additions and 79 deletions

View file

@ -67,7 +67,8 @@ static int si2165_write(struct si2165_state *state, const u16 reg,
{ {
int ret; int ret;
dev_dbg(&state->client->dev, "i2c write: reg: 0x%04x, data: %*ph\n", reg, count, src); dev_dbg(&state->client->dev, "i2c write: reg: 0x%04x, data: %*ph\n",
reg, count, src);
ret = regmap_bulk_write(state->regmap, reg, src, count); ret = regmap_bulk_write(state->regmap, reg, src, count);
@ -88,7 +89,8 @@ static int si2165_read(struct si2165_state *state,
return ret; return ret;
} }
dev_dbg(&state->client->dev, "i2c read: reg: 0x%04x, data: %*ph\n", reg, count, val); dev_dbg(&state->client->dev, "i2c read: reg: 0x%04x, data: %*ph\n",
reg, count, val);
return 0; return 0;
} }
@ -161,7 +163,9 @@ static int si2165_writereg_mask8(struct si2165_state *state, const u16 reg,
return si2165_writereg8(state, reg, val); return si2165_writereg8(state, reg, val);
} }
#define REG16(reg, val) { (reg), (val) & 0xff }, { (reg)+1, (val)>>8 & 0xff } #define REG16(reg, val) \
{ (reg), (val) & 0xff }, \
{ (reg) + 1, (val) >> 8 & 0xff }
struct si2165_reg_value_pair { struct si2165_reg_value_pair {
u16 reg; u16 reg;
u8 val; u8 val;
@ -191,7 +195,7 @@ static int si2165_get_tune_settings(struct dvb_frontend *fe,
static int si2165_init_pll(struct si2165_state *state) static int si2165_init_pll(struct si2165_state *state)
{ {
u32 ref_freq_Hz = state->config.ref_freq_Hz; u32 ref_freq_hz = state->config.ref_freq_hz;
u8 divr = 1; /* 1..7 */ u8 divr = 1; /* 1..7 */
u8 divp = 1; /* only 1 or 4 */ u8 divp = 1; /* only 1 or 4 */
u8 divn = 56; /* 1..63 */ u8 divn = 56; /* 1..63 */
@ -203,7 +207,7 @@ static int si2165_init_pll(struct si2165_state *state)
* hardcoded values can be deleted if calculation is verified * hardcoded values can be deleted if calculation is verified
* or it yields the same values as the windows driver * or it yields the same values as the windows driver
*/ */
switch (ref_freq_Hz) { switch (ref_freq_hz) {
case 16000000u: case 16000000u:
divn = 56; divn = 56;
break; break;
@ -214,23 +218,23 @@ static int si2165_init_pll(struct si2165_state *state)
break; break;
default: default:
/* ref_freq / divr must be between 4 and 16 MHz */ /* ref_freq / divr must be between 4 and 16 MHz */
if (ref_freq_Hz > 16000000u) if (ref_freq_hz > 16000000u)
divr = 2; divr = 2;
/* /*
* now select divn and divp such that * now select divn and divp such that
* fvco is in 1624..1824 MHz * fvco is in 1624..1824 MHz
*/ */
if (1624000000u * divr > ref_freq_Hz * 2u * 63u) if (1624000000u * divr > ref_freq_hz * 2u * 63u)
divp = 4; divp = 4;
/* is this already correct regarding rounding? */ /* is this already correct regarding rounding? */
divn = 1624000000u * divr / (ref_freq_Hz * 2u * divp); divn = 1624000000u * divr / (ref_freq_hz * 2u * divp);
break; break;
} }
/* adc_clk and sys_clk depend on xtal and pll settings */ /* adc_clk and sys_clk depend on xtal and pll settings */
state->fvco_hz = ref_freq_Hz / divr state->fvco_hz = ref_freq_hz / divr
* 2u * divn * divp; * 2u * divn * divp;
state->adc_clk = state->fvco_hz / (divm * 4u); state->adc_clk = state->fvco_hz / (divm * 4u);
state->sys_clk = state->fvco_hz / (divl * 2u); state->sys_clk = state->fvco_hz / (divl * 2u);
@ -272,7 +276,8 @@ static int si2165_wait_init_done(struct si2165_state *state)
} }
static int si2165_upload_firmware_block(struct si2165_state *state, static int si2165_upload_firmware_block(struct si2165_state *state,
const u8 *data, u32 len, u32 *poffset, u32 block_count) const u8 *data, u32 len, u32 *poffset,
u32 block_count)
{ {
int ret; int ret;
u8 buf_ctrl[4] = { 0x00, 0x00, 0x00, 0xc0 }; u8 buf_ctrl[4] = { 0x00, 0x00, 0x00, 0xc0 };
@ -286,12 +291,12 @@ static int si2165_upload_firmware_block(struct si2165_state *state,
return -EINVAL; return -EINVAL;
dev_dbg(&state->client->dev, dev_dbg(&state->client->dev,
"fw load: si2165_upload_firmware_block called with len=0x%x offset=0x%x blockcount=0x%x\n", "fw load: %s: called with len=0x%x offset=0x%x blockcount=0x%x\n",
len, offset, block_count); __func__, len, offset, block_count);
while (offset + 12 <= len && cur_block < block_count) { while (offset + 12 <= len && cur_block < block_count) {
dev_dbg(&state->client->dev, dev_dbg(&state->client->dev,
"fw load: si2165_upload_firmware_block in while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n", "fw load: %s: in while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n",
len, offset, cur_block, block_count); __func__, len, offset, cur_block, block_count);
wordcount = data[offset]; wordcount = data[offset];
if (wordcount < 1 || data[offset + 1] || if (wordcount < 1 || data[offset + 1] ||
data[offset + 2] || data[offset + 3]) { data[offset + 2] || data[offset + 3]) {
@ -330,15 +335,15 @@ static int si2165_upload_firmware_block(struct si2165_state *state,
} }
dev_dbg(&state->client->dev, dev_dbg(&state->client->dev,
"fw load: si2165_upload_firmware_block after while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n", "fw load: %s: after while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n",
len, offset, cur_block, block_count); __func__, len, offset, cur_block, block_count);
if (poffset) if (poffset)
*poffset = offset; *poffset = offset;
dev_dbg(&state->client->dev, dev_dbg(&state->client->dev,
"fw load: si2165_upload_firmware_block returned offset=0x%x\n", "fw load: %s: returned offset=0x%x\n",
offset); __func__, offset);
return 0; return 0;
error: error:
@ -436,8 +441,8 @@ static int si2165_upload_firmware(struct si2165_state *state)
/* start right after the header */ /* start right after the header */
offset = 8; offset = 8;
dev_info(&state->client->dev, "si2165_upload_firmware extracted patch_version=0x%02x, block_count=0x%02x, crc_expected=0x%04x\n", dev_info(&state->client->dev, "%s: extracted patch_version=0x%02x, block_count=0x%02x, crc_expected=0x%04x\n",
patch_version, block_count, crc_expected); __func__, patch_version, block_count, crc_expected);
ret = si2165_upload_firmware_block(state, data, len, &offset, 1); ret = si2165_upload_firmware_block(state, data, len, &offset, 1);
if (ret < 0) if (ret < 0)
@ -979,8 +984,8 @@ static int si2165_probe(struct i2c_client *client,
}; };
/* allocate memory for the internal state */ /* allocate memory for the internal state */
state = kzalloc(sizeof(struct si2165_state), GFP_KERNEL); state = kzalloc(sizeof(*state), GFP_KERNEL);
if (state == NULL) { if (!state) {
ret = -ENOMEM; ret = -ENOMEM;
goto error; goto error;
} }
@ -996,13 +1001,13 @@ static int si2165_probe(struct i2c_client *client,
state->client = client; state->client = client;
state->config.i2c_addr = client->addr; state->config.i2c_addr = client->addr;
state->config.chip_mode = pdata->chip_mode; state->config.chip_mode = pdata->chip_mode;
state->config.ref_freq_Hz = pdata->ref_freq_Hz; state->config.ref_freq_hz = pdata->ref_freq_hz;
state->config.inversion = pdata->inversion; state->config.inversion = pdata->inversion;
if (state->config.ref_freq_Hz < 4000000 if (state->config.ref_freq_hz < 4000000 ||
|| state->config.ref_freq_Hz > 27000000) { state->config.ref_freq_hz > 27000000) {
dev_err(&state->client->dev, "ref_freq of %d Hz not supported by this driver\n", dev_err(&state->client->dev, "ref_freq of %d Hz not supported by this driver\n",
state->config.ref_freq_Hz); state->config.ref_freq_hz);
ret = -EINVAL; ret = -EINVAL;
goto error; goto error;
} }

View file

@ -1,20 +1,21 @@
/* /*
Driver for Silicon Labs SI2165 DVB-C/-T Demodulator * Driver for Silicon Labs SI2165 DVB-C/-T Demodulator
*
Copyright (C) 2013-2014 Matthias Schwarzott <zzam@gentoo.org> * Copyright (C) 2013-2017 Matthias Schwarzott <zzam@gentoo.org>
*
This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. * (at your option) any later version.
*
This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. * GNU General Public License for more details.
*
References: * References:
http://www.silabs.com/Support%20Documents/TechnicalDocs/Si2165-short.pdf * http://www.silabs.com/Support%20Documents/TechnicalDocs/Si2165-short.pdf
*
*/ */
#ifndef _DVB_SI2165_H #ifndef _DVB_SI2165_H
@ -44,7 +45,7 @@ struct si2165_platform_data {
/* frequency of external clock or xtal in Hz /* frequency of external clock or xtal in Hz
* possible values: 4000000, 16000000, 20000000, 240000000, 27000000 * possible values: 4000000, 16000000, 20000000, 240000000, 27000000
*/ */
u32 ref_freq_Hz; u32 ref_freq_hz;
/* invert the spectrum */ /* invert the spectrum */
bool inversion; bool inversion;

View file

@ -1,18 +1,18 @@
/* /*
Driver for Silicon Labs SI2165 DVB-C/-T Demodulator * Driver for Silicon Labs SI2165 DVB-C/-T Demodulator
*
Copyright (C) 2013-2014 Matthias Schwarzott <zzam@gentoo.org> * Copyright (C) 2013-2017 Matthias Schwarzott <zzam@gentoo.org>
*
This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. * (at your option) any later version.
*
This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. * GNU General Public License for more details.
*
*/ */
#ifndef _DVB_SI2165_PRIV #ifndef _DVB_SI2165_PRIV
@ -22,7 +22,8 @@
struct si2165_config { struct si2165_config {
/* i2c addr /* i2c addr
* possible values: 0x64,0x65,0x66,0x67 */ * possible values: 0x64,0x65,0x66,0x67
*/
u8 i2c_addr; u8 i2c_addr;
/* external clock or XTAL */ /* external clock or XTAL */
@ -31,7 +32,7 @@ struct si2165_config {
/* frequency of external clock or xtal in Hz /* frequency of external clock or xtal in Hz
* possible values: 4000000, 16000000, 20000000, 240000000, 27000000 * possible values: 4000000, 16000000, 20000000, 240000000, 27000000
*/ */
u32 ref_freq_Hz; u32 ref_freq_hz;
/* invert the spectrum */ /* invert the spectrum */
bool inversion; bool inversion;

View file

@ -1853,7 +1853,7 @@ static int dvb_register(struct cx23885_tsport *port)
memset(&si2165_pdata, 0, sizeof(si2165_pdata)); memset(&si2165_pdata, 0, sizeof(si2165_pdata));
si2165_pdata.fe = &fe0->dvb.frontend; si2165_pdata.fe = &fe0->dvb.frontend;
si2165_pdata.chip_mode = SI2165_MODE_PLL_XTAL, si2165_pdata.chip_mode = SI2165_MODE_PLL_XTAL,
si2165_pdata.ref_freq_Hz = 16000000, si2165_pdata.ref_freq_hz = 16000000,
memset(&info, 0, sizeof(struct i2c_board_info)); memset(&info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, "si2165", I2C_NAME_SIZE); strlcpy(info.type, "si2165", I2C_NAME_SIZE);
info.addr = 0x64; info.addr = 0x64;

View file

@ -763,7 +763,7 @@ static int dvb_init(struct cx231xx *dev)
memset(&si2165_pdata, 0, sizeof(si2165_pdata)); memset(&si2165_pdata, 0, sizeof(si2165_pdata));
si2165_pdata.fe = &dev->dvb->frontend; si2165_pdata.fe = &dev->dvb->frontend;
si2165_pdata.chip_mode = SI2165_MODE_PLL_XTAL, si2165_pdata.chip_mode = SI2165_MODE_PLL_XTAL,
si2165_pdata.ref_freq_Hz = 16000000, si2165_pdata.ref_freq_hz = 16000000,
memset(&info, 0, sizeof(struct i2c_board_info)); memset(&info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, "si2165", I2C_NAME_SIZE); strlcpy(info.type, "si2165", I2C_NAME_SIZE);
@ -810,7 +810,7 @@ static int dvb_init(struct cx231xx *dev)
memset(&si2165_pdata, 0, sizeof(si2165_pdata)); memset(&si2165_pdata, 0, sizeof(si2165_pdata));
si2165_pdata.fe = &dev->dvb->frontend; si2165_pdata.fe = &dev->dvb->frontend;
si2165_pdata.chip_mode = SI2165_MODE_PLL_EXT, si2165_pdata.chip_mode = SI2165_MODE_PLL_EXT,
si2165_pdata.ref_freq_Hz = 24000000, si2165_pdata.ref_freq_hz = 24000000,
memset(&info, 0, sizeof(struct i2c_board_info)); memset(&info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, "si2165", I2C_NAME_SIZE); strlcpy(info.type, "si2165", I2C_NAME_SIZE);