[PATCH 2/3] staging: brcm80211: making device object accessible from wlc and phy

Greg KH greg at kroah.com
Wed Apr 20 21:10:01 UTC 2011


On Fri, Apr 01, 2011 at 10:35:20AM +0200, Roland Vossen wrote:
> Next commits will replace WL_ERROR with dev_err and friends. Because
> these functions require a linux device object, device object pointers
> have been added to three data structures.
> 
> Signed-off-by: Roland Vossen <rvossen at broadcom.com>
> Reviewed-by: Arend van Spriel <arend at broadcom.com>
> ---
>  .../staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c   |    4 +++-
>  .../staging/brcm80211/brcmsmac/phy/wlc_phy_hal.h   |    2 +-
>  .../staging/brcm80211/brcmsmac/phy/wlc_phy_int.h   |    1 +
>  drivers/staging/brcm80211/brcmsmac/wl_mac80211.c   |    4 +++-
>  drivers/staging/brcm80211/brcmsmac/wl_mac80211.h   |    1 +
>  drivers/staging/brcm80211/brcmsmac/wlc_bmac.c      |    3 ++-
>  drivers/staging/brcm80211/brcmsmac/wlc_main.c      |    4 +++-
>  drivers/staging/brcm80211/brcmsmac/wlc_main.h      |    1 +
>  drivers/staging/brcm80211/brcmsmac/wlc_pub.h       |    2 +-
>  9 files changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c
> index 2631382..b2aff08 100644
> --- a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c
> +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c
> @@ -586,7 +586,8 @@ void wlc_phy_shared_detach(shared_phy_t *phy_sh)
>  	}
>  }
>  
> -wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype, char *vars)
> +wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype,
> +			  char *vars, struct device *dev)
>  {
>  	phy_info_t *pi;
>  	u32 sflags = 0;
> @@ -616,6 +617,7 @@ wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype, char *vars
>  	if (pi == NULL) {
>  		return NULL;
>  	}
> +	pi->dev = dev;

Whenever you save off a pointer to a struct device that you do not own,
you MUST increase the reference count, otherwise it could disappear
underneath you and you would never know it.

So please do the proper increment/decrement when you are messing with
stuff like this, otherwise debugging your driver errors on unexpected
device removal is going to be a nightmare.

thanks,

greg k-h



More information about the devel mailing list