[PATCH] media: rockchip: rkisp1: remove some dead code

Dan Carpenter dan.carpenter at oracle.com
Tue Dec 1 09:27:54 EST 2020


On Mon, Nov 30, 2020 at 11:20:05AM -0300, Helen Koike wrote:
> Hi Dan,
> 
> Thank you for your patch.
> 
> On 11/30/20 9:53 AM, Dan Carpenter wrote:
> > The debugfs_create_dir() function never returns NULLs.  It's not supposed
> > to checked for errors in the normal case and there is no need to check
> > in this function so let's just delete this dead code.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
> > ---
> >  drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 4 ----
> >  1 file changed, 4 deletions(-)
> > 
> > diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
> > index 9af137e4967f..68da1eed753d 100644
> > --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
> > +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
> > @@ -430,10 +430,6 @@ static void rkisp1_debug_init(struct rkisp1_device *rkisp1)
> >  	struct rkisp1_debug *debug = &rkisp1->debug;
> >  
> >  	debug->debugfs_dir = debugfs_create_dir(RKISP1_DRIVER_NAME, NULL);
> > -	if (!debug->debugfs_dir) {
> > -		dev_dbg(rkisp1->dev, "failed to create debugfs directory\n");
> > -		return;
> > -	}
> 
> I was taking a look at the debugfs_create_dir() code, and I saw it can
> return ERR_PTR(), so ideally we should check for errors with IS_ERR() / PTR_ERR().

Debugfs functions aren't meant to be error checked in the normal case.
There are some drivers which dereference the dentry pointer so those
need to check it but that's not very common and isn't the case here.

I'm really sure this must be documented somewhere but I can't find it
at all.  :P  But look at commit 057e212eae72 ("media: usb: uvc: no need
to check return value of debugfs_create functions") for example.

regards,
dan carpenter



More information about the linux-arm-kernel mailing list