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

Commit 806f80a6 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz
Browse files

ide: add generic ATA/ATAPI disk driver



* Add struct ide_disk_ops containing protocol specific methods.

* Add 'struct ide_disk_ops *' to ide_drive_t.

* Convert ide-{disk,floppy} drivers to use struct ide_disk_ops.

* Merge ide-{disk,floppy} drivers into generic ide-gd driver.

While at it:
- ide_disk_init_capacity() -> ide_disk_get_capacity()

Acked-by: default avatarBorislav Petkov <petkovbb@gmail.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 79cb3803
Loading
Loading
Loading
Loading
+30 −34
Original line number Diff line number Diff line
@@ -84,21 +84,40 @@ config BLK_DEV_IDE_SATA

	  If unsure, say N.

config BLK_DEV_IDEDISK
	tristate "Include IDE/ATA-2 DISK support"
	---help---
	  This will include enhanced support for MFM/RLL/IDE hard disks.  If
	  you have a MFM/RLL/IDE disk, and there is no special reason to use
	  the old hard disk driver instead, say Y.  If you have an SCSI-only
	  system, you can say N here.
config IDE_GD
	tristate "generic ATA/ATAPI disk support"
	default y
	help
	  Support for ATA/ATAPI disks (including ATAPI floppy drives).

	  To compile this driver as a module, choose M here: the
	  module will be called ide-disk.
	  Do not compile this driver as a module if your root file system
	  (the one containing the directory /) is located on the IDE disk.
	  To compile this driver as a module, choose M here.
	  The module will be called ide-gd_mod.

	  If unsure, say Y.

config IDE_GD_ATA
	bool "ATA disk support"
	depends on IDE_GD
	default y
	help
	  This will include support for ATA hard disks.

	  If unsure, say Y.

config IDE_GD_ATAPI
	bool "ATAPI floppy support"
	depends on IDE_GD
	select IDE_ATAPI
	help
	  This will include support for ATAPI floppy drives
	  (i.e. Iomega ZIP or MKE LS-120).

	  For information about jumper settings and the question
	  of when a ZIP drive uses a partition table, see
	  <http://www.win.tue.nl/~aeb/linux/zip/zip-1.html>.

	  If unsure, say N.

config BLK_DEV_IDECS
	tristate "PCMCIA IDE support"
	depends on PCMCIA
@@ -163,29 +182,6 @@ config BLK_DEV_IDETAPE
	  To compile this driver as a module, choose M here: the
	  module will be called ide-tape.

config BLK_DEV_IDEFLOPPY
	tristate "Include IDE/ATAPI FLOPPY support"
	select IDE_ATAPI
	---help---
	  If you have an IDE floppy drive which uses the ATAPI protocol,
	  answer Y.  ATAPI is a newer protocol used by IDE CD-ROM/tape/floppy
	  drives, similar to the SCSI protocol.

	  The LS-120 and the IDE/ATAPI Iomega ZIP drive are also supported by
	  this driver. For information about jumper settings and the question
	  of when a ZIP drive uses a partition table, see
	  <http://www.win.tue.nl/~aeb/linux/zip/zip-1.html>.
	  (ATAPI PD-CD/CDR drives are not supported by this driver; support
	  for PD-CD/CDR drives is available if you answer Y to
	  "SCSI emulation support", below).

	  If you say Y here, the FLOPPY drive will be identified along with
	  other IDE devices, as "hdb" or "hdc", or something similar (check
	  the boot messages with dmesg).

	  To compile this driver as a module, choose M here: the
	  module will be called ide-floppy.

config BLK_DEV_IDESCSI
	tristate "SCSI emulation support (DEPRECATED)"
	depends on SCSI
+13 −6
Original line number Diff line number Diff line
@@ -37,18 +37,25 @@ obj-$(CONFIG_IDE_H8300) += h8300/
obj-$(CONFIG_IDE_GENERIC)		+= ide-generic.o
obj-$(CONFIG_BLK_DEV_IDEPNP)		+= ide-pnp.o

ide-disk_mod-y += ide-gd.o ide-disk.o ide-disk_ioctl.o
ide-gd_mod-y += ide-gd.o
ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o
ide-floppy_mod-y += ide-gd-floppy.o ide-floppy.o ide-floppy_ioctl.o

ifeq ($(CONFIG_IDE_GD_ATA), y)
	ide-gd_mod-y += ide-disk.o ide-disk_ioctl.o
ifeq ($(CONFIG_IDE_PROC_FS), y)
	ide-disk_mod-y += ide-disk_proc.o
	ide-floppy_mod-y += ide-floppy_proc.o
	ide-gd_mod-y += ide-disk_proc.o
endif
endif

ifeq ($(CONFIG_IDE_GD_ATAPI), y)
	ide-gd_mod-y += ide-floppy.o ide-floppy_ioctl.o
ifeq ($(CONFIG_IDE_PROC_FS), y)
	ide-gd_mod-y += ide-floppy_proc.o
endif
endif

obj-$(CONFIG_BLK_DEV_IDEDISK)		+= ide-disk_mod.o
obj-$(CONFIG_IDE_GD)			+= ide-gd_mod.o
obj-$(CONFIG_BLK_DEV_IDECD)		+= ide-cd_mod.o
obj-$(CONFIG_BLK_DEV_IDEFLOPPY)		+= ide-floppy_mod.o
obj-$(CONFIG_BLK_DEV_IDETAPE)		+= ide-tape.o

ifeq ($(CONFIG_BLK_DEV_IDECS), y)
+32 −7
Original line number Diff line number Diff line
@@ -184,7 +184,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
 * 1073741822 == 549756 MB or 48bit addressing fake drive
 */

ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
				      sector_t block)
{
	ide_hwif_t *hwif = HWIF(drive);
@@ -333,7 +333,7 @@ static void idedisk_check_hpa(ide_drive_t *drive)
	}
}

void ide_disk_init_capacity(ide_drive_t *drive)
static int ide_disk_get_capacity(ide_drive_t *drive)
{
	u16 *id = drive->id;
	int lba;
@@ -382,6 +382,8 @@ void ide_disk_init_capacity(ide_drive_t *drive)
		} else
			drive->dev_flags &= ~IDE_DFLAG_LBA48;
	}

	return 0;
}

static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
@@ -590,7 +592,12 @@ ide_ext_devset_rw(wcache, wcache);

ide_ext_devset_rw_sync(nowerr, nowerr);

void ide_disk_setup(ide_drive_t *drive)
static int ide_disk_check(ide_drive_t *drive, const char *s)
{
	return 1;
}

static void ide_disk_setup(ide_drive_t *drive)
{
	struct ide_disk_obj *idkp = drive->driver_data;
	ide_hwif_t *hwif = drive->hwif;
@@ -626,7 +633,7 @@ void ide_disk_setup(ide_drive_t *drive)
			 drive->queue->max_sectors / 2);

	/* calculate drive capacity, and select LBA if possible */
	ide_disk_init_capacity(drive);
	ide_disk_get_capacity(drive);

	/*
	 * if possible, give fdisk access to more of the drive,
@@ -682,7 +689,7 @@ void ide_disk_setup(ide_drive_t *drive)
		drive->dev_flags |= IDE_DFLAG_ATTACH;
}

void ide_disk_flush(ide_drive_t *drive)
static void ide_disk_flush(ide_drive_t *drive)
{
	if (ata_id_flush_enabled(drive->id) == 0 ||
	    (drive->dev_flags & IDE_DFLAG_WCACHE) == 0)
@@ -692,7 +699,13 @@ void ide_disk_flush(ide_drive_t *drive)
		printk(KERN_INFO "%s: wcache flush failed!\n", drive->name);
}

int ide_disk_set_doorlock(ide_drive_t *drive, int on)
static int ide_disk_init_media(ide_drive_t *drive, struct gendisk *disk)
{
	return 0;
}

static int ide_disk_set_doorlock(ide_drive_t *drive, struct gendisk *disk,
				 int on)
{
	ide_task_t task;
	int ret;
@@ -711,3 +724,15 @@ int ide_disk_set_doorlock(ide_drive_t *drive, int on)

	return ret;
}

const struct ide_disk_ops ide_ata_disk_ops = {
	.check		= ide_disk_check,
	.get_capacity	= ide_disk_get_capacity,
	.setup		= ide_disk_setup,
	.flush		= ide_disk_flush,
	.init_media	= ide_disk_init_media,
	.set_doorlock	= ide_disk_set_doorlock,
	.do_request	= ide_do_rw_disk,
	.end_request	= ide_end_request,
	.ioctl		= ide_disk_ioctl,
};
+9 −15
Original line number Diff line number Diff line
#ifndef __IDE_DISK_H
#define __IDE_DISK_H

struct ide_disk_obj {
	ide_drive_t	*drive;
	ide_driver_t	*driver;
	struct gendisk	*disk;
	struct kref	kref;
	unsigned int	openers;	/* protected by BKL for now */
};

sector_t ide_gd_capacity(ide_drive_t *);
#include "ide-gd.h"

#ifdef CONFIG_IDE_GD_ATA
/* ide-disk.c */
void ide_disk_init_capacity(ide_drive_t *);
void ide_disk_setup(ide_drive_t *);
void ide_disk_flush(ide_drive_t *);
int ide_disk_set_doorlock(ide_drive_t *, int);
ide_startstop_t ide_do_rw_disk(ide_drive_t *, struct request *, sector_t);
extern const struct ide_disk_ops ide_ata_disk_ops;
ide_decl_devset(address);
ide_decl_devset(multcount);
ide_decl_devset(nowerr);
@@ -24,12 +13,17 @@ ide_decl_devset(wcache);
ide_decl_devset(acoustic);

/* ide-disk_ioctl.c */
int ide_disk_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
int ide_disk_ioctl(ide_drive_t *, struct inode *, struct file *, unsigned int,
		   unsigned long);

#ifdef CONFIG_IDE_PROC_FS
/* ide-disk_proc.c */
extern ide_proc_entry_t ide_disk_proc[];
extern const struct ide_proc_devset ide_disk_settings[];
#endif
#else
#define ide_disk_proc		NULL
#define ide_disk_settings	NULL
#endif

#endif /* __IDE_DISK_H */
+1 −3
Original line number Diff line number Diff line
@@ -13,12 +13,10 @@ static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = {
{ 0 }
};

int ide_disk_ioctl(struct inode *inode, struct file *file,
int ide_disk_ioctl(ide_drive_t *drive, struct inode *inode, struct file *file,
		   unsigned int cmd, unsigned long arg)
{
	struct block_device *bdev = inode->i_bdev;
	struct ide_disk_obj *idkp = ide_drv_g(bdev->bd_disk, ide_disk_obj);
	ide_drive_t *drive = idkp->drive;
	int err;

	err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings);
Loading