public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Gerd Knorr <kraxel@bytesex.org>
To: Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	uml devel <user-mode-linux-devel@lists.sourceforge.net>,
	Jeff Dike <jdike@addtoit.com>,
	Blaisorblade <blaisorblade_spam@yahoo.it>
Subject: [patch] uml: sysfs support for the uml block devices.
Date: Tue, 7 Dec 2004 15:39:13 +0100	[thread overview]
Message-ID: <20041207143913.GA23659@bytesex> (raw)

$subject says all ;)

Signed-off-by: Gerd Knorr <kraxel@bytesex.org>
---
 arch/um/drivers/ubd_kern.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+)

Index: linux-2004-11-23/arch/um/drivers/ubd_kern.c
===================================================================
--- linux-2004-11-23.orig/arch/um/drivers/ubd_kern.c	2004-11-24 12:52:38.000000000 +0100
+++ linux-2004-11-23/arch/um/drivers/ubd_kern.c	2004-11-26 17:29:27.138934607 +0100
@@ -54,6 +54,8 @@
 #include "mem.h"
 #include "mem_kern.h"
 
+#define DRIVER_NAME "uml-blkdev"
+
 static spinlock_t ubd_io_lock = SPIN_LOCK_UNLOCKED;
 static spinlock_t ubd_lock = SPIN_LOCK_UNLOCKED;
 
@@ -117,6 +119,7 @@ struct ubd {
 	struct openflags openflags;
 	int no_cow;
 	struct cow cow;
+	struct platform_device pdev;
 
 	int map_writes;
 	int map_reads;
@@ -585,6 +588,14 @@ static int ubd_new_disk(int major, u64 s
 		sprintf(disk->devfs_name, "ubd_fake/disc%d", unit);
 	}
 
+	/* sysfs register (not for ide fake devices) */
+	if (major == MAJOR_NR) {
+		ubd_dev[unit].pdev.id   = unit;
+		ubd_dev[unit].pdev.name = DRIVER_NAME;
+		platform_device_register(&ubd_dev[unit].pdev);
+		disk->driverfs_dev = &ubd_dev[unit].pdev.dev;
+	}
+
 	disk->private_data = &ubd_dev[unit];
 	disk->queue = ubd_queue;
 	add_disk(disk);
@@ -718,6 +729,7 @@ static int ubd_remove(char *str)
 		fake_gendisk[n] = NULL;
 	}
 
+	platform_device_unregister(&dev->pdev);
 	*dev = ((struct ubd) DEFAULT_UBD);
 	err = 0;
  out:
@@ -740,6 +752,11 @@ static int ubd_mc_init(void)
 
 __initcall(ubd_mc_init);
 
+static struct device_driver ubd_driver = {
+	.name  = DRIVER_NAME,
+	.bus   = &platform_bus_type,
+};
+
 int ubd_init(void)
 {
         int i;
@@ -762,6 +779,7 @@ int ubd_init(void)
 		if (register_blkdev(fake_major, "ubd"))
 			return -1;
 	}
+	driver_register(&ubd_driver);
 	for (i = 0; i < MAX_DEV; i++) 
 		ubd_add(i);
 	return 0;

-- 
#define printk(args...) fprintf(stderr, ## args)

                 reply	other threads:[~2004-12-07 15:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20041207143913.GA23659@bytesex \
    --to=kraxel@bytesex.org \
    --cc=akpm@osdl.org \
    --cc=blaisorblade_spam@yahoo.it \
    --cc=jdike@addtoit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /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