[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191126153157.26355-1-dwlsalmeida@gmail.com>
Date: Tue, 26 Nov 2019 12:31:57 -0300
From: "Daniel W. S. Almeida" <dwlsalmeida@...il.com>
To: mchehab@...nel.org, gregkh@...uxfoundation.org,
rfontana@...hat.com, kstewart@...uxfoundation.org,
tglx@...utronix.de
Cc: "Daniel W. S. Almeida" <dwlsalmeida@...il.com>,
skhan@...uxfoundation.org,
linux-kernel-mentees@...ts.linuxfoundation.org,
linux-media@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] media: dummy_dvb_fe: register adapter/frontend
From: "Daniel W. S. Almeida" <dwlsalmeida@...il.com>
Before using the DTV frontend core, a bridge driver should register the
new frontend at the subsystem and unregister it at device detach / removal.
Signed-off-by: Daniel W. S. Almeida <dwlsalmeida@...il.com>
---
drivers/media/dvb-frontends/dvb_dummy_fe.c | 39 ++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/drivers/media/dvb-frontends/dvb_dummy_fe.c b/drivers/media/dvb-frontends/dvb_dummy_fe.c
index 4db679cb70ad..1ccb58c67e8e 100644
--- a/drivers/media/dvb-frontends/dvb_dummy_fe.c
+++ b/drivers/media/dvb-frontends/dvb_dummy_fe.c
@@ -13,12 +13,12 @@
#include <media/dvb_frontend.h>
#include "dvb_dummy_fe.h"
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
struct dvb_dummy_fe_state {
struct dvb_frontend frontend;
};
-
static int dvb_dummy_fe_read_status(struct dvb_frontend *fe,
enum fe_status *status)
{
@@ -84,7 +84,36 @@ static int dvb_dummy_fe_sleep(struct dvb_frontend* fe)
static int dvb_dummy_fe_init(struct dvb_frontend* fe)
{
- return 0;
+ int result = 0;
+ struct dvb_adapter *adapter = fe->dvb;
+
+ result = dvb_register_adapter(adapter,
+ KBUILD_MODNAME,
+ THIS_MODULE,
+ adapter->device,
+ adapter_nr);
+
+ if (!result) {
+ pr_err("DVB_DUMMY_FE: Failed to register the adapter, errno:%d",
+ result);
+ goto err;
+ }
+
+ result = dvb_register_frontend(adapter, fe);
+ if (!result) {
+ pr_err("DVB_DUMMY_FE: Failed to register the frontend, errno:%d",
+ result);
+ goto err;
+ }
+
+ return result;
+
+err:
+ dvb_unregister_adapter(adapter);
+ dvb_unregister_frontend(fe);
+ dvb_frontend_detach(fe);
+ return result;
+
}
static int dvb_dummy_fe_set_tone(struct dvb_frontend *fe,
@@ -102,6 +131,12 @@ static int dvb_dummy_fe_set_voltage(struct dvb_frontend *fe,
static void dvb_dummy_fe_release(struct dvb_frontend* fe)
{
struct dvb_dummy_fe_state* state = fe->demodulator_priv;
+ struct dvb_adapter *adapter = fe->dvb;
+
+ dvb_unregister_adapter(adapter);
+ dvb_unregister_frontend(fe);
+ dvb_frontend_detach(fe);
+
kfree(state);
}
--
2.24.0
Powered by blists - more mailing lists