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: 13798851 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) 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) { From patchwork Tue Sep 10 15:48:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13798850 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (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 614E519F10E; Tue, 10 Sep 2024 15:39:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982741; cv=none; b=TVYo8zMOAq1wK5NjMneGnGGb+hBZQmVspVV0VwbNtMZACoNygHRfRi67kufdKX9haselZtcbYoiSqAehOjZHkG/yvqUxrmtGIsnxiLd+p6czhOHobiXJuJbfzCJYb/neDE3VoS/gLvNmyKLelZhmE9uD+lWptVcxNAOp0y0ouFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982741; c=relaxed/simple; bh=Sru+Jm0Xua9EUuTZkWOgv2SKgkvzlCenJwKsV0GpANQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nGekJ0RvMXfkwSM89cf+onSJvPek8120tjLs/nerRmuowTKzd1enjE3eqjMPhde/PxUlulkdEDgLxCarht1zOIbPgfVkbJDJ6d09gWL5Y8g5VfgceBOgxhyx3H1mAA9hAPnXZKX2CV5hir+B0gDYvkoIsePE2cnJ08UPgerMNBQ= 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.191 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.88.234]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4X377c0YSwz1HJQL; Tue, 10 Sep 2024 23:35:24 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 57AA51402E0; 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 2/2] media: siano: remove redundant null pointer checks in cec_devnode_init() Date: Tue, 10 Sep 2024 23:48:03 +0800 Message-ID: <20240910154803.736951-2-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910154803.736951-1-lizetao1@huawei.com> References: <20240910154803.736951-1-lizetao1@huawei.com> 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) 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. Signed-off-by: Li Zetao --- v2 -> v3: Drop the redundant variable d and assign it directly v2: https://lore.kernel.org/all/20240907034400.3693797-2-lizetao1@huawei.com/ v1 -> v2: Remove this check since debugfs_create_file can handle IS_ERR pointers. v1: https://lore.kernel.org/all/20240903143607.2004802-2-lizetao1@huawei.com/ drivers/media/common/siano/smsdvb-debugfs.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/media/common/siano/smsdvb-debugfs.c b/drivers/media/common/siano/smsdvb-debugfs.c index 73990e469df9..d14ba271db50 100644 --- a/drivers/media/common/siano/smsdvb-debugfs.c +++ b/drivers/media/common/siano/smsdvb-debugfs.c @@ -398,8 +398,6 @@ void smsdvb_debugfs_release(struct smsdvb_client_t *client) void smsdvb_debugfs_register(void) { - struct dentry *d; - /* * FIXME: This was written to debug Siano USB devices. So, it creates * the debugfs node under /usb. @@ -410,12 +408,7 @@ void smsdvb_debugfs_register(void) * node for sdio-based boards, but this may need some logic at sdio * subsystem. */ - d = debugfs_create_dir("smsdvb", usb_debug_root); - if (IS_ERR_OR_NULL(d)) { - pr_err("Couldn't create sysfs node for smsdvb\n"); - return; - } - smsdvb_debugfs_usb_root = d; + smsdvb_debugfs_usb_root = debugfs_create_dir("smsdvb", usb_debug_root); } void smsdvb_debugfs_unregister(void)