]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
[media] dvb_frontend: merge the two dvb_frontend_detach() versions
authorMax Kellermann <max.kellermann@gmail.com>
Tue, 9 Aug 2016 21:32:36 +0000 (18:32 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 18 Nov 2016 17:08:49 +0000 (15:08 -0200)
This code duplication is confusing and error prone.  Let's merge them
by moving the release/dvb_detach call into one function with one

Signed-off-by: Max Kellermann <max.kellermann@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/dvb-core/dvb_frontend.c

index 023a7e4e616820f517c18de35cc7d98860b1b8e5..2465b0d7f43c18b93b0d6c9d2af46a98598e14fd 100644 (file)
@@ -2740,40 +2740,22 @@ int dvb_unregister_frontend(struct dvb_frontend* fe)
 }
 EXPORT_SYMBOL(dvb_unregister_frontend);
 
-#ifdef CONFIG_MEDIA_ATTACH
-void dvb_frontend_detach(struct dvb_frontend* fe)
+static void dvb_frontend_invoke_release(struct dvb_frontend *fe,
+                                       void (*release)(struct dvb_frontend *fe))
 {
-       void *ptr;
-
-       if (fe->ops.release_sec) {
-               fe->ops.release_sec(fe);
-               dvb_detach(fe->ops.release_sec);
-       }
-       if (fe->ops.tuner_ops.release) {
-               fe->ops.tuner_ops.release(fe);
-               dvb_detach(fe->ops.tuner_ops.release);
-       }
-       if (fe->ops.analog_ops.release) {
-               fe->ops.analog_ops.release(fe);
-               dvb_detach(fe->ops.analog_ops.release);
-       }
-       ptr = (void*)fe->ops.release;
-       if (ptr) {
-               fe->ops.release(fe);
-               dvb_detach(ptr);
+       if (release) {
+               release(fe);
+#ifdef CONFIG_MEDIA_ATTACH
+               dvb_detach(release);
+#endif
        }
 }
-#else
+
 void dvb_frontend_detach(struct dvb_frontend* fe)
 {
-       if (fe->ops.release_sec)
-               fe->ops.release_sec(fe);
-       if (fe->ops.tuner_ops.release)
-               fe->ops.tuner_ops.release(fe);
-       if (fe->ops.analog_ops.release)
-               fe->ops.analog_ops.release(fe);
-       if (fe->ops.release)
-               fe->ops.release(fe);
+       dvb_frontend_invoke_release(fe, fe->ops.release_sec);
+       dvb_frontend_invoke_release(fe, fe->ops.tuner_ops.release);
+       dvb_frontend_invoke_release(fe, fe->ops.analog_ops.release);
+       dvb_frontend_invoke_release(fe, fe->ops.release);
 }
-#endif
 EXPORT_SYMBOL(dvb_frontend_detach);