Skip to content

Commit 5e50b9e

Browse files
Ondrej ZaryJens Axboe
authored andcommitted
floppy: fix hibernation
Based on Ingo Molnar's patch from 2006, this makes the floppy work after resume from hibernation, at least on my machine. This fix resets the floppy controller on resume. It was experimentally determined to bring the controller back to life - we don't really know why it works. floppy_init() does the same thing at boot/modprobe time. Signed-off-by: Ondrej Zary <[email protected]> Cc: "Rafael J. Wysocki" <[email protected]> Cc: Ingo Molnar <[email protected]> Acked-by: Pavel Machek <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 1adbee5 commit 5e50b9e

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

drivers/block/floppy.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4148,6 +4148,24 @@ static void floppy_device_release(struct device *dev)
41484148
{
41494149
}
41504150

4151+
static int floppy_resume(struct platform_device *dev)
4152+
{
4153+
int fdc;
4154+
4155+
for (fdc = 0; fdc < N_FDC; fdc++)
4156+
if (FDCS->address != -1)
4157+
user_reset_fdc(-1, FD_RESET_ALWAYS, 0);
4158+
4159+
return 0;
4160+
}
4161+
4162+
static struct platform_driver floppy_driver = {
4163+
.resume = floppy_resume,
4164+
.driver = {
4165+
.name = "floppy",
4166+
},
4167+
};
4168+
41514169
static struct platform_device floppy_device[N_DRIVE];
41524170

41534171
static struct kobject *floppy_find(dev_t dev, int *part, void *data)
@@ -4196,10 +4214,14 @@ static int __init floppy_init(void)
41964214
if (err)
41974215
goto out_put_disk;
41984216

4217+
err = platform_driver_register(&floppy_driver);
4218+
if (err)
4219+
goto out_unreg_blkdev;
4220+
41994221
floppy_queue = blk_init_queue(do_fd_request, &floppy_lock);
42004222
if (!floppy_queue) {
42014223
err = -ENOMEM;
4202-
goto out_unreg_blkdev;
4224+
goto out_unreg_driver;
42034225
}
42044226
blk_queue_max_sectors(floppy_queue, 64);
42054227

@@ -4346,6 +4368,8 @@ static int __init floppy_init(void)
43464368
out_unreg_region:
43474369
blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
43484370
blk_cleanup_queue(floppy_queue);
4371+
out_unreg_driver:
4372+
platform_driver_unregister(&floppy_driver);
43494373
out_unreg_blkdev:
43504374
unregister_blkdev(FLOPPY_MAJOR, "fd");
43514375
out_put_disk:
@@ -4566,6 +4590,7 @@ static void __exit floppy_module_exit(void)
45664590

45674591
blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
45684592
unregister_blkdev(FLOPPY_MAJOR, "fd");
4593+
platform_driver_unregister(&floppy_driver);
45694594

45704595
for (drive = 0; drive < N_DRIVE; drive++) {
45714596
del_timer_sync(&motor_off_timer[drive]);

0 commit comments

Comments
 (0)