kernel: bump 4.19 to 4.19.62
[openwrt/staging/chunkeey.git] / target / linux / brcm2708 / patches-4.19 / 950-0237-staging-bcm2835-Don-t-probe-if-no-camera-is-detected.patch
1 From 55c9d1a762b9cbb5a4c574918fb41a9cde6bb491 Mon Sep 17 00:00:00 2001
2 From: Stefan Wahren <stefan.wahren@i2se.com>
3 Date: Mon, 22 Oct 2018 11:09:18 +0200
4 Subject: [PATCH 237/703] staging: bcm2835: Don't probe if no camera is
5 detected
6
7 It is a waste of resources to load the camera driver in case there isn't
8 a camera actually connected to the Raspberry Pi. This solution also
9 avoids a NULL ptr dereference of mmal instance on driver unload.
10
11 Fixes: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera driver.")
12 Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
13 ---
14 .../vc04_services/bcm2835-camera/bcm2835-camera.c | 9 +++++++++
15 1 file changed, 9 insertions(+)
16
17 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
18 +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
19 @@ -1860,6 +1860,12 @@ static int bcm2835_mmal_probe(struct pla
20 num_cameras = get_num_cameras(instance,
21 resolutions,
22 MAX_BCM2835_CAMERAS);
23 +
24 + if (num_cameras < 1) {
25 + ret = -ENODEV;
26 + goto cleanup_mmal;
27 + }
28 +
29 if (num_cameras > MAX_BCM2835_CAMERAS)
30 num_cameras = MAX_BCM2835_CAMERAS;
31
32 @@ -1968,6 +1974,9 @@ cleanup_gdev:
33 gdev[i] = NULL;
34 }
35
36 +cleanup_mmal:
37 + vchiq_mmal_finalise(instance);
38 +
39 return ret;
40 }
41