diff options
author | Borislav Petkov <petkovbb@googlemail.com> | 2008-10-13 15:39:34 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-13 15:39:34 -0400 |
commit | 5aeddf907f149cae7e19b7c23ccea3823d00698c (patch) | |
tree | c3507ed9a078f94bb091ed6557f570927b34f255 /drivers | |
parent | 91ddc9988efeaed487eb7dd81d2557e1b1d501ef (diff) |
ide: unify conversion macros
Introduce to_ide_drv() and ide_drv_g() macros and replace the respective
definitions of similar ones in each driver.
There should be no functionality change resulting from this patch.
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ide/ide-cd.c | 17 | ||||
-rw-r--r-- | drivers/ide/ide-floppy.c | 21 | ||||
-rw-r--r-- | drivers/ide/ide-tape.c | 23 |
3 files changed, 23 insertions, 38 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 465a92ca0179..8650ad43b324 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -52,11 +52,6 @@ | |||
52 | 52 | ||
53 | static DEFINE_MUTEX(idecd_ref_mutex); | 53 | static DEFINE_MUTEX(idecd_ref_mutex); |
54 | 54 | ||
55 | #define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref) | ||
56 | |||
57 | #define ide_cd_g(disk) \ | ||
58 | container_of((disk)->private_data, struct cdrom_info, driver) | ||
59 | |||
60 | static void ide_cd_release(struct kref *); | 55 | static void ide_cd_release(struct kref *); |
61 | 56 | ||
62 | static struct cdrom_info *ide_cd_get(struct gendisk *disk) | 57 | static struct cdrom_info *ide_cd_get(struct gendisk *disk) |
@@ -64,7 +59,7 @@ static struct cdrom_info *ide_cd_get(struct gendisk *disk) | |||
64 | struct cdrom_info *cd = NULL; | 59 | struct cdrom_info *cd = NULL; |
65 | 60 | ||
66 | mutex_lock(&idecd_ref_mutex); | 61 | mutex_lock(&idecd_ref_mutex); |
67 | cd = ide_cd_g(disk); | 62 | cd = ide_drv_g(disk, cdrom_info); |
68 | if (cd) { | 63 | if (cd) { |
69 | if (ide_device_get(cd->drive)) | 64 | if (ide_device_get(cd->drive)) |
70 | cd = NULL; | 65 | cd = NULL; |
@@ -1941,7 +1936,7 @@ static void ide_cd_remove(ide_drive_t *drive) | |||
1941 | 1936 | ||
1942 | static void ide_cd_release(struct kref *kref) | 1937 | static void ide_cd_release(struct kref *kref) |
1943 | { | 1938 | { |
1944 | struct cdrom_info *info = to_ide_cd(kref); | 1939 | struct cdrom_info *info = to_ide_drv(kref, cdrom_info); |
1945 | struct cdrom_device_info *devinfo = &info->devinfo; | 1940 | struct cdrom_device_info *devinfo = &info->devinfo; |
1946 | ide_drive_t *drive = info->drive; | 1941 | ide_drive_t *drive = info->drive; |
1947 | struct gendisk *g = info->disk; | 1942 | struct gendisk *g = info->disk; |
@@ -1999,7 +1994,7 @@ static int idecd_open(struct inode *inode, struct file *file) | |||
1999 | static int idecd_release(struct inode *inode, struct file *file) | 1994 | static int idecd_release(struct inode *inode, struct file *file) |
2000 | { | 1995 | { |
2001 | struct gendisk *disk = inode->i_bdev->bd_disk; | 1996 | struct gendisk *disk = inode->i_bdev->bd_disk; |
2002 | struct cdrom_info *info = ide_cd_g(disk); | 1997 | struct cdrom_info *info = ide_drv_g(disk, cdrom_info); |
2003 | 1998 | ||
2004 | cdrom_release(&info->devinfo, file); | 1999 | cdrom_release(&info->devinfo, file); |
2005 | 2000 | ||
@@ -2051,7 +2046,7 @@ static int idecd_ioctl(struct inode *inode, struct file *file, | |||
2051 | unsigned int cmd, unsigned long arg) | 2046 | unsigned int cmd, unsigned long arg) |
2052 | { | 2047 | { |
2053 | struct block_device *bdev = inode->i_bdev; | 2048 | struct block_device *bdev = inode->i_bdev; |
2054 | struct cdrom_info *info = ide_cd_g(bdev->bd_disk); | 2049 | struct cdrom_info *info = ide_drv_g(bdev->bd_disk, cdrom_info); |
2055 | int err; | 2050 | int err; |
2056 | 2051 | ||
2057 | switch (cmd) { | 2052 | switch (cmd) { |
@@ -2072,13 +2067,13 @@ static int idecd_ioctl(struct inode *inode, struct file *file, | |||
2072 | 2067 | ||
2073 | static int idecd_media_changed(struct gendisk *disk) | 2068 | static int idecd_media_changed(struct gendisk *disk) |
2074 | { | 2069 | { |
2075 | struct cdrom_info *info = ide_cd_g(disk); | 2070 | struct cdrom_info *info = ide_drv_g(disk, cdrom_info); |
2076 | return cdrom_media_changed(&info->devinfo); | 2071 | return cdrom_media_changed(&info->devinfo); |
2077 | } | 2072 | } |
2078 | 2073 | ||
2079 | static int idecd_revalidate_disk(struct gendisk *disk) | 2074 | static int idecd_revalidate_disk(struct gendisk *disk) |
2080 | { | 2075 | { |
2081 | struct cdrom_info *info = ide_cd_g(disk); | 2076 | struct cdrom_info *info = ide_drv_g(disk, cdrom_info); |
2082 | struct request_sense sense; | 2077 | struct request_sense sense; |
2083 | 2078 | ||
2084 | ide_cd_read_toc(info->drive, &sense); | 2079 | ide_cd_read_toc(info->drive, &sense); |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 2a34f1ad2284..2a54a25090cb 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -84,11 +84,6 @@ | |||
84 | 84 | ||
85 | static DEFINE_MUTEX(idefloppy_ref_mutex); | 85 | static DEFINE_MUTEX(idefloppy_ref_mutex); |
86 | 86 | ||
87 | #define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref) | ||
88 | |||
89 | #define ide_floppy_g(disk) \ | ||
90 | container_of((disk)->private_data, struct ide_floppy_obj, driver) | ||
91 | |||
92 | static void idefloppy_cleanup_obj(struct kref *); | 87 | static void idefloppy_cleanup_obj(struct kref *); |
93 | 88 | ||
94 | static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk) | 89 | static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk) |
@@ -96,7 +91,7 @@ static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk) | |||
96 | struct ide_floppy_obj *floppy = NULL; | 91 | struct ide_floppy_obj *floppy = NULL; |
97 | 92 | ||
98 | mutex_lock(&idefloppy_ref_mutex); | 93 | mutex_lock(&idefloppy_ref_mutex); |
99 | floppy = ide_floppy_g(disk); | 94 | floppy = ide_drv_g(disk, ide_floppy_obj); |
100 | if (floppy) { | 95 | if (floppy) { |
101 | if (ide_device_get(floppy->drive)) | 96 | if (ide_device_get(floppy->drive)) |
102 | floppy = NULL; | 97 | floppy = NULL; |
@@ -625,7 +620,7 @@ static void ide_floppy_remove(ide_drive_t *drive) | |||
625 | 620 | ||
626 | static void idefloppy_cleanup_obj(struct kref *kref) | 621 | static void idefloppy_cleanup_obj(struct kref *kref) |
627 | { | 622 | { |
628 | struct ide_floppy_obj *floppy = to_ide_floppy(kref); | 623 | struct ide_floppy_obj *floppy = to_ide_drv(kref, ide_floppy_obj); |
629 | ide_drive_t *drive = floppy->drive; | 624 | ide_drive_t *drive = floppy->drive; |
630 | struct gendisk *g = floppy->disk; | 625 | struct gendisk *g = floppy->disk; |
631 | 626 | ||
@@ -733,7 +728,7 @@ out_put_floppy: | |||
733 | static int idefloppy_release(struct inode *inode, struct file *filp) | 728 | static int idefloppy_release(struct inode *inode, struct file *filp) |
734 | { | 729 | { |
735 | struct gendisk *disk = inode->i_bdev->bd_disk; | 730 | struct gendisk *disk = inode->i_bdev->bd_disk; |
736 | struct ide_floppy_obj *floppy = ide_floppy_g(disk); | 731 | struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj); |
737 | ide_drive_t *drive = floppy->drive; | 732 | ide_drive_t *drive = floppy->drive; |
738 | 733 | ||
739 | debug_log("Reached %s\n", __func__); | 734 | debug_log("Reached %s\n", __func__); |
@@ -752,7 +747,8 @@ static int idefloppy_release(struct inode *inode, struct file *filp) | |||
752 | 747 | ||
753 | static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo) | 748 | static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo) |
754 | { | 749 | { |
755 | struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk); | 750 | struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk, |
751 | ide_floppy_obj); | ||
756 | ide_drive_t *drive = floppy->drive; | 752 | ide_drive_t *drive = floppy->drive; |
757 | 753 | ||
758 | geo->heads = drive->bios_head; | 754 | geo->heads = drive->bios_head; |
@@ -783,7 +779,8 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file, | |||
783 | unsigned int cmd, unsigned long arg) | 779 | unsigned int cmd, unsigned long arg) |
784 | { | 780 | { |
785 | struct block_device *bdev = inode->i_bdev; | 781 | struct block_device *bdev = inode->i_bdev; |
786 | struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk); | 782 | struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk, |
783 | ide_floppy_obj); | ||
787 | ide_drive_t *drive = floppy->drive; | 784 | ide_drive_t *drive = floppy->drive; |
788 | struct ide_atapi_pc pc; | 785 | struct ide_atapi_pc pc; |
789 | void __user *argp = (void __user *)arg; | 786 | void __user *argp = (void __user *)arg; |
@@ -812,7 +809,7 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file, | |||
812 | 809 | ||
813 | static int idefloppy_media_changed(struct gendisk *disk) | 810 | static int idefloppy_media_changed(struct gendisk *disk) |
814 | { | 811 | { |
815 | struct ide_floppy_obj *floppy = ide_floppy_g(disk); | 812 | struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj); |
816 | ide_drive_t *drive = floppy->drive; | 813 | ide_drive_t *drive = floppy->drive; |
817 | int ret; | 814 | int ret; |
818 | 815 | ||
@@ -828,7 +825,7 @@ static int idefloppy_media_changed(struct gendisk *disk) | |||
828 | 825 | ||
829 | static int idefloppy_revalidate_disk(struct gendisk *disk) | 826 | static int idefloppy_revalidate_disk(struct gendisk *disk) |
830 | { | 827 | { |
831 | struct ide_floppy_obj *floppy = ide_floppy_g(disk); | 828 | struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj); |
832 | set_capacity(disk, idefloppy_capacity(floppy->drive)); | 829 | set_capacity(disk, idefloppy_capacity(floppy->drive)); |
833 | return 0; | 830 | return 0; |
834 | } | 831 | } |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 622d5fed2dc5..2c235401aad1 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -267,11 +267,6 @@ static DEFINE_MUTEX(idetape_ref_mutex); | |||
267 | 267 | ||
268 | static struct class *idetape_sysfs_class; | 268 | static struct class *idetape_sysfs_class; |
269 | 269 | ||
270 | #define to_ide_tape(obj) container_of(obj, struct ide_tape_obj, kref) | ||
271 | |||
272 | #define ide_tape_g(disk) \ | ||
273 | container_of((disk)->private_data, struct ide_tape_obj, driver) | ||
274 | |||
275 | static void ide_tape_release(struct kref *); | 270 | static void ide_tape_release(struct kref *); |
276 | 271 | ||
277 | static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) | 272 | static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) |
@@ -279,7 +274,7 @@ static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) | |||
279 | struct ide_tape_obj *tape = NULL; | 274 | struct ide_tape_obj *tape = NULL; |
280 | 275 | ||
281 | mutex_lock(&idetape_ref_mutex); | 276 | mutex_lock(&idetape_ref_mutex); |
282 | tape = ide_tape_g(disk); | 277 | tape = ide_drv_g(disk, ide_tape_obj); |
283 | if (tape) { | 278 | if (tape) { |
284 | if (ide_device_get(tape->drive)) | 279 | if (ide_device_get(tape->drive)) |
285 | tape = NULL; | 280 | tape = NULL; |
@@ -306,8 +301,6 @@ static void ide_tape_put(struct ide_tape_obj *tape) | |||
306 | */ | 301 | */ |
307 | static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES]; | 302 | static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES]; |
308 | 303 | ||
309 | #define ide_tape_f(file) ((file)->private_data) | ||
310 | |||
311 | static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i) | 304 | static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i) |
312 | { | 305 | { |
313 | struct ide_tape_obj *tape = NULL; | 306 | struct ide_tape_obj *tape = NULL; |
@@ -1542,7 +1535,7 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, | |||
1542 | static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, | 1535 | static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, |
1543 | size_t count, loff_t *ppos) | 1536 | size_t count, loff_t *ppos) |
1544 | { | 1537 | { |
1545 | struct ide_tape_obj *tape = ide_tape_f(file); | 1538 | struct ide_tape_obj *tape = file->private_data; |
1546 | ide_drive_t *drive = tape->drive; | 1539 | ide_drive_t *drive = tape->drive; |
1547 | ssize_t bytes_read, temp, actually_read = 0, rc; | 1540 | ssize_t bytes_read, temp, actually_read = 0, rc; |
1548 | ssize_t ret = 0; | 1541 | ssize_t ret = 0; |
@@ -1604,7 +1597,7 @@ finish: | |||
1604 | static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, | 1597 | static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, |
1605 | size_t count, loff_t *ppos) | 1598 | size_t count, loff_t *ppos) |
1606 | { | 1599 | { |
1607 | struct ide_tape_obj *tape = ide_tape_f(file); | 1600 | struct ide_tape_obj *tape = file->private_data; |
1608 | ide_drive_t *drive = tape->drive; | 1601 | ide_drive_t *drive = tape->drive; |
1609 | ssize_t actually_written = 0; | 1602 | ssize_t actually_written = 0; |
1610 | ssize_t ret = 0; | 1603 | ssize_t ret = 0; |
@@ -1836,7 +1829,7 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
1836 | static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, | 1829 | static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, |
1837 | unsigned int cmd, unsigned long arg) | 1830 | unsigned int cmd, unsigned long arg) |
1838 | { | 1831 | { |
1839 | struct ide_tape_obj *tape = ide_tape_f(file); | 1832 | struct ide_tape_obj *tape = file->private_data; |
1840 | ide_drive_t *drive = tape->drive; | 1833 | ide_drive_t *drive = tape->drive; |
1841 | struct mtop mtop; | 1834 | struct mtop mtop; |
1842 | struct mtget mtget; | 1835 | struct mtget mtget; |
@@ -2013,7 +2006,7 @@ static void idetape_write_release(ide_drive_t *drive, unsigned int minor) | |||
2013 | 2006 | ||
2014 | static int idetape_chrdev_release(struct inode *inode, struct file *filp) | 2007 | static int idetape_chrdev_release(struct inode *inode, struct file *filp) |
2015 | { | 2008 | { |
2016 | struct ide_tape_obj *tape = ide_tape_f(filp); | 2009 | struct ide_tape_obj *tape = filp->private_data; |
2017 | ide_drive_t *drive = tape->drive; | 2010 | ide_drive_t *drive = tape->drive; |
2018 | unsigned int minor = iminor(inode); | 2011 | unsigned int minor = iminor(inode); |
2019 | 2012 | ||
@@ -2272,7 +2265,7 @@ static void ide_tape_remove(ide_drive_t *drive) | |||
2272 | 2265 | ||
2273 | static void ide_tape_release(struct kref *kref) | 2266 | static void ide_tape_release(struct kref *kref) |
2274 | { | 2267 | { |
2275 | struct ide_tape_obj *tape = to_ide_tape(kref); | 2268 | struct ide_tape_obj *tape = to_ide_drv(kref, ide_tape_obj); |
2276 | ide_drive_t *drive = tape->drive; | 2269 | ide_drive_t *drive = tape->drive; |
2277 | struct gendisk *g = tape->disk; | 2270 | struct gendisk *g = tape->disk; |
2278 | 2271 | ||
@@ -2355,7 +2348,7 @@ static int idetape_open(struct inode *inode, struct file *filp) | |||
2355 | static int idetape_release(struct inode *inode, struct file *filp) | 2348 | static int idetape_release(struct inode *inode, struct file *filp) |
2356 | { | 2349 | { |
2357 | struct gendisk *disk = inode->i_bdev->bd_disk; | 2350 | struct gendisk *disk = inode->i_bdev->bd_disk; |
2358 | struct ide_tape_obj *tape = ide_tape_g(disk); | 2351 | struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj); |
2359 | 2352 | ||
2360 | ide_tape_put(tape); | 2353 | ide_tape_put(tape); |
2361 | 2354 | ||
@@ -2366,7 +2359,7 @@ static int idetape_ioctl(struct inode *inode, struct file *file, | |||
2366 | unsigned int cmd, unsigned long arg) | 2359 | unsigned int cmd, unsigned long arg) |
2367 | { | 2360 | { |
2368 | struct block_device *bdev = inode->i_bdev; | 2361 | struct block_device *bdev = inode->i_bdev; |
2369 | struct ide_tape_obj *tape = ide_tape_g(bdev->bd_disk); | 2362 | struct ide_tape_obj *tape = ide_drv_g(bdev->bd_disk, ide_tape_obj); |
2370 | ide_drive_t *drive = tape->drive; | 2363 | ide_drive_t *drive = tape->drive; |
2371 | int err = generic_ide_ioctl(drive, file, bdev, cmd, arg); | 2364 | int err = generic_ide_ioctl(drive, file, bdev, cmd, arg); |
2372 | if (err == -EINVAL) | 2365 | if (err == -EINVAL) |