Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92f1f8fd authored by Elias Oltmanns's avatar Elias Oltmanns Committed by Bartlomiej Zolnierkiewicz
Browse files

ide: Remove ide_spin_wait_hwgroup() and use special requests instead



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: default avatarElias Oltmanns <eo@nebensachen.de>
[bart: use rq->cmd[] directly]
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent d6e2955a
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -1809,11 +1809,11 @@ static ide_proc_entry_t idecd_proc[] = {
	{ NULL, 0, NULL, NULL }
	{ 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[] = {
static const struct ide_proc_devset idecd_settings[] = {
	&ide_devset_dsc_overlap,
	IDE_PROC_DEVSET(dsc_overlap, 0, 1),
	NULL
	{ 0 },
};
};
#endif
#endif


+32 −34
Original line number Original line Diff line number Diff line
@@ -575,11 +575,8 @@ static int set_nowerr(ide_drive_t *drive, int arg)
	if (arg < 0 || arg > 1)
	if (arg < 0 || arg > 1)
		return -EINVAL;
		return -EINVAL;


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


@@ -702,33 +699,34 @@ static int set_addressing(ide_drive_t *drive, int arg)
	return 0;
	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
#ifdef CONFIG_IDE_PROC_FS
ide_devset_rw_nolock(acoustic,	0, 254, acoustic);
ide_devset_rw_field(bios_cyl, bios_cyl);
ide_devset_rw_nolock(address,	0,   2, addressing);
ide_devset_rw_field(bios_head, bios_head);
ide_devset_rw_nolock(multcount,	0,  16, multcount);
ide_devset_rw_field(bios_sect, bios_sect);
ide_devset_rw_nolock(nowerr,	0,   1, nowerr);
ide_devset_rw_field(failures, failures);
ide_devset_rw_nolock(wcache,	0,   1, wcache);
ide_devset_rw_field(lun, lun);

ide_devset_rw_field(max_failures, max_failures);
ide_devset_rw(bios_cyl,		0, 65535, bios_cyl);

ide_devset_rw(bios_head,	0,   255, bios_head);
static const struct ide_proc_devset idedisk_settings[] = {
ide_devset_rw(bios_sect,	0,    63, bios_sect);
	IDE_PROC_DEVSET(acoustic,	0,   254),
ide_devset_rw(failures,		0, 65535, failures);
	IDE_PROC_DEVSET(address,	0,     2),
ide_devset_rw(lun,		0,     7, lun);
	IDE_PROC_DEVSET(bios_cyl,	0, 65535),
ide_devset_rw(max_failures,	0, 65535, max_failures);
	IDE_PROC_DEVSET(bios_head,	0,   255),

	IDE_PROC_DEVSET(bios_sect,	0,    63),
static const struct ide_devset *idedisk_settings[] = {
	IDE_PROC_DEVSET(failures,	0, 65535),
	&ide_devset_acoustic,
	IDE_PROC_DEVSET(lun,		0,     7),
	&ide_devset_address,
	IDE_PROC_DEVSET(max_failures,	0, 65535),
	&ide_devset_bios_cyl,
	IDE_PROC_DEVSET(multcount,	0,    16),
	&ide_devset_bios_head,
	IDE_PROC_DEVSET(nowerr,		0,     1),
	&ide_devset_bios_sect,
	IDE_PROC_DEVSET(wcache,		0,     1),
	&ide_devset_failures,
	{ 0 },
	&ide_devset_lun,
	&ide_devset_max_failures,
	&ide_devset_multcount,
	&ide_devset_nowerr,
	&ide_devset_wcache,
	NULL
};
};
#endif
#endif


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


+10 −10
Original line number Original line Diff line number Diff line
@@ -629,9 +629,9 @@ static sector_t idefloppy_capacity(ide_drive_t *drive)
}
}


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


static int get_ticks(ide_drive_t *drive)
static int get_ticks(ide_drive_t *drive)
{
{
@@ -646,14 +646,14 @@ static int set_ticks(ide_drive_t *drive, int arg)
	return 0;
	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[] = {
static const struct ide_proc_devset idefloppy_settings[] = {
	&ide_devset_bios_cyl,
	IDE_PROC_DEVSET(bios_cyl,  0, 1023),
	&ide_devset_bios_head,
	IDE_PROC_DEVSET(bios_head, 0,  255),
	&ide_devset_bios_sect,
	IDE_PROC_DEVSET(bios_sect, 0,   63),
	&ide_devset_ticks,
	IDE_PROC_DEVSET(ticks,	   0,  255),
	NULL
	{ 0 },
};
};
#endif
#endif


+40 −0
Original line number Original line Diff line number Diff line
@@ -716,9 +716,49 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
 	return ide_stopped;
 	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)
static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq)
{
{
	switch (rq->cmd[0]) {
	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:
	case REQ_DRIVE_RESET:
		return ide_do_reset(drive);
		return ide_do_reset(drive);
	default:
	default:
+11 −10
Original line number Original line Diff line number Diff line
@@ -6,11 +6,11 @@
#include <linux/ide.h>
#include <linux/ide.h>


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


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


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


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