Message ID | X8TrSj3PbqVtN5XQ@mwanda (mailing list archive) |
---|---|
State | Accepted, archived |
Headers |
Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from <linux-media-owner@vger.kernel.org>) id 1kjiiI-00GnfS-0R; Mon, 30 Nov 2020 12:55:30 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726370AbgK3Myh (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Mon, 30 Nov 2020 07:54:37 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:47348 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726343AbgK3Myg (ORCPT <rfc822;linux-media@vger.kernel.org>); Mon, 30 Nov 2020 07:54:36 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AUCT3mC013966; Mon, 30 Nov 2020 12:53:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2020-01-29; bh=T4e4SA0nsSEz5R/oPuOynUVhSHa8l4YzlQu9nbAV6w0=; b=Q37V5W8BrV9ozjYfQYey5wQMtLuLQ4dmuxgiTZBdTxDJp0/FHLpDNWXFDvMVmNBdLR+v XssuGqWJVxMTnYzAgT/wMDDY0XqipupHDTedLvuArKTytQ5SWxLNtHRaJ9oSF3+GZCbk +S0h2Zf92kCHJH2lKo0ODJT4OV5FablRJU5o7psx3W5ufD4Dqge78TjQ1Cshr/xe2CJA +eDi8+n/7dlCQLCCw4KjCMhm+2W4Rn8gSLB0CvFBQOsfdE6OJAj/fkM+DQZK1kr6UU8Y /ubilApDr6oJZUlFcgpmIl3DK65hBlIJKn01E8NoVSyfHWhQm0iOx5RWW9orbSgwiFYx cw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 353egkctw6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 30 Nov 2020 12:53:43 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AUCpG43118219; Mon, 30 Nov 2020 12:53:42 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 3540fv1u59-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Nov 2020 12:53:42 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0AUCreQG015374; Mon, 30 Nov 2020 12:53:40 GMT Received: from mwanda (/102.36.221.92) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 30 Nov 2020 04:53:39 -0800 Date: Mon, 30 Nov 2020 15:53:30 +0300 From: Dan Carpenter <dan.carpenter@oracle.com> To: Helen Koike <helen.koike@collabora.com> Cc: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Heiko Stuebner <heiko@sntech.de>, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] media: rockchip: rkisp1: remove some dead code Message-ID: <X8TrSj3PbqVtN5XQ@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9820 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011300082 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9820 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 priorityscore=1501 spamscore=0 impostorscore=0 clxscore=1011 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011300081 Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -2.5 (--) X-LSpam-Report: No, score=-2.5 required=5.0 tests=BAYES_00=-1.9,DKIMWL_WL_HIGH=0.001,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no |
Series |
media: rockchip: rkisp1: remove some dead code
|
|
Commit Message
Dan Carpenter
Nov. 30, 2020, 12:53 p.m. UTC
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@oracle.com>
---
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 4 ----
1 file changed, 4 deletions(-)
Comments
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@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(). Also from the docs: * <snip> If an error occurs, ERR_PTR(-ERROR) will be * returned. * * If debugfs is not enabled in the kernel, the value -%ENODEV will be * returned. > debugfs_create_ulong("data_loss", 0444, debug->debugfs_dir, > &debug->data_loss); > debugfs_create_ulong("outform_size_err", 0444, debug->debugfs_dir, > nit: I would change the name of the commit just to make it clear what it does. Example: Remove useless error check from debugfs_create_dir() Thanks, Helen
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@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
Hi Dan, On 12/1/20 11:27 AM, Dan Carpenter wrote: > 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@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. right, I just saw the functions in inode.c already checks the parent with IS_ERR(). the debugfs_create_*() function calls start_creating() which already checks the parent. ok, fair enough, I'll ack v2. Regards, Helen > > 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 >
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; - } debugfs_create_ulong("data_loss", 0444, debug->debugfs_dir, &debug->data_loss); debugfs_create_ulong("outform_size_err", 0444, debug->debugfs_dir,