Issue
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.
Solution
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
).
Answered By - Tsyvarev Answer Checked By - Katrina (WPSolving Volunteer)