aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2011-03-25 11:10:05 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-05-20 06:26:27 -0400
commit9999daf446b9fa43b5301af423b6798a600e36bc (patch)
tree236c6345254181cd650836ecccd80803d810da2a
parent58d5eaec9f877a9bcfa9b6dca0ea51850975c49f (diff)
[media] drxd: CodingStyle cleanups
There are still lots of 80-columns warnings and a few errors at some tables, but changing them would require more work and with probably not much gain. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/dvb/frontends/drxd_hard.c87
1 files changed, 43 insertions, 44 deletions
diff --git a/drivers/media/dvb/frontends/drxd_hard.c b/drivers/media/dvb/frontends/drxd_hard.c
index df70e18fc9b6..117df556ec3e 100644
--- a/drivers/media/dvb/frontends/drxd_hard.c
+++ b/drivers/media/dvb/frontends/drxd_hard.c
@@ -209,7 +209,7 @@ struct drxd_state {
209 209
210static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 * data, int len) 210static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 * data, int len)
211{ 211{
212 struct i2c_msg msg = {.addr = adr,.flags = 0,.buf = data,.len = len }; 212 struct i2c_msg msg = {.addr = adr, .flags = 0, .buf = data, .len = len };
213 213
214 if (i2c_transfer(adap, &msg, 1) != 1) 214 if (i2c_transfer(adap, &msg, 1) != 1)
215 return -1; 215 return -1;
@@ -217,12 +217,16 @@ static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 * data, int len)
217} 217}
218 218
219static int i2c_read(struct i2c_adapter *adap, 219static int i2c_read(struct i2c_adapter *adap,
220 u8 adr, u8 * msg, int len, u8 * answ, int alen) 220 u8 adr, u8 *msg, int len, u8 *answ, int alen)
221{ 221{
222 struct i2c_msg msgs[2] = { {.addr = adr,.flags = 0, 222 struct i2c_msg msgs[2] = {
223 .buf = msg,.len = len}, 223 {
224 {.addr = adr,.flags = I2C_M_RD, 224 .addr = adr, .flags = 0,
225 .buf = answ,.len = alen} 225 .buf = msg, .len = len
226 }, {
227 .addr = adr, .flags = I2C_M_RD,
228 .buf = answ, .len = alen
229 }
226 }; 230 };
227 if (i2c_transfer(adap, msgs, 2) != 2) 231 if (i2c_transfer(adap, msgs, 2) != 2)
228 return -1; 232 return -1;
@@ -233,13 +237,13 @@ inline u32 MulDiv32(u32 a, u32 b, u32 c)
233{ 237{
234 u64 tmp64; 238 u64 tmp64;
235 239
236 tmp64 = (u64) a *(u64) b; 240 tmp64 = (u64)a * (u64)b;
237 do_div(tmp64, c); 241 do_div(tmp64, c);
238 242
239 return (u32) tmp64; 243 return (u32) tmp64;
240} 244}
241 245
242static int Read16(struct drxd_state *state, u32 reg, u16 * data, u8 flags) 246static int Read16(struct drxd_state *state, u32 reg, u16 *data, u8 flags)
243{ 247{
244 u8 adr = state->config.demod_address; 248 u8 adr = state->config.demod_address;
245 u8 mm1[4] = { reg & 0xff, (reg >> 16) & 0xff, 249 u8 mm1[4] = { reg & 0xff, (reg >> 16) & 0xff,
@@ -253,7 +257,7 @@ static int Read16(struct drxd_state *state, u32 reg, u16 * data, u8 flags)
253 return mm2[0] | (mm2[1] << 8); 257 return mm2[0] | (mm2[1] << 8);
254} 258}
255 259
256static int Read32(struct drxd_state *state, u32 reg, u32 * data, u8 flags) 260static int Read32(struct drxd_state *state, u32 reg, u32 *data, u8 flags)
257{ 261{
258 u8 adr = state->config.demod_address; 262 u8 adr = state->config.demod_address;
259 u8 mm1[4] = { reg & 0xff, (reg >> 16) & 0xff, 263 u8 mm1[4] = { reg & 0xff, (reg >> 16) & 0xff,
@@ -297,7 +301,7 @@ static int Write32(struct drxd_state *state, u32 reg, u32 data, u8 flags)
297} 301}
298 302
299static int write_chunk(struct drxd_state *state, 303static int write_chunk(struct drxd_state *state,
300 u32 reg, u8 * data, u32 len, u8 flags) 304 u32 reg, u8 *data, u32 len, u8 flags)
301{ 305{
302 u8 adr = state->config.demod_address; 306 u8 adr = state->config.demod_address;
303 u8 mm[CHUNK_SIZE + 4] = { reg & 0xff, (reg >> 16) & 0xff, 307 u8 mm[CHUNK_SIZE + 4] = { reg & 0xff, (reg >> 16) & 0xff,
@@ -308,14 +312,14 @@ static int write_chunk(struct drxd_state *state,
308 for (i = 0; i < len; i++) 312 for (i = 0; i < len; i++)
309 mm[4 + i] = data[i]; 313 mm[4 + i] = data[i];
310 if (i2c_write(state->i2c, adr, mm, 4 + len) < 0) { 314 if (i2c_write(state->i2c, adr, mm, 4 + len) < 0) {
311 printk("error in write_chunk\n"); 315 printk(KERN_ERR "error in write_chunk\n");
312 return -1; 316 return -1;
313 } 317 }
314 return 0; 318 return 0;
315} 319}
316 320
317static int WriteBlock(struct drxd_state *state, 321static int WriteBlock(struct drxd_state *state,
318 u32 Address, u16 BlockSize, u8 * pBlock, u8 Flags) 322 u32 Address, u16 BlockSize, u8 *pBlock, u8 Flags)
319{ 323{
320 while (BlockSize > 0) { 324 while (BlockSize > 0) {
321 u16 Chunk = BlockSize > CHUNK_SIZE ? CHUNK_SIZE : BlockSize; 325 u16 Chunk = BlockSize > CHUNK_SIZE ? CHUNK_SIZE : BlockSize;
@@ -421,7 +425,7 @@ static int StopOC(struct drxd_state *state)
421 /* Store output configuration */ 425 /* Store output configuration */
422 status = Read16(state, EC_OC_REG_SNC_ISC_LVL__A, &ocSyncLvl, 0); 426 status = Read16(state, EC_OC_REG_SNC_ISC_LVL__A, &ocSyncLvl, 0);
423 if (status < 0) 427 if (status < 0)
424 break;; 428 break;
425 /* CHK_ERROR(Read16(EC_OC_REG_OC_MODE_LOP__A, &ocModeLop)); */ 429 /* CHK_ERROR(Read16(EC_OC_REG_OC_MODE_LOP__A, &ocModeLop)); */
426 state->m_EcOcRegSncSncLvl = ocSyncLvl; 430 state->m_EcOcRegSncSncLvl = ocSyncLvl;
427 /* m_EcOcRegOcModeLop = ocModeLop; */ 431 /* m_EcOcRegOcModeLop = ocModeLop; */
@@ -545,7 +549,7 @@ static int DRX_GetLockStatus(struct drxd_state *state, u32 * pLockStatus)
545 549
546 status = Read16(state, SC_RA_RAM_LOCK__A, &ScRaRamLock, 0x0000); 550 status = Read16(state, SC_RA_RAM_LOCK__A, &ScRaRamLock, 0x0000);
547 if (status < 0) { 551 if (status < 0) {
548 printk("Can't read SC_RA_RAM_LOCK__A status = %08x\n", status); 552 printk(KERN_ERR "Can't read SC_RA_RAM_LOCK__A status = %08x\n", status);
549 return status; 553 return status;
550 } 554 }
551 555
@@ -593,15 +597,14 @@ static int SetCfgIfAgc(struct drxd_state *state, struct SCfgAgc *cfg)
593 status = Write16(state, FE_AG_REG_PM1_AGC_WRI__A, FeAgRegPm1AgcWri, 0); 597 status = Write16(state, FE_AG_REG_PM1_AGC_WRI__A, FeAgRegPm1AgcWri, 0);
594 if (status < 0) 598 if (status < 0)
595 break; 599 break;
596 } 600 } while (0);
597 while (0);
598 } else if (cfg->ctrlMode == AGC_CTRL_AUTO) { 601 } else if (cfg->ctrlMode == AGC_CTRL_AUTO) {
599 if (((cfg->maxOutputLevel) < (cfg->minOutputLevel)) || 602 if (((cfg->maxOutputLevel) < (cfg->minOutputLevel)) ||
600 ((cfg->maxOutputLevel) > DRXD_FE_CTRL_MAX) || 603 ((cfg->maxOutputLevel) > DRXD_FE_CTRL_MAX) ||
601 ((cfg->speed) > DRXD_FE_CTRL_MAX) || 604 ((cfg->speed) > DRXD_FE_CTRL_MAX) ||
602 ((cfg->settleLevel) > DRXD_FE_CTRL_MAX) 605 ((cfg->settleLevel) > DRXD_FE_CTRL_MAX)
603 ) 606 )
604 return (-1); 607 return -1;
605 do { 608 do {
606 u16 FeAgRegAgModeLop; 609 u16 FeAgRegAgModeLop;
607 u16 FeAgRegEgcSetLvl; 610 u16 FeAgRegEgcSetLvl;
@@ -706,7 +709,7 @@ static int SetCfgIfAgc(struct drxd_state *state, struct SCfgAgc *cfg)
706 709
707 } else { 710 } else {
708 /* No OFF mode for IF control */ 711 /* No OFF mode for IF control */
709 return (-1); 712 return -1;
710 } 713 }
711 return status; 714 return status;
712} 715}
@@ -919,7 +922,7 @@ static int load_firmware(struct drxd_state *state, const char *fw_name)
919} 922}
920 923
921static int DownloadMicrocode(struct drxd_state *state, 924static int DownloadMicrocode(struct drxd_state *state,
922 const u8 * pMCImage, u32 Length) 925 const u8 *pMCImage, u32 Length)
923{ 926{
924 u8 *pSrc; 927 u8 *pSrc;
925 u16 Flags; 928 u16 Flags;
@@ -973,7 +976,8 @@ static int HI_Command(struct drxd_state *state, u16 cmd, u16 * pResult)
973 u16 waitCmd; 976 u16 waitCmd;
974 int status; 977 int status;
975 978
976 if ((status = Write16(state, HI_RA_RAM_SRV_CMD__A, cmd, 0)) < 0) 979 status = Write16(state, HI_RA_RAM_SRV_CMD__A, cmd, 0);
980 if (status < 0)
977 return status; 981 return status;
978 982
979 do { 983 do {
@@ -1053,7 +1057,7 @@ static int DRX_ConfigureI2CBridge(struct drxd_state *state, int bEnableBridge)
1053 1057
1054#if 0 1058#if 0
1055static int AtomicReadBlock(struct drxd_state *state, 1059static int AtomicReadBlock(struct drxd_state *state,
1056 u32 Addr, u16 DataSize, u8 * pData, u8 Flags) 1060 u32 Addr, u16 DataSize, u8 *pData, u8 Flags)
1057{ 1061{
1058 int status; 1062 int status;
1059 int i = 0; 1063 int i = 0;
@@ -1106,7 +1110,7 @@ static int AtomicReadBlock(struct drxd_state *state,
1106} 1110}
1107 1111
1108static int AtomicReadReg32(struct drxd_state *state, 1112static int AtomicReadReg32(struct drxd_state *state,
1109 u32 Addr, u32 * pData, u8 Flags) 1113 u32 Addr, u32 *pData, u8 Flags)
1110{ 1114{
1111 u8 buf[sizeof(u32)]; 1115 u8 buf[sizeof(u32)];
1112 int status; 1116 int status;
@@ -1145,7 +1149,7 @@ static int InitCC(struct drxd_state *state)
1145 if (state->osc_clock_freq == 0 || 1149 if (state->osc_clock_freq == 0 ||
1146 state->osc_clock_freq > 20000 || 1150 state->osc_clock_freq > 20000 ||
1147 (state->osc_clock_freq % 4000) != 0) { 1151 (state->osc_clock_freq % 4000) != 0) {
1148 printk("invalid osc frequency %d\n", state->osc_clock_freq); 1152 printk(KERN_ERR "invalid osc frequency %d\n", state->osc_clock_freq);
1149 return -1; 1153 return -1;
1150 } 1154 }
1151 1155
@@ -1239,8 +1243,7 @@ static int SetCfgPga(struct drxd_state *state, int pgaSwitch)
1239 if (status < 0) 1243 if (status < 0)
1240 break; 1244 break;
1241 } 1245 }
1242 } 1246 } while (0);
1243 while (0);
1244 return status; 1247 return status;
1245} 1248}
1246 1249
@@ -1318,7 +1321,7 @@ static int SC_SendCommand(struct drxd_state *state, u16 cmd)
1318 Read16(state, SC_RA_RAM_CMD_ADDR__A, &errCode, 0); 1321 Read16(state, SC_RA_RAM_CMD_ADDR__A, &errCode, 0);
1319 1322
1320 if (errCode == 0xFFFF) { 1323 if (errCode == 0xFFFF) {
1321 printk("Command Error\n"); 1324 printk(KERN_ERR "Command Error\n");
1322 status = -1; 1325 status = -1;
1323 } 1326 }
1324 1327
@@ -1502,17 +1505,17 @@ static int SetDeviceTypeId(struct drxd_state *state)
1502 status = Read16(state, CC_REG_JTAGID_L__A, &deviceId, 0); 1505 status = Read16(state, CC_REG_JTAGID_L__A, &deviceId, 0);
1503 if (status < 0) 1506 if (status < 0)
1504 break; 1507 break;
1505 printk("drxd: deviceId = %04x\n", deviceId); 1508 printk(KERN_INFO "drxd: deviceId = %04x\n", deviceId);
1506 1509
1507 state->type_A = 0; 1510 state->type_A = 0;
1508 state->PGA = 0; 1511 state->PGA = 0;
1509 state->diversity = 0; 1512 state->diversity = 0;
1510 if (deviceId == 0) { /* on A2 only 3975 available */ 1513 if (deviceId == 0) { /* on A2 only 3975 available */
1511 state->type_A = 1; 1514 state->type_A = 1;
1512 printk("DRX3975D-A2\n"); 1515 printk(KERN_INFO "DRX3975D-A2\n");
1513 } else { 1516 } else {
1514 deviceId >>= 12; 1517 deviceId >>= 12;
1515 printk("DRX397%dD-B1\n", deviceId); 1518 printk(KERN_INFO "DRX397%dD-B1\n", deviceId);
1516 switch (deviceId) { 1519 switch (deviceId) {
1517 case 4: 1520 case 4:
1518 state->diversity = 1; 1521 state->diversity = 1;
@@ -1597,10 +1600,10 @@ static int CorrectSysClockDeviation(struct drxd_state *state)
1597 1600
1598 /* These accesses should be AtomicReadReg32, but that 1601 /* These accesses should be AtomicReadReg32, but that
1599 causes trouble (at least for diversity */ 1602 causes trouble (at least for diversity */
1600 status = Read32(state, LC_RA_RAM_IFINCR_NOM_L__A, ((u32 *) & nomincr), 0); 1603 status = Read32(state, LC_RA_RAM_IFINCR_NOM_L__A, ((u32 *) &nomincr), 0);
1601 if (status < 0) 1604 if (status < 0)
1602 break; 1605 break;
1603 status = Read32(state, FE_IF_REG_INCR0__A, (u32 *) & incr, 0); 1606 status = Read32(state, FE_IF_REG_INCR0__A, (u32 *) &incr, 0);
1604 if (status < 0) 1607 if (status < 0)
1605 break; 1608 break;
1606 1609
@@ -1633,9 +1636,8 @@ static int CorrectSysClockDeviation(struct drxd_state *state)
1633 sysClockInHz = MulDiv32(incr, bandwidth, 1 << 21); 1636 sysClockInHz = MulDiv32(incr, bandwidth, 1 << 21);
1634 sysClockFreq = (u32) (sysClockInHz / 1000); 1637 sysClockFreq = (u32) (sysClockInHz / 1000);
1635 /* rounding */ 1638 /* rounding */
1636 if ((sysClockInHz % 1000) > 500) { 1639 if ((sysClockInHz % 1000) > 500)
1637 sysClockFreq++; 1640 sysClockFreq++;
1638 }
1639 1641
1640 /* Compute clock deviation in ppm */ 1642 /* Compute clock deviation in ppm */
1641 oscClockDeviation = (u16) ((((s32) (sysClockFreq) - 1643 oscClockDeviation = (u16) ((((s32) (sysClockFreq) -
@@ -1646,7 +1648,7 @@ static int CorrectSysClockDeviation(struct drxd_state *state)
1646 (state->expected_sys_clock_freq)); 1648 (state->expected_sys_clock_freq));
1647 1649
1648 Diff = oscClockDeviation - state->osc_clock_deviation; 1650 Diff = oscClockDeviation - state->osc_clock_deviation;
1649 /*printk("sysclockdiff=%d\n", Diff); */ 1651 /*printk(KERN_INFO "sysclockdiff=%d\n", Diff); */
1650 if (Diff >= -200 && Diff <= 200) { 1652 if (Diff >= -200 && Diff <= 200) {
1651 state->sys_clock_freq = (u16) sysClockFreq; 1653 state->sys_clock_freq = (u16) sysClockFreq;
1652 if (oscClockDeviation != state->osc_clock_deviation) { 1654 if (oscClockDeviation != state->osc_clock_deviation) {
@@ -1671,7 +1673,7 @@ static int CorrectSysClockDeviation(struct drxd_state *state)
1671 } 1673 }
1672 } while (0); 1674 } while (0);
1673 1675
1674 return (status); 1676 return status;
1675} 1677}
1676 1678
1677static int DRX_Stop(struct drxd_state *state) 1679static int DRX_Stop(struct drxd_state *state)
@@ -1843,9 +1845,8 @@ static int SetFrequencyShift(struct drxd_state *state,
1843 1 << 28, state->sys_clock_freq); 1845 1 << 28, state->sys_clock_freq);
1844 /* Remove integer part */ 1846 /* Remove integer part */
1845 state->fe_fs_add_incr &= 0x0FFFFFFFL; 1847 state->fe_fs_add_incr &= 0x0FFFFFFFL;
1846 if (negativeShift) { 1848 if (negativeShift)
1847 state->fe_fs_add_incr = ((1 << 28) - state->fe_fs_add_incr); 1849 state->fe_fs_add_incr = ((1 << 28) - state->fe_fs_add_incr);
1848 }
1849 1850
1850 /* Save the frequency shift without tunerOffset compensation 1851 /* Save the frequency shift without tunerOffset compensation
1851 for CtrlGetChannel. */ 1852 for CtrlGetChannel. */
@@ -2530,9 +2531,8 @@ static int CDRXD(struct drxd_state *state, u32 IntermediateFrequency)
2530 state->rf_agc_cfg.speed = (u16) (ulRfAgcSpeed); 2531 state->rf_agc_cfg.speed = (u16) (ulRfAgcSpeed);
2531 } 2532 }
2532 2533
2533 if (ulRfAgcMode == 2) { 2534 if (ulRfAgcMode == 2)
2534 state->rf_agc_cfg.ctrlMode = AGC_CTRL_OFF; 2535 state->rf_agc_cfg.ctrlMode = AGC_CTRL_OFF;
2535 }
2536 2536
2537 if (ulEnvironment <= 2) 2537 if (ulEnvironment <= 2)
2538 state->app_env_default = (enum app_env) 2538 state->app_env_default = (enum app_env)
@@ -2842,6 +2842,7 @@ int drxd_config_i2c(struct dvb_frontend *fe, int onoff)
2842 2842
2843 return DRX_ConfigureI2CBridge(state, onoff); 2843 return DRX_ConfigureI2CBridge(state, onoff);
2844} 2844}
2845EXPORT_SYMBOL(drxd_config_i2c);
2845 2846
2846static int drxd_get_tune_settings(struct dvb_frontend *fe, 2847static int drxd_get_tune_settings(struct dvb_frontend *fe,
2847 struct dvb_frontend_tune_settings *sets) 2848 struct dvb_frontend_tune_settings *sets)
@@ -2909,7 +2910,7 @@ static int drxd_set_frontend(struct dvb_frontend *fe,
2909 state->config.pll_set(state->priv, param, 2910 state->config.pll_set(state->priv, param,
2910 state->config.pll_address, 2911 state->config.pll_address,
2911 state->config.demoda_address, &off) < 0) { 2912 state->config.demoda_address, &off) < 0) {
2912 printk("Error in pll_set\n"); 2913 printk(KERN_ERR "Error in pll_set\n");
2913 return -1; 2914 return -1;
2914 } 2915 }
2915 2916
@@ -2988,14 +2989,12 @@ struct dvb_frontend *drxd_attach(const struct drxd_config *config,
2988 return &state->frontend; 2989 return &state->frontend;
2989 2990
2990error: 2991error:
2991 printk("drxd: not found\n"); 2992 printk(KERN_ERR "drxd: not found\n");
2992 kfree(state); 2993 kfree(state);
2993 return NULL; 2994 return NULL;
2994} 2995}
2996EXPORT_SYMBOL(drxd_attach);
2995 2997
2996MODULE_DESCRIPTION("DRXD driver"); 2998MODULE_DESCRIPTION("DRXD driver");
2997MODULE_AUTHOR("Micronas"); 2999MODULE_AUTHOR("Micronas");
2998MODULE_LICENSE("GPL"); 3000MODULE_LICENSE("GPL");
2999
3000EXPORT_SYMBOL(drxd_attach);
3001EXPORT_SYMBOL(drxd_config_i2c);