Go back –> ath6kl
ath6kl Coding Style
Error code variable
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)
return ret;
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)
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;
err_cleanup_scatter:
ath6kl_cleanup_target(ar);
err_power_off:
ath6kl_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 ath6kl_htc_start(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.
Linux style
Follow Linux Coding Style.