[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210113143343.GA8430@gofer.mess.org>
Date: Wed, 13 Jan 2021 14:33:43 +0000
From: Sean Young <sean@...s.org>
To: Samuel Holland <samuel@...lland.org>
Cc: Mauro Carvalho Chehab <mchehab@...nel.org>,
Maxime Ripard <mripard@...nel.org>,
Chen-Yu Tsai <wens@...e.org>,
Jernej Skrabec <jernej.skrabec@...l.net>,
linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-sunxi@...glegroups.com
Subject: Re: [PATCH 1/4] media: sunxi-cir: Clean up dead register writes
On Tue, Jan 12, 2021 at 10:51:29PM -0600, Samuel Holland wrote:
> The register writes during driver removal occur after the device is
> already put back in reset, so they never had any effect.
>
> Signed-off-by: Samuel Holland <samuel@...lland.org>
> ---
> drivers/media/rc/sunxi-cir.c | 10 ----------
> 1 file changed, 10 deletions(-)
>
> diff --git a/drivers/media/rc/sunxi-cir.c b/drivers/media/rc/sunxi-cir.c
> index 8555c7798706..0a7f7eab3cc3 100644
> --- a/drivers/media/rc/sunxi-cir.c
> +++ b/drivers/media/rc/sunxi-cir.c
> @@ -342,22 +342,12 @@ static int sunxi_ir_probe(struct platform_device *pdev)
>
> static int sunxi_ir_remove(struct platform_device *pdev)
> {
> - unsigned long flags;
> struct sunxi_ir *ir = platform_get_drvdata(pdev);
>
> clk_disable_unprepare(ir->clk);
> clk_disable_unprepare(ir->apb_clk);
> reset_control_assert(ir->rst);
>
> - spin_lock_irqsave(&ir->ir_lock, flags);
> - /* disable IR IRQ */
> - writel(0, ir->base + SUNXI_IR_RXINT_REG);
> - /* clear All Rx Interrupt Status */
> - writel(REG_RXSTA_CLEARALL, ir->base + SUNXI_IR_RXSTA_REG);
> - /* disable IR */
> - writel(0, ir->base + SUNXI_IR_CTL_REG);
> - spin_unlock_irqrestore(&ir->ir_lock, flags);
> -
> rc_unregister_device(ir->rc);
> return 0;
> }
I don't think there is anything wrong with the patch, however here the
driver does rc_unregister_device() *after* disabling it. Userspace can
still hold a file descriptor open, and call e.g. LIRC_SET_REC_TIMEOUT
ioctl, which causes various writes the sunxi-cir registers.
The order should be reversed.
Sean
Powered by blists - more mailing lists