This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
en:users:drivers:ath10k:codingstyle [2018/04/12 13:37] Kalle Valo Move Linux coding style and checking code sections to the beginning of the page |
en:users:drivers:ath10k:codingstyle [2018/08/24 09:30] Kalle Valo [Naming] Add register/unregister examples |
||
---|---|---|---|
Line 125: | Line 125: | ||
Example: | Example: | ||
+ | <code>int ath10k_mac_start(struct ath10k *ar)</code> | ||
- | <code>int ath10k_init_hw(struct ath10k *ar)</code> | + | For each component use function names create/destroy for allocating and freeing something, register/unregister for initialising and cleaning up them afterwards and start/stop to temporarily pause something. |
- | For each component use function names create/destroy for allocating and freeing something, init/cleanup for initialising variables and cleaning up them afterwards and start/stop to temporarily pause something. | + | |
Example: | Example: | ||
Line 133: | Line 133: | ||
<code>int ath10k_cfg80211_create(struct ath10k *ar) | <code>int ath10k_cfg80211_create(struct ath10k *ar) | ||
+ | int ath10k_cfg80211_register(struct ath10k *ar) | ||
int ath10k_cfg80211_start(struct ath10k *ar) | int ath10k_cfg80211_start(struct ath10k *ar) | ||
void ath10k_cfg80211_stop(struct ath10k *ar) | void ath10k_cfg80211_stop(struct ath10k *ar) | ||
- | void ath10k_cfg80211_destory(struct ath10k *ar)</code> | + | int ath10k_cfg80211_unregister(struct ath10k *ar) |
+ | void ath10k_cfg80211_destroy(struct ath10k *ar)</code> | ||
==== Comments ==== | ==== Comments ==== | ||
Line 146: | Line 148: | ||
*/</code> | */</code> | ||
+ | ==== Error messages ==== | ||
+ | |||
+ | For warning and error messages we have ath10k_warn() and ath10k_err(). | ||
+ | |||
+ | ath10k_warn() should be used when ath10k still continues to work, for example then some limit has been reached or an unknown event has been received. It's also rate limited. | ||
+ | |||
+ | ath10k_err() should be used when a fatal error has been detected and ath10k will shut itself down, for example during driver initialisation or firmware recover fails. It is NOT rate limited. | ||
+ | |||
+ | Examples: | ||
+ | |||
+ | ath10k_warn(ar, "failed to submit frame %d: %d\n", frame_index, ret); | ||
+ | ath10k_err(ar, "failed to wake up the device from sleep: %d\n", ret); | ||
+ | |||
+ | ==== Debug messages ==== | ||
+ | |||
+ | Use ath10k_dbg() or ath10k_dbg_dump(). | ||
+ | |||
+ | The format string for ath10k_dbg() should start with debug level followed by name of the command or event and then parameters. All uppercase and no commas, colons or periods. | ||
+ | |||
+ | Examples: | ||
+ | |||
+ | <code>ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot suspend complete\n"); | ||
+ | |||
+ | ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi mgmt tx skb %pK len %d ftype %02x stype %02x\n", | ||
+ | msdu, skb->len, fc & IEEE80211_FCTL_FTYPE, | ||
+ | fc & IEEE80211_FCTL_STYPE); | ||
+ | |||
+ | ath10k_dbg(ar, ATH10K_DBG_MAC, "mac update sta %pM peer bw %d\n", | ||
+ | sta->addr, bw); | ||
+ | </code> | ||
==== Things NOT to do ==== | ==== Things NOT to do ==== | ||