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
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.
11 Fixes: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera driver.")
12 Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
14 .../vc04_services/bcm2835-camera/bcm2835-camera.c | 9 +++++++++
15 1 file changed, 9 insertions(+)
17 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
18 +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
19 @@ -1847,6 +1847,12 @@ static int bcm2835_mmal_probe(struct pla
20 num_cameras = get_num_cameras(instance,
24 + if (num_cameras < 1) {
29 if (num_cameras > MAX_BCM2835_CAMERAS)
30 num_cameras = MAX_BCM2835_CAMERAS;
32 @@ -1955,6 +1961,9 @@ cleanup_gdev:
37 + vchiq_mmal_finalise(instance);