media: media dvb_frontend: add suspend and resume callbacks to dvb_frontend_ops

While dvb_tuner_ops already has dedicated suspend and resume callbacks,
dvb_frontend_ops currently does not have them. Add those callbacks and
use them for suspend and resume. If they are not set, the old behavior
of calling sleep or init is used.

This allows dvb_frontend drivers to handle resume differently from init,
and suspend differently from sleep. No change is required for drivers
not needing this functionality.

Link: https://lore.kernel.org/linux-media/20210418001204.7453-2-kernel@tuxforce.de

Cc: Lukas Middendorf <kernel@tuxforce.de>, Antti Palosaari <crope@iki.fi>, Mauro Carvalho Chehab <mchehab@kernel.org>, Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Lukas Middendorf <kernel@tuxforce.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
Lukas Middendorf 2021-04-18 01:12:03 +01:00 коммит произвёл Mauro Carvalho Chehab
Родитель b13203032e
Коммит 98a1ca2976
2 изменённых файлов: 17 добавлений и 4 удалений

Просмотреть файл

@ -2935,7 +2935,9 @@ int dvb_frontend_suspend(struct dvb_frontend *fe)
else if (fe->ops.tuner_ops.sleep) else if (fe->ops.tuner_ops.sleep)
ret = fe->ops.tuner_ops.sleep(fe); ret = fe->ops.tuner_ops.sleep(fe);
if (fe->ops.sleep) if (fe->ops.suspend)
ret = fe->ops.suspend(fe);
else if (fe->ops.sleep)
ret = fe->ops.sleep(fe); ret = fe->ops.sleep(fe);
return ret; return ret;
@ -2951,7 +2953,9 @@ int dvb_frontend_resume(struct dvb_frontend *fe)
fe->id); fe->id);
fe->exit = DVB_FE_DEVICE_RESUME; fe->exit = DVB_FE_DEVICE_RESUME;
if (fe->ops.init) if (fe->ops.resume)
ret = fe->ops.resume(fe);
else if (fe->ops.init)
ret = fe->ops.init(fe); ret = fe->ops.init(fe);
if (fe->ops.tuner_ops.resume) if (fe->ops.tuner_ops.resume)

Просмотреть файл

@ -364,6 +364,10 @@ struct dvb_frontend_internal_info {
* allocated by the driver. * allocated by the driver.
* @init: callback function used to initialize the tuner device. * @init: callback function used to initialize the tuner device.
* @sleep: callback function used to put the tuner to sleep. * @sleep: callback function used to put the tuner to sleep.
* @suspend: callback function used to inform that the Kernel will
* suspend.
* @resume: callback function used to inform that the Kernel is
* resuming from suspend.
* @write: callback function used by some demod legacy drivers to * @write: callback function used by some demod legacy drivers to
* allow other drivers to write data into their registers. * allow other drivers to write data into their registers.
* Should not be used on new drivers. * Should not be used on new drivers.
@ -443,6 +447,8 @@ struct dvb_frontend_ops {
int (*init)(struct dvb_frontend* fe); int (*init)(struct dvb_frontend* fe);
int (*sleep)(struct dvb_frontend* fe); int (*sleep)(struct dvb_frontend* fe);
int (*suspend)(struct dvb_frontend *fe);
int (*resume)(struct dvb_frontend *fe);
int (*write)(struct dvb_frontend* fe, const u8 buf[], int len); int (*write)(struct dvb_frontend* fe, const u8 buf[], int len);
@ -755,7 +761,8 @@ void dvb_frontend_detach(struct dvb_frontend *fe);
* &dvb_frontend_ops.tuner_ops.suspend\(\) is available, it calls it. Otherwise, * &dvb_frontend_ops.tuner_ops.suspend\(\) is available, it calls it. Otherwise,
* it will call &dvb_frontend_ops.tuner_ops.sleep\(\), if available. * it will call &dvb_frontend_ops.tuner_ops.sleep\(\), if available.
* *
* It will also call &dvb_frontend_ops.sleep\(\) to put the demod to suspend. * It will also call &dvb_frontend_ops.suspend\(\) to put the demod to suspend,
* if available. Otherwise it will call &dvb_frontend_ops.sleep\(\).
* *
* The drivers should also call dvb_frontend_suspend\(\) as part of their * The drivers should also call dvb_frontend_suspend\(\) as part of their
* handler for the &device_driver.suspend\(\). * handler for the &device_driver.suspend\(\).
@ -769,7 +776,9 @@ int dvb_frontend_suspend(struct dvb_frontend *fe);
* *
* This function resumes the usual operation of the tuner after resume. * This function resumes the usual operation of the tuner after resume.
* *
* In order to resume the frontend, it calls the demod &dvb_frontend_ops.init\(\). * In order to resume the frontend, it calls the demod
* &dvb_frontend_ops.resume\(\) if available. Otherwise it calls demod
* &dvb_frontend_ops.init\(\).
* *
* If &dvb_frontend_ops.tuner_ops.resume\(\) is available, It, it calls it. * If &dvb_frontend_ops.tuner_ops.resume\(\) is available, It, it calls it.
* Otherwise,t will call &dvb_frontend_ops.tuner_ops.init\(\), if available. * Otherwise,t will call &dvb_frontend_ops.tuner_ops.init\(\), if available.