Commit 04297b00 authored by Evgeny Novikov's avatar Evgeny Novikov Committed by Mauro Carvalho Chehab

media: st_rc: Handle errors of clk_prepare_enable()

Hadle errors of clk_prepare_enable() in st_rc_hardware_init() and its
callers.

Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: default avatarEvgeny Novikov <novikov@ispras.ru>
Signed-off-by: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent da9a805b
...@@ -157,8 +157,9 @@ static irqreturn_t st_rc_rx_interrupt(int irq, void *data) ...@@ -157,8 +157,9 @@ static irqreturn_t st_rc_rx_interrupt(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static void st_rc_hardware_init(struct st_rc_device *dev) static int st_rc_hardware_init(struct st_rc_device *dev)
{ {
int ret;
int baseclock, freqdiff; int baseclock, freqdiff;
unsigned int rx_max_symbol_per = MAX_SYMB_TIME; unsigned int rx_max_symbol_per = MAX_SYMB_TIME;
unsigned int rx_sampling_freq_div; unsigned int rx_sampling_freq_div;
...@@ -166,7 +167,12 @@ static void st_rc_hardware_init(struct st_rc_device *dev) ...@@ -166,7 +167,12 @@ static void st_rc_hardware_init(struct st_rc_device *dev)
/* Enable the IP */ /* Enable the IP */
reset_control_deassert(dev->rstc); reset_control_deassert(dev->rstc);
clk_prepare_enable(dev->sys_clock); ret = clk_prepare_enable(dev->sys_clock);
if (ret) {
dev_err(dev->dev, "Failed to prepare/enable system clock\n");
return ret;
}
baseclock = clk_get_rate(dev->sys_clock); baseclock = clk_get_rate(dev->sys_clock);
/* IRB input pins are inverted internally from high to low. */ /* IRB input pins are inverted internally from high to low. */
...@@ -184,6 +190,8 @@ static void st_rc_hardware_init(struct st_rc_device *dev) ...@@ -184,6 +190,8 @@ static void st_rc_hardware_init(struct st_rc_device *dev)
} }
writel(rx_max_symbol_per, dev->rx_base + IRB_MAX_SYM_PERIOD); writel(rx_max_symbol_per, dev->rx_base + IRB_MAX_SYM_PERIOD);
return 0;
} }
static int st_rc_remove(struct platform_device *pdev) static int st_rc_remove(struct platform_device *pdev)
...@@ -287,7 +295,9 @@ static int st_rc_probe(struct platform_device *pdev) ...@@ -287,7 +295,9 @@ static int st_rc_probe(struct platform_device *pdev)
rc_dev->dev = dev; rc_dev->dev = dev;
platform_set_drvdata(pdev, rc_dev); platform_set_drvdata(pdev, rc_dev);
st_rc_hardware_init(rc_dev); ret = st_rc_hardware_init(rc_dev);
if (ret)
goto err;
rdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; rdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
/* rx sampling rate is 10Mhz */ /* rx sampling rate is 10Mhz */
...@@ -359,6 +369,7 @@ static int st_rc_suspend(struct device *dev) ...@@ -359,6 +369,7 @@ static int st_rc_suspend(struct device *dev)
static int st_rc_resume(struct device *dev) static int st_rc_resume(struct device *dev)
{ {
int ret;
struct st_rc_device *rc_dev = dev_get_drvdata(dev); struct st_rc_device *rc_dev = dev_get_drvdata(dev);
struct rc_dev *rdev = rc_dev->rdev; struct rc_dev *rdev = rc_dev->rdev;
...@@ -367,7 +378,10 @@ static int st_rc_resume(struct device *dev) ...@@ -367,7 +378,10 @@ static int st_rc_resume(struct device *dev)
rc_dev->irq_wake = 0; rc_dev->irq_wake = 0;
} else { } else {
pinctrl_pm_select_default_state(dev); pinctrl_pm_select_default_state(dev);
st_rc_hardware_init(rc_dev); ret = st_rc_hardware_init(rc_dev);
if (ret)
return ret;
if (rdev->users) { if (rdev->users) {
writel(IRB_RX_INTS, rc_dev->rx_base + IRB_RX_INT_EN); writel(IRB_RX_INTS, rc_dev->rx_base + IRB_RX_INT_EN);
writel(0x01, rc_dev->rx_base + IRB_RX_EN); writel(0x01, rc_dev->rx_base + IRB_RX_EN);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment