Skip to contentSkip to conversation

media: rc: rdev->open or rdev->close can be NULL

PATCH New Juergen Lock 1 participant 1 message Aug 16, 2013 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

PATCH 1/1 media: rc: rdev->open or rdev->close can be NULL

Quoted 7 lines · Srinivas KANDAGATLA

+ adding Mauro Chehab

Quoted 4 lines · Hans Petter Selasky

Hi Jurgen,

I think this is something broken at the Linux side or I have sources out of sync.
You should just ignore the NULL function pointer, hence the technisat driver does not have these callbacks.

Quoted 7 lines

I agree, I was under the impression that open/close are mandatory.

Can you please send a patch to fix this to [email protected].

Thanks,
srini

At least technisat-usb2.c doesn't set these...

drivers/media/rc/rc-main.c +2 -2
@@ -707,7 +707,7 @@ int rc_open(struct rc_dev *rdev)
 		return -EINVAL;
 
 	mutex_lock(&rdev->lock);
-	if (!rdev->users++)
+	if (!rdev->users++ && rdev->open != NULL)
 		rval = rdev->open(rdev);
 
 	if (rval)
@@ -731,7 +731,7 @@ void rc_close(struct rc_dev *rdev)
 	if (rdev) {
 		mutex_lock(&rdev->lock);
 
-		 if (!--rdev->users)
+		 if (!--rdev->users && rdev->close != NULL)
 			rdev->close(rdev);
 
 		mutex_unlock(&rdev->lock);