Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 126431
b: refs/heads/master
c: b40d1b8
h: refs/heads/master
i:
  126429: d0ecfbd
  126427: 64f1bba
  126423: c0c6b02
  126415: 1e1056c
  126399: 00dee87
v: v3
  • Loading branch information
Bartlomiej Zolnierkiewicz committed Jan 6, 2009
1 parent 687f318 commit 030a87e
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 155 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: ff670e632e818535950d9e31d9d0dcfc7d5b4090
refs/heads/master: b40d1b88f1001f0224c63fa2c008914514bcef33
135 changes: 135 additions & 0 deletions trunk/drivers/ide/ide-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,8 @@ static int ide_init_queue(ide_drive_t *drive)
return 0;
}

static DEFINE_MUTEX(ide_cfg_mtx);

/*
* For any present drive:
* - allocate the block device queue
Expand Down Expand Up @@ -1273,6 +1275,69 @@ static void ide_port_cable_detect(ide_hwif_t *hwif)
}
}

static const u8 ide_hwif_to_major[] =
{ IDE0_MAJOR, IDE1_MAJOR, IDE2_MAJOR, IDE3_MAJOR, IDE4_MAJOR,
IDE5_MAJOR, IDE6_MAJOR, IDE7_MAJOR, IDE8_MAJOR, IDE9_MAJOR };

static void ide_port_init_devices_data(ide_hwif_t *hwif)
{
int unit;

for (unit = 0; unit < MAX_DRIVES; ++unit) {
ide_drive_t *drive = &hwif->drives[unit];
u8 j = (hwif->index * MAX_DRIVES) + unit;

memset(drive, 0, sizeof(*drive));

drive->media = ide_disk;
drive->select = (unit << 4) | ATA_DEVICE_OBS;
drive->hwif = hwif;
drive->ready_stat = ATA_DRDY;
drive->bad_wstat = BAD_W_STAT;
drive->special.b.recalibrate = 1;
drive->special.b.set_geometry = 1;
drive->name[0] = 'h';
drive->name[1] = 'd';
drive->name[2] = 'a' + j;
drive->max_failures = IDE_DEFAULT_MAX_FAILURES;

INIT_LIST_HEAD(&drive->list);
init_completion(&drive->gendev_rel_comp);
}
}

static void ide_init_port_data(ide_hwif_t *hwif, unsigned int index)
{
/* bulk initialize hwif & drive info with zeros */
memset(hwif, 0, sizeof(ide_hwif_t));

/* fill in any non-zero initial values */
hwif->index = index;
hwif->major = ide_hwif_to_major[index];

hwif->name[0] = 'i';
hwif->name[1] = 'd';
hwif->name[2] = 'e';
hwif->name[3] = '0' + index;

init_completion(&hwif->gendev_rel_comp);

hwif->tp_ops = &default_tp_ops;

ide_port_init_devices_data(hwif);
}

static void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw)
{
memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports));
hwif->irq = hw->irq;
hwif->chipset = hw->chipset;
hwif->dev = hw->dev;
hwif->gendev.parent = hw->parent ? hw->parent : hw->dev;
hwif->ack_intr = hw->ack_intr;
hwif->config_data = hw->config;
}

static unsigned int ide_indexes;

/**
Expand Down Expand Up @@ -1503,6 +1568,76 @@ int ide_host_add(const struct ide_port_info *d, hw_regs_t **hws,
}
EXPORT_SYMBOL_GPL(ide_host_add);

static void __ide_port_unregister_devices(ide_hwif_t *hwif)
{
int i;

for (i = 0; i < MAX_DRIVES; i++) {
ide_drive_t *drive = &hwif->drives[i];

if (drive->dev_flags & IDE_DFLAG_PRESENT) {
device_unregister(&drive->gendev);
wait_for_completion(&drive->gendev_rel_comp);
}
}
}

void ide_port_unregister_devices(ide_hwif_t *hwif)
{
mutex_lock(&ide_cfg_mtx);
__ide_port_unregister_devices(hwif);
hwif->present = 0;
ide_port_init_devices_data(hwif);
mutex_unlock(&ide_cfg_mtx);
}
EXPORT_SYMBOL_GPL(ide_port_unregister_devices);

/**
* ide_unregister - free an IDE interface
* @hwif: IDE interface
*
* Perform the final unregister of an IDE interface.
*
* Locking:
* The caller must not hold the IDE locks.
*
* It is up to the caller to be sure there is no pending I/O here,
* and that the interface will not be reopened (present/vanishing
* locking isn't yet done BTW).
*/

static void ide_unregister(ide_hwif_t *hwif)
{
BUG_ON(in_interrupt());
BUG_ON(irqs_disabled());

mutex_lock(&ide_cfg_mtx);

if (hwif->present) {
__ide_port_unregister_devices(hwif);
hwif->present = 0;
}

ide_proc_unregister_port(hwif);

free_irq(hwif->irq, hwif);

device_unregister(hwif->portdev);
device_unregister(&hwif->gendev);
wait_for_completion(&hwif->gendev_rel_comp);

/*
* Remove us from the kernel's knowledge
*/
blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS);
kfree(hwif->sg_table);
unregister_blkdev(hwif->major, hwif->name);

ide_release_dma_engine(hwif);

mutex_unlock(&ide_cfg_mtx);
}

void ide_host_free(struct ide_host *host)
{
ide_hwif_t *hwif;
Expand Down
146 changes: 0 additions & 146 deletions trunk/drivers/ide/ide.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,154 +60,8 @@
#include <linux/completion.h>
#include <linux/device.h>


/* default maximum number of failures */
#define IDE_DEFAULT_MAX_FAILURES 1

struct class *ide_port_class;

static const u8 ide_hwif_to_major[] = { IDE0_MAJOR, IDE1_MAJOR,
IDE2_MAJOR, IDE3_MAJOR,
IDE4_MAJOR, IDE5_MAJOR,
IDE6_MAJOR, IDE7_MAJOR,
IDE8_MAJOR, IDE9_MAJOR };

DEFINE_MUTEX(ide_cfg_mtx);

static void ide_port_init_devices_data(ide_hwif_t *);

/*
* Do not even *think* about calling this!
*/
void ide_init_port_data(ide_hwif_t *hwif, unsigned int index)
{
/* bulk initialize hwif & drive info with zeros */
memset(hwif, 0, sizeof(ide_hwif_t));

/* fill in any non-zero initial values */
hwif->index = index;
hwif->major = ide_hwif_to_major[index];

hwif->name[0] = 'i';
hwif->name[1] = 'd';
hwif->name[2] = 'e';
hwif->name[3] = '0' + index;

init_completion(&hwif->gendev_rel_comp);

hwif->tp_ops = &default_tp_ops;

ide_port_init_devices_data(hwif);
}

static void ide_port_init_devices_data(ide_hwif_t *hwif)
{
int unit;

for (unit = 0; unit < MAX_DRIVES; ++unit) {
ide_drive_t *drive = &hwif->drives[unit];
u8 j = (hwif->index * MAX_DRIVES) + unit;

memset(drive, 0, sizeof(*drive));

drive->media = ide_disk;
drive->select = (unit << 4) | ATA_DEVICE_OBS;
drive->hwif = hwif;
drive->ready_stat = ATA_DRDY;
drive->bad_wstat = BAD_W_STAT;
drive->special.b.recalibrate = 1;
drive->special.b.set_geometry = 1;
drive->name[0] = 'h';
drive->name[1] = 'd';
drive->name[2] = 'a' + j;
drive->max_failures = IDE_DEFAULT_MAX_FAILURES;

INIT_LIST_HEAD(&drive->list);
init_completion(&drive->gendev_rel_comp);
}
}

static void __ide_port_unregister_devices(ide_hwif_t *hwif)
{
int i;

for (i = 0; i < MAX_DRIVES; i++) {
ide_drive_t *drive = &hwif->drives[i];

if (drive->dev_flags & IDE_DFLAG_PRESENT) {
device_unregister(&drive->gendev);
wait_for_completion(&drive->gendev_rel_comp);
}
}
}

void ide_port_unregister_devices(ide_hwif_t *hwif)
{
mutex_lock(&ide_cfg_mtx);
__ide_port_unregister_devices(hwif);
hwif->present = 0;
ide_port_init_devices_data(hwif);
mutex_unlock(&ide_cfg_mtx);
}
EXPORT_SYMBOL_GPL(ide_port_unregister_devices);

/**
* ide_unregister - free an IDE interface
* @hwif: IDE interface
*
* Perform the final unregister of an IDE interface.
*
* Locking:
* The caller must not hold the IDE locks.
*
* It is up to the caller to be sure there is no pending I/O here,
* and that the interface will not be reopened (present/vanishing
* locking isn't yet done BTW).
*/

void ide_unregister(ide_hwif_t *hwif)
{
BUG_ON(in_interrupt());
BUG_ON(irqs_disabled());

mutex_lock(&ide_cfg_mtx);

if (hwif->present) {
__ide_port_unregister_devices(hwif);
hwif->present = 0;
}

ide_proc_unregister_port(hwif);

free_irq(hwif->irq, hwif);

device_unregister(hwif->portdev);
device_unregister(&hwif->gendev);
wait_for_completion(&hwif->gendev_rel_comp);

/*
* Remove us from the kernel's knowledge
*/
blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS);
kfree(hwif->sg_table);
unregister_blkdev(hwif->major, hwif->name);

ide_release_dma_engine(hwif);

mutex_unlock(&ide_cfg_mtx);
}

void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw)
{
memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports));
hwif->irq = hw->irq;
hwif->chipset = hw->chipset;
hwif->dev = hw->dev;
hwif->gendev.parent = hw->parent ? hw->parent : hw->dev;
hwif->ack_intr = hw->ack_intr;
hwif->config_data = hw->config;
}

/*
* Locks for IDE setting functionality
*/
Expand Down
9 changes: 1 addition & 8 deletions trunk/include/linux/ide.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ typedef unsigned char byte; /* used everywhere */
/*
* Probably not wise to fiddle with these
*/
#define IDE_DEFAULT_MAX_FAILURES 1
#define ERROR_MAX 8 /* Max read/write errors per sector */
#define ERROR_RESET 3 /* Reset controller every 4th retry */
#define ERROR_RECAL 1 /* Recalibrate every 2nd retry */
Expand Down Expand Up @@ -184,9 +185,6 @@ typedef struct hw_regs_s {
unsigned long config;
} hw_regs_t;

void ide_init_port_data(struct hwif_s *, unsigned int);
void ide_init_port_hw(struct hwif_s *, hw_regs_t *);

static inline void ide_std_init_ports(hw_regs_t *hw,
unsigned long io_addr,
unsigned long ctl_addr)
Expand Down Expand Up @@ -1506,8 +1504,6 @@ static inline void ide_acpi_port_init_devices(ide_hwif_t *hwif) { ; }
static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {}
#endif

void ide_unregister(ide_hwif_t *);

void ide_register_region(struct gendisk *);
void ide_unregister_region(struct gendisk *);

Expand Down Expand Up @@ -1592,9 +1588,6 @@ static inline void ide_set_max_pio(ide_drive_t *drive)
ide_set_pio(drive, 255);
}

extern spinlock_t ide_lock;
extern struct mutex ide_cfg_mtx;

#define local_irq_set(flags) do { local_save_flags((flags)); local_irq_enable_in_hardirq(); } while (0)

char *ide_media_string(ide_drive_t *);
Expand Down

0 comments on commit 030a87e

Please sign in to comment.