aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2015-04-15 11:35:47 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-05-18 14:49:57 -0400
commit154cdfb03df77dc09ab07243dc531ad0ff1cc044 (patch)
treeafd9c989a021450329d950ee3049aceeb5e635e2 /drivers
parent46de761572b86953133776db494f6aa870183319 (diff)
[media] fc2580: cleanups and variable renames
Rename driver state from priv to dev. Remove legacy i2c-gate control. Use I2C client for proper dev_() logging. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/tuners/fc2580.c172
-rw-r--r--drivers/media/tuners/fc2580_priv.h2
2 files changed, 76 insertions, 98 deletions
diff --git a/drivers/media/tuners/fc2580.c b/drivers/media/tuners/fc2580.c
index 9324855216f5..f4b31db5f826 100644
--- a/drivers/media/tuners/fc2580.c
+++ b/drivers/media/tuners/fc2580.c
@@ -36,13 +36,14 @@
36 */ 36 */
37 37
38/* write multiple registers */ 38/* write multiple registers */
39static int fc2580_wr_regs(struct fc2580_priv *priv, u8 reg, u8 *val, int len) 39static int fc2580_wr_regs(struct fc2580_dev *dev, u8 reg, u8 *val, int len)
40{ 40{
41 struct i2c_client *client = dev->client;
41 int ret; 42 int ret;
42 u8 buf[MAX_XFER_SIZE]; 43 u8 buf[MAX_XFER_SIZE];
43 struct i2c_msg msg[1] = { 44 struct i2c_msg msg[1] = {
44 { 45 {
45 .addr = priv->i2c_addr, 46 .addr = dev->i2c_addr,
46 .flags = 0, 47 .flags = 0,
47 .len = 1 + len, 48 .len = 1 + len,
48 .buf = buf, 49 .buf = buf,
@@ -50,7 +51,7 @@ static int fc2580_wr_regs(struct fc2580_priv *priv, u8 reg, u8 *val, int len)
50 }; 51 };
51 52
52 if (1 + len > sizeof(buf)) { 53 if (1 + len > sizeof(buf)) {
53 dev_warn(&priv->i2c->dev, 54 dev_warn(&client->dev,
54 "%s: i2c wr reg=%04x: len=%d is too big!\n", 55 "%s: i2c wr reg=%04x: len=%d is too big!\n",
55 KBUILD_MODNAME, reg, len); 56 KBUILD_MODNAME, reg, len);
56 return -EINVAL; 57 return -EINVAL;
@@ -59,30 +60,31 @@ static int fc2580_wr_regs(struct fc2580_priv *priv, u8 reg, u8 *val, int len)
59 buf[0] = reg; 60 buf[0] = reg;
60 memcpy(&buf[1], val, len); 61 memcpy(&buf[1], val, len);
61 62
62 ret = i2c_transfer(priv->i2c, msg, 1); 63 ret = i2c_transfer(dev->i2c, msg, 1);
63 if (ret == 1) { 64 if (ret == 1) {
64 ret = 0; 65 ret = 0;
65 } else { 66 } else {
66 dev_warn(&priv->i2c->dev, "%s: i2c wr failed=%d reg=%02x " \ 67 dev_warn(&dev->i2c->dev, "%s: i2c wr failed=%d reg=%02x len=%d\n",
67 "len=%d\n", KBUILD_MODNAME, ret, reg, len); 68 KBUILD_MODNAME, ret, reg, len);
68 ret = -EREMOTEIO; 69 ret = -EREMOTEIO;
69 } 70 }
70 return ret; 71 return ret;
71} 72}
72 73
73/* read multiple registers */ 74/* read multiple registers */
74static int fc2580_rd_regs(struct fc2580_priv *priv, u8 reg, u8 *val, int len) 75static int fc2580_rd_regs(struct fc2580_dev *dev, u8 reg, u8 *val, int len)
75{ 76{
77 struct i2c_client *client = dev->client;
76 int ret; 78 int ret;
77 u8 buf[MAX_XFER_SIZE]; 79 u8 buf[MAX_XFER_SIZE];
78 struct i2c_msg msg[2] = { 80 struct i2c_msg msg[2] = {
79 { 81 {
80 .addr = priv->i2c_addr, 82 .addr = dev->i2c_addr,
81 .flags = 0, 83 .flags = 0,
82 .len = 1, 84 .len = 1,
83 .buf = &reg, 85 .buf = &reg,
84 }, { 86 }, {
85 .addr = priv->i2c_addr, 87 .addr = dev->i2c_addr,
86 .flags = I2C_M_RD, 88 .flags = I2C_M_RD,
87 .len = len, 89 .len = len,
88 .buf = buf, 90 .buf = buf,
@@ -90,19 +92,19 @@ static int fc2580_rd_regs(struct fc2580_priv *priv, u8 reg, u8 *val, int len)
90 }; 92 };
91 93
92 if (len > sizeof(buf)) { 94 if (len > sizeof(buf)) {
93 dev_warn(&priv->i2c->dev, 95 dev_warn(&client->dev,
94 "%s: i2c rd reg=%04x: len=%d is too big!\n", 96 "%s: i2c rd reg=%04x: len=%d is too big!\n",
95 KBUILD_MODNAME, reg, len); 97 KBUILD_MODNAME, reg, len);
96 return -EINVAL; 98 return -EINVAL;
97 } 99 }
98 100
99 ret = i2c_transfer(priv->i2c, msg, 2); 101 ret = i2c_transfer(dev->i2c, msg, 2);
100 if (ret == 2) { 102 if (ret == 2) {
101 memcpy(val, buf, len); 103 memcpy(val, buf, len);
102 ret = 0; 104 ret = 0;
103 } else { 105 } else {
104 dev_warn(&priv->i2c->dev, "%s: i2c rd failed=%d reg=%02x " \ 106 dev_warn(&client->dev, "%s: i2c rd failed=%d reg=%02x len=%d\n",
105 "len=%d\n", KBUILD_MODNAME, ret, reg, len); 107 KBUILD_MODNAME, ret, reg, len);
106 ret = -EREMOTEIO; 108 ret = -EREMOTEIO;
107 } 109 }
108 110
@@ -110,33 +112,33 @@ static int fc2580_rd_regs(struct fc2580_priv *priv, u8 reg, u8 *val, int len)
110} 112}
111 113
112/* write single register */ 114/* write single register */
113static int fc2580_wr_reg(struct fc2580_priv *priv, u8 reg, u8 val) 115static int fc2580_wr_reg(struct fc2580_dev *dev, u8 reg, u8 val)
114{ 116{
115 return fc2580_wr_regs(priv, reg, &val, 1); 117 return fc2580_wr_regs(dev, reg, &val, 1);
116} 118}
117 119
118/* read single register */ 120/* read single register */
119static int fc2580_rd_reg(struct fc2580_priv *priv, u8 reg, u8 *val) 121static int fc2580_rd_reg(struct fc2580_dev *dev, u8 reg, u8 *val)
120{ 122{
121 return fc2580_rd_regs(priv, reg, val, 1); 123 return fc2580_rd_regs(dev, reg, val, 1);
122} 124}
123 125
124/* write single register conditionally only when value differs from 0xff 126/* write single register conditionally only when value differs from 0xff
125 * XXX: This is special routine meant only for writing fc2580_freq_regs_lut[] 127 * XXX: This is special routine meant only for writing fc2580_freq_regs_lut[]
126 * values. Do not use for the other purposes. */ 128 * values. Do not use for the other purposes. */
127static int fc2580_wr_reg_ff(struct fc2580_priv *priv, u8 reg, u8 val) 129static int fc2580_wr_reg_ff(struct fc2580_dev *dev, u8 reg, u8 val)
128{ 130{
129 if (val == 0xff) 131 if (val == 0xff)
130 return 0; 132 return 0;
131 else 133 else
132 return fc2580_wr_regs(priv, reg, &val, 1); 134 return fc2580_wr_regs(dev, reg, &val, 1);
133} 135}
134 136
135 137
136static int fc2580_set_params(struct dvb_frontend *fe) 138static int fc2580_set_params(struct dvb_frontend *fe)
137{ 139{
138 struct fc2580_priv *priv = fe->tuner_priv; 140 struct fc2580_dev *dev = fe->tuner_priv;
139 struct i2c_client *client = priv->client; 141 struct i2c_client *client = dev->client;
140 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 142 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
141 int ret, i; 143 int ret, i;
142 unsigned int uitmp, div_ref, div_ref_val, div_n, k, k_cw, div_out; 144 unsigned int uitmp, div_ref, div_ref_val, div_n, k, k_cw, div_out;
@@ -148,9 +150,6 @@ static int fc2580_set_params(struct dvb_frontend *fe)
148 "delivery_system=%u frequency=%u bandwidth_hz=%u\n", 150 "delivery_system=%u frequency=%u bandwidth_hz=%u\n",
149 c->delivery_system, c->frequency, c->bandwidth_hz); 151 c->delivery_system, c->frequency, c->bandwidth_hz);
150 152
151 if (fe->ops.i2c_gate_ctrl)
152 fe->ops.i2c_gate_ctrl(fe, 1);
153
154 /* 153 /*
155 * Fractional-N synthesizer 154 * Fractional-N synthesizer
156 * 155 *
@@ -176,7 +175,7 @@ static int fc2580_set_params(struct dvb_frontend *fe)
176 } 175 }
177 176
178 #define DIV_PRE_N 2 177 #define DIV_PRE_N 2
179 #define F_REF priv->clk 178 #define F_REF dev->clk
180 div_out = fc2580_pll_lut[i].div_out; 179 div_out = fc2580_pll_lut[i].div_out;
181 f_vco = (u64) c->frequency * div_out; 180 f_vco = (u64) c->frequency * div_out;
182 synth_config = fc2580_pll_lut[i].band; 181 synth_config = fc2580_pll_lut[i].band;
@@ -207,23 +206,23 @@ static int fc2580_set_params(struct dvb_frontend *fe)
207 "frequency=%u f_vco=%llu F_REF=%u div_ref=%u div_n=%u k=%u div_out=%u k_cw=%0x\n", 206 "frequency=%u f_vco=%llu F_REF=%u div_ref=%u div_n=%u k=%u div_out=%u k_cw=%0x\n",
208 c->frequency, f_vco, F_REF, div_ref, div_n, k, div_out, k_cw); 207 c->frequency, f_vco, F_REF, div_ref, div_n, k, div_out, k_cw);
209 208
210 ret = fc2580_wr_reg(priv, 0x02, synth_config); 209 ret = fc2580_wr_reg(dev, 0x02, synth_config);
211 if (ret < 0) 210 if (ret < 0)
212 goto err; 211 goto err;
213 212
214 ret = fc2580_wr_reg(priv, 0x18, div_ref_val << 0 | k_cw >> 16); 213 ret = fc2580_wr_reg(dev, 0x18, div_ref_val << 0 | k_cw >> 16);
215 if (ret < 0) 214 if (ret < 0)
216 goto err; 215 goto err;
217 216
218 ret = fc2580_wr_reg(priv, 0x1a, (k_cw >> 8) & 0xff); 217 ret = fc2580_wr_reg(dev, 0x1a, (k_cw >> 8) & 0xff);
219 if (ret < 0) 218 if (ret < 0)
220 goto err; 219 goto err;
221 220
222 ret = fc2580_wr_reg(priv, 0x1b, (k_cw >> 0) & 0xff); 221 ret = fc2580_wr_reg(dev, 0x1b, (k_cw >> 0) & 0xff);
223 if (ret < 0) 222 if (ret < 0)
224 goto err; 223 goto err;
225 224
226 ret = fc2580_wr_reg(priv, 0x1c, div_n); 225 ret = fc2580_wr_reg(dev, 0x1c, div_n);
227 if (ret < 0) 226 if (ret < 0)
228 goto err; 227 goto err;
229 228
@@ -237,99 +236,99 @@ static int fc2580_set_params(struct dvb_frontend *fe)
237 goto err; 236 goto err;
238 } 237 }
239 238
240 ret = fc2580_wr_reg_ff(priv, 0x25, fc2580_freq_regs_lut[i].r25_val); 239 ret = fc2580_wr_reg_ff(dev, 0x25, fc2580_freq_regs_lut[i].r25_val);
241 if (ret < 0) 240 if (ret < 0)
242 goto err; 241 goto err;
243 242
244 ret = fc2580_wr_reg_ff(priv, 0x27, fc2580_freq_regs_lut[i].r27_val); 243 ret = fc2580_wr_reg_ff(dev, 0x27, fc2580_freq_regs_lut[i].r27_val);
245 if (ret < 0) 244 if (ret < 0)
246 goto err; 245 goto err;
247 246
248 ret = fc2580_wr_reg_ff(priv, 0x28, fc2580_freq_regs_lut[i].r28_val); 247 ret = fc2580_wr_reg_ff(dev, 0x28, fc2580_freq_regs_lut[i].r28_val);
249 if (ret < 0) 248 if (ret < 0)
250 goto err; 249 goto err;
251 250
252 ret = fc2580_wr_reg_ff(priv, 0x29, fc2580_freq_regs_lut[i].r29_val); 251 ret = fc2580_wr_reg_ff(dev, 0x29, fc2580_freq_regs_lut[i].r29_val);
253 if (ret < 0) 252 if (ret < 0)
254 goto err; 253 goto err;
255 254
256 ret = fc2580_wr_reg_ff(priv, 0x2b, fc2580_freq_regs_lut[i].r2b_val); 255 ret = fc2580_wr_reg_ff(dev, 0x2b, fc2580_freq_regs_lut[i].r2b_val);
257 if (ret < 0) 256 if (ret < 0)
258 goto err; 257 goto err;
259 258
260 ret = fc2580_wr_reg_ff(priv, 0x2c, fc2580_freq_regs_lut[i].r2c_val); 259 ret = fc2580_wr_reg_ff(dev, 0x2c, fc2580_freq_regs_lut[i].r2c_val);
261 if (ret < 0) 260 if (ret < 0)
262 goto err; 261 goto err;
263 262
264 ret = fc2580_wr_reg_ff(priv, 0x2d, fc2580_freq_regs_lut[i].r2d_val); 263 ret = fc2580_wr_reg_ff(dev, 0x2d, fc2580_freq_regs_lut[i].r2d_val);
265 if (ret < 0) 264 if (ret < 0)
266 goto err; 265 goto err;
267 266
268 ret = fc2580_wr_reg_ff(priv, 0x30, fc2580_freq_regs_lut[i].r30_val); 267 ret = fc2580_wr_reg_ff(dev, 0x30, fc2580_freq_regs_lut[i].r30_val);
269 if (ret < 0) 268 if (ret < 0)
270 goto err; 269 goto err;
271 270
272 ret = fc2580_wr_reg_ff(priv, 0x44, fc2580_freq_regs_lut[i].r44_val); 271 ret = fc2580_wr_reg_ff(dev, 0x44, fc2580_freq_regs_lut[i].r44_val);
273 if (ret < 0) 272 if (ret < 0)
274 goto err; 273 goto err;
275 274
276 ret = fc2580_wr_reg_ff(priv, 0x50, fc2580_freq_regs_lut[i].r50_val); 275 ret = fc2580_wr_reg_ff(dev, 0x50, fc2580_freq_regs_lut[i].r50_val);
277 if (ret < 0) 276 if (ret < 0)
278 goto err; 277 goto err;
279 278
280 ret = fc2580_wr_reg_ff(priv, 0x53, fc2580_freq_regs_lut[i].r53_val); 279 ret = fc2580_wr_reg_ff(dev, 0x53, fc2580_freq_regs_lut[i].r53_val);
281 if (ret < 0) 280 if (ret < 0)
282 goto err; 281 goto err;
283 282
284 ret = fc2580_wr_reg_ff(priv, 0x5f, fc2580_freq_regs_lut[i].r5f_val); 283 ret = fc2580_wr_reg_ff(dev, 0x5f, fc2580_freq_regs_lut[i].r5f_val);
285 if (ret < 0) 284 if (ret < 0)
286 goto err; 285 goto err;
287 286
288 ret = fc2580_wr_reg_ff(priv, 0x61, fc2580_freq_regs_lut[i].r61_val); 287 ret = fc2580_wr_reg_ff(dev, 0x61, fc2580_freq_regs_lut[i].r61_val);
289 if (ret < 0) 288 if (ret < 0)
290 goto err; 289 goto err;
291 290
292 ret = fc2580_wr_reg_ff(priv, 0x62, fc2580_freq_regs_lut[i].r62_val); 291 ret = fc2580_wr_reg_ff(dev, 0x62, fc2580_freq_regs_lut[i].r62_val);
293 if (ret < 0) 292 if (ret < 0)
294 goto err; 293 goto err;
295 294
296 ret = fc2580_wr_reg_ff(priv, 0x63, fc2580_freq_regs_lut[i].r63_val); 295 ret = fc2580_wr_reg_ff(dev, 0x63, fc2580_freq_regs_lut[i].r63_val);
297 if (ret < 0) 296 if (ret < 0)
298 goto err; 297 goto err;
299 298
300 ret = fc2580_wr_reg_ff(priv, 0x67, fc2580_freq_regs_lut[i].r67_val); 299 ret = fc2580_wr_reg_ff(dev, 0x67, fc2580_freq_regs_lut[i].r67_val);
301 if (ret < 0) 300 if (ret < 0)
302 goto err; 301 goto err;
303 302
304 ret = fc2580_wr_reg_ff(priv, 0x68, fc2580_freq_regs_lut[i].r68_val); 303 ret = fc2580_wr_reg_ff(dev, 0x68, fc2580_freq_regs_lut[i].r68_val);
305 if (ret < 0) 304 if (ret < 0)
306 goto err; 305 goto err;
307 306
308 ret = fc2580_wr_reg_ff(priv, 0x69, fc2580_freq_regs_lut[i].r69_val); 307 ret = fc2580_wr_reg_ff(dev, 0x69, fc2580_freq_regs_lut[i].r69_val);
309 if (ret < 0) 308 if (ret < 0)
310 goto err; 309 goto err;
311 310
312 ret = fc2580_wr_reg_ff(priv, 0x6a, fc2580_freq_regs_lut[i].r6a_val); 311 ret = fc2580_wr_reg_ff(dev, 0x6a, fc2580_freq_regs_lut[i].r6a_val);
313 if (ret < 0) 312 if (ret < 0)
314 goto err; 313 goto err;
315 314
316 ret = fc2580_wr_reg_ff(priv, 0x6b, fc2580_freq_regs_lut[i].r6b_val); 315 ret = fc2580_wr_reg_ff(dev, 0x6b, fc2580_freq_regs_lut[i].r6b_val);
317 if (ret < 0) 316 if (ret < 0)
318 goto err; 317 goto err;
319 318
320 ret = fc2580_wr_reg_ff(priv, 0x6c, fc2580_freq_regs_lut[i].r6c_val); 319 ret = fc2580_wr_reg_ff(dev, 0x6c, fc2580_freq_regs_lut[i].r6c_val);
321 if (ret < 0) 320 if (ret < 0)
322 goto err; 321 goto err;
323 322
324 ret = fc2580_wr_reg_ff(priv, 0x6d, fc2580_freq_regs_lut[i].r6d_val); 323 ret = fc2580_wr_reg_ff(dev, 0x6d, fc2580_freq_regs_lut[i].r6d_val);
325 if (ret < 0) 324 if (ret < 0)
326 goto err; 325 goto err;
327 326
328 ret = fc2580_wr_reg_ff(priv, 0x6e, fc2580_freq_regs_lut[i].r6e_val); 327 ret = fc2580_wr_reg_ff(dev, 0x6e, fc2580_freq_regs_lut[i].r6e_val);
329 if (ret < 0) 328 if (ret < 0)
330 goto err; 329 goto err;
331 330
332 ret = fc2580_wr_reg_ff(priv, 0x6f, fc2580_freq_regs_lut[i].r6f_val); 331 ret = fc2580_wr_reg_ff(dev, 0x6f, fc2580_freq_regs_lut[i].r6f_val);
333 if (ret < 0) 332 if (ret < 0)
334 goto err; 333 goto err;
335 334
@@ -343,112 +342,91 @@ static int fc2580_set_params(struct dvb_frontend *fe)
343 goto err; 342 goto err;
344 } 343 }
345 344
346 ret = fc2580_wr_reg(priv, 0x36, fc2580_if_filter_lut[i].r36_val); 345 ret = fc2580_wr_reg(dev, 0x36, fc2580_if_filter_lut[i].r36_val);
347 if (ret < 0) 346 if (ret < 0)
348 goto err; 347 goto err;
349 348
350 u8tmp = div_u64((u64) priv->clk * fc2580_if_filter_lut[i].mul, 349 u8tmp = div_u64((u64) dev->clk * fc2580_if_filter_lut[i].mul,
351 1000000000); 350 1000000000);
352 ret = fc2580_wr_reg(priv, 0x37, u8tmp); 351 ret = fc2580_wr_reg(dev, 0x37, u8tmp);
353 if (ret < 0) 352 if (ret < 0)
354 goto err; 353 goto err;
355 354
356 ret = fc2580_wr_reg(priv, 0x39, fc2580_if_filter_lut[i].r39_val); 355 ret = fc2580_wr_reg(dev, 0x39, fc2580_if_filter_lut[i].r39_val);
357 if (ret < 0) 356 if (ret < 0)
358 goto err; 357 goto err;
359 358
360 timeout = jiffies + msecs_to_jiffies(30); 359 timeout = jiffies + msecs_to_jiffies(30);
361 for (uitmp = ~0xc0; !time_after(jiffies, timeout) && uitmp != 0xc0;) { 360 for (uitmp = ~0xc0; !time_after(jiffies, timeout) && uitmp != 0xc0;) {
362 /* trigger filter */ 361 /* trigger filter */
363 ret = fc2580_wr_reg(priv, 0x2e, 0x09); 362 ret = fc2580_wr_reg(dev, 0x2e, 0x09);
364 if (ret) 363 if (ret)
365 goto err; 364 goto err;
366 365
367 /* locked when [7:6] are set (val: d7 6MHz, d5 7MHz, cd 8MHz) */ 366 /* locked when [7:6] are set (val: d7 6MHz, d5 7MHz, cd 8MHz) */
368 ret = fc2580_rd_reg(priv, 0x2f, &u8tmp); 367 ret = fc2580_rd_reg(dev, 0x2f, &u8tmp);
369 if (ret) 368 if (ret)
370 goto err; 369 goto err;
371 uitmp = u8tmp & 0xc0; 370 uitmp = u8tmp & 0xc0;
372 371
373 ret = fc2580_wr_reg(priv, 0x2e, 0x01); 372 ret = fc2580_wr_reg(dev, 0x2e, 0x01);
374 if (ret) 373 if (ret)
375 goto err; 374 goto err;
376 } 375 }
377 if (uitmp != 0xc0) 376 if (uitmp != 0xc0)
378 dev_dbg(&client->dev, "filter did not lock %02x\n", uitmp); 377 dev_dbg(&client->dev, "filter did not lock %02x\n", uitmp);
379 378
380 if (fe->ops.i2c_gate_ctrl)
381 fe->ops.i2c_gate_ctrl(fe, 0);
382
383 return 0; 379 return 0;
384err: 380err:
385 if (fe->ops.i2c_gate_ctrl)
386 fe->ops.i2c_gate_ctrl(fe, 0);
387
388 dev_dbg(&client->dev, "failed=%d\n", ret); 381 dev_dbg(&client->dev, "failed=%d\n", ret);
389 return ret; 382 return ret;
390} 383}
391 384
392static int fc2580_init(struct dvb_frontend *fe) 385static int fc2580_init(struct dvb_frontend *fe)
393{ 386{
394 struct fc2580_priv *priv = fe->tuner_priv; 387 struct fc2580_dev *dev = fe->tuner_priv;
388 struct i2c_client *client = dev->client;
395 int ret, i; 389 int ret, i;
396 390
397 dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 391 dev_dbg(&client->dev, "\n");
398
399 if (fe->ops.i2c_gate_ctrl)
400 fe->ops.i2c_gate_ctrl(fe, 1);
401 392
402 for (i = 0; i < ARRAY_SIZE(fc2580_init_reg_vals); i++) { 393 for (i = 0; i < ARRAY_SIZE(fc2580_init_reg_vals); i++) {
403 ret = fc2580_wr_reg(priv, fc2580_init_reg_vals[i].reg, 394 ret = fc2580_wr_reg(dev, fc2580_init_reg_vals[i].reg,
404 fc2580_init_reg_vals[i].val); 395 fc2580_init_reg_vals[i].val);
405 if (ret < 0) 396 if (ret < 0)
406 goto err; 397 goto err;
407 } 398 }
408 399
409 if (fe->ops.i2c_gate_ctrl)
410 fe->ops.i2c_gate_ctrl(fe, 0);
411
412 return 0; 400 return 0;
413err: 401err:
414 if (fe->ops.i2c_gate_ctrl) 402 dev_dbg(&client->dev, "failed=%d\n", ret);
415 fe->ops.i2c_gate_ctrl(fe, 0);
416
417 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
418 return ret; 403 return ret;
419} 404}
420 405
421static int fc2580_sleep(struct dvb_frontend *fe) 406static int fc2580_sleep(struct dvb_frontend *fe)
422{ 407{
423 struct fc2580_priv *priv = fe->tuner_priv; 408 struct fc2580_dev *dev = fe->tuner_priv;
409 struct i2c_client *client = dev->client;
424 int ret; 410 int ret;
425 411
426 dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 412 dev_dbg(&client->dev, "\n");
427
428 if (fe->ops.i2c_gate_ctrl)
429 fe->ops.i2c_gate_ctrl(fe, 1);
430 413
431 ret = fc2580_wr_reg(priv, 0x02, 0x0a); 414 ret = fc2580_wr_reg(dev, 0x02, 0x0a);
432 if (ret < 0) 415 if (ret < 0)
433 goto err; 416 goto err;
434 417
435 if (fe->ops.i2c_gate_ctrl)
436 fe->ops.i2c_gate_ctrl(fe, 0);
437
438 return 0; 418 return 0;
439err: 419err:
440 if (fe->ops.i2c_gate_ctrl) 420 dev_dbg(&client->dev, "failed=%d\n", ret);
441 fe->ops.i2c_gate_ctrl(fe, 0);
442
443 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
444 return ret; 421 return ret;
445} 422}
446 423
447static int fc2580_get_if_frequency(struct dvb_frontend *fe, u32 *frequency) 424static int fc2580_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)
448{ 425{
449 struct fc2580_priv *priv = fe->tuner_priv; 426 struct fc2580_dev *dev = fe->tuner_priv;
427 struct i2c_client *client = dev->client;
450 428
451 dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 429 dev_dbg(&client->dev, "\n");
452 430
453 *frequency = 0; /* Zero-IF */ 431 *frequency = 0; /* Zero-IF */
454 432
@@ -472,7 +450,7 @@ static const struct dvb_tuner_ops fc2580_tuner_ops = {
472static int fc2580_probe(struct i2c_client *client, 450static int fc2580_probe(struct i2c_client *client,
473 const struct i2c_device_id *id) 451 const struct i2c_device_id *id)
474{ 452{
475 struct fc2580_priv *dev; 453 struct fc2580_dev *dev;
476 struct fc2580_platform_data *pdata = client->dev.platform_data; 454 struct fc2580_platform_data *pdata = client->dev.platform_data;
477 struct dvb_frontend *fe = pdata->dvb_frontend; 455 struct dvb_frontend *fe = pdata->dvb_frontend;
478 int ret; 456 int ret;
@@ -523,7 +501,7 @@ err:
523 501
524static int fc2580_remove(struct i2c_client *client) 502static int fc2580_remove(struct i2c_client *client)
525{ 503{
526 struct fc2580_priv *dev = i2c_get_clientdata(client); 504 struct fc2580_dev *dev = i2c_get_clientdata(client);
527 505
528 dev_dbg(&client->dev, "\n"); 506 dev_dbg(&client->dev, "\n");
529 507
diff --git a/drivers/media/tuners/fc2580_priv.h b/drivers/media/tuners/fc2580_priv.h
index 068531b70078..16245ee878b1 100644
--- a/drivers/media/tuners/fc2580_priv.h
+++ b/drivers/media/tuners/fc2580_priv.h
@@ -127,7 +127,7 @@ static const struct fc2580_freq_regs fc2580_freq_regs_lut[] = {
127 0x0a, 0xa0, 0x50, 0x14}, 127 0x0a, 0xa0, 0x50, 0x14},
128}; 128};
129 129
130struct fc2580_priv { 130struct fc2580_dev {
131 u32 clk; 131 u32 clk;
132 struct i2c_client *client; 132 struct i2c_client *client;
133 struct i2c_adapter *i2c; 133 struct i2c_adapter *i2c;