lkml.org 
[lkml]   [2020]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] staging: r8188eu: replace rtw_netdev_priv define with inline function
From
Date
On Sat, 2020-08-01 at 19:52 +0300, Ivan Safonov wrote:
> The function guarantees type checking of arguments and return value.
>
> Result of rtw_netdev_priv macro can be assigned to pointer
> with incompatible type without warning. The function allow compiler
> to perform this check.
[]
> diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h
[]
> @@ -71,8 +71,11 @@ struct rtw_netdev_priv_indicator {
> };
> struct net_device *rtw_alloc_etherdev_with_old_priv(void *old_priv);
>
> -#define rtw_netdev_priv(netdev) \
> - (((struct rtw_netdev_priv_indicator *)netdev_priv(netdev))->priv)
> +static inline struct adapter *rtw_netdev_priv(struct net_device *dev)
> +{
> + return (((struct rtw_netdev_priv_indicator *)netdev_priv(dev))->priv);
> +}

To be similar to existing uses, this variable name should be
netdev not dev. There are also unnecessary parentheses.

> void rtw_free_netdev(struct net_device *netdev);

Better to use netdev like this one.

---
static inline struct adapter *rtw_netdev_priv(struct net_device *netdev)
{
return ((struct rtw_netdev_priv_indicator *)netdev_priv(netdev))->priv;
}



\
 
 \ /
  Last update: 2020-08-01 19:29    [W:0.274 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site