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

Go back –> ath6kl

ath6kl 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.


int ret;

ret = request_firmware(&fw_entry, filename, ar->dev);
if (ret)
        return ret;

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


struct ath6kl *ar = ptr;
struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);

For consistency always use the main context (struct ath6kl *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.


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

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

ret = ath6kl_init_upload(ar);
if (ret)
        goto err_cleanup_target;

return 0;

return ret;


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


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


int ath6kl_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.


int ath6kl_cfg80211_create(struct ath6kl *ar)
int ath6kl_cfg80211_start(struct ath6kl *ar)
void ath6kl_cfg80211_stop(struct ath6kl *ar)
void ath6kl_cfg80211_destory(struct ath6kl *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
versions of this page: last, v5, v4, v3, v2, v1