Re: [PATCH net-next v01 5/9] hinic3: Add netdev register interfaces

From: Jakub Kicinski

Date: Wed Oct 15 2025 - 16:10:20 EST


On Wed, 15 Oct 2025 15:15:31 +0800 Fan Gong wrote:
> +static int hinic3_netdev_event(struct notifier_block *notifier,
> + unsigned long event, void *ptr);

please reorder the code to avoid the fwd declaration

> +/* used for netdev notifier register/unregister */
> +static DEFINE_MUTEX(hinic3_netdev_notifiers_mutex);
> +static int hinic3_netdev_notifiers_ref_cnt;
> +static struct notifier_block hinic3_netdev_notifier = {
> + .notifier_call = hinic3_netdev_event,
> +};
> +
> +static u16 hinic3_get_vlan_depth(struct net_device *netdev)
> +{
> + u16 vlan_depth = 0;
> +
> +#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
> + while (is_vlan_dev(netdev)) {
> + netdev = vlan_dev_priv(netdev)->real_dev;
> + vlan_depth++;
> + }
> +#endif
> + return vlan_depth;
> +}
> +
> +static int hinic3_netdev_event(struct notifier_block *notifier,
> + unsigned long event, void *ptr)
> +{
> + struct net_device *ndev = netdev_notifier_info_to_dev(ptr);
> + u16 vlan_depth;
> +
> + if (!is_vlan_dev(ndev))
> + return NOTIFY_DONE;
> +
> + dev_hold(ndev);

please use netdev_hold()

> + switch (event) {
> + case NETDEV_REGISTER:
> + vlan_depth = hinic3_get_vlan_depth(ndev);
> + if (vlan_depth == HINIC3_MAX_VLAN_DEPTH_OFFLOAD_SUPPORT) {
> + ndev->vlan_features &= (~HINIC3_VLAN_CLEAR_OFFLOAD);
> + } else if (vlan_depth > HINIC3_MAX_VLAN_DEPTH_OFFLOAD_SUPPORT) {
> + ndev->hw_features &= (~HINIC3_VLAN_CLEAR_OFFLOAD);
> + ndev->features &= (~HINIC3_VLAN_CLEAR_OFFLOAD);
> + }
> +
> + break;
> +
> + default:
> + break;
> + };

unnecessary semicolon

> + dev_put(ndev);
--
pw-bot: cr