Skip to content

Commit cc6d618

Browse files
Dinesh Rammchehab
authored andcommitted
[media] si4713: move supply list to si4713_platform_data
The supply list is needed by the platform driver, but not by the usb driver. So this information belongs to the platform data and should not be hardcoded in the subdevice driver. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Tested-by: Eduardo Valentin <edubezval@gmail.com> Acked-by: Eduardo Valentin <edubezval@gmail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
1 parent 99995de commit cc6d618

4 files changed

Lines changed: 37 additions & 27 deletions

File tree

‎arch/arm/mach-omap2/board-rx51-peripherals.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,14 @@ static struct regulator_init_data rx51_vintdig = {
760760
},
761761
};
762762

763+
static const char * const si4713_supply_names[] = {
764+
"vio",
765+
"vdd",
766+
};
767+
763768
static struct si4713_platform_data rx51_si4713_i2c_data __initdata_or_module = {
769+
.supplies = ARRAY_SIZE(si4713_supply_names),
770+
.supply_names = si4713_supply_names,
764771
.gpio_reset = RX51_FMTX_RESET_GPIO,
765772
};
766773

‎drivers/media/radio/si4713/si4713.c‎

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ MODULE_AUTHOR("Eduardo Valentin <eduardo.valentin@nokia.com>");
4444
MODULE_DESCRIPTION("I2C driver for Si4713 FM Radio Transmitter");
4545
MODULE_VERSION("0.0.1");
4646

47-
static const char *si4713_supply_names[SI4713_NUM_SUPPLIES] = {
48-
"vio",
49-
"vdd",
50-
};
51-
5247
#define DEFAULT_RDS_PI 0x00
5348
#define DEFAULT_RDS_PTY 0x00
5449
#define DEFAULT_RDS_DEVIATION 0x00C8
@@ -368,11 +363,12 @@ static int si4713_powerup(struct si4713_device *sdev)
368363
if (sdev->power_state)
369364
return 0;
370365

371-
err = regulator_bulk_enable(ARRAY_SIZE(sdev->supplies),
372-
sdev->supplies);
373-
if (err) {
374-
v4l2_err(&sdev->sd, "Failed to enable supplies: %d\n", err);
375-
return err;
366+
if (sdev->supplies) {
367+
err = regulator_bulk_enable(sdev->supplies, sdev->supply_data);
368+
if (err) {
369+
v4l2_err(&sdev->sd, "Failed to enable supplies: %d\n", err);
370+
return err;
371+
}
376372
}
377373
if (gpio_is_valid(sdev->gpio_reset)) {
378374
udelay(50);
@@ -396,11 +392,12 @@ static int si4713_powerup(struct si4713_device *sdev)
396392
if (client->irq)
397393
err = si4713_write_property(sdev, SI4713_GPO_IEN,
398394
SI4713_STC_INT | SI4713_CTS);
399-
} else {
400-
if (gpio_is_valid(sdev->gpio_reset))
401-
gpio_set_value(sdev->gpio_reset, 0);
402-
err = regulator_bulk_disable(ARRAY_SIZE(sdev->supplies),
403-
sdev->supplies);
395+
return err;
396+
}
397+
if (gpio_is_valid(sdev->gpio_reset))
398+
gpio_set_value(sdev->gpio_reset, 0);
399+
if (sdev->supplies) {
400+
err = regulator_bulk_disable(sdev->supplies, sdev->supply_data);
404401
if (err)
405402
v4l2_err(&sdev->sd,
406403
"Failed to disable supplies: %d\n", err);
@@ -432,11 +429,13 @@ static int si4713_powerdown(struct si4713_device *sdev)
432429
v4l2_dbg(1, debug, &sdev->sd, "Device in reset mode\n");
433430
if (gpio_is_valid(sdev->gpio_reset))
434431
gpio_set_value(sdev->gpio_reset, 0);
435-
err = regulator_bulk_disable(ARRAY_SIZE(sdev->supplies),
436-
sdev->supplies);
437-
if (err)
438-
v4l2_err(&sdev->sd,
439-
"Failed to disable supplies: %d\n", err);
432+
if (sdev->supplies) {
433+
err = regulator_bulk_disable(sdev->supplies,
434+
sdev->supply_data);
435+
if (err)
436+
v4l2_err(&sdev->sd,
437+
"Failed to disable supplies: %d\n", err);
438+
}
440439
sdev->power_state = POWER_OFF;
441440
}
442441

@@ -1381,13 +1380,14 @@ static int si4713_probe(struct i2c_client *client,
13811380
}
13821381
sdev->gpio_reset = pdata->gpio_reset;
13831382
gpio_direction_output(sdev->gpio_reset, 0);
1383+
sdev->supplies = pdata->supplies;
13841384
}
13851385

1386-
for (i = 0; i < ARRAY_SIZE(sdev->supplies); i++)
1387-
sdev->supplies[i].supply = si4713_supply_names[i];
1386+
for (i = 0; i < sdev->supplies; i++)
1387+
sdev->supply_data[i].supply = pdata->supply_names[i];
13881388

1389-
rval = regulator_bulk_get(&client->dev, ARRAY_SIZE(sdev->supplies),
1390-
sdev->supplies);
1389+
rval = regulator_bulk_get(&client->dev, sdev->supplies,
1390+
sdev->supply_data);
13911391
if (rval) {
13921392
dev_err(&client->dev, "Cannot get regulators: %d\n", rval);
13931393
goto free_gpio;
@@ -1500,7 +1500,7 @@ static int si4713_probe(struct i2c_client *client,
15001500
free_ctrls:
15011501
v4l2_ctrl_handler_free(hdl);
15021502
put_reg:
1503-
regulator_bulk_free(ARRAY_SIZE(sdev->supplies), sdev->supplies);
1503+
regulator_bulk_free(sdev->supplies, sdev->supply_data);
15041504
free_gpio:
15051505
if (gpio_is_valid(sdev->gpio_reset))
15061506
gpio_free(sdev->gpio_reset);
@@ -1524,7 +1524,7 @@ static int si4713_remove(struct i2c_client *client)
15241524

15251525
v4l2_device_unregister_subdev(sd);
15261526
v4l2_ctrl_handler_free(sd->ctrl_handler);
1527-
regulator_bulk_free(ARRAY_SIZE(sdev->supplies), sdev->supplies);
1527+
regulator_bulk_free(sdev->supplies, sdev->supply_data);
15281528
if (gpio_is_valid(sdev->gpio_reset))
15291529
gpio_free(sdev->gpio_reset);
15301530
kfree(sdev);

‎drivers/media/radio/si4713/si4713.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ struct si4713_device {
227227
struct v4l2_ctrl *tune_ant_cap;
228228
};
229229
struct completion work;
230-
struct regulator_bulk_data supplies[SI4713_NUM_SUPPLIES];
230+
unsigned supplies;
231+
struct regulator_bulk_data supply_data[SI4713_NUM_SUPPLIES];
231232
int gpio_reset;
232233
u32 power_state;
233234
u32 rds_enabled;

‎include/media/si4713.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* Platform dependent definition
2424
*/
2525
struct si4713_platform_data {
26+
const char * const *supply_names;
27+
unsigned supplies;
2628
int gpio_reset; /* < 0 if not used */
2729
};
2830

0 commit comments

Comments
 (0)