ide: prepare for merging ide-gd-floppy.c with ide-gd.c

- idefloppy_ref_mutex -> ide_disk_ref_mutex
- idefloppy_cleanup_obj() -> ide_disk_release()
- ide_floppy_get() -> ide_disk_get()
- ide_floppy_put() -> ide_disk_put()
- ide_floppy_capacity() -> ide_gd_capacity()
- ide_floppy_remove() -> ide_gd_remove()
- ide_floppy_probe() -> ide_gd_probe()
- idefloppy_driver -> ide_gd_driver
- idefloppy_open() -> ide_gd_open()
- idefloppy_release() -> ide_gd_release()
- idefloppy_getgeo() -> ide_gd_getgeo()
- idefloppy_media_changed() -> ide_gd_media_changed()
- idefloppy_revalidate_disk() -> ide_gd_revalidate_disk()
- idefloppy_ops -> ide_gd_ops
- idefloppy_init() -> ide_gd_init()
- idefloppy_exit() -> ide_gd_exit()

- 'floppy' -> 'idkp' in ide_disk_*() and ide_gd_*()
- idefloppy_floppy_t -> struct ide_floppy_obj

There should be no functional changes caused by this patch.
Acked-by: default avatarBorislav Petkov <petkovbb@gmail.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent c84d9bbe
...@@ -57,7 +57,7 @@ typedef struct ide_floppy_obj { ...@@ -57,7 +57,7 @@ typedef struct ide_floppy_obj {
#define IDEFLOPPY_IOCTL_FORMAT_START 0x4602 #define IDEFLOPPY_IOCTL_FORMAT_START 0x4602
#define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603 #define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603
sector_t ide_floppy_capacity(ide_drive_t *); sector_t ide_gd_capacity(ide_drive_t *);
/* ide-floppy.c */ /* ide-floppy.c */
void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *, u8); void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *, u8);
......
...@@ -9,7 +9,7 @@ static int proc_idefloppy_read_capacity(char *page, char **start, off_t off, ...@@ -9,7 +9,7 @@ static int proc_idefloppy_read_capacity(char *page, char **start, off_t off,
ide_drive_t*drive = (ide_drive_t *)data; ide_drive_t*drive = (ide_drive_t *)data;
int len; int len;
len = sprintf(page, "%llu\n", (long long)ide_floppy_capacity(drive)); len = sprintf(page, "%llu\n", (long long)ide_gd_capacity(drive));
PROC_IDE_READ_RETURN(page, start, off, count, eof, len); PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
} }
......
...@@ -16,75 +16,75 @@ ...@@ -16,75 +16,75 @@
static unsigned long debug_mask; static unsigned long debug_mask;
module_param(debug_mask, ulong, 0644); module_param(debug_mask, ulong, 0644);
static DEFINE_MUTEX(idefloppy_ref_mutex); static DEFINE_MUTEX(ide_disk_ref_mutex);
static void idefloppy_cleanup_obj(struct kref *); static void ide_disk_release(struct kref *);
static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk) static struct ide_floppy_obj *ide_disk_get(struct gendisk *disk)
{ {
struct ide_floppy_obj *floppy = NULL; struct ide_floppy_obj *idkp = NULL;
mutex_lock(&idefloppy_ref_mutex); mutex_lock(&ide_disk_ref_mutex);
floppy = ide_drv_g(disk, ide_floppy_obj); idkp = ide_drv_g(disk, ide_floppy_obj);
if (floppy) { if (idkp) {
if (ide_device_get(floppy->drive)) if (ide_device_get(idkp->drive))
floppy = NULL; idkp = NULL;
else else
kref_get(&floppy->kref); kref_get(&idkp->kref);
} }
mutex_unlock(&idefloppy_ref_mutex); mutex_unlock(&ide_disk_ref_mutex);
return floppy; return idkp;
} }
static void ide_floppy_put(struct ide_floppy_obj *floppy) static void ide_disk_put(struct ide_floppy_obj *idkp)
{ {
ide_drive_t *drive = floppy->drive; ide_drive_t *drive = idkp->drive;
mutex_lock(&idefloppy_ref_mutex); mutex_lock(&ide_disk_ref_mutex);
kref_put(&floppy->kref, idefloppy_cleanup_obj); kref_put(&idkp->kref, ide_disk_release);
ide_device_put(drive); ide_device_put(drive);
mutex_unlock(&idefloppy_ref_mutex); mutex_unlock(&ide_disk_ref_mutex);
} }
sector_t ide_floppy_capacity(ide_drive_t *drive) sector_t ide_gd_capacity(ide_drive_t *drive)
{ {
return drive->capacity64; return drive->capacity64;
} }
static void ide_floppy_remove(ide_drive_t *drive) static int ide_gd_probe(ide_drive_t *);
static void ide_gd_remove(ide_drive_t *drive)
{ {
idefloppy_floppy_t *floppy = drive->driver_data; struct ide_floppy_obj *idkp = drive->driver_data;
struct gendisk *g = floppy->disk; struct gendisk *g = idkp->disk;
ide_proc_unregister_driver(drive, floppy->driver); ide_proc_unregister_driver(drive, idkp->driver);
del_gendisk(g); del_gendisk(g);
ide_floppy_put(floppy); ide_disk_put(idkp);
} }
static void idefloppy_cleanup_obj(struct kref *kref) static void ide_disk_release(struct kref *kref)
{ {
struct ide_floppy_obj *floppy = to_ide_drv(kref, ide_floppy_obj); struct ide_floppy_obj *idkp = to_ide_drv(kref, ide_floppy_obj);
ide_drive_t *drive = floppy->drive; ide_drive_t *drive = idkp->drive;
struct gendisk *g = floppy->disk; struct gendisk *g = idkp->disk;
drive->driver_data = NULL; drive->driver_data = NULL;
g->private_data = NULL; g->private_data = NULL;
put_disk(g); put_disk(g);
kfree(floppy); kfree(idkp);
} }
static int ide_floppy_probe(ide_drive_t *); static ide_driver_t ide_gd_driver = {
static ide_driver_t idefloppy_driver = {
.gen_driver = { .gen_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "ide-floppy", .name = "ide-floppy",
.bus = &ide_bus_type, .bus = &ide_bus_type,
}, },
.probe = ide_floppy_probe, .probe = ide_gd_probe,
.remove = ide_floppy_remove, .remove = ide_gd_remove,
.version = IDEFLOPPY_VERSION, .version = IDEFLOPPY_VERSION,
.do_request = ide_floppy_do_request, .do_request = ide_floppy_do_request,
.end_request = ide_floppy_end_request, .end_request = ide_floppy_end_request,
...@@ -95,24 +95,24 @@ static ide_driver_t idefloppy_driver = { ...@@ -95,24 +95,24 @@ static ide_driver_t idefloppy_driver = {
#endif #endif
}; };
static int idefloppy_open(struct inode *inode, struct file *filp) static int ide_gd_open(struct inode *inode, struct file *filp)
{ {
struct gendisk *disk = inode->i_bdev->bd_disk; struct gendisk *disk = inode->i_bdev->bd_disk;
struct ide_floppy_obj *floppy; struct ide_floppy_obj *idkp;
ide_drive_t *drive; ide_drive_t *drive;
int ret = 0; int ret = 0;
floppy = ide_floppy_get(disk); idkp = ide_disk_get(disk);
if (!floppy) if (idkp == NULL)
return -ENXIO; return -ENXIO;
drive = floppy->drive; drive = idkp->drive;
ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
floppy->openers++; idkp->openers++;
if (floppy->openers == 1) { if (idkp->openers == 1) {
drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS; drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS;
/* Just in case */ /* Just in case */
...@@ -121,7 +121,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp) ...@@ -121,7 +121,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
ret = ide_floppy_get_capacity(drive); ret = ide_floppy_get_capacity(drive);
set_capacity(disk, ide_floppy_capacity(drive)); set_capacity(disk, ide_gd_capacity(drive));
if (ret && (filp->f_flags & O_NDELAY) == 0) { if (ret && (filp->f_flags & O_NDELAY) == 0) {
/* /*
...@@ -130,12 +130,12 @@ static int idefloppy_open(struct inode *inode, struct file *filp) ...@@ -130,12 +130,12 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
* of the drive or begin the format - Sam * of the drive or begin the format - Sam
*/ */
ret = -EIO; ret = -EIO;
goto out_put_floppy; goto out_put_idkp;
} }
if ((drive->dev_flags & IDE_DFLAG_WP) && (filp->f_mode & 2)) { if ((drive->dev_flags & IDE_DFLAG_WP) && (filp->f_mode & 2)) {
ret = -EROFS; ret = -EROFS;
goto out_put_floppy; goto out_put_idkp;
} }
ide_set_media_lock(drive, disk, 1); ide_set_media_lock(drive, disk, 1);
...@@ -143,41 +143,40 @@ static int idefloppy_open(struct inode *inode, struct file *filp) ...@@ -143,41 +143,40 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
check_disk_change(inode->i_bdev); check_disk_change(inode->i_bdev);
} else if (drive->dev_flags & IDE_DFLAG_FORMAT_IN_PROGRESS) { } else if (drive->dev_flags & IDE_DFLAG_FORMAT_IN_PROGRESS) {
ret = -EBUSY; ret = -EBUSY;
goto out_put_floppy; goto out_put_idkp;
} }
return 0; return 0;
out_put_floppy: out_put_idkp:
floppy->openers--; idkp->openers--;
ide_floppy_put(floppy); ide_disk_put(idkp);
return ret; return ret;
} }
static int idefloppy_release(struct inode *inode, struct file *filp) static int ide_gd_release(struct inode *inode, struct file *filp)
{ {
struct gendisk *disk = inode->i_bdev->bd_disk; struct gendisk *disk = inode->i_bdev->bd_disk;
struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj); struct ide_floppy_obj *idkp = ide_drv_g(disk, ide_floppy_obj);
ide_drive_t *drive = floppy->drive; ide_drive_t *drive = idkp->drive;
ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
if (floppy->openers == 1) { if (idkp->openers == 1) {
ide_set_media_lock(drive, disk, 0); ide_set_media_lock(drive, disk, 0);
drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS; drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS;
} }
floppy->openers--; idkp->openers--;
ide_floppy_put(floppy); ide_disk_put(idkp);
return 0; return 0;
} }
static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo) static int ide_gd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
{ {
struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk, struct ide_floppy_obj *idkp = ide_drv_g(bdev->bd_disk, ide_floppy_obj);
ide_floppy_obj); ide_drive_t *drive = idkp->drive;
ide_drive_t *drive = floppy->drive;
geo->heads = drive->bios_head; geo->heads = drive->bios_head;
geo->sectors = drive->bios_sect; geo->sectors = drive->bios_sect;
...@@ -185,10 +184,10 @@ static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo) ...@@ -185,10 +184,10 @@ static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo)
return 0; return 0;
} }
static int idefloppy_media_changed(struct gendisk *disk) static int ide_gd_media_changed(struct gendisk *disk)
{ {
struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj); struct ide_floppy_obj *idkp = ide_drv_g(disk, ide_floppy_obj);
ide_drive_t *drive = floppy->drive; ide_drive_t *drive = idkp->drive;
int ret; int ret;
/* do not scan partitions twice if this is a removable device */ /* do not scan partitions twice if this is a removable device */
...@@ -203,26 +202,26 @@ static int idefloppy_media_changed(struct gendisk *disk) ...@@ -203,26 +202,26 @@ static int idefloppy_media_changed(struct gendisk *disk)
return ret; return ret;
} }
static int idefloppy_revalidate_disk(struct gendisk *disk) static int ide_gd_revalidate_disk(struct gendisk *disk)
{ {
struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj); struct ide_floppy_obj *idkp = ide_drv_g(disk, ide_floppy_obj);
set_capacity(disk, ide_floppy_capacity(floppy->drive)); set_capacity(disk, ide_gd_capacity(idkp->drive));
return 0; return 0;
} }
static struct block_device_operations idefloppy_ops = { static struct block_device_operations ide_gd_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = idefloppy_open, .open = ide_gd_open,
.release = idefloppy_release, .release = ide_gd_release,
.ioctl = ide_floppy_ioctl, .ioctl = ide_floppy_ioctl,
.getgeo = idefloppy_getgeo, .getgeo = ide_gd_getgeo,
.media_changed = idefloppy_media_changed, .media_changed = ide_gd_media_changed,
.revalidate_disk = idefloppy_revalidate_disk .revalidate_disk = ide_gd_revalidate_disk
}; };
static int ide_floppy_probe(ide_drive_t *drive) static int ide_gd_probe(ide_drive_t *drive)
{ {
idefloppy_floppy_t *floppy; struct ide_floppy_obj *idkp;
struct gendisk *g; struct gendisk *g;
if (!strstr("ide-floppy", drive->driver_req)) if (!strstr("ide-floppy", drive->driver_req))
...@@ -236,8 +235,8 @@ static int ide_floppy_probe(ide_drive_t *drive) ...@@ -236,8 +235,8 @@ static int ide_floppy_probe(ide_drive_t *drive)
DRV_NAME "\n", drive->name); DRV_NAME "\n", drive->name);
goto failed; goto failed;
} }
floppy = kzalloc(sizeof(idefloppy_floppy_t), GFP_KERNEL); idkp = kzalloc(sizeof(*idkp), GFP_KERNEL);
if (!floppy) { if (!idkp) {
printk(KERN_ERR PFX "%s: Can't allocate a floppy structure\n", printk(KERN_ERR PFX "%s: Can't allocate a floppy structure\n",
drive->name); drive->name);
goto failed; goto failed;
...@@ -245,54 +244,54 @@ static int ide_floppy_probe(ide_drive_t *drive) ...@@ -245,54 +244,54 @@ static int ide_floppy_probe(ide_drive_t *drive)
g = alloc_disk_node(1 << PARTN_BITS, hwif_to_node(drive->hwif)); g = alloc_disk_node(1 << PARTN_BITS, hwif_to_node(drive->hwif));
if (!g) if (!g)
goto out_free_floppy; goto out_free_idkp;
ide_init_disk(g, drive); ide_init_disk(g, drive);
kref_init(&floppy->kref); kref_init(&idkp->kref);
floppy->drive = drive; idkp->drive = drive;
floppy->driver = &idefloppy_driver; idkp->driver = &ide_gd_driver;
floppy->disk = g; idkp->disk = g;
g->private_data = &floppy->driver; g->private_data = &idkp->driver;
drive->driver_data = floppy; drive->driver_data = idkp;
drive->debug_mask = debug_mask; drive->debug_mask = debug_mask;
ide_floppy_setup(drive); ide_floppy_setup(drive);
set_capacity(g, ide_floppy_capacity(drive)); set_capacity(g, ide_gd_capacity(drive));
g->minors = 1 << PARTN_BITS; g->minors = 1 << PARTN_BITS;
g->driverfs_dev = &drive->gendev; g->driverfs_dev = &drive->gendev;
if (drive->dev_flags & IDE_DFLAG_REMOVABLE) if (drive->dev_flags & IDE_DFLAG_REMOVABLE)
g->flags = GENHD_FL_REMOVABLE; g->flags = GENHD_FL_REMOVABLE;
g->fops = &idefloppy_ops; g->fops = &ide_gd_ops;
add_disk(g); add_disk(g);
return 0; return 0;
out_free_floppy: out_free_idkp:
kfree(floppy); kfree(idkp);
failed: failed:
return -ENODEV; return -ENODEV;
} }
static int __init idefloppy_init(void) static int __init ide_gd_init(void)
{ {
printk(KERN_INFO DRV_NAME " driver " IDEFLOPPY_VERSION "\n"); printk(KERN_INFO DRV_NAME " driver " IDEFLOPPY_VERSION "\n");
return driver_register(&idefloppy_driver.gen_driver); return driver_register(&ide_gd_driver.gen_driver);
} }
static void __exit idefloppy_exit(void) static void __exit ide_gd_exit(void)
{ {
driver_unregister(&idefloppy_driver.gen_driver); driver_unregister(&ide_gd_driver.gen_driver);
} }
MODULE_ALIAS("ide:*m-floppy*"); MODULE_ALIAS("ide:*m-floppy*");
MODULE_ALIAS("ide-floppy"); MODULE_ALIAS("ide-floppy");
module_init(idefloppy_init); module_init(ide_gd_init);
module_exit(idefloppy_exit); module_exit(ide_gd_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("ATAPI FLOPPY Driver"); MODULE_DESCRIPTION("ATAPI FLOPPY Driver");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment