* [PATCH net-next v02 0/4] net: hinic3: Fix code styles
@ 2026-01-26 1:03 Fan Gong
2026-01-26 1:03 ` [PATCH net-next v02 1/4] hinic3: Fix code Style(remove empty lines between error handling) Fan Gong
` (4 more replies)
0 siblings, 5 replies; 13+ messages in thread
From: Fan Gong @ 2026-01-26 1:03 UTC (permalink / raw)
To: Fan Gong, Zhu Yikai, netdev, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Andrew Lunn
Cc: linux-kernel, linux-doc, luosifu, Xin Guo, Zhou Shuai, Wu Like,
Shi Jing, Luo Yang
This patchset provides 4 code styles fixes:
Remove empty lines between error handling.
Remove redundant defensive code.
Use array_size instead of multiplying.
SQ use SQ_CTXT_PREF_CI_HI to improve readability.
Thanks,
Fan gong
Fan Gong (4):
hinic3: Fix code Style(remove empty lines between error handling)
hinic3: Remove redundant defensive code
hinic3: Use array_size instead of multiplying
hinic3: RQ use RQ_CTXT_PREF_CI_HI instead of SQ_CTXT_PREF_CI_HI
drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c | 3 ---
drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c | 1 -
drivers/net/ethernet/huawei/hinic3/hinic3_lld.c | 5 -----
drivers/net/ethernet/huawei/hinic3/hinic3_main.c | 4 ----
drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c | 2 --
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c | 6 ++++--
drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c | 6 +++++-
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c | 7 -------
8 files changed, 9 insertions(+), 25 deletions(-)
base-commit: 4515ec4ad58a37e70a9e1256c0b993958c9b7497
--
2.43.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net-next v02 1/4] hinic3: Fix code Style(remove empty lines between error handling)
2026-01-26 1:03 [PATCH net-next v02 0/4] net: hinic3: Fix code styles Fan Gong
@ 2026-01-26 1:03 ` Fan Gong
2026-03-05 14:21 ` Fan Gong
2026-01-26 1:03 ` [PATCH net-next v02 2/4] hinic3: Remove redundant defensive code Fan Gong
` (3 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Fan Gong @ 2026-01-26 1:03 UTC (permalink / raw)
To: Fan Gong, Zhu Yikai, netdev, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Andrew Lunn
Cc: linux-kernel, linux-doc, luosifu, Xin Guo, Zhou Shuai, Wu Like,
Shi Jing, Luo Yang
Fix code style of removing empty lines between the actions on the
error handling path.
Co-developed-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Fan Gong <gongfan1@huawei.com>
---
drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c | 3 ---
drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c | 1 -
drivers/net/ethernet/huawei/hinic3/hinic3_lld.c | 5 -----
drivers/net/ethernet/huawei/hinic3/hinic3_main.c | 4 ----
drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c | 2 --
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c | 1 -
6 files changed, 16 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c b/drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c
index ef539d1b69a3..86720bb119e9 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c
@@ -878,14 +878,11 @@ int hinic3_cmdqs_init(struct hinic3_hwdev *hwdev)
}
hinic3_free_db_addr(hwdev, cmdqs->cmdqs_db_base);
-
err_destroy_cmdq_wq:
destroy_cmdq_wq(hwdev, cmdqs);
-
err_free_cmdqs:
dma_pool_destroy(cmdqs->cmd_buf_pool);
kfree(cmdqs);
-
err_out:
return err;
}
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c b/drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c
index 1ecc2aca1e35..a2c3962116d5 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c
@@ -686,7 +686,6 @@ int hinic3_aeqs_init(struct hinic3_hwdev *hwdev, u16 num_aeqs,
}
destroy_workqueue(aeqs->workq);
-
err_free_aeqs:
kfree(aeqs);
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_lld.c b/drivers/net/ethernet/huawei/hinic3/hinic3_lld.c
index 2b77fea1e0b3..87413e192f10 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_lld.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_lld.c
@@ -230,7 +230,6 @@ static int hinic3_mapping_bar(struct pci_dev *pdev,
iounmap(pci_adapter->mgmt_reg_base);
err_unmap_intr_reg_base:
iounmap(pci_adapter->intr_reg_base);
-
err_unmap_cfg_reg_base:
iounmap(pci_adapter->cfg_reg_base);
@@ -285,10 +284,8 @@ static int hinic3_pci_init(struct pci_dev *pdev)
err_release_regions:
pci_clear_master(pdev);
pci_release_regions(pdev);
-
err_disable_device:
pci_disable_device(pdev);
-
err_free_pci_adapter:
pci_set_drvdata(pdev, NULL);
mutex_destroy(&pci_adapter->pdev_mutex);
@@ -382,7 +379,6 @@ static int hinic3_probe_func(struct hinic3_pcidev *pci_adapter)
hinic3_func_uninit(pdev);
err_unmap_bar:
hinic3_unmapping_bar(pci_adapter);
-
err_out:
dev_err(&pdev->dev, "PCIe device probe function failed\n");
@@ -415,7 +411,6 @@ static int hinic3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
err_uninit_pci:
hinic3_pci_uninit(pdev);
-
err_out:
dev_err(&pdev->dev, "PCIe device probe failed\n");
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_main.c b/drivers/net/ethernet/huawei/hinic3/hinic3_main.c
index a33f86675954..6275d94dfefd 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_main.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_main.c
@@ -104,7 +104,6 @@ static int hinic3_alloc_txrxqs(struct net_device *netdev)
err_free_rxqs:
hinic3_free_rxqs(netdev);
-
err_free_txqs:
hinic3_free_txqs(netdev);
@@ -475,17 +474,14 @@ static int hinic3_nic_probe(struct auxiliary_device *adev,
disable_delayed_work_sync(&nic_dev->periodic_work);
hinic3_update_nic_feature(nic_dev, 0);
hinic3_set_nic_feature_to_hw(nic_dev);
-
err_uninit_sw:
hinic3_sw_uninit(netdev);
-
err_free_nic_io:
hinic3_free_nic_io(nic_dev);
err_free_nic_dev:
hinic3_free_nic_dev(nic_dev);
err_free_netdev:
free_netdev(netdev);
-
err_unregister_adev_event:
hinic3_adev_event_unregister(adev);
dev_err(&pdev->dev, "NIC service probe failed\n");
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c b/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c
index 6eb441d6a590..c871fd0fb109 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c
@@ -446,10 +446,8 @@ int hinic3_init_mbox(struct hinic3_hwdev *hwdev)
hinic3_uninit_func_mbox_msg_channel(hwdev);
err_uninit_mgmt_msg_ch:
uninit_mgmt_msg_channel(mbox);
-
err_destroy_workqueue:
destroy_workqueue(mbox->workq);
-
err_free_mbox:
kfree(mbox);
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c b/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
index ef32aed7d761..4e361c9bd043 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
@@ -609,7 +609,6 @@ static netdev_tx_t hinic3_send_one_skb(struct sk_buff *skb,
err_drop_pkt:
dev_kfree_skb_any(skb);
-
err_out:
return NETDEV_TX_OK;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next v02 2/4] hinic3: Remove redundant defensive code
2026-01-26 1:03 [PATCH net-next v02 0/4] net: hinic3: Fix code styles Fan Gong
2026-01-26 1:03 ` [PATCH net-next v02 1/4] hinic3: Fix code Style(remove empty lines between error handling) Fan Gong
@ 2026-01-26 1:03 ` Fan Gong
2026-01-27 16:25 ` Simon Horman
2026-03-05 14:21 ` Fan Gong
2026-01-26 1:03 ` [PATCH net-next v02 3/4] hinic3: Use array_size instead of multiplying Fan Gong
` (2 subsequent siblings)
4 siblings, 2 replies; 13+ messages in thread
From: Fan Gong @ 2026-01-26 1:03 UTC (permalink / raw)
To: Fan Gong, Zhu Yikai, netdev, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Andrew Lunn
Cc: linux-kernel, linux-doc, luosifu, Xin Guo, Zhou Shuai, Wu Like,
Shi Jing, Luo Yang
According to comment of patch 03, check codes that were merged and
remove redundant defensive codes.
Co-developed-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Fan Gong <gongfan1@huawei.com>
---
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c b/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
index 4e361c9bd043..6d3dc930ca97 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
@@ -44,16 +44,10 @@ static void hinic3_txq_stats_init(struct hinic3_txq *txq)
int hinic3_alloc_txqs(struct net_device *netdev)
{
struct hinic3_nic_dev *nic_dev = netdev_priv(netdev);
- struct hinic3_hwdev *hwdev = nic_dev->hwdev;
u16 q_id, num_txqs = nic_dev->max_qps;
struct pci_dev *pdev = nic_dev->pdev;
struct hinic3_txq *txq;
- if (!num_txqs) {
- dev_err(hwdev->dev, "Cannot allocate zero size txqs\n");
- return -EINVAL;
- }
-
nic_dev->txqs = kcalloc(num_txqs, sizeof(*nic_dev->txqs), GFP_KERNEL);
if (!nic_dev->txqs)
return -ENOMEM;
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next v02 3/4] hinic3: Use array_size instead of multiplying
2026-01-26 1:03 [PATCH net-next v02 0/4] net: hinic3: Fix code styles Fan Gong
2026-01-26 1:03 ` [PATCH net-next v02 1/4] hinic3: Fix code Style(remove empty lines between error handling) Fan Gong
2026-01-26 1:03 ` [PATCH net-next v02 2/4] hinic3: Remove redundant defensive code Fan Gong
@ 2026-01-26 1:03 ` Fan Gong
2026-03-05 14:22 ` Fan Gong
2026-01-26 1:03 ` [PATCH net-next v02 4/4] hinic3: RQ use RQ_CTXT_PREF_CI_HI instead of SQ_CTXT_PREF_CI_HI Fan Gong
2026-03-05 14:21 ` [PATCH net-next v02 0/4] net: hinic3: Fix code styles Fan Gong
4 siblings, 1 reply; 13+ messages in thread
From: Fan Gong @ 2026-01-26 1:03 UTC (permalink / raw)
To: Fan Gong, Zhu Yikai, netdev, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Andrew Lunn
Cc: linux-kernel, linux-doc, luosifu, Xin Guo, Zhou Shuai, Wu Like,
Shi Jing, Luo Yang
According to comment of patch 03, check codes that were merged and
use array_size instead of multiplying.
Co-developed-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Fan Gong <gongfan1@huawei.com>
---
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c b/drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c
index b6cc7bb7bb0c..44abccf9cb29 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c
@@ -23,7 +23,8 @@ static int hinic3_feature_nego(struct hinic3_hwdev *hwdev, u8 opcode,
feature_nego.func_id = hinic3_global_func_id(hwdev);
feature_nego.opcode = opcode;
if (opcode == MGMT_MSG_CMD_OP_SET)
- memcpy(feature_nego.s_feature, s_feature, size * sizeof(u64));
+ memcpy(feature_nego.s_feature, s_feature,
+ array_size(size, sizeof(u64)));
mgmt_msg_params_init_default(&msg_params, &feature_nego,
sizeof(feature_nego));
@@ -37,7 +38,8 @@ static int hinic3_feature_nego(struct hinic3_hwdev *hwdev, u8 opcode,
}
if (opcode == MGMT_MSG_CMD_OP_GET)
- memcpy(s_feature, feature_nego.s_feature, size * sizeof(u64));
+ memcpy(s_feature, feature_nego.s_feature,
+ array_size(size, sizeof(u64)));
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next v02 4/4] hinic3: RQ use RQ_CTXT_PREF_CI_HI instead of SQ_CTXT_PREF_CI_HI
2026-01-26 1:03 [PATCH net-next v02 0/4] net: hinic3: Fix code styles Fan Gong
` (2 preceding siblings ...)
2026-01-26 1:03 ` [PATCH net-next v02 3/4] hinic3: Use array_size instead of multiplying Fan Gong
@ 2026-01-26 1:03 ` Fan Gong
2026-03-05 14:22 ` Fan Gong
2026-03-05 14:21 ` [PATCH net-next v02 0/4] net: hinic3: Fix code styles Fan Gong
4 siblings, 1 reply; 13+ messages in thread
From: Fan Gong @ 2026-01-26 1:03 UTC (permalink / raw)
To: Fan Gong, Zhu Yikai, netdev, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Andrew Lunn
Cc: linux-kernel, linux-doc, luosifu, Xin Guo, Zhou Shuai, Wu Like,
Shi Jing, Luo Yang
Separate the CTX_PREF_CI_HI of rq and sq to improve readability.
Co-developed-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Fan Gong <gongfan1@huawei.com>
---
drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c b/drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c
index d86cd1ba4605..90887d2bb127 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c
@@ -162,6 +162,9 @@ struct hinic3_clean_queue_ctxt {
#define SQ_CTXT_WQ_BLOCK_SET(val, member) \
FIELD_PREP(SQ_CTXT_WQ_BLOCK_##member##_MASK, val)
+/* reuse SQ macro for RQ because the hardware format is identical */
+#define RQ_CTXT_PREF_CI_HI(val) SQ_CTXT_PREF_CI_HI(val)
+
#define RQ_CTXT_PI_IDX_MASK GENMASK(15, 0)
#define RQ_CTXT_CI_IDX_MASK GENMASK(31, 16)
#define RQ_CTXT_CI_PI_SET(val, member) \
@@ -629,7 +632,8 @@ static void hinic3_rq_prepare_ctxt(struct hinic3_io_queue *rq,
RQ_CTXT_PREF_SET(RQ_WQ_PREFETCH_THRESHOLD, CACHE_THRESHOLD));
rq_ctxt->pref_ci_owner =
- cpu_to_le32(RQ_CTXT_PREF_SET(SQ_CTXT_PREF_CI_HI(ci_start), CI_HI) |
+ cpu_to_le32(RQ_CTXT_PREF_SET(RQ_CTXT_PREF_CI_HI(ci_start),
+ CI_HI) |
RQ_CTXT_PREF_SET(1, OWNER));
rq_ctxt->pref_wq_pfn_hi_ci =
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH net-next v02 2/4] hinic3: Remove redundant defensive code
2026-01-26 1:03 ` [PATCH net-next v02 2/4] hinic3: Remove redundant defensive code Fan Gong
@ 2026-01-27 16:25 ` Simon Horman
2026-01-28 6:50 ` Fan Gong
2026-03-05 14:21 ` Fan Gong
1 sibling, 1 reply; 13+ messages in thread
From: Simon Horman @ 2026-01-27 16:25 UTC (permalink / raw)
To: Fan Gong
Cc: Zhu Yikai, netdev, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Andrew Lunn, linux-kernel, linux-doc, luosifu,
Xin Guo, Zhou Shuai, Wu Like, Shi Jing, Luo Yang
On Mon, Jan 26, 2026 at 09:03:32AM +0800, Fan Gong wrote:
> According to comment of patch 03, check codes that were merged and
> remove redundant defensive codes.
>
> Co-developed-by: Zhu Yikai <zhuyikai1@h-partners.com>
> Signed-off-by: Zhu Yikai <zhuyikai1@h-partners.com>
> Signed-off-by: Fan Gong <gongfan1@huawei.com>
Hi,
I agree that defensive coding is unnecessary in Networking drivers.
But I'm unsure what "codes that were merged" and "patch 03" refers to.
Could you clarify this?
Likewise in patch 3/4 of this series.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next v02 2/4] hinic3: Remove redundant defensive code
2026-01-27 16:25 ` Simon Horman
@ 2026-01-28 6:50 ` Fan Gong
2026-01-28 14:42 ` Simon Horman
0 siblings, 1 reply; 13+ messages in thread
From: Fan Gong @ 2026-01-28 6:50 UTC (permalink / raw)
To: horms
Cc: andrew+netdev, davem, edumazet, gongfan1, guoxin09, kuba,
linux-doc, linux-kernel, luosifu, luoyang82, netdev, pabeni,
shijing34, wulike1, zhoushuai28, zhuyikai1
On 1/28/2026 12:25 AM, Simon Horman wrote:
> On Mon, Jan 26, 2026 at 09:03:32AM +0800, Fan Gong wrote:
>> According to comment of patch 03, check codes that were merged and
>> remove redundant defensive codes.
>>
>> Co-developed-by: Zhu Yikai <zhuyikai1@h-partners.com>
>> Signed-off-by: Zhu Yikai <zhuyikai1@h-partners.com>
>> Signed-off-by: Fan Gong <gongfan1@huawei.com>
>
> Hi,
>
> I agree that defensive coding is unnecessary in Networking drivers.
> But I'm unsure what "codes that were merged" and "patch 03" refers to.
> Could you clarify this?
>
> Likewise in patch 3/4 of this series.
>
Our negligence did not explain this clearly.
Patch 03 points to the mergeed patch "net: hinic3: Add a driver for Huawei 3rd
gen NIC - sw and hw initialization".
"codes that were merged" means that we review the code already merged into
Linux based on Jakub's review comments.
https://lore.kernel.org/netdev/20250902180843.5ba05bf2@kernel.org/
At that time, "patch 03" could only modify the parts where the code was to be
merged. Therefore, after we checked the previous codes ,the codes already
merged are modified in this current patchset.
Thanks,
Fan gong
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next v02 2/4] hinic3: Remove redundant defensive code
2026-01-28 6:50 ` Fan Gong
@ 2026-01-28 14:42 ` Simon Horman
0 siblings, 0 replies; 13+ messages in thread
From: Simon Horman @ 2026-01-28 14:42 UTC (permalink / raw)
To: Fan Gong
Cc: andrew+netdev, davem, edumazet, guoxin09, kuba, linux-doc,
linux-kernel, luosifu, luoyang82, netdev, pabeni, shijing34,
wulike1, zhoushuai28, zhuyikai1
On Wed, Jan 28, 2026 at 02:50:37PM +0800, Fan Gong wrote:
> On 1/28/2026 12:25 AM, Simon Horman wrote:
> > On Mon, Jan 26, 2026 at 09:03:32AM +0800, Fan Gong wrote:
> >> According to comment of patch 03, check codes that were merged and
> >> remove redundant defensive codes.
> >>
> >> Co-developed-by: Zhu Yikai <zhuyikai1@h-partners.com>
> >> Signed-off-by: Zhu Yikai <zhuyikai1@h-partners.com>
> >> Signed-off-by: Fan Gong <gongfan1@huawei.com>
> >
> > Hi,
> >
> > I agree that defensive coding is unnecessary in Networking drivers.
> > But I'm unsure what "codes that were merged" and "patch 03" refers to.
> > Could you clarify this?
> >
> > Likewise in patch 3/4 of this series.
> >
>
> Our negligence did not explain this clearly.
>
> Patch 03 points to the mergeed patch "net: hinic3: Add a driver for Huawei 3rd
> gen NIC - sw and hw initialization".
>
> "codes that were merged" means that we review the code already merged into
> Linux based on Jakub's review comments.
> https://lore.kernel.org/netdev/20250902180843.5ba05bf2@kernel.org/
>
> At that time, "patch 03" could only modify the parts where the code was to be
> merged. Therefore, after we checked the previous codes ,the codes already
> merged are modified in this current patchset.
Thanks, and apologies if I still have this mixed up.
I'm wondering if the following commit message would make things clearer.
Subject: [PATCH net-next v3 2/4] hinic3: remove defensive txq_num check
Since commit 1f3838b84a63 ("hinic3: Add Rss function") nic_dev->num_txqs
cannot be zero in hinic3_alloc_txqs(). So remove the check for this case.
Link: https://lore.kernel.org/netdev/20250902180843.5ba05bf2@kernel.org/
Signed-off-by: ...
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net-next v02 0/4] net: hinic3: Fix code styles
2026-01-26 1:03 [PATCH net-next v02 0/4] net: hinic3: Fix code styles Fan Gong
` (3 preceding siblings ...)
2026-01-26 1:03 ` [PATCH net-next v02 4/4] hinic3: RQ use RQ_CTXT_PREF_CI_HI instead of SQ_CTXT_PREF_CI_HI Fan Gong
@ 2026-03-05 14:21 ` Fan Gong
4 siblings, 0 replies; 13+ messages in thread
From: Fan Gong @ 2026-03-05 14:21 UTC (permalink / raw)
To: Fan Gong, Zhu Yikai, netdev, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Andrew Lunn
Cc: linux-kernel, linux-doc, luosifu, Xin Guo, Zhou Shuai, Wu Like,
Shi Jing, Luo Yang
This patchset provides 4 code styles fixes:
Remove empty lines between error handling.
Remove redundant defensive code.
Use array_size instead of multiplying.
SQ use SQ_CTXT_PREF_CI_HI to improve readability.
Thanks,
Fan gong
Fan Gong (4):
hinic3: Fix code Style(remove empty lines between error handling)
hinic3: Remove redundant defensive code
hinic3: Use array_size instead of multiplying
hinic3: RQ use RQ_CTXT_PREF_CI_HI instead of SQ_CTXT_PREF_CI_HI
drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c | 3 ---
drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c | 1 -
drivers/net/ethernet/huawei/hinic3/hinic3_lld.c | 5 -----
drivers/net/ethernet/huawei/hinic3/hinic3_main.c | 4 ----
drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c | 2 --
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c | 6 ++++--
drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c | 6 +++++-
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c | 7 -------
8 files changed, 9 insertions(+), 25 deletions(-)
base-commit: 4515ec4ad58a37e70a9e1256c0b993958c9b7497
--
2.43.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net-next v02 1/4] hinic3: Fix code Style(remove empty lines between error handling)
2026-01-26 1:03 ` [PATCH net-next v02 1/4] hinic3: Fix code Style(remove empty lines between error handling) Fan Gong
@ 2026-03-05 14:21 ` Fan Gong
0 siblings, 0 replies; 13+ messages in thread
From: Fan Gong @ 2026-03-05 14:21 UTC (permalink / raw)
To: Fan Gong, Zhu Yikai, netdev, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Andrew Lunn
Cc: linux-kernel, linux-doc, luosifu, Xin Guo, Zhou Shuai, Wu Like,
Shi Jing, Luo Yang
Fix code style of removing empty lines between the actions on the
error handling path.
Co-developed-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Fan Gong <gongfan1@huawei.com>
---
drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c | 3 ---
drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c | 1 -
drivers/net/ethernet/huawei/hinic3/hinic3_lld.c | 5 -----
drivers/net/ethernet/huawei/hinic3/hinic3_main.c | 4 ----
drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c | 2 --
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c | 1 -
6 files changed, 16 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c b/drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c
index ef539d1b69a3..86720bb119e9 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c
@@ -878,14 +878,11 @@ int hinic3_cmdqs_init(struct hinic3_hwdev *hwdev)
}
hinic3_free_db_addr(hwdev, cmdqs->cmdqs_db_base);
-
err_destroy_cmdq_wq:
destroy_cmdq_wq(hwdev, cmdqs);
-
err_free_cmdqs:
dma_pool_destroy(cmdqs->cmd_buf_pool);
kfree(cmdqs);
-
err_out:
return err;
}
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c b/drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c
index 1ecc2aca1e35..a2c3962116d5 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c
@@ -686,7 +686,6 @@ int hinic3_aeqs_init(struct hinic3_hwdev *hwdev, u16 num_aeqs,
}
destroy_workqueue(aeqs->workq);
-
err_free_aeqs:
kfree(aeqs);
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_lld.c b/drivers/net/ethernet/huawei/hinic3/hinic3_lld.c
index 2b77fea1e0b3..87413e192f10 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_lld.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_lld.c
@@ -230,7 +230,6 @@ static int hinic3_mapping_bar(struct pci_dev *pdev,
iounmap(pci_adapter->mgmt_reg_base);
err_unmap_intr_reg_base:
iounmap(pci_adapter->intr_reg_base);
-
err_unmap_cfg_reg_base:
iounmap(pci_adapter->cfg_reg_base);
@@ -285,10 +284,8 @@ static int hinic3_pci_init(struct pci_dev *pdev)
err_release_regions:
pci_clear_master(pdev);
pci_release_regions(pdev);
-
err_disable_device:
pci_disable_device(pdev);
-
err_free_pci_adapter:
pci_set_drvdata(pdev, NULL);
mutex_destroy(&pci_adapter->pdev_mutex);
@@ -382,7 +379,6 @@ static int hinic3_probe_func(struct hinic3_pcidev *pci_adapter)
hinic3_func_uninit(pdev);
err_unmap_bar:
hinic3_unmapping_bar(pci_adapter);
-
err_out:
dev_err(&pdev->dev, "PCIe device probe function failed\n");
@@ -415,7 +411,6 @@ static int hinic3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
err_uninit_pci:
hinic3_pci_uninit(pdev);
-
err_out:
dev_err(&pdev->dev, "PCIe device probe failed\n");
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_main.c b/drivers/net/ethernet/huawei/hinic3/hinic3_main.c
index a33f86675954..6275d94dfefd 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_main.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_main.c
@@ -104,7 +104,6 @@ static int hinic3_alloc_txrxqs(struct net_device *netdev)
err_free_rxqs:
hinic3_free_rxqs(netdev);
-
err_free_txqs:
hinic3_free_txqs(netdev);
@@ -475,17 +474,14 @@ static int hinic3_nic_probe(struct auxiliary_device *adev,
disable_delayed_work_sync(&nic_dev->periodic_work);
hinic3_update_nic_feature(nic_dev, 0);
hinic3_set_nic_feature_to_hw(nic_dev);
-
err_uninit_sw:
hinic3_sw_uninit(netdev);
-
err_free_nic_io:
hinic3_free_nic_io(nic_dev);
err_free_nic_dev:
hinic3_free_nic_dev(nic_dev);
err_free_netdev:
free_netdev(netdev);
-
err_unregister_adev_event:
hinic3_adev_event_unregister(adev);
dev_err(&pdev->dev, "NIC service probe failed\n");
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c b/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c
index 6eb441d6a590..c871fd0fb109 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c
@@ -446,10 +446,8 @@ int hinic3_init_mbox(struct hinic3_hwdev *hwdev)
hinic3_uninit_func_mbox_msg_channel(hwdev);
err_uninit_mgmt_msg_ch:
uninit_mgmt_msg_channel(mbox);
-
err_destroy_workqueue:
destroy_workqueue(mbox->workq);
-
err_free_mbox:
kfree(mbox);
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c b/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
index ef32aed7d761..4e361c9bd043 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
@@ -609,7 +609,6 @@ static netdev_tx_t hinic3_send_one_skb(struct sk_buff *skb,
err_drop_pkt:
dev_kfree_skb_any(skb);
-
err_out:
return NETDEV_TX_OK;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next v02 2/4] hinic3: Remove redundant defensive code
2026-01-26 1:03 ` [PATCH net-next v02 2/4] hinic3: Remove redundant defensive code Fan Gong
2026-01-27 16:25 ` Simon Horman
@ 2026-03-05 14:21 ` Fan Gong
1 sibling, 0 replies; 13+ messages in thread
From: Fan Gong @ 2026-03-05 14:21 UTC (permalink / raw)
To: Fan Gong, Zhu Yikai, netdev, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Andrew Lunn
Cc: linux-kernel, linux-doc, luosifu, Xin Guo, Zhou Shuai, Wu Like,
Shi Jing, Luo Yang
According to comment of patch 03, check codes that were merged and
remove redundant defensive codes.
Co-developed-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Fan Gong <gongfan1@huawei.com>
---
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c b/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
index 4e361c9bd043..6d3dc930ca97 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
@@ -44,16 +44,10 @@ static void hinic3_txq_stats_init(struct hinic3_txq *txq)
int hinic3_alloc_txqs(struct net_device *netdev)
{
struct hinic3_nic_dev *nic_dev = netdev_priv(netdev);
- struct hinic3_hwdev *hwdev = nic_dev->hwdev;
u16 q_id, num_txqs = nic_dev->max_qps;
struct pci_dev *pdev = nic_dev->pdev;
struct hinic3_txq *txq;
- if (!num_txqs) {
- dev_err(hwdev->dev, "Cannot allocate zero size txqs\n");
- return -EINVAL;
- }
-
nic_dev->txqs = kcalloc(num_txqs, sizeof(*nic_dev->txqs), GFP_KERNEL);
if (!nic_dev->txqs)
return -ENOMEM;
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next v02 3/4] hinic3: Use array_size instead of multiplying
2026-01-26 1:03 ` [PATCH net-next v02 3/4] hinic3: Use array_size instead of multiplying Fan Gong
@ 2026-03-05 14:22 ` Fan Gong
0 siblings, 0 replies; 13+ messages in thread
From: Fan Gong @ 2026-03-05 14:22 UTC (permalink / raw)
To: Fan Gong, Zhu Yikai, netdev, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Andrew Lunn
Cc: linux-kernel, linux-doc, luosifu, Xin Guo, Zhou Shuai, Wu Like,
Shi Jing, Luo Yang
According to comment of patch 03, check codes that were merged and
use array_size instead of multiplying.
Co-developed-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Fan Gong <gongfan1@huawei.com>
---
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c b/drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c
index b6cc7bb7bb0c..44abccf9cb29 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c
@@ -23,7 +23,8 @@ static int hinic3_feature_nego(struct hinic3_hwdev *hwdev, u8 opcode,
feature_nego.func_id = hinic3_global_func_id(hwdev);
feature_nego.opcode = opcode;
if (opcode == MGMT_MSG_CMD_OP_SET)
- memcpy(feature_nego.s_feature, s_feature, size * sizeof(u64));
+ memcpy(feature_nego.s_feature, s_feature,
+ array_size(size, sizeof(u64)));
mgmt_msg_params_init_default(&msg_params, &feature_nego,
sizeof(feature_nego));
@@ -37,7 +38,8 @@ static int hinic3_feature_nego(struct hinic3_hwdev *hwdev, u8 opcode,
}
if (opcode == MGMT_MSG_CMD_OP_GET)
- memcpy(s_feature, feature_nego.s_feature, size * sizeof(u64));
+ memcpy(s_feature, feature_nego.s_feature,
+ array_size(size, sizeof(u64)));
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next v02 4/4] hinic3: RQ use RQ_CTXT_PREF_CI_HI instead of SQ_CTXT_PREF_CI_HI
2026-01-26 1:03 ` [PATCH net-next v02 4/4] hinic3: RQ use RQ_CTXT_PREF_CI_HI instead of SQ_CTXT_PREF_CI_HI Fan Gong
@ 2026-03-05 14:22 ` Fan Gong
0 siblings, 0 replies; 13+ messages in thread
From: Fan Gong @ 2026-03-05 14:22 UTC (permalink / raw)
To: Fan Gong, Zhu Yikai, netdev, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Andrew Lunn
Cc: linux-kernel, linux-doc, luosifu, Xin Guo, Zhou Shuai, Wu Like,
Shi Jing, Luo Yang
Separate the CTX_PREF_CI_HI of rq and sq to improve readability.
Co-developed-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Zhu Yikai <zhuyikai1@h-partners.com>
Signed-off-by: Fan Gong <gongfan1@huawei.com>
---
drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c b/drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c
index d86cd1ba4605..90887d2bb127 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c
@@ -162,6 +162,9 @@ struct hinic3_clean_queue_ctxt {
#define SQ_CTXT_WQ_BLOCK_SET(val, member) \
FIELD_PREP(SQ_CTXT_WQ_BLOCK_##member##_MASK, val)
+/* reuse SQ macro for RQ because the hardware format is identical */
+#define RQ_CTXT_PREF_CI_HI(val) SQ_CTXT_PREF_CI_HI(val)
+
#define RQ_CTXT_PI_IDX_MASK GENMASK(15, 0)
#define RQ_CTXT_CI_IDX_MASK GENMASK(31, 16)
#define RQ_CTXT_CI_PI_SET(val, member) \
@@ -629,7 +632,8 @@ static void hinic3_rq_prepare_ctxt(struct hinic3_io_queue *rq,
RQ_CTXT_PREF_SET(RQ_WQ_PREFETCH_THRESHOLD, CACHE_THRESHOLD));
rq_ctxt->pref_ci_owner =
- cpu_to_le32(RQ_CTXT_PREF_SET(SQ_CTXT_PREF_CI_HI(ci_start), CI_HI) |
+ cpu_to_le32(RQ_CTXT_PREF_SET(RQ_CTXT_PREF_CI_HI(ci_start),
+ CI_HI) |
RQ_CTXT_PREF_SET(1, OWNER));
rq_ctxt->pref_wq_pfn_hi_ci =
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-03-05 14:22 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-26 1:03 [PATCH net-next v02 0/4] net: hinic3: Fix code styles Fan Gong
2026-01-26 1:03 ` [PATCH net-next v02 1/4] hinic3: Fix code Style(remove empty lines between error handling) Fan Gong
2026-03-05 14:21 ` Fan Gong
2026-01-26 1:03 ` [PATCH net-next v02 2/4] hinic3: Remove redundant defensive code Fan Gong
2026-01-27 16:25 ` Simon Horman
2026-01-28 6:50 ` Fan Gong
2026-01-28 14:42 ` Simon Horman
2026-03-05 14:21 ` Fan Gong
2026-01-26 1:03 ` [PATCH net-next v02 3/4] hinic3: Use array_size instead of multiplying Fan Gong
2026-03-05 14:22 ` Fan Gong
2026-01-26 1:03 ` [PATCH net-next v02 4/4] hinic3: RQ use RQ_CTXT_PREF_CI_HI instead of SQ_CTXT_PREF_CI_HI Fan Gong
2026-03-05 14:22 ` Fan Gong
2026-03-05 14:21 ` [PATCH net-next v02 0/4] net: hinic3: Fix code styles Fan Gong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox