Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 114174
b: refs/heads/master
c: 5aeddf9
h: refs/heads/master
v: v3
  • Loading branch information
Borislav Petkov authored and Bartlomiej Zolnierkiewicz committed Oct 13, 2008
1 parent fc694f0 commit 4c969b5
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 40 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 91ddc9988efeaed487eb7dd81d2557e1b1d501ef
refs/heads/master: 5aeddf907f149cae7e19b7c23ccea3823d00698c
17 changes: 6 additions & 11 deletions trunk/drivers/ide/ide-cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,14 @@

static DEFINE_MUTEX(idecd_ref_mutex);

#define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref)

#define ide_cd_g(disk) \
container_of((disk)->private_data, struct cdrom_info, driver)

static void ide_cd_release(struct kref *);

static struct cdrom_info *ide_cd_get(struct gendisk *disk)
{
struct cdrom_info *cd = NULL;

mutex_lock(&idecd_ref_mutex);
cd = ide_cd_g(disk);
cd = ide_drv_g(disk, cdrom_info);
if (cd) {
if (ide_device_get(cd->drive))
cd = NULL;
Expand Down Expand Up @@ -1941,7 +1936,7 @@ static void ide_cd_remove(ide_drive_t *drive)

static void ide_cd_release(struct kref *kref)
{
struct cdrom_info *info = to_ide_cd(kref);
struct cdrom_info *info = to_ide_drv(kref, cdrom_info);
struct cdrom_device_info *devinfo = &info->devinfo;
ide_drive_t *drive = info->drive;
struct gendisk *g = info->disk;
Expand Down Expand Up @@ -1999,7 +1994,7 @@ static int idecd_open(struct inode *inode, struct file *file)
static int idecd_release(struct inode *inode, struct file *file)
{
struct gendisk *disk = inode->i_bdev->bd_disk;
struct cdrom_info *info = ide_cd_g(disk);
struct cdrom_info *info = ide_drv_g(disk, cdrom_info);

cdrom_release(&info->devinfo, file);

Expand Down Expand Up @@ -2051,7 +2046,7 @@ static int idecd_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
struct block_device *bdev = inode->i_bdev;
struct cdrom_info *info = ide_cd_g(bdev->bd_disk);
struct cdrom_info *info = ide_drv_g(bdev->bd_disk, cdrom_info);
int err;

switch (cmd) {
Expand All @@ -2072,13 +2067,13 @@ static int idecd_ioctl(struct inode *inode, struct file *file,

static int idecd_media_changed(struct gendisk *disk)
{
struct cdrom_info *info = ide_cd_g(disk);
struct cdrom_info *info = ide_drv_g(disk, cdrom_info);
return cdrom_media_changed(&info->devinfo);
}

static int idecd_revalidate_disk(struct gendisk *disk)
{
struct cdrom_info *info = ide_cd_g(disk);
struct cdrom_info *info = ide_drv_g(disk, cdrom_info);
struct request_sense sense;

ide_cd_read_toc(info->drive, &sense);
Expand Down
21 changes: 9 additions & 12 deletions trunk/drivers/ide/ide-floppy.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,14 @@

static DEFINE_MUTEX(idefloppy_ref_mutex);

#define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref)

#define ide_floppy_g(disk) \
container_of((disk)->private_data, struct ide_floppy_obj, driver)

static void idefloppy_cleanup_obj(struct kref *);

static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk)
{
struct ide_floppy_obj *floppy = NULL;

mutex_lock(&idefloppy_ref_mutex);
floppy = ide_floppy_g(disk);
floppy = ide_drv_g(disk, ide_floppy_obj);
if (floppy) {
if (ide_device_get(floppy->drive))
floppy = NULL;
Expand Down Expand Up @@ -625,7 +620,7 @@ static void ide_floppy_remove(ide_drive_t *drive)

static void idefloppy_cleanup_obj(struct kref *kref)
{
struct ide_floppy_obj *floppy = to_ide_floppy(kref);
struct ide_floppy_obj *floppy = to_ide_drv(kref, ide_floppy_obj);
ide_drive_t *drive = floppy->drive;
struct gendisk *g = floppy->disk;

Expand Down Expand Up @@ -733,7 +728,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
static int idefloppy_release(struct inode *inode, struct file *filp)
{
struct gendisk *disk = inode->i_bdev->bd_disk;
struct ide_floppy_obj *floppy = ide_floppy_g(disk);
struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj);
ide_drive_t *drive = floppy->drive;

debug_log("Reached %s\n", __func__);
Expand All @@ -752,7 +747,8 @@ static int idefloppy_release(struct inode *inode, struct file *filp)

static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo)
{
struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk);
struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk,
ide_floppy_obj);
ide_drive_t *drive = floppy->drive;

geo->heads = drive->bios_head;
Expand Down Expand Up @@ -783,7 +779,8 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
struct block_device *bdev = inode->i_bdev;
struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk);
struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk,
ide_floppy_obj);
ide_drive_t *drive = floppy->drive;
struct ide_atapi_pc pc;
void __user *argp = (void __user *)arg;
Expand Down Expand Up @@ -812,7 +809,7 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file,

static int idefloppy_media_changed(struct gendisk *disk)
{
struct ide_floppy_obj *floppy = ide_floppy_g(disk);
struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj);
ide_drive_t *drive = floppy->drive;
int ret;

Expand All @@ -828,7 +825,7 @@ static int idefloppy_media_changed(struct gendisk *disk)

static int idefloppy_revalidate_disk(struct gendisk *disk)
{
struct ide_floppy_obj *floppy = ide_floppy_g(disk);
struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj);
set_capacity(disk, idefloppy_capacity(floppy->drive));
return 0;
}
Expand Down
23 changes: 8 additions & 15 deletions trunk/drivers/ide/ide-tape.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,19 +267,14 @@ static DEFINE_MUTEX(idetape_ref_mutex);

static struct class *idetape_sysfs_class;

#define to_ide_tape(obj) container_of(obj, struct ide_tape_obj, kref)

#define ide_tape_g(disk) \
container_of((disk)->private_data, struct ide_tape_obj, driver)

static void ide_tape_release(struct kref *);

static struct ide_tape_obj *ide_tape_get(struct gendisk *disk)
{
struct ide_tape_obj *tape = NULL;

mutex_lock(&idetape_ref_mutex);
tape = ide_tape_g(disk);
tape = ide_drv_g(disk, ide_tape_obj);
if (tape) {
if (ide_device_get(tape->drive))
tape = NULL;
Expand All @@ -306,8 +301,6 @@ static void ide_tape_put(struct ide_tape_obj *tape)
*/
static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES];

#define ide_tape_f(file) ((file)->private_data)

static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i)
{
struct ide_tape_obj *tape = NULL;
Expand Down Expand Up @@ -1542,7 +1535,7 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op,
static ssize_t idetape_chrdev_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
struct ide_tape_obj *tape = ide_tape_f(file);
struct ide_tape_obj *tape = file->private_data;
ide_drive_t *drive = tape->drive;
ssize_t bytes_read, temp, actually_read = 0, rc;
ssize_t ret = 0;
Expand Down Expand Up @@ -1604,7 +1597,7 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf,
static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
struct ide_tape_obj *tape = ide_tape_f(file);
struct ide_tape_obj *tape = file->private_data;
ide_drive_t *drive = tape->drive;
ssize_t actually_written = 0;
ssize_t ret = 0;
Expand Down Expand Up @@ -1836,7 +1829,7 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count)
static int idetape_chrdev_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
struct ide_tape_obj *tape = ide_tape_f(file);
struct ide_tape_obj *tape = file->private_data;
ide_drive_t *drive = tape->drive;
struct mtop mtop;
struct mtget mtget;
Expand Down Expand Up @@ -2013,7 +2006,7 @@ static void idetape_write_release(ide_drive_t *drive, unsigned int minor)

static int idetape_chrdev_release(struct inode *inode, struct file *filp)
{
struct ide_tape_obj *tape = ide_tape_f(filp);
struct ide_tape_obj *tape = filp->private_data;
ide_drive_t *drive = tape->drive;
unsigned int minor = iminor(inode);

Expand Down Expand Up @@ -2272,7 +2265,7 @@ static void ide_tape_remove(ide_drive_t *drive)

static void ide_tape_release(struct kref *kref)
{
struct ide_tape_obj *tape = to_ide_tape(kref);
struct ide_tape_obj *tape = to_ide_drv(kref, ide_tape_obj);
ide_drive_t *drive = tape->drive;
struct gendisk *g = tape->disk;

Expand Down Expand Up @@ -2355,7 +2348,7 @@ static int idetape_open(struct inode *inode, struct file *filp)
static int idetape_release(struct inode *inode, struct file *filp)
{
struct gendisk *disk = inode->i_bdev->bd_disk;
struct ide_tape_obj *tape = ide_tape_g(disk);
struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj);

ide_tape_put(tape);

Expand All @@ -2366,7 +2359,7 @@ static int idetape_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
struct block_device *bdev = inode->i_bdev;
struct ide_tape_obj *tape = ide_tape_g(bdev->bd_disk);
struct ide_tape_obj *tape = ide_drv_g(bdev->bd_disk, ide_tape_obj);
ide_drive_t *drive = tape->drive;
int err = generic_ide_ioctl(drive, file, bdev, cmd, arg);
if (err == -EINVAL)
Expand Down
8 changes: 7 additions & 1 deletion trunk/include/linux/ide.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,13 @@ struct ide_drive_s {

typedef struct ide_drive_s ide_drive_t;

#define to_ide_device(dev)container_of(dev, ide_drive_t, gendev)
#define to_ide_device(dev) container_of(dev, ide_drive_t, gendev)

#define to_ide_drv(obj, cont_type) \
container_of(obj, struct cont_type, kref)

#define ide_drv_g(disk, cont_type) \
container_of((disk)->private_data, struct cont_type, driver)

struct ide_task_s;
struct ide_port_info;
Expand Down

0 comments on commit 4c969b5

Please sign in to comment.