Skip to content

Commit

Permalink
ide: Remove ide_spin_wait_hwgroup() and use special requests instead
Browse files Browse the repository at this point in the history
Use a special request for serialisation purposes and get rid of the
awkward ide_spin_wait_hwgroup(). This also involves converting the
ide_devset structure so it can be shared by the /proc and the ioctl code.

Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
[bart: use rq->cmd[] directly]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
  • Loading branch information
EOltmanns authored and bzolnier committed Oct 10, 2008
1 parent d6e2955 commit 92f1f8f
Show file tree
Hide file tree
Showing 10 changed files with 274 additions and 284 deletions.
8 changes: 4 additions & 4 deletions drivers/ide/ide-cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1809,11 +1809,11 @@ static ide_proc_entry_t idecd_proc[] = {
{ NULL, 0, NULL, NULL }
};

ide_devset_rw(dsc_overlap, 0, 1, dsc_overlap);
ide_devset_rw_field(dsc_overlap, dsc_overlap);

static const struct ide_devset *idecd_settings[] = {
&ide_devset_dsc_overlap,
NULL
static const struct ide_proc_devset idecd_settings[] = {
IDE_PROC_DEVSET(dsc_overlap, 0, 1),
{ 0 },
};
#endif

Expand Down
66 changes: 32 additions & 34 deletions drivers/ide/ide-disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,11 +575,8 @@ static int set_nowerr(ide_drive_t *drive, int arg)
if (arg < 0 || arg > 1)
return -EINVAL;

if (ide_spin_wait_hwgroup(drive))
return -EBUSY;
drive->nowerr = arg;
drive->bad_wstat = arg ? BAD_R_STAT : BAD_W_STAT;
spin_unlock_irq(&ide_lock);
return 0;
}

Expand Down Expand Up @@ -702,33 +699,34 @@ static int set_addressing(ide_drive_t *drive, int arg)
return 0;
}

ide_devset_rw(acoustic, acoustic);
ide_devset_rw(address, addressing);
ide_devset_rw(multcount, multcount);
ide_devset_rw(wcache, wcache);

ide_devset_rw_sync(nowerr, nowerr);

#ifdef CONFIG_IDE_PROC_FS
ide_devset_rw_nolock(acoustic, 0, 254, acoustic);
ide_devset_rw_nolock(address, 0, 2, addressing);
ide_devset_rw_nolock(multcount, 0, 16, multcount);
ide_devset_rw_nolock(nowerr, 0, 1, nowerr);
ide_devset_rw_nolock(wcache, 0, 1, wcache);

ide_devset_rw(bios_cyl, 0, 65535, bios_cyl);
ide_devset_rw(bios_head, 0, 255, bios_head);
ide_devset_rw(bios_sect, 0, 63, bios_sect);
ide_devset_rw(failures, 0, 65535, failures);
ide_devset_rw(lun, 0, 7, lun);
ide_devset_rw(max_failures, 0, 65535, max_failures);

static const struct ide_devset *idedisk_settings[] = {
&ide_devset_acoustic,
&ide_devset_address,
&ide_devset_bios_cyl,
&ide_devset_bios_head,
&ide_devset_bios_sect,
&ide_devset_failures,
&ide_devset_lun,
&ide_devset_max_failures,
&ide_devset_multcount,
&ide_devset_nowerr,
&ide_devset_wcache,
NULL
ide_devset_rw_field(bios_cyl, bios_cyl);
ide_devset_rw_field(bios_head, bios_head);
ide_devset_rw_field(bios_sect, bios_sect);
ide_devset_rw_field(failures, failures);
ide_devset_rw_field(lun, lun);
ide_devset_rw_field(max_failures, max_failures);

static const struct ide_proc_devset idedisk_settings[] = {
IDE_PROC_DEVSET(acoustic, 0, 254),
IDE_PROC_DEVSET(address, 0, 2),
IDE_PROC_DEVSET(bios_cyl, 0, 65535),
IDE_PROC_DEVSET(bios_head, 0, 255),
IDE_PROC_DEVSET(bios_sect, 0, 63),
IDE_PROC_DEVSET(failures, 0, 65535),
IDE_PROC_DEVSET(lun, 0, 7),
IDE_PROC_DEVSET(max_failures, 0, 65535),
IDE_PROC_DEVSET(multcount, 0, 16),
IDE_PROC_DEVSET(nowerr, 0, 1),
IDE_PROC_DEVSET(wcache, 0, 1),
{ 0 },
};
#endif

Expand Down Expand Up @@ -1001,11 +999,11 @@ static int idedisk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
}

static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = {
{ HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, get_addressing, set_addressing },
{ HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, get_multcount, set_multcount },
{ HDIO_GET_NOWERR, HDIO_SET_NOWERR, get_nowerr, set_nowerr },
{ HDIO_GET_WCACHE, HDIO_SET_WCACHE, get_wcache, set_wcache },
{ HDIO_GET_ACOUSTIC, HDIO_SET_ACOUSTIC, get_acoustic, set_acoustic },
{ HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, &ide_devset_address },
{ HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, &ide_devset_multcount },
{ HDIO_GET_NOWERR, HDIO_SET_NOWERR, &ide_devset_nowerr },
{ HDIO_GET_WCACHE, HDIO_SET_WCACHE, &ide_devset_wcache },
{ HDIO_GET_ACOUSTIC, HDIO_SET_ACOUSTIC, &ide_devset_acoustic },
{ 0 }
};

Expand Down
20 changes: 10 additions & 10 deletions drivers/ide/ide-floppy.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,9 @@ static sector_t idefloppy_capacity(ide_drive_t *drive)
}

#ifdef CONFIG_IDE_PROC_FS
ide_devset_rw(bios_cyl, 0, 1023, bios_cyl);
ide_devset_rw(bios_head, 0, 255, bios_head);
ide_devset_rw(bios_sect, 0, 63, bios_sect);
ide_devset_rw_field(bios_cyl, bios_cyl);
ide_devset_rw_field(bios_head, bios_head);
ide_devset_rw_field(bios_sect, bios_sect);

static int get_ticks(ide_drive_t *drive)
{
Expand All @@ -646,14 +646,14 @@ static int set_ticks(ide_drive_t *drive, int arg)
return 0;
}

IDE_DEVSET(ticks, S_RW, 0, 255, get_ticks, set_ticks);
IDE_DEVSET(ticks, DS_SYNC, get_ticks, set_ticks);

static const struct ide_devset *idefloppy_settings[] = {
&ide_devset_bios_cyl,
&ide_devset_bios_head,
&ide_devset_bios_sect,
&ide_devset_ticks,
NULL
static const struct ide_proc_devset idefloppy_settings[] = {
IDE_PROC_DEVSET(bios_cyl, 0, 1023),
IDE_PROC_DEVSET(bios_head, 0, 255),
IDE_PROC_DEVSET(bios_sect, 0, 63),
IDE_PROC_DEVSET(ticks, 0, 255),
{ 0 },
};
#endif

Expand Down
40 changes: 40 additions & 0 deletions drivers/ide/ide-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,9 +716,49 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
return ide_stopped;
}

int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting,
int arg)
{
struct request_queue *q = drive->queue;
struct request *rq;
int ret = 0;

if (!(setting->flags & DS_SYNC))
return setting->set(drive, arg);

rq = blk_get_request(q, READ, GFP_KERNEL);
if (!rq)
return -ENOMEM;

rq->cmd_type = REQ_TYPE_SPECIAL;
rq->cmd_len = 5;
rq->cmd[0] = REQ_DEVSET_EXEC;
*(int *)&rq->cmd[1] = arg;
rq->special = setting->set;

if (blk_execute_rq(q, NULL, rq, 0))
ret = rq->errors;
blk_put_request(rq);

return ret;
}
EXPORT_SYMBOL_GPL(ide_devset_execute);

static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq)
{
switch (rq->cmd[0]) {
case REQ_DEVSET_EXEC:
{
int err, (*setfunc)(ide_drive_t *, int) = rq->special;

err = setfunc(drive, *(int *)&rq->cmd[1]);
if (err)
rq->errors = err;
else
err = 1;
ide_end_request(drive, err, 0);
return ide_stopped;
}
case REQ_DRIVE_RESET:
return ide_do_reset(drive);
default:
Expand Down
21 changes: 11 additions & 10 deletions drivers/ide/ide-ioctls.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,26 @@
#include <linux/ide.h>

static const struct ide_ioctl_devset ide_ioctl_settings[] = {
{ HDIO_GET_32BIT, HDIO_SET_32BIT, get_io_32bit, set_io_32bit },
{ HDIO_GET_KEEPSETTINGS, HDIO_SET_KEEPSETTINGS, get_ksettings, set_ksettings },
{ HDIO_GET_UNMASKINTR, HDIO_SET_UNMASKINTR, get_unmaskirq, set_unmaskirq },
{ HDIO_GET_DMA, HDIO_SET_DMA, get_using_dma, set_using_dma },
{ -1, HDIO_SET_PIO_MODE, NULL, set_pio_mode },
{ HDIO_GET_32BIT, HDIO_SET_32BIT, &ide_devset_io_32bit },
{ HDIO_GET_KEEPSETTINGS, HDIO_SET_KEEPSETTINGS, &ide_devset_keepsettings },
{ HDIO_GET_UNMASKINTR, HDIO_SET_UNMASKINTR, &ide_devset_unmaskirq },
{ HDIO_GET_DMA, HDIO_SET_DMA, &ide_devset_using_dma },
{ -1, HDIO_SET_PIO_MODE, &ide_devset_pio_mode },
{ 0 }
};

int ide_setting_ioctl(ide_drive_t *drive, struct block_device *bdev,
unsigned int cmd, unsigned long arg,
const struct ide_ioctl_devset *s)
{
const struct ide_devset *ds;
unsigned long flags;
int err = -EOPNOTSUPP;

for (; s->get_ioctl; s++) {
if (s->get && s->get_ioctl == cmd)
for (; (ds = s->setting); s++) {
if (ds->get && s->get_ioctl == cmd)
goto read_val;
else if (s->set && s->set_ioctl == cmd)
else if (ds->set && s->set_ioctl == cmd)
goto set_val;
}

Expand All @@ -33,7 +34,7 @@ int ide_setting_ioctl(ide_drive_t *drive, struct block_device *bdev,
read_val:
mutex_lock(&ide_setting_mtx);
spin_lock_irqsave(&ide_lock, flags);
err = s->get(drive);
err = ds->get(drive);
spin_unlock_irqrestore(&ide_lock, flags);
mutex_unlock(&ide_setting_mtx);
return err >= 0 ? put_user(err, (long __user *)arg) : err;
Expand All @@ -46,7 +47,7 @@ int ide_setting_ioctl(ide_drive_t *drive, struct block_device *bdev,
err = -EACCES;
else {
mutex_lock(&ide_setting_mtx);
err = s->set(drive, arg);
err = ide_devset_execute(drive, ds, arg);
mutex_unlock(&ide_setting_mtx);
}
}
Expand Down
Loading

0 comments on commit 92f1f8f

Please sign in to comment.