From patchwork Tue Sep 10 15:48:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 104161 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from ny.mirrors.kernel.org ([147.75.199.223]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1so2xu-0008RM-1h for patchwork@linuxtv.org; Tue, 10 Sep 2024 15:39:41 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 51D701C25E3D for ; Tue, 10 Sep 2024 15:39:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F35231A08CB; Tue, 10 Sep 2024 15:39:02 +0000 (UTC) X-Original-To: linux-media@vger.kernel.org Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 045EE191476; Tue, 10 Sep 2024 15:39:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982742; cv=none; b=Yedn149ZAo7+KmYZjHz7jNwlaVsmAR3kMCtqJXTufDySAw5pw/iRjgvBnCvEmqK0kCg8cEWj5Bo4Wayu2M/ljloz5VwYngCra4NxGjevkrvlb87NTPA4VSvub2EczUGbDeCrdb68rfEbEphrmsBHEXorDlouDIhxRTP4fKusANk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982742; c=relaxed/simple; bh=YRf1kntM3OQ/bV0snIFQ6PnuTop0YlcgFHTlaiqRqaA=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=sUByT7vvosuxa+0FbxXJTaB0S5KYV7GlOqP1aoFn5R0XucPkVVFvT7YI9CKa5s82+/9VDaXr6t8pQ0GENumMKQxBS77zaULUBlgPUhKuyca1Hsij4R0zcj2LRtDlHbW1m95ruf/dxi7TyokYq/t2rzHoLwQLaVY7eY/CtZgeMps= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4X37Cc55Xjz69SX; Tue, 10 Sep 2024 23:38:52 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 06BD0180AE6; Tue, 10 Sep 2024 23:38:58 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Tue, 10 Sep 2024 23:38:57 +0800 From: Li Zetao To: , , , , CC: , , Subject: [PATCH -next v3 1/2] media: cec: remove redundant null pointer checks in cec_devnode_init() Date: Tue, 10 Sep 2024 23:48:02 +0800 Message-ID: <20240910154803.736951-1-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemd500012.china.huawei.com (7.221.188.25) X-LSpam-Score: -5.0 (-----) X-LSpam-Report: No, score=-5.0 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DMARC_QUAR=1.198,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no Since the debugfs_create_dir() never returns a null pointer, checking the return value for a null pointer is redundant. Remove this check since debugfs_create_file can handle IS_ERR pointers. At the same time, debugfs_create_dir returns ERR_PTR (-ENODEV) by default when CONFIG_DEBUG_FS=N, so there is no need for CONFIG_DEBUG_FS macro isolation. Signed-off-by: Li Zetao --- v2 -> v3: Drop the null pointer check for top_cec_dir v2: https://lore.kernel.org/all/20240907034400.3693797-1-lizetao1@huawei.com/ v1 -> v2: Remove this check since debugfs_create_file can handle IS_ERR pointers. And drop the ifdef CONFIG_DEBUG_FS statement. v1: https://lore.kernel.org/all/20240903143607.2004802-1-lizetao1@huawei.com/ drivers/media/cec/core/cec-core.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/media/cec/core/cec-core.c b/drivers/media/cec/core/cec-core.c index e0756826d629..2897283ebe72 100644 --- a/drivers/media/cec/core/cec-core.c +++ b/drivers/media/cec/core/cec-core.c @@ -374,10 +374,6 @@ int cec_register_adapter(struct cec_adapter *adap, } dev_set_drvdata(&adap->devnode.dev, adap); -#ifdef CONFIG_DEBUG_FS - if (!top_cec_dir) - return 0; - adap->cec_dir = debugfs_create_dir(dev_name(&adap->devnode.dev), top_cec_dir); @@ -388,7 +384,6 @@ int cec_register_adapter(struct cec_adapter *adap, return 0; debugfs_create_file("error-inj", 0644, adap->cec_dir, adap, &cec_error_inj_fops); -#endif return 0; } EXPORT_SYMBOL_GPL(cec_register_adapter); @@ -439,13 +434,7 @@ static int __init cec_devnode_init(void) return ret; } -#ifdef CONFIG_DEBUG_FS top_cec_dir = debugfs_create_dir("cec", NULL); - if (IS_ERR_OR_NULL(top_cec_dir)) { - pr_warn("cec: Failed to create debugfs cec dir\n"); - top_cec_dir = NULL; - } -#endif ret = bus_register(&cec_bus_type); if (ret < 0) {