Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7dbbb4bf authored by Matthias Schwarzott's avatar Matthias Schwarzott Committed by Mauro Carvalho Chehab
Browse files

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: default avatarMatthias Schwarzott <zzam@gentoo.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 1b54da77
Loading
Loading
Loading
Loading
+46 −41
Original line number Diff line number Diff line
@@ -67,7 +67,8 @@ static int si2165_write(struct si2165_state *state, const u16 reg,
{
	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);

@@ -88,7 +89,8 @@ static int si2165_read(struct si2165_state *state,
		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;
}
@@ -161,7 +163,9 @@ static int si2165_writereg_mask8(struct si2165_state *state, const u16 reg,
	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 {
	u16 reg;
	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)
{
	u32 ref_freq_Hz = state->config.ref_freq_Hz;
	u32 ref_freq_hz = state->config.ref_freq_hz;
	u8 divr = 1; /* 1..7 */
	u8 divp = 1; /* only 1 or 4 */
	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
	 * or it yields the same values as the windows driver
	 */
	switch (ref_freq_Hz) {
	switch (ref_freq_hz) {
	case 16000000u:
		divn = 56;
		break;
@@ -214,23 +218,23 @@ static int si2165_init_pll(struct si2165_state *state)
		break;
	default:
		/* ref_freq / divr must be between 4 and 16 MHz */
		if (ref_freq_Hz > 16000000u)
		if (ref_freq_hz > 16000000u)
			divr = 2;

		/*
		 * now select divn and divp such that
		 * fvco is in 1624..1824 MHz
		 */
		if (1624000000u * divr > ref_freq_Hz * 2u * 63u)
		if (1624000000u * divr > ref_freq_hz * 2u * 63u)
			divp = 4;

		/* is this already correct regarding rounding? */
		divn = 1624000000u * divr / (ref_freq_Hz * 2u * divp);
		divn = 1624000000u * divr / (ref_freq_hz * 2u * divp);
		break;
	}

	/* 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;
	state->adc_clk = state->fvco_hz / (divm * 4u);
	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,
	const u8 *data, u32 len, u32 *poffset, u32 block_count)
					const u8 *data, u32 len, u32 *poffset,
					u32 block_count)
{
	int ret;
	u8 buf_ctrl[4] = { 0x00, 0x00, 0x00, 0xc0 };
@@ -286,12 +291,12 @@ static int si2165_upload_firmware_block(struct si2165_state *state,
		return -EINVAL;

	dev_dbg(&state->client->dev,
		"fw load: si2165_upload_firmware_block called with len=0x%x offset=0x%x blockcount=0x%x\n",
				len, offset, block_count);
		"fw load: %s: called with len=0x%x offset=0x%x blockcount=0x%x\n",
		__func__, len, offset, block_count);
	while (offset + 12 <= len && cur_block < block_count) {
		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",
					len, offset, cur_block, block_count);
			"fw load: %s: in while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n",
			__func__, len, offset, cur_block, block_count);
		wordcount = data[offset];
		if (wordcount < 1 || data[offset + 1] ||
		    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,
		"fw load: si2165_upload_firmware_block after while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n",
				len, offset, cur_block, block_count);
		"fw load: %s: after while len=0x%x offset=0x%x cur_block=0x%x blockcount=0x%x\n",
		__func__, len, offset, cur_block, block_count);

	if (poffset)
		*poffset = offset;

	dev_dbg(&state->client->dev,
		"fw load: si2165_upload_firmware_block returned offset=0x%x\n",
				offset);
		"fw load: %s: returned offset=0x%x\n",
		__func__, offset);

	return 0;
error:
@@ -436,8 +441,8 @@ static int si2165_upload_firmware(struct si2165_state *state)
	/* start right after the header */
	offset = 8;

	dev_info(&state->client->dev, "si2165_upload_firmware extracted patch_version=0x%02x, block_count=0x%02x, crc_expected=0x%04x\n",
		patch_version, block_count, crc_expected);
	dev_info(&state->client->dev, "%s: extracted patch_version=0x%02x, block_count=0x%02x, crc_expected=0x%04x\n",
		 __func__, patch_version, block_count, crc_expected);

	ret = si2165_upload_firmware_block(state, data, len, &offset, 1);
	if (ret < 0)
@@ -979,8 +984,8 @@ static int si2165_probe(struct i2c_client *client,
	};

	/* allocate memory for the internal state */
	state = kzalloc(sizeof(struct si2165_state), GFP_KERNEL);
	if (state == NULL) {
	state = kzalloc(sizeof(*state), GFP_KERNEL);
	if (!state) {
		ret = -ENOMEM;
		goto error;
	}
@@ -996,13 +1001,13 @@ static int si2165_probe(struct i2c_client *client,
	state->client = client;
	state->config.i2c_addr = client->addr;
	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;

	if (state->config.ref_freq_Hz < 4000000
	    || state->config.ref_freq_Hz > 27000000) {
	if (state->config.ref_freq_hz < 4000000 ||
	    state->config.ref_freq_hz > 27000000) {
		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;
		goto error;
	}
+19 −18
Original line number Diff line number Diff line
/*
    Driver for Silicon Labs SI2165 DVB-C/-T Demodulator

    Copyright (C) 2013-2014 Matthias Schwarzott <zzam@gentoo.org>

    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
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    References:
    http://www.silabs.com/Support%20Documents/TechnicalDocs/Si2165-short.pdf
 * Driver for Silicon Labs SI2165 DVB-C/-T Demodulator
 *
 * Copyright (C) 2013-2017 Matthias Schwarzott <zzam@gentoo.org>
 *
 *   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
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 * References:
 *   http://www.silabs.com/Support%20Documents/TechnicalDocs/Si2165-short.pdf
 *
 */

#ifndef _DVB_SI2165_H
@@ -44,7 +45,7 @@ struct si2165_platform_data {
	/* frequency of external clock or xtal in Hz
	 * possible values: 4000000, 16000000, 20000000, 240000000, 27000000
	 */
	u32 ref_freq_Hz;
	u32 ref_freq_hz;

	/* invert the spectrum */
	bool inversion;
+18 −17
Original line number Diff line number Diff line
/*
    Driver for Silicon Labs SI2165 DVB-C/-T Demodulator

    Copyright (C) 2013-2014 Matthias Schwarzott <zzam@gentoo.org>

    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
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

 * Driver for Silicon Labs SI2165 DVB-C/-T Demodulator
 *
 * Copyright (C) 2013-2017 Matthias Schwarzott <zzam@gentoo.org>
 *
 *   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
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 */

#ifndef _DVB_SI2165_PRIV
@@ -22,7 +22,8 @@

struct si2165_config {
	/* i2c addr
	 * possible values: 0x64,0x65,0x66,0x67 */
	 * possible values: 0x64,0x65,0x66,0x67
	 */
	u8 i2c_addr;

	/* external clock or XTAL */
@@ -31,7 +32,7 @@ struct si2165_config {
	/* frequency of external clock or xtal in Hz
	 * possible values: 4000000, 16000000, 20000000, 240000000, 27000000
	 */
	u32 ref_freq_Hz;
	u32 ref_freq_hz;

	/* invert the spectrum */
	bool inversion;
+1 −1
Original line number Diff line number Diff line
@@ -1853,7 +1853,7 @@ static int dvb_register(struct cx23885_tsport *port)
			memset(&si2165_pdata, 0, sizeof(si2165_pdata));
			si2165_pdata.fe = &fe0->dvb.frontend;
			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));
			strlcpy(info.type, "si2165", I2C_NAME_SIZE);
			info.addr = 0x64;
+2 −2
Original line number Diff line number Diff line
@@ -763,7 +763,7 @@ static int dvb_init(struct cx231xx *dev)
		memset(&si2165_pdata, 0, sizeof(si2165_pdata));
		si2165_pdata.fe = &dev->dvb->frontend;
		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));
		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));
		si2165_pdata.fe = &dev->dvb->frontend;
		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));
		strlcpy(info.type, "si2165", I2C_NAME_SIZE);