1 From b0ebcf556b543b0b509ad071584ca6b41076a2da 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] 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 @@ -1860,6 +1860,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 @@ -1968,6 +1974,9 @@ cleanup_gdev:
37 + vchiq_mmal_finalise(instance);