MirkoBanchi..
5
我找到了方法.我简要解释一下,也许它可能有用.我们可以使用的方法是device_find_child.该方法将第三个参数作为指向实现比较逻辑的函数的指针.如果在使用特定设备作为第一个参数调用时函数返回非零,device_find_child则返回该指针.
#include
#include
static int custom_match_dev(struct device *dev, void *data)
{
/* this function implements the comaparison logic. Return not zero if device
pointed by dev is the device you are searching for.
*/
}
static struct device *find_dev()
{
struct device *ofdev = bus_find_device_by_name(&of_platform_bus_type,
NULL, "OF_device_name");
if (ofdev)
{
/* of device is the parent of device we are interested in */
struct device *real_dev = device_find_child(ofdev,
NULL, /* passed in the second param to custom_match_dev */
custom_match_dev);
if (real_dev)
return real_dev;
}
return NULL;
}