media: sunxi-cir: Factor out hardware initialization
authorSamuel Holland <samuel@sholland.org>
Mon, 18 Jan 2021 06:00:47 +0000 (07:00 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 27 Jan 2021 07:26:49 +0000 (08:26 +0100)
commit8f9061fa773c726b4311d65954284b6dfce44485
tree40e1ee1ba384172098a5b59486c9dfcfa8679246
parentd1036eb43f71b5f8051e42ea1504dd5fd303025d
media: sunxi-cir: Factor out hardware initialization

In preparation for adding suspend/resume hooks, factor out the hardware
initialization from the driver probe/remove functions.

The timeout programmed during init is taken from the `struct rc_dev` so
it is maintained across an exit/init cycle.

This resolves some trivial issues with the probe function: throwing away
the error from clk_prepare_enable and using the wrong type for the
temporary register value.

It also fixes the order of the remove function to unregister the RC
device before turning off the hardware. This prevents userspace from
triggering register writes (via LIRC_SET_REC_TIMEOUT) while the hardware
is disabled.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/rc/sunxi-cir.c