public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Pavel Machek <pavel@suse.cz>, Linux PM <linux-pm@osdl.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [linux-pm] [RFC/RFT][PATCH -mm 2/5] swsusp: userland interface (rev. 2)
Date: Wed, 4 Jan 2006 15:49:18 -0800	[thread overview]
Message-ID: <20060104234918.GA15983@kroah.com> (raw)
In-Reply-To: <200601042351.58667.rjw@sisk.pl>

On Wed, Jan 04, 2006 at 11:51:58PM +0100, Rafael J. Wysocki wrote:
> +static struct snapshot_dev interface = {
> +	.name = "snapshot",
> +};
> +
> +static ssize_t snapshot_show(struct subsystem * subsys, char *buf)
> +{
> +	return sprintf(buf, "%d:%d\n", MAJOR(interface.devno),
> +		       MINOR(interface.devno));
> +}
> +
> +static struct subsys_attribute snapshot_attr = {
> +	.attr = {
> +		.name = __stringify(snapshot),
> +		.mode = S_IRUGO,
> +	},
> +	.show = snapshot_show,
> +};
> +
> +static int __init snapshot_dev_init(void)
> +{
> +	int error;
> +
> +	error =  alloc_chrdev_region(&interface.devno, 0, 1, interface.name);
> +	if (error)
> +		return error;
> +	cdev_init(&interface.cdev, &snapshot_fops);
> +	interface.cdev.ops = &snapshot_fops;
> +	error = cdev_add(&interface.cdev, interface.devno, 1);
> +	if (error)
> +		goto Unregister;
> +	error = sysfs_create_file(&power_subsys.kset.kobj, &snapshot_attr.attr);

Heh, that's a neat hack, register a sysfs file that contains the
major:minor (there is a function that will print that the correct way,
if you really want to do that), in sysfs.  It's better to just register
a misc character device with the name "snapshot", and then udev will
create your userspace node with the proper major:minor all automatically
for you.

Unless you want to turn these into syscalls :)

thanks,

greg k-h

  reply	other threads:[~2006-01-04 23:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-04 22:40 [RFC/RFT][PATCH -mm 0/5] swsusp: userland interface (rev. 2) Rafael J. Wysocki
2006-01-04 22:47 ` [RFC/RFT][PATCH -mm 1/5] swsusp: swsusp: low level " Rafael J. Wysocki
2006-01-04 22:51 ` [RFC/RFT][PATCH -mm 2/5] swsusp: userland " Rafael J. Wysocki
2006-01-04 23:49   ` Greg KH [this message]
2006-01-05  0:18     ` Pavel Machek
2006-01-05  0:26       ` Greg KH
2006-01-05  0:54         ` Pavel Machek
2006-01-05  0:55         ` Pavel Machek
2006-01-05 23:34         ` Rafael J. Wysocki
2006-01-05 23:45           ` Greg KH
2006-01-04 22:53 ` [RFC/RFT][PATCH -mm 3/5] swsusp: separate swap-writing and reading code " Rafael J. Wysocki
2006-01-04 22:55 ` [RFC/RFT][PATCH -mm 4/5] swsusp: move highmem-handling code to swsusp.c " Rafael J. Wysocki
2006-01-04 22:56 ` [RFC/RFT][PATCH -mm 5/5] swsusp: userland interface documentation and config Rafael J. Wysocki
2006-01-05  1:05 ` [RFC/RFT][PATCH -mm 0/5] swsusp: userland interface (rev. 2) Pavel Machek
2006-01-05 23:30 ` Pavel Machek
2006-01-06 21:17   ` Rafael J. Wysocki
2006-01-06 22:44     ` Pavel Machek
2006-01-06 23:41       ` Rafael J. Wysocki
2006-01-06 23:59         ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060104234918.GA15983@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@osdl.org \
    --cc=pavel@suse.cz \
    --cc=rjw@sisk.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox