Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: cxd2880-spi: Add optional vcc regulator

This patchset adds an optional VCC regulator to the driver probe function
to make sure power is enabled to the module before starting attaching to
the device.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Acked-by: Yasunari Takiguchi <Yasunari.Takiguchi@sony.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

authored by

Neil Armstrong and committed by
Mauro Carvalho Chehab
cb496cd4 6c0943cd

+16
+16
drivers/media/spi/cxd2880-spi.c
··· 10 10 #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__ 11 11 12 12 #include <linux/spi/spi.h> 13 + #include <linux/regulator/consumer.h> 13 14 #include <linux/ktime.h> 14 15 15 16 #include <media/dvb_demux.h> ··· 52 51 struct mutex spi_mutex; /* For SPI access exclusive control */ 53 52 int feed_count; 54 53 int all_pid_feed_count; 54 + struct regulator *vcc_supply; 55 55 u8 *ts_buf; 56 56 struct cxd2880_pid_filter_config filter_config; 57 57 }; ··· 520 518 if (!dvb_spi) 521 519 return -ENOMEM; 522 520 521 + dvb_spi->vcc_supply = devm_regulator_get_optional(&spi->dev, "vcc"); 522 + if (IS_ERR(dvb_spi->vcc_supply)) { 523 + if (PTR_ERR(dvb_spi->vcc_supply) == -EPROBE_DEFER) 524 + return -EPROBE_DEFER; 525 + dvb_spi->vcc_supply = NULL; 526 + } else { 527 + ret = regulator_enable(dvb_spi->vcc_supply); 528 + if (ret) 529 + return ret; 530 + } 531 + 523 532 dvb_spi->spi = spi; 524 533 mutex_init(&dvb_spi->spi_mutex); 525 534 dev_set_drvdata(&spi->dev, dvb_spi); ··· 643 630 dvb_unregister_frontend(&dvb_spi->dvb_fe); 644 631 dvb_frontend_detach(&dvb_spi->dvb_fe); 645 632 dvb_unregister_adapter(&dvb_spi->adapter); 633 + 634 + if (dvb_spi->vcc_supply) 635 + regulator_disable(dvb_spi->vcc_supply); 646 636 647 637 kfree(dvb_spi); 648 638 pr_info("cxd2880_spi remove ok.\n");