All of lore.kernel.org
 help / color / mirror / Atom feed
* having trouble getting device from kobject
@ 2012-10-25 15:22 Christopher Harvey
  0 siblings, 0 replies; only message in thread
From: Christopher Harvey @ 2012-10-25 15:22 UTC (permalink / raw)
  To: kernelnewbies

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-10-25 15:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-25 15:22 having trouble getting device from kobject Christopher Harvey

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.