public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* register mtdchar devices in sysfs
@ 2006-04-27 17:55 Andre Puschmann
  2006-04-28  5:40 ` Artem B. Bityutskiy
  2006-04-28  5:48 ` Artem B. Bityutskiy
  0 siblings, 2 replies; 3+ messages in thread
From: Andre Puschmann @ 2006-04-27 17:55 UTC (permalink / raw)
  To: linux-mtd

hi folks,
i am trying to get mtdchar devices to work with sysfs + udev.
my goal is that every mtd-partition gets a device attribute called 
partname which i can use in my udev-rules to give them explicit names 
like /dev/filesystem or /dev/kernel (instead of /dev/mtd0 and /dev/mtd1 
in case that they change their order on the flash device).
to do so i modified mdrchar.c a little bit to add a attribute "partname" 
in every specific sysfs-folder.
well, this is working so far with a dummy entry "partname" but how can i 
get the specific partition name stored in "struct mtd_info*" out of 
"struct class_device" to set it correctly in read_partname()???

thank you in advance

regards
andré



my code looks like this:
<code>
static ssize_t read_partname( struct class_device *cd, char *buf)
{
	return snprintf(buf, 265, "%s\n", "partname");
}
static CLASS_DEVICE_ATTR( partname, S_IRUGO, read_partname, NULL );

static void mtd_notify_add(struct mtd_info* mtd)
{
	struct class_device *class_dev;

	if (!mtd)
		return;

	class_dev = class_device_create(mtd_class, NULL, 					 
MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
			NULL, "mtd%d", mtd->index);
	if (!class_dev)
		return;

	class_device_create_file(class_dev,&class_device_attr_partname);

	class_device_create(mtd_class, NULL,
			    MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
			    NULL, "mtd%dro", mtd->index);

}
</code>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: register mtdchar devices in sysfs
  2006-04-27 17:55 register mtdchar devices in sysfs Andre Puschmann
@ 2006-04-28  5:40 ` Artem B. Bityutskiy
  2006-04-28  5:48 ` Artem B. Bityutskiy
  1 sibling, 0 replies; 3+ messages in thread
From: Artem B. Bityutskiy @ 2006-04-28  5:40 UTC (permalink / raw)
  To: Andre Puschmann; +Cc: linux-mtd

On Thu, 2006-04-27 at 19:55 +0200, Andre Puschmann wrote:
> hi folks,
> i am trying to get mtdchar devices to work with sysfs + udev.
> my goal is that every mtd-partition gets a device attribute called 
> partname which i can use in my udev-rules to give them explicit names 
> like /dev/filesystem or /dev/kernel (instead of /dev/mtd0 and /dev/mtd1 
> in case that they change their order on the flash device).
> to do so i modified mdrchar.c a little bit to add a attribute "partname" 
> in every specific sysfs-folder.
> well, this is working so far with a dummy entry "partname" but how can i 
> get the specific partition name stored in "struct mtd_info*" out of 
> "struct class_device" to set it correctly in read_partname()???
I wonder, why mtd->name is not suitable?

-- 
Best Regards,
Artem B. Bityutskiy,
St.-Petersburg, Russia.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: register mtdchar devices in sysfs
  2006-04-27 17:55 register mtdchar devices in sysfs Andre Puschmann
  2006-04-28  5:40 ` Artem B. Bityutskiy
@ 2006-04-28  5:48 ` Artem B. Bityutskiy
  1 sibling, 0 replies; 3+ messages in thread
From: Artem B. Bityutskiy @ 2006-04-28  5:48 UTC (permalink / raw)
  To: Andre Puschmann; +Cc: linux-mtd

On Thu, 2006-04-27 at 19:55 +0200, Andre Puschmann wrote:
> hi folks,
> i am trying to get mtdchar devices to work with sysfs + udev.
> my goal is that every mtd-partition gets a device attribute called 
> partname which i can use in my udev-rules to give them explicit names 
> like /dev/filesystem or /dev/kernel (instead of /dev/mtd0 and /dev/mtd1 
> in case that they change their order on the flash device).
> to do so i modified mdrchar.c a little bit to add a attribute "partname" 
> in every specific sysfs-folder.
> well, this is working so far with a dummy entry "partname" but how can i 
> get the specific partition name stored in "struct mtd_info*" out of 
> "struct class_device" to set it correctly in read_partname()???
You have to embed struct class_device to mtd_info and use
constructor_of(). Read LDD3. LDD3 does not contain much information
about the class_device stuff, but the techniques used in "struct device"
stuff are the same.

Why don't you use the "struct device/device_driver/bus" stuff which
would be natural? 

-- 
Best Regards,
Artem B. Bityutskiy,
St.-Petersburg, Russia.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-04-28  5:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-27 17:55 register mtdchar devices in sysfs Andre Puschmann
2006-04-28  5:40 ` Artem B. Bityutskiy
2006-04-28  5:48 ` Artem B. Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox