Skip to contentSkip to conversation

having trouble getting device from kobject

DISCUSSION Christopher Harvey 1 participant 1 message Oct 25, 2012

lore
Share & tools
lore
#0 lore raw

I added an entry to a sysfs device (drivers/mtd/nand/omap2.c) like this:

static int __devinit omap_nand_probe(struct platform_device *pdev)

{
    ...
    ...

	ret = sysfs_create_group(&pdev->dev.kobj, &ef_group);
	if (ret) {
		err = -ENOMEM;
		goto out_free_info;
	}

    ...
    ...
}

that works, I get the following files:
/sys/devices/platform/omap2-nand.0/0xEF/set /sys/devices/platform/omap2-nand.0/0xEF/unset (I added the 0xEF directory and the set and unset files)

then in the store function of one of the attributes I do this, in an attempt to get the original pdev back:

static ssize_t EF_set_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count)

{
	struct kobject *nand_kobj = kobj->parent;
	struct device *dev = container_of(nand_kobj, struct device, kobj);
	struct platform_device *pdev = container_of(dev, struct 

platform_device, dev);

	printk(KERN_ALERT "pdev is 0x%x\n", (unsigned int)pdev);

	return count;
}

but I'm not getting the same address back. Not sure why.

thanks,
Chris