NOTE: this page is for archival only, see the note at the end of the page.

Go back –> ath10k

ath10k Coding Style

Status/error variables

Use a variable named "ret" to store return values or status codes. Also propagate the error code to upper levels.

Example:

int ret;

ret = request_firmware(&fw_entry, filename, ar->dev);
if (ret) {
        ath10k_warn("Failed to request firmware '%s': %d\n",
                    filename, ret);
        return ret;
}

return 0;

Print error codes after a colon:

ath10k_warn("Peer assoc failed for STA %pM\n: %d",
            sta->addr, ret);

Name context variables either "ar" or "ar_<hifname>". Use ath10k_<hifname>_priv() to get access to hif specific context.

Examples:

struct ath10k *ar = ptr;
struct ath10k_pci *ar_sdio = ath10k_pci_priv(ar);

For consistency always use the main context (struct ath10k *ar) as function parameter, don't use hif specific context.

Error path

Use goto labels err_<action> for handing error path, with <action> giving a clear idea what the label does.

Example:

ret = ath10k_hif_power_on(ar);
if (ret)
        return ret;

ret = ath10k_target_start(ar);
if (ret)
        goto err_power_off;

ret = ath10k_init_upload(ar);
if (ret)
        goto err_target_stop;

return 0;

err_target_stop:
        ath10k_target_stop(ar);

err_power_off:
        ath10k_hif_power_off(ar);

return ret;

Locking

Always document what spinlock/mutex/rcu actually protects. Locks should always protect data, not code flow.

Naming

Name of symbols and functions follow style <drivername>_<filename>_<symbolname>.

Example:

int ath10k_init_hw(struct ath6kl *ar)

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:

int ath10k_cfg80211_create(struct ath10k *ar)
int ath10k_cfg80211_start(struct ath10k *ar)
void ath10k_cfg80211_stop(struct ath10k *ar)
void ath10k_cfg80211_destory(struct ath10k *ar)

Things NOT to do

Don't use void pointers.

Don't use typedef.

Linux style

Follow Linux Coding Style.


This is a static dump of the old wiki, taken after locking it in January 2015. The new wiki is at https://wireless.wiki.kernel.org/.
versions of this page: last, v6, v5, v4, v3, v2, v1