Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dev_err() function definition

I can see that dev_*() family of functions such as dev_err() are given as prototype in include/linux/device.h, but no where I could find its definition. I have visited sites like lxr.free-electrons, but without success. Used tags in the source code of linux kernel, even then failed.

What I am trying to find is how the dev_err(const struct device *dev, const char *fmt, ...) is able to get the device information such as pci bus, etc from just giving const struct device *dev as argument to print in logs.

like image 581
Code zan Avatar asked Oct 28 '16 12:10

Code zan


1 Answers

Description of the device is constructed in function create_syslog_header, defined in drivers/base/core.c. The function just extracts some fields from struct device object, and emits them via snprintf() into the string.

The function dev_err is implemented via define_dev_printk_level macro in the same file (drivers/base/core.c).

like image 149
Tsyvarev Avatar answered Sep 19 '22 09:09

Tsyvarev