From: Ondrej Zary <linux@rainbow-software.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu,
"Rafael J. Wysocki" <rjw@sisk.pl>
Subject: Re: [PATCH] Fix floppy hibernation
Date: Tue, 2 Jun 2009 18:30:50 +0200 [thread overview]
Message-ID: <200906021830.53531.linux@rainbow-software.org> (raw)
In-Reply-To: <20090601164520.281cc4c8.akpm@linux-foundation.org>
On Tuesday 02 June 2009 01:45:20 Andrew Morton wrote:
> On Sat, 30 May 2009 18:04:25 +0200
>
> Ondrej Zary <linux@rainbow-software.org> wrote:
> > Hello,
> > floppy driver was always missing hibernation support. After resume,
> > floppy did not work (until a couple of disk reinserts and retries),
> > producing errors like this:
> > end_request: I/O error, dev fd0, sector 0
> >
> > Ingo Molnar tried to fix it in 2006: http://lkml.org/lkml/2006/11/12/92
> >
> >
> >
> >
> > Based on Ingo Molnar's patch from 2006, this makes the floppy work after
> > resume from hibernation, at least on my machine.
> >
> >
> > Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
> >
> > --- linux-2.6.29.4-orig/drivers/block/floppy.c 2009-05-30
> > 14:38:29.000000000 +0200 +++ linux/drivers/block/floppy.c 2009-05-30
> > 17:50:32.000000000 +0200 @@ -4148,6 +4148,24 @@
> > {
> > }
> >
> > +static int floppy_resume(struct platform_device *dev)
> > +{
> > + int i;
> > +
> > + for (i = 0; i < N_FDC; i++)
> > + if (FDCS->address != -1)
> > + user_reset_fdc(-1, FD_RESET_ALWAYS, 0);
> > +
> > + return 0;
> > +}
>
> hm, how does this work?
>
> FDCS is a revolting should-not-exist macro which assumes the presence
> of a local variable called `fdc'.
The driver is complete mess - there is also a global static fdc variable.
So it worked because I have only one floppy controller.
> So I think the loop control variable here should be called `fdc', not `i'.
See the v2 patch below. Tested and works too.
>
> It's pretty amazing that something like this still exists in a core
> driver. Someone please save us!
Based on Ingo Molnar's patch from 2006, this makes the floppy work after
resume from hibernation, at least on my machine.
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
--- linux-2.6.29.4-orig/drivers/block/floppy.c 2009-05-30 14:38:29.000000000 +0200
+++ linux/drivers/block/floppy.c 2009-06-02 17:32:56.000000000 +0200
@@ -4148,6 +4148,24 @@
{
}
+static int floppy_resume(struct platform_device *dev)
+{
+ int fdc;
+
+ for (fdc = 0; fdc < N_FDC; fdc++)
+ if (FDCS->address != -1)
+ user_reset_fdc(-1, FD_RESET_ALWAYS, 0);
+
+ return 0;
+}
+
+static struct platform_driver floppy_driver = {
+ .resume = floppy_resume,
+ .driver = {
+ .name = "floppy",
+ },
+};
+
static struct platform_device floppy_device[N_DRIVE];
static struct kobject *floppy_find(dev_t dev, int *part, void *data)
@@ -4196,10 +4214,14 @@
if (err)
goto out_put_disk;
+ err = platform_driver_register(&floppy_driver);
+ if (err)
+ goto out_unreg_blkdev;
+
floppy_queue = blk_init_queue(do_fd_request, &floppy_lock);
if (!floppy_queue) {
err = -ENOMEM;
- goto out_unreg_blkdev;
+ goto out_unreg_driver;
}
blk_queue_max_sectors(floppy_queue, 64);
@@ -4346,6 +4368,8 @@
out_unreg_region:
blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
blk_cleanup_queue(floppy_queue);
+out_unreg_driver:
+ platform_driver_unregister(&floppy_driver);
out_unreg_blkdev:
unregister_blkdev(FLOPPY_MAJOR, "fd");
out_put_disk:
@@ -4566,6 +4590,7 @@
blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
unregister_blkdev(FLOPPY_MAJOR, "fd");
+ platform_driver_unregister(&floppy_driver);
for (drive = 0; drive < N_DRIVE; drive++) {
del_timer_sync(&motor_off_timer[drive]);
--
Ondrej Zary
next prev parent reply other threads:[~2009-06-02 16:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-30 16:04 [PATCH] Fix floppy hibernation Ondrej Zary
2009-06-01 11:43 ` Pavel Machek
2009-06-01 19:51 ` Ingo Molnar
2009-06-01 20:52 ` Rafael J. Wysocki
2009-06-01 23:12 ` Ingo Molnar
2009-06-01 23:45 ` Andrew Morton
2009-06-02 16:30 ` Ondrej Zary [this message]
2009-06-02 22:15 ` Andrew Morton
2009-06-03 6:13 ` Ondrej Zary
2009-06-03 6:25 ` Andrew Morton
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=200906021830.53531.linux@rainbow-software.org \
--to=linux@rainbow-software.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--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 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.