[PATCH] libertas: fix error handling

Holger Schurig hs4233 at mail.mn-solutions.de
Tue Feb 27 07:23:48 EST 2007


> I understand... But I think its cleaner and less bugprone if
> we handle errors right at the callers, not later by a common
> function.

Hm, either I backout the the split of wlan_add_card() into two 
functions and do something like outlined in my last mail.

Or I add a new function, libertas_deactive_card(), which just 
un-does what libertas_active_card() did. And 
libertas_remove_card() would undo what libertas_add_card() did. 
This way, we can code in if_usb.c and if_cs.c:

if_usb_probe()
{
   ...

   priv = libertas_add_card();
   if (!priv) {
      /* add_card() removed it's own mess */
      goto error;
   }

   priv->hw_XXXX = if_usb_XXXX;
   priv->hw_YYYY = if_usb_YYYY;

   ret = libertas_activate_card(priv);
   if (ret) {
       /* activate_card removed it's own mess */
       /* but not the mess of add_card */
       goto error_remove;
   }

   ret = libertas_add_mesh(priv);
   if (ret) {
       /* add_mesh removed it's own mess */
       /* but not the mess of activate_card and add_card */
      error_deactivate;
   }

   ...
   return 0;
   
error_deactivate:
   libertas_deactivate_card(priv);
error_remove:
   libertas_remove_card(priv);
error:
   return -1;
}



More information about the libertas-dev mailing list