1
0
Fork 0

media: ov5640 mipi: fix kernel warning when no camera is plugged in

in 5451781dad commit, it added the check that
the regulator need to be disabled before calling regulator_put().
If not do so, the kernel will print warning message as below.
To fix this, need to disable regulator before probe function return if the
camera's not found. regulator_put() will be called when probe fails in this case
as devm_regulator_get() already called in probe function.

[   11.444811] ------------[ cut here ]------------
[   11.444866] WARNING: CPU: 1 PID: 317 at drivers/regulator/core.c:2039 _regulator_put.part.4+0x100/0x120
[   11.444881] Modules linked in: ov5640_camera_mipi_int(+) ov5640_camera_int(+) v4l2_int_device
[   11.444949] CPU: 1 PID: 317 Comm: systemd-udevd Tainted: G        W  O      5.3.0-rc3-next-20190809-02774-g6e085ec #18
[   11.444965] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[   11.445008] [<c0112868>] (unwind_backtrace) from [<c010cd9c>] (show_stack+0x10/0x14)
[   11.445047] [<c010cd9c>] (show_stack) from [<c0d26ad4>] (dump_stack+0xd8/0x110)
[   11.445081] [<c0d26ad4>] (dump_stack) from [<c01362c4>] (__warn.part.3+0xa8/0xe8)
[   11.445107] [<c01362c4>] (__warn.part.3) from [<c013645c>] (warn_slowpath_null+0x40/0x4c)
[   11.445143] [<c013645c>] (warn_slowpath_null) from [<c05e6520>] (_regulator_put.part.4+0x100/0x120)
[   11.445177] [<c05e6520>] (_regulator_put.part.4) from [<c05e656c>] (regulator_put+0x2c/0x3c)
[   11.445213] [<c05e656c>] (regulator_put) from [<c06dce90>] (release_nodes+0x1ac/0x1f8)
[   11.445247] [<c06dce90>] (release_nodes) from [<c06d8968>] (really_probe+0x104/0x340)
[   11.445266] [<c06d8968>] (really_probe) from [<c06d8d50>] (driver_probe_device+0x84/0x194)
[   11.445281] [<c06d8d50>] (driver_probe_device) from [<c06d9044>] (device_driver_attach+0x58/0x60)
[   11.445295] [<c06d9044>] (device_driver_attach) from [<c06d90a4>] (__driver_attach+0x58/0xd0)
[   11.445308] [<c06d90a4>] (__driver_attach) from [<c06d6d70>] (bus_for_each_dev+0x70/0xb4)
[   11.445322] [<c06d6d70>] (bus_for_each_dev) from [<c06d7d9c>] (bus_add_driver+0x198/0x1d0)
[   11.445337] [<c06d7d9c>] (bus_add_driver) from [<c06d9d30>] (driver_register+0x74/0x108)
[   11.445355] [<c06d9d30>] (driver_register) from [<c088ae30>] (i2c_register_driver+0x38/0x84)
[   11.445394] [<c088ae30>] (i2c_register_driver) from [<bf01b010>] (ov5640_init+0x10/0x1000 [ov5640_camera_mipi_int])
[   11.445442] [<bf01b010>] (ov5640_init [ov5640_camera_mipi_int]) from [<c0103078>] (do_one_initcall+0x80/0x338)
[   11.445482] [<c0103078>] (do_one_initcall) from [<c01e163c>] (do_init_module+0x5c/0x238)
[   11.445512] [<c01e163c>] (do_init_module) from [<c01e3b00>] (load_module+0x2260/0x256c)
[   11.445535] [<c01e3b00>] (load_module) from [<c01e4060>] (sys_finit_module+0xbc/0xdc)
[   11.445550] [<c01e4060>] (sys_finit_module) from [<c0101000>] (ret_fast_syscall+0x0/0x28)
[   11.445559] Exception stack(0xed885fa8 to 0xed885ff0)
[   11.445571] 5fa0:                   00000000 00000000 00000007 b6f167e8 00000000 007f2e78
[   11.445583] 5fc0: 00000000 00000000 beebbddc 0000017b 00000000 00000000 beebbda0 007f0890
[   11.445593] 5fe0: beebbd08 beebbcf8 b6f0ed84 b6d81510
[   11.445604] irq event stamp: 19099
[   11.445618] hardirqs last  enabled at (19105): [<c019d9f4>] vprintk_emit+0x294/0x2c8
[   11.445629] hardirqs last disabled at (19110): [<c019d884>] vprintk_emit+0x124/0x2c8
[   11.445641] softirqs last  enabled at (18974): [<c01024e4>] __do_softirq+0x2c4/0x514
[   11.445657] softirqs last disabled at (18917): [<c013da4c>] irq_exit+0x100/0x188
[   11.445666] ---[ end trace 13b19ccc3a78aa48 ]---

Signed-off-by: Robby Cai <robby.cai@nxp.com>
(cherry picked from commit 5c9b5de893eda4e328d1b72a244fe790efaddd54)
5.4-rM2-2.2.x-imx-squashed
Robby Cai 2019-10-08 22:28:17 +08:00 committed by Dong Aisheng
parent 00bb85342b
commit 1b8ca61ed2
1 changed files with 20 additions and 19 deletions

View File

@ -786,6 +786,21 @@ static int ov5640_power_on(struct device *dev)
return ret;
}
static void ov5640_power_off(void)
{
if (analog_regulator)
regulator_disable(analog_regulator);
if (core_regulator)
regulator_disable(core_regulator);
if (io_regulator)
regulator_disable(io_regulator);
if (gpo_regulator)
regulator_disable(gpo_regulator);
}
static s32 ov5640_write_reg(u16 reg, u8 val)
{
u8 au8Buf[3] = {0};
@ -1503,14 +1518,8 @@ static int ioctl_s_power(struct v4l2_int_device *s, int on)
/* Make sure power on */
ov5640_standby(0);
} else if (!on && sensor->on) {
if (analog_regulator)
regulator_disable(analog_regulator);
if (core_regulator)
regulator_disable(core_regulator);
if (io_regulator)
regulator_disable(io_regulator);
if (gpo_regulator)
regulator_disable(gpo_regulator);
ov5640_power_off();
ov5640_standby(1);
}
@ -2071,12 +2080,14 @@ static int ov5640_probe(struct i2c_client *client,
retval = ov5640_read_reg(OV5640_CHIP_ID_HIGH_BYTE, &chip_id_high);
if (retval < 0 || chip_id_high != 0x56) {
pr_warning("camera ov5640_mipi is not found\n");
ov5640_power_off();
clk_disable_unprepare(ov5640_data.sensor_clk);
return -ENODEV;
}
retval = ov5640_read_reg(OV5640_CHIP_ID_LOW_BYTE, &chip_id_low);
if (retval < 0 || chip_id_low != 0x40) {
pr_warning("camera ov5640_mipi is not found\n");
ov5640_power_off();
clk_disable_unprepare(ov5640_data.sensor_clk);
return -ENODEV;
}
@ -2102,17 +2113,7 @@ static int ov5640_remove(struct i2c_client *client)
{
v4l2_int_device_unregister(&ov5640_int_device);
if (gpo_regulator)
regulator_disable(gpo_regulator);
if (analog_regulator)
regulator_disable(analog_regulator);
if (core_regulator)
regulator_disable(core_regulator);
if (io_regulator)
regulator_disable(io_regulator);
ov5640_power_off();
return 0;
}