aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-wl1273.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio/radio-wl1273.c')
-rw-r--r--drivers/media/radio/radio-wl1273.c365
1 files changed, 106 insertions, 259 deletions
diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c
index 4698eb00b59f..e2550dc2944f 100644
--- a/drivers/media/radio/radio-wl1273.c
+++ b/drivers/media/radio/radio-wl1273.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for the Texas Instruments WL1273 FM radio. 2 * Driver for the Texas Instruments WL1273 FM radio.
3 * 3 *
4 * Copyright (C) 2010 Nokia Corporation 4 * Copyright (C) 2011 Nokia Corporation
5 * Author: Matti J. Aaltonen <matti.j.aaltonen@nokia.com> 5 * Author: Matti J. Aaltonen <matti.j.aaltonen@nokia.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
@@ -67,7 +67,6 @@ struct wl1273_device {
67 67
68 /* RDS */ 68 /* RDS */
69 unsigned int rds_on; 69 unsigned int rds_on;
70 struct delayed_work work;
71 70
72 wait_queue_head_t read_queue; 71 wait_queue_head_t read_queue;
73 struct mutex lock; /* for serializing fm radio operations */ 72 struct mutex lock; /* for serializing fm radio operations */
@@ -104,58 +103,6 @@ static unsigned int rds_buf = 100;
104module_param(rds_buf, uint, 0); 103module_param(rds_buf, uint, 0);
105MODULE_PARM_DESC(rds_buf, "Number of RDS buffer entries. Default = 100"); 104MODULE_PARM_DESC(rds_buf, "Number of RDS buffer entries. Default = 100");
106 105
107static int wl1273_fm_read_reg(struct wl1273_core *core, u8 reg, u16 *value)
108{
109 struct i2c_client *client = core->client;
110 u8 b[2];
111 int r;
112
113 r = i2c_smbus_read_i2c_block_data(client, reg, sizeof(b), b);
114 if (r != 2) {
115 dev_err(&client->dev, "%s: Read: %d fails.\n", __func__, reg);
116 return -EREMOTEIO;
117 }
118
119 *value = (u16)b[0] << 8 | b[1];
120
121 return 0;
122}
123
124static int wl1273_fm_write_cmd(struct wl1273_core *core, u8 cmd, u16 param)
125{
126 struct i2c_client *client = core->client;
127 u8 buf[] = { (param >> 8) & 0xff, param & 0xff };
128 int r;
129
130 r = i2c_smbus_write_i2c_block_data(client, cmd, sizeof(buf), buf);
131 if (r) {
132 dev_err(&client->dev, "%s: Cmd: %d fails.\n", __func__, cmd);
133 return r;
134 }
135
136 return 0;
137}
138
139static int wl1273_fm_write_data(struct wl1273_core *core, u8 *data, u16 len)
140{
141 struct i2c_client *client = core->client;
142 struct i2c_msg msg;
143 int r;
144
145 msg.addr = client->addr;
146 msg.flags = 0;
147 msg.buf = data;
148 msg.len = len;
149
150 r = i2c_transfer(client->adapter, &msg, 1);
151 if (r != 1) {
152 dev_err(&client->dev, "%s: write error.\n", __func__);
153 return -EREMOTEIO;
154 }
155
156 return 0;
157}
158
159static int wl1273_fm_write_fw(struct wl1273_core *core, 106static int wl1273_fm_write_fw(struct wl1273_core *core,
160 __u8 *fw, int len) 107 __u8 *fw, int len)
161{ 108{
@@ -188,94 +135,6 @@ static int wl1273_fm_write_fw(struct wl1273_core *core,
188 return r; 135 return r;
189} 136}
190 137
191/**
192 * wl1273_fm_set_audio() - Set audio mode.
193 * @core: A pointer to the device struct.
194 * @new_mode: The new audio mode.
195 *
196 * Audio modes are WL1273_AUDIO_DIGITAL and WL1273_AUDIO_ANALOG.
197 */
198static int wl1273_fm_set_audio(struct wl1273_core *core, unsigned int new_mode)
199{
200 int r = 0;
201
202 if (core->mode == WL1273_MODE_OFF ||
203 core->mode == WL1273_MODE_SUSPENDED)
204 return -EPERM;
205
206 if (core->mode == WL1273_MODE_RX && new_mode == WL1273_AUDIO_DIGITAL) {
207 r = wl1273_fm_write_cmd(core, WL1273_PCM_MODE_SET,
208 WL1273_PCM_DEF_MODE);
209 if (r)
210 goto out;
211
212 r = wl1273_fm_write_cmd(core, WL1273_I2S_MODE_CONFIG_SET,
213 core->i2s_mode);
214 if (r)
215 goto out;
216
217 r = wl1273_fm_write_cmd(core, WL1273_AUDIO_ENABLE,
218 WL1273_AUDIO_ENABLE_I2S);
219 if (r)
220 goto out;
221
222 } else if (core->mode == WL1273_MODE_RX &&
223 new_mode == WL1273_AUDIO_ANALOG) {
224 r = wl1273_fm_write_cmd(core, WL1273_AUDIO_ENABLE,
225 WL1273_AUDIO_ENABLE_ANALOG);
226 if (r)
227 goto out;
228
229 } else if (core->mode == WL1273_MODE_TX &&
230 new_mode == WL1273_AUDIO_DIGITAL) {
231 r = wl1273_fm_write_cmd(core, WL1273_I2S_MODE_CONFIG_SET,
232 core->i2s_mode);
233 if (r)
234 goto out;
235
236 r = wl1273_fm_write_cmd(core, WL1273_AUDIO_IO_SET,
237 WL1273_AUDIO_IO_SET_I2S);
238 if (r)
239 goto out;
240
241 } else if (core->mode == WL1273_MODE_TX &&
242 new_mode == WL1273_AUDIO_ANALOG) {
243 r = wl1273_fm_write_cmd(core, WL1273_AUDIO_IO_SET,
244 WL1273_AUDIO_IO_SET_ANALOG);
245 if (r)
246 goto out;
247 }
248
249 core->audio_mode = new_mode;
250out:
251 return r;
252}
253
254/**
255 * wl1273_fm_set_volume() - Set volume.
256 * @core: A pointer to the device struct.
257 * @volume: The new volume value.
258 */
259static int wl1273_fm_set_volume(struct wl1273_core *core, unsigned int volume)
260{
261 u16 val;
262 int r;
263
264 if (volume > WL1273_MAX_VOLUME)
265 return -EINVAL;
266
267 if (core->volume == volume)
268 return 0;
269
270 val = volume;
271 r = wl1273_fm_read_reg(core, WL1273_VOLUME_SET, &val);
272 if (r)
273 return r;
274
275 core->volume = volume;
276 return 0;
277}
278
279#define WL1273_FIFO_HAS_DATA(status) (1 << 5 & status) 138#define WL1273_FIFO_HAS_DATA(status) (1 << 5 & status)
280#define WL1273_RDS_CORRECTABLE_ERROR (1 << 3) 139#define WL1273_RDS_CORRECTABLE_ERROR (1 << 3)
281#define WL1273_RDS_UNCORRECTABLE_ERROR (1 << 4) 140#define WL1273_RDS_UNCORRECTABLE_ERROR (1 << 4)
@@ -306,7 +165,7 @@ static int wl1273_fm_rds(struct wl1273_device *radio)
306 if (core->mode != WL1273_MODE_RX) 165 if (core->mode != WL1273_MODE_RX)
307 return 0; 166 return 0;
308 167
309 r = wl1273_fm_read_reg(core, WL1273_RDS_SYNC_GET, &val); 168 r = core->read(core, WL1273_RDS_SYNC_GET, &val);
310 if (r) 169 if (r)
311 return r; 170 return r;
312 171
@@ -374,7 +233,7 @@ static irqreturn_t wl1273_fm_irq_thread_handler(int irq, void *dev_id)
374 u16 flags; 233 u16 flags;
375 int r; 234 int r;
376 235
377 r = wl1273_fm_read_reg(core, WL1273_FLAG_GET, &flags); 236 r = core->read(core, WL1273_FLAG_GET, &flags);
378 if (r) 237 if (r)
379 goto out; 238 goto out;
380 239
@@ -398,7 +257,7 @@ static irqreturn_t wl1273_fm_irq_thread_handler(int irq, void *dev_id)
398 if (flags & WL1273_LEV_EVENT) { 257 if (flags & WL1273_LEV_EVENT) {
399 u16 level; 258 u16 level;
400 259
401 r = wl1273_fm_read_reg(core, WL1273_RSSI_LVL_GET, &level); 260 r = core->read(core, WL1273_RSSI_LVL_GET, &level);
402 if (r) 261 if (r)
403 goto out; 262 goto out;
404 263
@@ -439,8 +298,8 @@ static irqreturn_t wl1273_fm_irq_thread_handler(int irq, void *dev_id)
439 dev_dbg(radio->dev, "IRQ: FR:\n"); 298 dev_dbg(radio->dev, "IRQ: FR:\n");
440 299
441 if (core->mode == WL1273_MODE_RX) { 300 if (core->mode == WL1273_MODE_RX) {
442 r = wl1273_fm_write_cmd(core, WL1273_TUNER_MODE_SET, 301 r = core->write(core, WL1273_TUNER_MODE_SET,
443 TUNER_MODE_STOP_SEARCH); 302 TUNER_MODE_STOP_SEARCH);
444 if (r) { 303 if (r) {
445 dev_err(radio->dev, 304 dev_err(radio->dev,
446 "%s: TUNER_MODE_SET fails: %d\n", 305 "%s: TUNER_MODE_SET fails: %d\n",
@@ -448,7 +307,7 @@ static irqreturn_t wl1273_fm_irq_thread_handler(int irq, void *dev_id)
448 goto out; 307 goto out;
449 } 308 }
450 309
451 r = wl1273_fm_read_reg(core, WL1273_FREQ_SET, &freq); 310 r = core->read(core, WL1273_FREQ_SET, &freq);
452 if (r) 311 if (r)
453 goto out; 312 goto out;
454 313
@@ -467,7 +326,7 @@ static irqreturn_t wl1273_fm_irq_thread_handler(int irq, void *dev_id)
467 dev_dbg(radio->dev, "%dkHz\n", radio->rx_frequency); 326 dev_dbg(radio->dev, "%dkHz\n", radio->rx_frequency);
468 327
469 } else { 328 } else {
470 r = wl1273_fm_read_reg(core, WL1273_CHANL_SET, &freq); 329 r = core->read(core, WL1273_CHANL_SET, &freq);
471 if (r) 330 if (r)
472 goto out; 331 goto out;
473 332
@@ -477,8 +336,7 @@ static irqreturn_t wl1273_fm_irq_thread_handler(int irq, void *dev_id)
477 } 336 }
478 337
479out: 338out:
480 wl1273_fm_write_cmd(core, WL1273_INT_MASK_SET, 339 core->write(core, WL1273_INT_MASK_SET, radio->irq_flags);
481 radio->irq_flags);
482 complete(&radio->busy); 340 complete(&radio->busy);
483 341
484 return IRQ_HANDLED; 342 return IRQ_HANDLED;
@@ -512,7 +370,7 @@ static int wl1273_fm_set_tx_freq(struct wl1273_device *radio, unsigned int freq)
512 dev_dbg(radio->dev, "%s: freq: %d kHz\n", __func__, freq); 370 dev_dbg(radio->dev, "%s: freq: %d kHz\n", __func__, freq);
513 371
514 /* Set the current tx channel */ 372 /* Set the current tx channel */
515 r = wl1273_fm_write_cmd(core, WL1273_CHANL_SET, freq / 10); 373 r = core->write(core, WL1273_CHANL_SET, freq / 10);
516 if (r) 374 if (r)
517 return r; 375 return r;
518 376
@@ -526,7 +384,7 @@ static int wl1273_fm_set_tx_freq(struct wl1273_device *radio, unsigned int freq)
526 dev_dbg(radio->dev, "WL1273_CHANL_SET: %d\n", r); 384 dev_dbg(radio->dev, "WL1273_CHANL_SET: %d\n", r);
527 385
528 /* Enable the output power */ 386 /* Enable the output power */
529 r = wl1273_fm_write_cmd(core, WL1273_POWER_ENB_SET, 1); 387 r = core->write(core, WL1273_POWER_ENB_SET, 1);
530 if (r) 388 if (r)
531 return r; 389 return r;
532 390
@@ -566,20 +424,20 @@ static int wl1273_fm_set_rx_freq(struct wl1273_device *radio, unsigned int freq)
566 424
567 dev_dbg(radio->dev, "%s: %dkHz\n", __func__, freq); 425 dev_dbg(radio->dev, "%s: %dkHz\n", __func__, freq);
568 426
569 wl1273_fm_write_cmd(core, WL1273_INT_MASK_SET, radio->irq_flags); 427 core->write(core, WL1273_INT_MASK_SET, radio->irq_flags);
570 428
571 if (radio->band == WL1273_BAND_JAPAN) 429 if (radio->band == WL1273_BAND_JAPAN)
572 f = (freq - WL1273_BAND_JAPAN_LOW) / 50; 430 f = (freq - WL1273_BAND_JAPAN_LOW) / 50;
573 else 431 else
574 f = (freq - WL1273_BAND_OTHER_LOW) / 50; 432 f = (freq - WL1273_BAND_OTHER_LOW) / 50;
575 433
576 r = wl1273_fm_write_cmd(core, WL1273_FREQ_SET, f); 434 r = core->write(core, WL1273_FREQ_SET, f);
577 if (r) { 435 if (r) {
578 dev_err(radio->dev, "FREQ_SET fails\n"); 436 dev_err(radio->dev, "FREQ_SET fails\n");
579 goto err; 437 goto err;
580 } 438 }
581 439
582 r = wl1273_fm_write_cmd(core, WL1273_TUNER_MODE_SET, TUNER_MODE_PRESET); 440 r = core->write(core, WL1273_TUNER_MODE_SET, TUNER_MODE_PRESET);
583 if (r) { 441 if (r) {
584 dev_err(radio->dev, "TUNER_MODE_SET fails\n"); 442 dev_err(radio->dev, "TUNER_MODE_SET fails\n");
585 goto err; 443 goto err;
@@ -609,7 +467,7 @@ static int wl1273_fm_get_freq(struct wl1273_device *radio)
609 int r; 467 int r;
610 468
611 if (core->mode == WL1273_MODE_RX) { 469 if (core->mode == WL1273_MODE_RX) {
612 r = wl1273_fm_read_reg(core, WL1273_FREQ_SET, &f); 470 r = core->read(core, WL1273_FREQ_SET, &f);
613 if (r) 471 if (r)
614 return r; 472 return r;
615 473
@@ -619,7 +477,7 @@ static int wl1273_fm_get_freq(struct wl1273_device *radio)
619 else 477 else
620 freq = WL1273_BAND_OTHER_LOW + 50 * f; 478 freq = WL1273_BAND_OTHER_LOW + 50 * f;
621 } else { 479 } else {
622 r = wl1273_fm_read_reg(core, WL1273_CHANL_SET, &f); 480 r = core->read(core, WL1273_CHANL_SET, &f);
623 if (r) 481 if (r)
624 return r; 482 return r;
625 483
@@ -670,7 +528,7 @@ static int wl1273_fm_upload_firmware_patch(struct wl1273_device *radio)
670 } 528 }
671 529
672 /* ignore possible error here */ 530 /* ignore possible error here */
673 wl1273_fm_write_cmd(core, WL1273_RESET, 0); 531 core->write(core, WL1273_RESET, 0);
674 532
675 dev_dbg(dev, "%s - download OK, r: %d\n", __func__, r); 533 dev_dbg(dev, "%s - download OK, r: %d\n", __func__, r);
676out: 534out:
@@ -683,14 +541,14 @@ static int wl1273_fm_stop(struct wl1273_device *radio)
683 struct wl1273_core *core = radio->core; 541 struct wl1273_core *core = radio->core;
684 542
685 if (core->mode == WL1273_MODE_RX) { 543 if (core->mode == WL1273_MODE_RX) {
686 int r = wl1273_fm_write_cmd(core, WL1273_POWER_SET, 544 int r = core->write(core, WL1273_POWER_SET,
687 WL1273_POWER_SET_OFF); 545 WL1273_POWER_SET_OFF);
688 if (r) 546 if (r)
689 dev_err(radio->dev, "%s: POWER_SET fails: %d\n", 547 dev_err(radio->dev, "%s: POWER_SET fails: %d\n",
690 __func__, r); 548 __func__, r);
691 } else if (core->mode == WL1273_MODE_TX) { 549 } else if (core->mode == WL1273_MODE_TX) {
692 int r = wl1273_fm_write_cmd(core, WL1273_PUPD_SET, 550 int r = core->write(core, WL1273_PUPD_SET,
693 WL1273_PUPD_SET_OFF); 551 WL1273_PUPD_SET_OFF);
694 if (r) 552 if (r)
695 dev_err(radio->dev, 553 dev_err(radio->dev,
696 "%s: PUPD_SET fails: %d\n", __func__, r); 554 "%s: PUPD_SET fails: %d\n", __func__, r);
@@ -725,11 +583,11 @@ static int wl1273_fm_start(struct wl1273_device *radio, int new_mode)
725 val |= WL1273_POWER_SET_RDS; 583 val |= WL1273_POWER_SET_RDS;
726 584
727 /* If this fails try again */ 585 /* If this fails try again */
728 r = wl1273_fm_write_cmd(core, WL1273_POWER_SET, val); 586 r = core->write(core, WL1273_POWER_SET, val);
729 if (r) { 587 if (r) {
730 msleep(100); 588 msleep(100);
731 589
732 r = wl1273_fm_write_cmd(core, WL1273_POWER_SET, val); 590 r = core->write(core, WL1273_POWER_SET, val);
733 if (r) { 591 if (r) {
734 dev_err(dev, "%s: POWER_SET fails\n", __func__); 592 dev_err(dev, "%s: POWER_SET fails\n", __func__);
735 goto fail; 593 goto fail;
@@ -742,11 +600,10 @@ static int wl1273_fm_start(struct wl1273_device *radio, int new_mode)
742 600
743 } else if (new_mode == WL1273_MODE_TX) { 601 } else if (new_mode == WL1273_MODE_TX) {
744 /* If this fails try again once */ 602 /* If this fails try again once */
745 r = wl1273_fm_write_cmd(core, WL1273_PUPD_SET, 603 r = core->write(core, WL1273_PUPD_SET, WL1273_PUPD_SET_ON);
746 WL1273_PUPD_SET_ON);
747 if (r) { 604 if (r) {
748 msleep(100); 605 msleep(100);
749 r = wl1273_fm_write_cmd(core, WL1273_PUPD_SET, 606 r = core->write(core, WL1273_PUPD_SET,
750 WL1273_PUPD_SET_ON); 607 WL1273_PUPD_SET_ON);
751 if (r) { 608 if (r) {
752 dev_err(dev, "%s: PUPD_SET fails\n", __func__); 609 dev_err(dev, "%s: PUPD_SET fails\n", __func__);
@@ -755,9 +612,9 @@ static int wl1273_fm_start(struct wl1273_device *radio, int new_mode)
755 } 612 }
756 613
757 if (radio->rds_on) 614 if (radio->rds_on)
758 r = wl1273_fm_write_cmd(core, WL1273_RDS_DATA_ENB, 1); 615 r = core->write(core, WL1273_RDS_DATA_ENB, 1);
759 else 616 else
760 r = wl1273_fm_write_cmd(core, WL1273_RDS_DATA_ENB, 0); 617 r = core->write(core, WL1273_RDS_DATA_ENB, 0);
761 } else { 618 } else {
762 dev_warn(dev, "%s: Illegal mode.\n", __func__); 619 dev_warn(dev, "%s: Illegal mode.\n", __func__);
763 } 620 }
@@ -777,14 +634,14 @@ static int wl1273_fm_start(struct wl1273_device *radio, int new_mode)
777 if (radio->rds_on) 634 if (radio->rds_on)
778 val |= WL1273_POWER_SET_RDS; 635 val |= WL1273_POWER_SET_RDS;
779 636
780 r = wl1273_fm_write_cmd(core, WL1273_POWER_SET, val); 637 r = core->write(core, WL1273_POWER_SET, val);
781 if (r) { 638 if (r) {
782 dev_err(dev, "%s: POWER_SET fails\n", __func__); 639 dev_err(dev, "%s: POWER_SET fails\n", __func__);
783 goto fail; 640 goto fail;
784 } 641 }
785 } else if (new_mode == WL1273_MODE_TX) { 642 } else if (new_mode == WL1273_MODE_TX) {
786 r = wl1273_fm_write_cmd(core, WL1273_PUPD_SET, 643 r = core->write(core, WL1273_PUPD_SET,
787 WL1273_PUPD_SET_ON); 644 WL1273_PUPD_SET_ON);
788 if (r) { 645 if (r) {
789 dev_err(dev, "%s: PUPD_SET fails\n", __func__); 646 dev_err(dev, "%s: PUPD_SET fails\n", __func__);
790 goto fail; 647 goto fail;
@@ -808,10 +665,10 @@ static int wl1273_fm_suspend(struct wl1273_device *radio)
808 665
809 /* Cannot go from OFF to SUSPENDED */ 666 /* Cannot go from OFF to SUSPENDED */
810 if (core->mode == WL1273_MODE_RX) 667 if (core->mode == WL1273_MODE_RX)
811 r = wl1273_fm_write_cmd(core, WL1273_POWER_SET, 668 r = core->write(core, WL1273_POWER_SET,
812 WL1273_POWER_SET_RETENTION); 669 WL1273_POWER_SET_RETENTION);
813 else if (core->mode == WL1273_MODE_TX) 670 else if (core->mode == WL1273_MODE_TX)
814 r = wl1273_fm_write_cmd(core, WL1273_PUPD_SET, 671 r = core->write(core, WL1273_PUPD_SET,
815 WL1273_PUPD_SET_RETENTION); 672 WL1273_PUPD_SET_RETENTION);
816 else 673 else
817 r = -EINVAL; 674 r = -EINVAL;
@@ -852,8 +709,7 @@ static int wl1273_fm_set_mode(struct wl1273_device *radio, int mode)
852 } 709 }
853 710
854 core->mode = mode; 711 core->mode = mode;
855 r = wl1273_fm_write_cmd(core, WL1273_INT_MASK_SET, 712 r = core->write(core, WL1273_INT_MASK_SET, radio->irq_flags);
856 radio->irq_flags);
857 if (r) { 713 if (r) {
858 dev_err(dev, "INT_MASK_SET fails.\n"); 714 dev_err(dev, "INT_MASK_SET fails.\n");
859 goto out; 715 goto out;
@@ -951,22 +807,21 @@ static int wl1273_fm_set_seek(struct wl1273_device *radio,
951 INIT_COMPLETION(radio->busy); 807 INIT_COMPLETION(radio->busy);
952 dev_dbg(radio->dev, "%s: BUSY\n", __func__); 808 dev_dbg(radio->dev, "%s: BUSY\n", __func__);
953 809
954 r = wl1273_fm_write_cmd(core, WL1273_INT_MASK_SET, radio->irq_flags); 810 r = core->write(core, WL1273_INT_MASK_SET, radio->irq_flags);
955 if (r) 811 if (r)
956 goto out; 812 goto out;
957 813
958 dev_dbg(radio->dev, "%s\n", __func__); 814 dev_dbg(radio->dev, "%s\n", __func__);
959 815
960 r = wl1273_fm_write_cmd(core, WL1273_SEARCH_LVL_SET, level); 816 r = core->write(core, WL1273_SEARCH_LVL_SET, level);
961 if (r) 817 if (r)
962 goto out; 818 goto out;
963 819
964 r = wl1273_fm_write_cmd(core, WL1273_SEARCH_DIR_SET, dir); 820 r = core->write(core, WL1273_SEARCH_DIR_SET, dir);
965 if (r) 821 if (r)
966 goto out; 822 goto out;
967 823
968 r = wl1273_fm_write_cmd(core, WL1273_TUNER_MODE_SET, 824 r = core->write(core, WL1273_TUNER_MODE_SET, TUNER_MODE_AUTO_SEEK);
969 TUNER_MODE_AUTO_SEEK);
970 if (r) 825 if (r)
971 goto out; 826 goto out;
972 827
@@ -994,8 +849,7 @@ static int wl1273_fm_set_seek(struct wl1273_device *radio,
994 INIT_COMPLETION(radio->busy); 849 INIT_COMPLETION(radio->busy);
995 dev_dbg(radio->dev, "%s: BUSY\n", __func__); 850 dev_dbg(radio->dev, "%s: BUSY\n", __func__);
996 851
997 r = wl1273_fm_write_cmd(core, WL1273_TUNER_MODE_SET, 852 r = core->write(core, WL1273_TUNER_MODE_SET, TUNER_MODE_AUTO_SEEK);
998 TUNER_MODE_AUTO_SEEK);
999 if (r) 853 if (r)
1000 goto out; 854 goto out;
1001 855
@@ -1020,7 +874,7 @@ static unsigned int wl1273_fm_get_tx_ctune(struct wl1273_device *radio)
1020 core->mode == WL1273_MODE_SUSPENDED) 874 core->mode == WL1273_MODE_SUSPENDED)
1021 return -EPERM; 875 return -EPERM;
1022 876
1023 r = wl1273_fm_read_reg(core, WL1273_READ_FMANT_TUNE_VALUE, &val); 877 r = core->read(core, WL1273_READ_FMANT_TUNE_VALUE, &val);
1024 if (r) { 878 if (r) {
1025 dev_err(dev, "%s: read error: %d\n", __func__, r); 879 dev_err(dev, "%s: read error: %d\n", __func__, r);
1026 goto out; 880 goto out;
@@ -1066,7 +920,7 @@ static int wl1273_fm_set_preemphasis(struct wl1273_device *radio,
1066 goto out; 920 goto out;
1067 } 921 }
1068 922
1069 r = wl1273_fm_write_cmd(core, WL1273_PREMPH_SET, em); 923 r = core->write(core, WL1273_PREMPH_SET, em);
1070 if (r) 924 if (r)
1071 goto out; 925 goto out;
1072 926
@@ -1086,7 +940,7 @@ static int wl1273_fm_rds_on(struct wl1273_device *radio)
1086 if (radio->rds_on) 940 if (radio->rds_on)
1087 return 0; 941 return 0;
1088 942
1089 r = wl1273_fm_write_cmd(core, WL1273_POWER_SET, 943 r = core->write(core, WL1273_POWER_SET,
1090 WL1273_POWER_SET_FM | WL1273_POWER_SET_RDS); 944 WL1273_POWER_SET_FM | WL1273_POWER_SET_RDS);
1091 if (r) 945 if (r)
1092 goto out; 946 goto out;
@@ -1108,19 +962,16 @@ static int wl1273_fm_rds_off(struct wl1273_device *radio)
1108 962
1109 radio->irq_flags &= ~WL1273_RDS_EVENT; 963 radio->irq_flags &= ~WL1273_RDS_EVENT;
1110 964
1111 r = wl1273_fm_write_cmd(core, WL1273_INT_MASK_SET, radio->irq_flags); 965 r = core->write(core, WL1273_INT_MASK_SET, radio->irq_flags);
1112 if (r) 966 if (r)
1113 goto out; 967 goto out;
1114 968
1115 /* stop rds reception */
1116 cancel_delayed_work(&radio->work);
1117
1118 /* Service pending read */ 969 /* Service pending read */
1119 wake_up_interruptible(&radio->read_queue); 970 wake_up_interruptible(&radio->read_queue);
1120 971
1121 dev_dbg(radio->dev, "%s\n", __func__); 972 dev_dbg(radio->dev, "%s\n", __func__);
1122 973
1123 r = wl1273_fm_write_cmd(core, WL1273_POWER_SET, WL1273_POWER_SET_FM); 974 r = core->write(core, WL1273_POWER_SET, WL1273_POWER_SET_FM);
1124 if (r) 975 if (r)
1125 goto out; 976 goto out;
1126 977
@@ -1143,14 +994,14 @@ static int wl1273_fm_set_rds(struct wl1273_device *radio, unsigned int new_mode)
1143 return -EPERM; 994 return -EPERM;
1144 995
1145 if (new_mode == WL1273_RDS_RESET) { 996 if (new_mode == WL1273_RDS_RESET) {
1146 r = wl1273_fm_write_cmd(core, WL1273_RDS_CNTRL_SET, 1); 997 r = core->write(core, WL1273_RDS_CNTRL_SET, 1);
1147 return r; 998 return r;
1148 } 999 }
1149 1000
1150 if (core->mode == WL1273_MODE_TX && new_mode == WL1273_RDS_OFF) { 1001 if (core->mode == WL1273_MODE_TX && new_mode == WL1273_RDS_OFF) {
1151 r = wl1273_fm_write_cmd(core, WL1273_RDS_DATA_ENB, 0); 1002 r = core->write(core, WL1273_RDS_DATA_ENB, 0);
1152 } else if (core->mode == WL1273_MODE_TX && new_mode == WL1273_RDS_ON) { 1003 } else if (core->mode == WL1273_MODE_TX && new_mode == WL1273_RDS_ON) {
1153 r = wl1273_fm_write_cmd(core, WL1273_RDS_DATA_ENB, 1); 1004 r = core->write(core, WL1273_RDS_DATA_ENB, 1);
1154 } else if (core->mode == WL1273_MODE_RX && new_mode == WL1273_RDS_OFF) { 1005 } else if (core->mode == WL1273_MODE_RX && new_mode == WL1273_RDS_OFF) {
1155 r = wl1273_fm_rds_off(radio); 1006 r = wl1273_fm_rds_off(radio);
1156 } else if (core->mode == WL1273_MODE_RX && new_mode == WL1273_RDS_ON) { 1007 } else if (core->mode == WL1273_MODE_RX && new_mode == WL1273_RDS_ON) {
@@ -1171,12 +1022,13 @@ static ssize_t wl1273_fm_fops_write(struct file *file, const char __user *buf,
1171 size_t count, loff_t *ppos) 1022 size_t count, loff_t *ppos)
1172{ 1023{
1173 struct wl1273_device *radio = video_get_drvdata(video_devdata(file)); 1024 struct wl1273_device *radio = video_get_drvdata(video_devdata(file));
1025 struct wl1273_core *core = radio->core;
1174 u16 val; 1026 u16 val;
1175 int r; 1027 int r;
1176 1028
1177 dev_dbg(radio->dev, "%s\n", __func__); 1029 dev_dbg(radio->dev, "%s\n", __func__);
1178 1030
1179 if (radio->core->mode != WL1273_MODE_TX) 1031 if (core->mode != WL1273_MODE_TX)
1180 return count; 1032 return count;
1181 1033
1182 if (radio->rds_users == 0) { 1034 if (radio->rds_users == 0) {
@@ -1184,7 +1036,7 @@ static ssize_t wl1273_fm_fops_write(struct file *file, const char __user *buf,
1184 return 0; 1036 return 0;
1185 } 1037 }
1186 1038
1187 if (mutex_lock_interruptible(&radio->core->lock)) 1039 if (mutex_lock_interruptible(&core->lock))
1188 return -EINTR; 1040 return -EINTR;
1189 /* 1041 /*
1190 * Multiple processes can open the device, but only 1042 * Multiple processes can open the device, but only
@@ -1202,7 +1054,7 @@ static ssize_t wl1273_fm_fops_write(struct file *file, const char __user *buf,
1202 else 1054 else
1203 val = count; 1055 val = count;
1204 1056
1205 wl1273_fm_write_cmd(radio->core, WL1273_RDS_CONFIG_DATA_SET, val); 1057 core->write(core, WL1273_RDS_CONFIG_DATA_SET, val);
1206 1058
1207 if (copy_from_user(radio->write_buf + 1, buf, val)) { 1059 if (copy_from_user(radio->write_buf + 1, buf, val)) {
1208 r = -EFAULT; 1060 r = -EFAULT;
@@ -1213,11 +1065,11 @@ static ssize_t wl1273_fm_fops_write(struct file *file, const char __user *buf,
1213 dev_dbg(radio->dev, "From user: \"%s\"\n", radio->write_buf); 1065 dev_dbg(radio->dev, "From user: \"%s\"\n", radio->write_buf);
1214 1066
1215 radio->write_buf[0] = WL1273_RDS_DATA_SET; 1067 radio->write_buf[0] = WL1273_RDS_DATA_SET;
1216 wl1273_fm_write_data(radio->core, radio->write_buf, val + 1); 1068 core->write_data(core, radio->write_buf, val + 1);
1217 1069
1218 r = val; 1070 r = val;
1219out: 1071out:
1220 mutex_unlock(&radio->core->lock); 1072 mutex_unlock(&core->lock);
1221 1073
1222 return r; 1074 return r;
1223} 1075}
@@ -1263,8 +1115,8 @@ static int wl1273_fm_fops_open(struct file *file)
1263 1115
1264 radio->irq_flags |= WL1273_RDS_EVENT; 1116 radio->irq_flags |= WL1273_RDS_EVENT;
1265 1117
1266 r = wl1273_fm_write_cmd(core, WL1273_INT_MASK_SET, 1118 r = core->write(core, WL1273_INT_MASK_SET,
1267 radio->irq_flags); 1119 radio->irq_flags);
1268 if (r) { 1120 if (r) {
1269 mutex_unlock(&core->lock); 1121 mutex_unlock(&core->lock);
1270 goto out; 1122 goto out;
@@ -1295,9 +1147,9 @@ static int wl1273_fm_fops_release(struct file *file)
1295 radio->irq_flags &= ~WL1273_RDS_EVENT; 1147 radio->irq_flags &= ~WL1273_RDS_EVENT;
1296 1148
1297 if (core->mode == WL1273_MODE_RX) { 1149 if (core->mode == WL1273_MODE_RX) {
1298 r = wl1273_fm_write_cmd(core, 1150 r = core->write(core,
1299 WL1273_INT_MASK_SET, 1151 WL1273_INT_MASK_SET,
1300 radio->irq_flags); 1152 radio->irq_flags);
1301 if (r) { 1153 if (r) {
1302 mutex_unlock(&core->lock); 1154 mutex_unlock(&core->lock);
1303 goto out; 1155 goto out;
@@ -1324,7 +1176,7 @@ static ssize_t wl1273_fm_fops_read(struct file *file, char __user *buf,
1324 1176
1325 dev_dbg(radio->dev, "%s\n", __func__); 1177 dev_dbg(radio->dev, "%s\n", __func__);
1326 1178
1327 if (radio->core->mode != WL1273_MODE_RX) 1179 if (core->mode != WL1273_MODE_RX)
1328 return 0; 1180 return 0;
1329 1181
1330 if (radio->rds_users == 0) { 1182 if (radio->rds_users == 0) {
@@ -1345,7 +1197,7 @@ static ssize_t wl1273_fm_fops_read(struct file *file, char __user *buf,
1345 } 1197 }
1346 radio->owner = file; 1198 radio->owner = file;
1347 1199
1348 r = wl1273_fm_read_reg(core, WL1273_RDS_SYNC_GET, &val); 1200 r = core->read(core, WL1273_RDS_SYNC_GET, &val);
1349 if (r) { 1201 if (r) {
1350 dev_err(radio->dev, "%s: Get RDS_SYNC fails.\n", __func__); 1202 dev_err(radio->dev, "%s: Get RDS_SYNC fails.\n", __func__);
1351 goto out; 1203 goto out;
@@ -1466,23 +1318,24 @@ static int wl1273_fm_vidioc_s_input(struct file *file, void *priv,
1466 */ 1318 */
1467static int wl1273_fm_set_tx_power(struct wl1273_device *radio, u16 power) 1319static int wl1273_fm_set_tx_power(struct wl1273_device *radio, u16 power)
1468{ 1320{
1321 struct wl1273_core *core = radio->core;
1469 int r; 1322 int r;
1470 1323
1471 if (radio->core->mode == WL1273_MODE_OFF || 1324 if (core->mode == WL1273_MODE_OFF ||
1472 radio->core->mode == WL1273_MODE_SUSPENDED) 1325 core->mode == WL1273_MODE_SUSPENDED)
1473 return -EPERM; 1326 return -EPERM;
1474 1327
1475 mutex_lock(&radio->core->lock); 1328 mutex_lock(&core->lock);
1476 1329
1477 /* Convert the dBuV value to chip presentation */ 1330 /* Convert the dBuV value to chip presentation */
1478 r = wl1273_fm_write_cmd(radio->core, WL1273_POWER_LEV_SET, 122 - power); 1331 r = core->write(core, WL1273_POWER_LEV_SET, 122 - power);
1479 if (r) 1332 if (r)
1480 goto out; 1333 goto out;
1481 1334
1482 radio->tx_power = power; 1335 radio->tx_power = power;
1483 1336
1484out: 1337out:
1485 mutex_unlock(&radio->core->lock); 1338 mutex_unlock(&core->lock);
1486 return r; 1339 return r;
1487} 1340}
1488 1341
@@ -1493,23 +1346,24 @@ out:
1493static int wl1273_fm_tx_set_spacing(struct wl1273_device *radio, 1346static int wl1273_fm_tx_set_spacing(struct wl1273_device *radio,
1494 unsigned int spacing) 1347 unsigned int spacing)
1495{ 1348{
1349 struct wl1273_core *core = radio->core;
1496 int r; 1350 int r;
1497 1351
1498 if (spacing == 0) { 1352 if (spacing == 0) {
1499 r = wl1273_fm_write_cmd(radio->core, WL1273_SCAN_SPACING_SET, 1353 r = core->write(core, WL1273_SCAN_SPACING_SET,
1500 WL1273_SPACING_100kHz); 1354 WL1273_SPACING_100kHz);
1501 radio->spacing = 100; 1355 radio->spacing = 100;
1502 } else if (spacing - 50000 < 25000) { 1356 } else if (spacing - 50000 < 25000) {
1503 r = wl1273_fm_write_cmd(radio->core, WL1273_SCAN_SPACING_SET, 1357 r = core->write(core, WL1273_SCAN_SPACING_SET,
1504 WL1273_SPACING_50kHz); 1358 WL1273_SPACING_50kHz);
1505 radio->spacing = 50; 1359 radio->spacing = 50;
1506 } else if (spacing - 100000 < 50000) { 1360 } else if (spacing - 100000 < 50000) {
1507 r = wl1273_fm_write_cmd(radio->core, WL1273_SCAN_SPACING_SET, 1361 r = core->write(core, WL1273_SCAN_SPACING_SET,
1508 WL1273_SPACING_100kHz); 1362 WL1273_SPACING_100kHz);
1509 radio->spacing = 100; 1363 radio->spacing = 100;
1510 } else { 1364 } else {
1511 r = wl1273_fm_write_cmd(radio->core, WL1273_SCAN_SPACING_SET, 1365 r = core->write(core, WL1273_SCAN_SPACING_SET,
1512 WL1273_SPACING_200kHz); 1366 WL1273_SPACING_200kHz);
1513 radio->spacing = 200; 1367 radio->spacing = 200;
1514 } 1368 }
1515 1369
@@ -1567,17 +1421,17 @@ static int wl1273_fm_vidioc_s_ctrl(struct v4l2_ctrl *ctrl)
1567 return -EINTR; 1421 return -EINTR;
1568 1422
1569 if (core->mode == WL1273_MODE_RX && ctrl->val) 1423 if (core->mode == WL1273_MODE_RX && ctrl->val)
1570 r = wl1273_fm_write_cmd(core, 1424 r = core->write(core,
1571 WL1273_MUTE_STATUS_SET, 1425 WL1273_MUTE_STATUS_SET,
1572 WL1273_MUTE_HARD_LEFT | 1426 WL1273_MUTE_HARD_LEFT |
1573 WL1273_MUTE_HARD_RIGHT); 1427 WL1273_MUTE_HARD_RIGHT);
1574 else if (core->mode == WL1273_MODE_RX) 1428 else if (core->mode == WL1273_MODE_RX)
1575 r = wl1273_fm_write_cmd(core, 1429 r = core->write(core,
1576 WL1273_MUTE_STATUS_SET, 0x0); 1430 WL1273_MUTE_STATUS_SET, 0x0);
1577 else if (core->mode == WL1273_MODE_TX && ctrl->val) 1431 else if (core->mode == WL1273_MODE_TX && ctrl->val)
1578 r = wl1273_fm_write_cmd(core, WL1273_MUTE, 1); 1432 r = core->write(core, WL1273_MUTE, 1);
1579 else if (core->mode == WL1273_MODE_TX) 1433 else if (core->mode == WL1273_MODE_TX)
1580 r = wl1273_fm_write_cmd(core, WL1273_MUTE, 0); 1434 r = core->write(core, WL1273_MUTE, 0);
1581 1435
1582 mutex_unlock(&core->lock); 1436 mutex_unlock(&core->lock);
1583 break; 1437 break;
@@ -1672,7 +1526,7 @@ static int wl1273_fm_vidioc_g_tuner(struct file *file, void *priv,
1672 if (mutex_lock_interruptible(&core->lock)) 1526 if (mutex_lock_interruptible(&core->lock))
1673 return -EINTR; 1527 return -EINTR;
1674 1528
1675 r = wl1273_fm_read_reg(core, WL1273_STEREO_GET, &val); 1529 r = core->read(core, WL1273_STEREO_GET, &val);
1676 if (r) 1530 if (r)
1677 goto out; 1531 goto out;
1678 1532
@@ -1681,7 +1535,7 @@ static int wl1273_fm_vidioc_g_tuner(struct file *file, void *priv,
1681 else 1535 else
1682 tuner->rxsubchans = V4L2_TUNER_SUB_MONO; 1536 tuner->rxsubchans = V4L2_TUNER_SUB_MONO;
1683 1537
1684 r = wl1273_fm_read_reg(core, WL1273_RSSI_LVL_GET, &val); 1538 r = core->read(core, WL1273_RSSI_LVL_GET, &val);
1685 if (r) 1539 if (r)
1686 goto out; 1540 goto out;
1687 1541
@@ -1690,7 +1544,7 @@ static int wl1273_fm_vidioc_g_tuner(struct file *file, void *priv,
1690 1544
1691 tuner->afc = 0; 1545 tuner->afc = 0;
1692 1546
1693 r = wl1273_fm_read_reg(core, WL1273_RDS_SYNC_GET, &val); 1547 r = core->read(core, WL1273_RDS_SYNC_GET, &val);
1694 if (r) 1548 if (r)
1695 goto out; 1549 goto out;
1696 1550
@@ -1736,8 +1590,7 @@ static int wl1273_fm_vidioc_s_tuner(struct file *file, void *priv,
1736 dev_warn(radio->dev, "%s: RDS fails: %d\n", __func__, r); 1590 dev_warn(radio->dev, "%s: RDS fails: %d\n", __func__, r);
1737 1591
1738 if (tuner->audmode == V4L2_TUNER_MODE_MONO) { 1592 if (tuner->audmode == V4L2_TUNER_MODE_MONO) {
1739 r = wl1273_fm_write_cmd(core, WL1273_MOST_MODE_SET, 1593 r = core->write(core, WL1273_MOST_MODE_SET, WL1273_RX_MONO);
1740 WL1273_RX_MONO);
1741 if (r < 0) { 1594 if (r < 0) {
1742 dev_warn(radio->dev, "%s: MOST_MODE fails: %d\n", 1595 dev_warn(radio->dev, "%s: MOST_MODE fails: %d\n",
1743 __func__, r); 1596 __func__, r);
@@ -1745,8 +1598,7 @@ static int wl1273_fm_vidioc_s_tuner(struct file *file, void *priv,
1745 } 1598 }
1746 radio->stereo = false; 1599 radio->stereo = false;
1747 } else if (tuner->audmode == V4L2_TUNER_MODE_STEREO) { 1600 } else if (tuner->audmode == V4L2_TUNER_MODE_STEREO) {
1748 r = wl1273_fm_write_cmd(core, WL1273_MOST_MODE_SET, 1601 r = core->write(core, WL1273_MOST_MODE_SET, WL1273_RX_STEREO);
1749 WL1273_RX_STEREO);
1750 if (r < 0) { 1602 if (r < 0) {
1751 dev_warn(radio->dev, "%s: MOST_MODE fails: %d\n", 1603 dev_warn(radio->dev, "%s: MOST_MODE fails: %d\n",
1752 __func__, r); 1604 __func__, r);
@@ -1885,10 +1737,10 @@ static int wl1273_fm_vidioc_s_modulator(struct file *file, void *priv,
1885 r = wl1273_fm_set_rds(radio, WL1273_RDS_OFF); 1737 r = wl1273_fm_set_rds(radio, WL1273_RDS_OFF);
1886 1738
1887 if (modulator->txsubchans & V4L2_TUNER_SUB_MONO) 1739 if (modulator->txsubchans & V4L2_TUNER_SUB_MONO)
1888 r = wl1273_fm_write_cmd(core, WL1273_MONO_SET, WL1273_TX_MONO); 1740 r = core->write(core, WL1273_MONO_SET, WL1273_TX_MONO);
1889 else 1741 else
1890 r = wl1273_fm_write_cmd(core, WL1273_MONO_SET, 1742 r = core->write(core, WL1273_MONO_SET,
1891 WL1273_RX_STEREO); 1743 WL1273_RX_STEREO);
1892 if (r < 0) 1744 if (r < 0)
1893 dev_warn(radio->dev, WL1273_FM_DRIVER_NAME 1745 dev_warn(radio->dev, WL1273_FM_DRIVER_NAME
1894 "MONO_SET fails: %d\n", r); 1746 "MONO_SET fails: %d\n", r);
@@ -1923,7 +1775,7 @@ static int wl1273_fm_vidioc_g_modulator(struct file *file, void *priv,
1923 if (mutex_lock_interruptible(&core->lock)) 1775 if (mutex_lock_interruptible(&core->lock))
1924 return -EINTR; 1776 return -EINTR;
1925 1777
1926 r = wl1273_fm_read_reg(core, WL1273_MONO_SET, &val); 1778 r = core->read(core, WL1273_MONO_SET, &val);
1927 if (r) 1779 if (r)
1928 goto out; 1780 goto out;
1929 1781
@@ -1960,38 +1812,38 @@ static int wl1273_fm_vidioc_log_status(struct file *file, void *priv)
1960 return 0; 1812 return 0;
1961 } 1813 }
1962 1814
1963 r = wl1273_fm_read_reg(core, WL1273_ASIC_ID_GET, &val); 1815 r = core->read(core, WL1273_ASIC_ID_GET, &val);
1964 if (r) 1816 if (r)
1965 dev_err(dev, "%s: Get ASIC_ID fails.\n", __func__); 1817 dev_err(dev, "%s: Get ASIC_ID fails.\n", __func__);
1966 else 1818 else
1967 dev_info(dev, "ASIC_ID: 0x%04x\n", val); 1819 dev_info(dev, "ASIC_ID: 0x%04x\n", val);
1968 1820
1969 r = wl1273_fm_read_reg(core, WL1273_ASIC_VER_GET, &val); 1821 r = core->read(core, WL1273_ASIC_VER_GET, &val);
1970 if (r) 1822 if (r)
1971 dev_err(dev, "%s: Get ASIC_VER fails.\n", __func__); 1823 dev_err(dev, "%s: Get ASIC_VER fails.\n", __func__);
1972 else 1824 else
1973 dev_info(dev, "ASIC Version: 0x%04x\n", val); 1825 dev_info(dev, "ASIC Version: 0x%04x\n", val);
1974 1826
1975 r = wl1273_fm_read_reg(core, WL1273_FIRM_VER_GET, &val); 1827 r = core->read(core, WL1273_FIRM_VER_GET, &val);
1976 if (r) 1828 if (r)
1977 dev_err(dev, "%s: Get FIRM_VER fails.\n", __func__); 1829 dev_err(dev, "%s: Get FIRM_VER fails.\n", __func__);
1978 else 1830 else
1979 dev_info(dev, "FW version: %d(0x%04x)\n", val, val); 1831 dev_info(dev, "FW version: %d(0x%04x)\n", val, val);
1980 1832
1981 r = wl1273_fm_read_reg(core, WL1273_BAND_SET, &val); 1833 r = core->read(core, WL1273_BAND_SET, &val);
1982 if (r) 1834 if (r)
1983 dev_err(dev, "%s: Get BAND fails.\n", __func__); 1835 dev_err(dev, "%s: Get BAND fails.\n", __func__);
1984 else 1836 else
1985 dev_info(dev, "BAND: %d\n", val); 1837 dev_info(dev, "BAND: %d\n", val);
1986 1838
1987 if (core->mode == WL1273_MODE_TX) { 1839 if (core->mode == WL1273_MODE_TX) {
1988 r = wl1273_fm_read_reg(core, WL1273_PUPD_SET, &val); 1840 r = core->read(core, WL1273_PUPD_SET, &val);
1989 if (r) 1841 if (r)
1990 dev_err(dev, "%s: Get PUPD fails.\n", __func__); 1842 dev_err(dev, "%s: Get PUPD fails.\n", __func__);
1991 else 1843 else
1992 dev_info(dev, "PUPD: 0x%04x\n", val); 1844 dev_info(dev, "PUPD: 0x%04x\n", val);
1993 1845
1994 r = wl1273_fm_read_reg(core, WL1273_CHANL_SET, &val); 1846 r = core->read(core, WL1273_CHANL_SET, &val);
1995 if (r) 1847 if (r)
1996 dev_err(dev, "%s: Get CHANL fails.\n", __func__); 1848 dev_err(dev, "%s: Get CHANL fails.\n", __func__);
1997 else 1849 else
@@ -1999,13 +1851,13 @@ static int wl1273_fm_vidioc_log_status(struct file *file, void *priv)
1999 } else if (core->mode == WL1273_MODE_RX) { 1851 } else if (core->mode == WL1273_MODE_RX) {
2000 int bf = radio->rangelow; 1852 int bf = radio->rangelow;
2001 1853
2002 r = wl1273_fm_read_reg(core, WL1273_FREQ_SET, &val); 1854 r = core->read(core, WL1273_FREQ_SET, &val);
2003 if (r) 1855 if (r)
2004 dev_err(dev, "%s: Get FREQ fails.\n", __func__); 1856 dev_err(dev, "%s: Get FREQ fails.\n", __func__);
2005 else 1857 else
2006 dev_info(dev, "RX Frequency: %dkHz\n", bf + val*50); 1858 dev_info(dev, "RX Frequency: %dkHz\n", bf + val*50);
2007 1859
2008 r = wl1273_fm_read_reg(core, WL1273_MOST_MODE_SET, &val); 1860 r = core->read(core, WL1273_MOST_MODE_SET, &val);
2009 if (r) 1861 if (r)
2010 dev_err(dev, "%s: Get MOST_MODE fails.\n", 1862 dev_err(dev, "%s: Get MOST_MODE fails.\n",
2011 __func__); 1863 __func__);
@@ -2016,7 +1868,7 @@ static int wl1273_fm_vidioc_log_status(struct file *file, void *priv)
2016 else 1868 else
2017 dev_info(dev, "MOST_MODE: Unexpected value: %d\n", val); 1869 dev_info(dev, "MOST_MODE: Unexpected value: %d\n", val);
2018 1870
2019 r = wl1273_fm_read_reg(core, WL1273_MOST_BLEND_SET, &val); 1871 r = core->read(core, WL1273_MOST_BLEND_SET, &val);
2020 if (r) 1872 if (r)
2021 dev_err(dev, "%s: Get MOST_BLEND fails.\n", __func__); 1873 dev_err(dev, "%s: Get MOST_BLEND fails.\n", __func__);
2022 else if (val == 0) 1874 else if (val == 0)
@@ -2027,7 +1879,7 @@ static int wl1273_fm_vidioc_log_status(struct file *file, void *priv)
2027 else 1879 else
2028 dev_info(dev, "MOST_BLEND: Unexpected val: %d\n", val); 1880 dev_info(dev, "MOST_BLEND: Unexpected val: %d\n", val);
2029 1881
2030 r = wl1273_fm_read_reg(core, WL1273_STEREO_GET, &val); 1882 r = core->read(core, WL1273_STEREO_GET, &val);
2031 if (r) 1883 if (r)
2032 dev_err(dev, "%s: Get STEREO fails.\n", __func__); 1884 dev_err(dev, "%s: Get STEREO fails.\n", __func__);
2033 else if (val == 0) 1885 else if (val == 0)
@@ -2037,25 +1889,25 @@ static int wl1273_fm_vidioc_log_status(struct file *file, void *priv)
2037 else 1889 else
2038 dev_info(dev, "STEREO: Unexpected value: %d\n", val); 1890 dev_info(dev, "STEREO: Unexpected value: %d\n", val);
2039 1891
2040 r = wl1273_fm_read_reg(core, WL1273_RSSI_LVL_GET, &val); 1892 r = core->read(core, WL1273_RSSI_LVL_GET, &val);
2041 if (r) 1893 if (r)
2042 dev_err(dev, "%s: Get RSSI_LVL fails.\n", __func__); 1894 dev_err(dev, "%s: Get RSSI_LVL fails.\n", __func__);
2043 else 1895 else
2044 dev_info(dev, "RX signal strength: %d\n", (s16) val); 1896 dev_info(dev, "RX signal strength: %d\n", (s16) val);
2045 1897
2046 r = wl1273_fm_read_reg(core, WL1273_POWER_SET, &val); 1898 r = core->read(core, WL1273_POWER_SET, &val);
2047 if (r) 1899 if (r)
2048 dev_err(dev, "%s: Get POWER fails.\n", __func__); 1900 dev_err(dev, "%s: Get POWER fails.\n", __func__);
2049 else 1901 else
2050 dev_info(dev, "POWER: 0x%04x\n", val); 1902 dev_info(dev, "POWER: 0x%04x\n", val);
2051 1903
2052 r = wl1273_fm_read_reg(core, WL1273_INT_MASK_SET, &val); 1904 r = core->read(core, WL1273_INT_MASK_SET, &val);
2053 if (r) 1905 if (r)
2054 dev_err(dev, "%s: Get INT_MASK fails.\n", __func__); 1906 dev_err(dev, "%s: Get INT_MASK fails.\n", __func__);
2055 else 1907 else
2056 dev_info(dev, "INT_MASK: 0x%04x\n", val); 1908 dev_info(dev, "INT_MASK: 0x%04x\n", val);
2057 1909
2058 r = wl1273_fm_read_reg(core, WL1273_RDS_SYNC_GET, &val); 1910 r = core->read(core, WL1273_RDS_SYNC_GET, &val);
2059 if (r) 1911 if (r)
2060 dev_err(dev, "%s: Get RDS_SYNC fails.\n", 1912 dev_err(dev, "%s: Get RDS_SYNC fails.\n",
2061 __func__); 1913 __func__);
@@ -2067,14 +1919,14 @@ static int wl1273_fm_vidioc_log_status(struct file *file, void *priv)
2067 else 1919 else
2068 dev_info(dev, "RDS_SYNC: Unexpected value: %d\n", val); 1920 dev_info(dev, "RDS_SYNC: Unexpected value: %d\n", val);
2069 1921
2070 r = wl1273_fm_read_reg(core, WL1273_I2S_MODE_CONFIG_SET, &val); 1922 r = core->read(core, WL1273_I2S_MODE_CONFIG_SET, &val);
2071 if (r) 1923 if (r)
2072 dev_err(dev, "%s: Get I2S_MODE_CONFIG fails.\n", 1924 dev_err(dev, "%s: Get I2S_MODE_CONFIG fails.\n",
2073 __func__); 1925 __func__);
2074 else 1926 else
2075 dev_info(dev, "I2S_MODE_CONFIG: 0x%04x\n", val); 1927 dev_info(dev, "I2S_MODE_CONFIG: 0x%04x\n", val);
2076 1928
2077 r = wl1273_fm_read_reg(core, WL1273_VOLUME_SET, &val); 1929 r = core->read(core, WL1273_VOLUME_SET, &val);
2078 if (r) 1930 if (r)
2079 dev_err(dev, "%s: Get VOLUME fails.\n", __func__); 1931 dev_err(dev, "%s: Get VOLUME fails.\n", __func__);
2080 else 1932 else
@@ -2184,10 +2036,6 @@ static int __devinit wl1273_fm_radio_probe(struct platform_device *pdev)
2184 radio->stereo = true; 2036 radio->stereo = true;
2185 radio->bus_type = "I2C"; 2037 radio->bus_type = "I2C";
2186 2038
2187 radio->core->write = wl1273_fm_write_cmd;
2188 radio->core->set_audio = wl1273_fm_set_audio;
2189 radio->core->set_volume = wl1273_fm_set_volume;
2190
2191 if (radio->core->pdata->request_resources) { 2039 if (radio->core->pdata->request_resources) {
2192 r = radio->core->pdata->request_resources(radio->core->client); 2040 r = radio->core->pdata->request_resources(radio->core->client);
2193 if (r) { 2041 if (r) {
@@ -2319,7 +2167,6 @@ module_init(wl1273_fm_module_init);
2319 2167
2320static void __exit wl1273_fm_module_exit(void) 2168static void __exit wl1273_fm_module_exit(void)
2321{ 2169{
2322 flush_scheduled_work();
2323 platform_driver_unregister(&wl1273_fm_radio_driver); 2170 platform_driver_unregister(&wl1273_fm_radio_driver);
2324 pr_info(DRIVER_DESC ", Exiting.\n"); 2171 pr_info(DRIVER_DESC ", Exiting.\n");
2325} 2172}