num_resources=0 in platform_driver
by DeanAnderson from LinuxQuestions.org on (#4Z54P)
Hi
What might be the reason that num_resources in platform_driver "sth,child" is 0 when its parent is not root? How to make it work?
This one doesn't work, num_resources is 0 for "sth,child"
Code:/ {
parentPlatformDevice {
compatible = "sth,parent", "simple-mfd";
childPlatformDevice: itsname@0 {
compatible = "sth,child";
#address-cells = <0x2>;
#size-cells = <0x2>;
reg = <0x0 0xFFD66000 0x0 0x4>, <0x0 0xFFD66110 0x0 0x4>;
reg-names = "name1", "name2";
};
};
};This one works, num_resources is 2 (OK):
Code:/ {
childPlatformDevice: itsname@0 {
compatible = "sth,child";
#address-cells = <0x2>;
#size-cells = <0x2>;
reg = <0x0 0xFFD66000 0x0 0x4>, <0x0 0xFFD66110 0x0 0x4>;
reg-names = "name1", "name2";
};
};The part of code for child platform driver:
Code:static int sth_child_probe(struct platform_device *pdev)
{
int ret;
struct device *dev = &pdev->dev;
struct device_node* node = dev->of_node;
struct resource *res;
printk(KERN_ALERT "probing %s\n", node->name);
childdata = devm_kzalloc(&pdev->dev, sizeof(struct child_data), GFP_KERNEL);
if (!childdata)
return -ENOMEM;
/*this one returns NULL when driver is in dts as child node of parent, but doesn't return NULL when driver is child of root*/
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "name1");
....I debugged with printk prints the num_resources value:
Code:struct resource *platform_get_resource_byname(struct platform_device *dev,
unsigned int type,
const char *name)
{
int i;
printk(KERN_ALERT "platform_get_resource_byname num_res=%u\n", dev->num_resources);
printk(KERN_ALERT "platform_get_resource_byname name=%s\n", dev->name);
}I really don't know what to additionally add to make it work. This is really annoying.


What might be the reason that num_resources in platform_driver "sth,child" is 0 when its parent is not root? How to make it work?
This one doesn't work, num_resources is 0 for "sth,child"
Code:/ {
parentPlatformDevice {
compatible = "sth,parent", "simple-mfd";
childPlatformDevice: itsname@0 {
compatible = "sth,child";
#address-cells = <0x2>;
#size-cells = <0x2>;
reg = <0x0 0xFFD66000 0x0 0x4>, <0x0 0xFFD66110 0x0 0x4>;
reg-names = "name1", "name2";
};
};
};This one works, num_resources is 2 (OK):
Code:/ {
childPlatformDevice: itsname@0 {
compatible = "sth,child";
#address-cells = <0x2>;
#size-cells = <0x2>;
reg = <0x0 0xFFD66000 0x0 0x4>, <0x0 0xFFD66110 0x0 0x4>;
reg-names = "name1", "name2";
};
};The part of code for child platform driver:
Code:static int sth_child_probe(struct platform_device *pdev)
{
int ret;
struct device *dev = &pdev->dev;
struct device_node* node = dev->of_node;
struct resource *res;
printk(KERN_ALERT "probing %s\n", node->name);
childdata = devm_kzalloc(&pdev->dev, sizeof(struct child_data), GFP_KERNEL);
if (!childdata)
return -ENOMEM;
/*this one returns NULL when driver is in dts as child node of parent, but doesn't return NULL when driver is child of root*/
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "name1");
....I debugged with printk prints the num_resources value:
Code:struct resource *platform_get_resource_byname(struct platform_device *dev,
unsigned int type,
const char *name)
{
int i;
printk(KERN_ALERT "platform_get_resource_byname num_res=%u\n", dev->num_resources);
printk(KERN_ALERT "platform_get_resource_byname name=%s\n", dev->name);
}I really don't know what to additionally add to make it work. This is really annoying.