recovery.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (c) 2012 Qualcomm Atheros, Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "core.h"
  17. #include "cfg80211.h"
  18. #include "debug.h"
  19. static void ath6kl_recovery_work(struct work_struct *work)
  20. {
  21. struct ath6kl *ar = container_of(work, struct ath6kl,
  22. fw_recovery.recovery_work);
  23. ath6kl_init_hw_restart(ar);
  24. }
  25. void ath6kl_recovery_err_notify(struct ath6kl *ar, enum ath6kl_fw_err reason)
  26. {
  27. ath6kl_dbg(ATH6KL_DBG_RECOVERY, "Fw error detected, reason:%d\n",
  28. reason);
  29. set_bit(reason, &ar->fw_recovery.err_reason);
  30. if (ar->fw_recovery.enable && ar->state != ATH6KL_STATE_RECOVERY)
  31. queue_work(ar->ath6kl_wq, &ar->fw_recovery.recovery_work);
  32. }
  33. void ath6kl_recovery_init(struct ath6kl *ar)
  34. {
  35. struct ath6kl_fw_recovery *recovery = &ar->fw_recovery;
  36. recovery->enable = true;
  37. INIT_WORK(&recovery->recovery_work, ath6kl_recovery_work);
  38. }
  39. void ath6kl_recovery_cleanup(struct ath6kl *ar)
  40. {
  41. ar->fw_recovery.enable = false;
  42. cancel_work_sync(&ar->fw_recovery.recovery_work);
  43. }
  44. void ath6kl_recovery_suspend(struct ath6kl *ar)
  45. {
  46. ath6kl_recovery_cleanup(ar);
  47. /* Process pending fw error detection */
  48. if (ar->fw_recovery.err_reason)
  49. ath6kl_init_hw_restart(ar);
  50. }