ath6kl Coding Style#

Status/error variables#

Use a variable named “ret” to store return values or status codes. Alsopropagate the error code to upper levels.

Example:

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

Name context variables either “ar” or “ar_<hifname>”. Useath6kl_<hifname>_priv() to get access to hif specific context.

Examples:

structath6kl*ar=ptr;structath6kl_sdio*ar_sdio=ath6kl_sdio_priv(ar);

For consistency always use the main context (struct ath6kl *ar) asfunction 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=ath6kl_hif_power_on(ar);if(ret)returnret;ret=ath6kl_configure_target(ar);if(ret)gotoerr_power_off;ret=ath6kl_init_upload(ar);if(ret)gotoerr_cleanup_target;return0;err_cleanup_scatter:ath6kl_cleanup_target(ar);err_power_off:ath6kl_hif_power_off(ar);returnret;

Locking#

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

Naming#

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

Example:

intath6kl_init_hw(structath6kl*ar)

For each component use function names create/destroy for allocating andfreeing something, init/cleanup for initialising variables and cleaningup them afterwards and start/stop to temporarily pause something.

Example:

intath6kl_cfg80211_create(structath6kl*ar)intath6kl_cfg80211_start(structath6kl*ar)voidath6kl_cfg80211_stop(structath6kl*ar)voidath6kl_cfg80211_destory(structath6kl*ar)

Things NOT to do#

Don’t use void pointers.

Don’t use typedef.

Linux style#

FollowLinux Coding Style.