Skip to content

Commit

Permalink
ide: keep pointer to struct device instead of struct pci_dev in ide_h…
Browse files Browse the repository at this point in the history
…wif_t

Keep pointer to struct device instead of struct pci_dev in ide_hwif_t.

While on it:
* Use *dev->dma_mask instead of pci_dev->dma_mask in ide_toggle_bounce().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
  • Loading branch information
Bartlomiej Zolnierkiewicz committed Feb 1, 2008
1 parent f6fb786 commit 3650165
Show file tree
Hide file tree
Showing 38 changed files with 236 additions and 182 deletions.
23 changes: 13 additions & 10 deletions drivers/ide/ide-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ static int ide_dma_good_drive(ide_drive_t *drive)
int ide_build_sglist(ide_drive_t *drive, struct request *rq)
{
ide_hwif_t *hwif = HWIF(drive);
struct pci_dev *pdev = to_pci_dev(hwif->dev);
struct scatterlist *sg = hwif->sg_table;

ide_map_sg(drive, rq);
Expand All @@ -193,7 +194,7 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq)
else
hwif->sg_dma_direction = PCI_DMA_TODEVICE;

return pci_map_sg(hwif->pci_dev, sg, hwif->sg_nents, hwif->sg_dma_direction);
return pci_map_sg(pdev, sg, hwif->sg_nents, hwif->sg_dma_direction);
}

EXPORT_SYMBOL_GPL(ide_build_sglist);
Expand Down Expand Up @@ -306,11 +307,11 @@ EXPORT_SYMBOL_GPL(ide_build_dmatable);

void ide_destroy_dmatable (ide_drive_t *drive)
{
struct pci_dev *dev = HWIF(drive)->pci_dev;
struct scatterlist *sg = HWIF(drive)->sg_table;
int nents = HWIF(drive)->sg_nents;
ide_hwif_t *hwif = drive->hwif;
struct pci_dev *pdev = to_pci_dev(hwif->dev);

pci_unmap_sg(dev, sg, nents, HWIF(drive)->sg_dma_direction);
pci_unmap_sg(pdev, hwif->sg_table, hwif->sg_nents,
hwif->sg_dma_direction);
}

EXPORT_SYMBOL_GPL(ide_destroy_dmatable);
Expand Down Expand Up @@ -843,10 +844,10 @@ EXPORT_SYMBOL(ide_dma_timeout);
static void ide_release_dma_engine(ide_hwif_t *hwif)
{
if (hwif->dmatable_cpu) {
pci_free_consistent(hwif->pci_dev,
PRD_ENTRIES * PRD_BYTES,
hwif->dmatable_cpu,
hwif->dmatable_dma);
struct pci_dev *pdev = to_pci_dev(hwif->dev);

pci_free_consistent(pdev, PRD_ENTRIES * PRD_BYTES,
hwif->dmatable_cpu, hwif->dmatable_dma);
hwif->dmatable_cpu = NULL;
}
}
Expand Down Expand Up @@ -874,7 +875,9 @@ int ide_release_dma(ide_hwif_t *hwif)

static int ide_allocate_dma_engine(ide_hwif_t *hwif)
{
hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev,
struct pci_dev *pdev = to_pci_dev(hwif->dev);

hwif->dmatable_cpu = pci_alloc_consistent(pdev,
PRD_ENTRIES * PRD_BYTES,
&hwif->dmatable_dma);

Expand Down
6 changes: 4 additions & 2 deletions drivers/ide/ide-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,10 @@ void ide_toggle_bounce(ide_drive_t *drive, int on)
if (!PCI_DMA_BUS_IS_PHYS) {
addr = BLK_BOUNCE_ANY;
} else if (on && drive->media == ide_disk) {
if (HWIF(drive)->pci_dev)
addr = HWIF(drive)->pci_dev->dma_mask;
struct device *dev = drive->hwif->dev;

if (dev && dev->dma_mask)
addr = *dev->dma_mask;
}

if (drive->queue)
Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/ide-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,8 @@ static void hwif_register (ide_hwif_t *hwif)
strlcpy(hwif->gendev.bus_id,hwif->name,BUS_ID_SIZE);
hwif->gendev.driver_data = hwif;
if (hwif->gendev.parent == NULL) {
if (hwif->pci_dev)
hwif->gendev.parent = &hwif->pci_dev->dev;
if (hwif->dev)
hwif->gendev.parent = hwif->dev;
else
/* Would like to do = &device_legacy */
hwif->gendev.parent = NULL;
Expand Down
3 changes: 2 additions & 1 deletion drivers/ide/ide.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,9 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
hwif->chipset = tmp_hwif->chipset;
hwif->hold = tmp_hwif->hold;

hwif->dev = tmp_hwif->dev;

#ifdef CONFIG_BLK_DEV_IDEPCI
hwif->pci_dev = tmp_hwif->pci_dev;
hwif->cds = tmp_hwif->cds;
#endif

Expand Down
8 changes: 4 additions & 4 deletions drivers/ide/pci/aec62xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static u8 pci_bus_clock_list_ultra (u8 speed, struct chipset_bus_clock_list_entr
static void aec6210_set_mode(ide_drive_t *drive, const u8 speed)
{
ide_hwif_t *hwif = HWIF(drive);
struct pci_dev *dev = hwif->pci_dev;
struct pci_dev *dev = to_pci_dev(hwif->dev);
u16 d_conf = 0;
u8 ultra = 0, ultra_conf = 0;
u8 tmp0 = 0, tmp1 = 0, tmp2 = 0;
Expand All @@ -116,7 +116,7 @@ static void aec6210_set_mode(ide_drive_t *drive, const u8 speed)
static void aec6260_set_mode(ide_drive_t *drive, const u8 speed)
{
ide_hwif_t *hwif = HWIF(drive);
struct pci_dev *dev = hwif->pci_dev;
struct pci_dev *dev = to_pci_dev(hwif->dev);
u8 unit = (drive->select.b.unit & 0x01);
u8 tmp1 = 0, tmp2 = 0;
u8 ultra = 0, drive_conf = 0, ultra_conf = 0;
Expand Down Expand Up @@ -170,7 +170,7 @@ static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const ch

static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif)
{
struct pci_dev *dev = hwif->pci_dev;
struct pci_dev *dev = to_pci_dev(hwif->dev);

hwif->set_pio_mode = &aec_set_pio_mode;

Expand All @@ -188,7 +188,7 @@ static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif)
if (hwif->cbl != ATA_CBL_PATA40_SHORT) {
u8 ata66 = 0, mask = hwif->channel ? 0x02 : 0x01;

pci_read_config_byte(hwif->pci_dev, 0x49, &ata66);
pci_read_config_byte(dev, 0x49, &ata66);

hwif->cbl = (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
}
Expand Down
9 changes: 5 additions & 4 deletions drivers/ide/pci/alim15x3.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ static int ali_get_info (char *buffer, char **addr, off_t offset, int count)
static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
{
ide_hwif_t *hwif = HWIF(drive);
struct pci_dev *dev = hwif->pci_dev;
struct pci_dev *dev = to_pci_dev(hwif->dev);
int s_time, a_time, c_time;
u8 s_clc, a_clc, r_clc;
unsigned long flags;
Expand Down Expand Up @@ -396,7 +396,7 @@ static u8 ali_udma_filter(ide_drive_t *drive)
static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed)
{
ide_hwif_t *hwif = HWIF(drive);
struct pci_dev *dev = hwif->pci_dev;
struct pci_dev *dev = to_pci_dev(hwif->dev);
u8 speed1 = speed;
u8 unit = (drive->select.b.unit & 0x01);
u8 tmpbyte = 0x00;
Expand Down Expand Up @@ -625,7 +625,7 @@ static int ali_cable_override(struct pci_dev *pdev)

static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif)
{
struct pci_dev *dev = hwif->pci_dev;
struct pci_dev *dev = to_pci_dev(hwif->dev);
unsigned long flags;
u8 cbl = ATA_CBL_PATA40, tmpbyte;

Expand Down Expand Up @@ -688,12 +688,13 @@ static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif)

static void __devinit init_hwif_ali15x3 (ide_hwif_t *hwif)
{
struct pci_dev *dev = to_pci_dev(hwif->dev);
u8 ideic, inmir;
s8 irq_routing_table[] = { -1, 9, 3, 10, 4, 5, 7, 6,
1, 11, 0, 12, 0, 14, 0, 15 };
int irq = -1;

if (hwif->pci_dev->device == PCI_DEVICE_ID_AL_M5229)
if (dev->device == PCI_DEVICE_ID_AL_M5229)
hwif->irq = hwif->channel ? 15 : 14;

if (isa_dev) {
Expand Down
7 changes: 5 additions & 2 deletions drivers/ide/pci/amd74xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ static void amd_set_speed(struct pci_dev *dev, u8 dn, u8 udma_mask,
static void amd_set_drive(ide_drive_t *drive, const u8 speed)
{
ide_hwif_t *hwif = drive->hwif;
struct pci_dev *dev = to_pci_dev(hwif->dev);
ide_drive_t *peer = hwif->drives + (~drive->dn & 1);
struct ide_timing t, p;
int T, UT;
Expand All @@ -104,7 +105,7 @@ static void amd_set_drive(ide_drive_t *drive, const u8 speed)
if (speed == XFER_UDMA_5 && amd_clock <= 33333) t.udma = 1;
if (speed == XFER_UDMA_6 && amd_clock <= 33333) t.udma = 15;

amd_set_speed(hwif->pci_dev, drive->dn, udma_mask, &t);
amd_set_speed(dev, drive->dn, udma_mask, &t);
}

/*
Expand Down Expand Up @@ -202,8 +203,10 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev,

static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
{
struct pci_dev *dev = to_pci_dev(hwif->dev);

if (hwif->irq == 0) /* 0 is bogus but will do for now */
hwif->irq = pci_get_legacy_ide_irq(hwif->pci_dev, hwif->channel);
hwif->irq = pci_get_legacy_ide_irq(dev, hwif->channel);

hwif->set_pio_mode = &amd_set_pio_mode;
hwif->set_dma_mode = &amd_set_drive;
Expand Down
9 changes: 4 additions & 5 deletions drivers/ide/pci/atiixp.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static DEFINE_SPINLOCK(atiixp_lock);

static void atiixp_set_pio_mode(ide_drive_t *drive, const u8 pio)
{
struct pci_dev *dev = drive->hwif->pci_dev;
struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
unsigned long flags;
int timing_shift = (drive->dn & 2) ? 16 : 0 + (drive->dn & 1) ? 0 : 8;
u32 pio_timing_data;
Expand Down Expand Up @@ -88,7 +88,7 @@ static void atiixp_set_pio_mode(ide_drive_t *drive, const u8 pio)

static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed)
{
struct pci_dev *dev = drive->hwif->pci_dev;
struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
unsigned long flags;
int timing_shift = (drive->dn & 2) ? 16 : 0 + (drive->dn & 1) ? 0 : 8;
u32 tmp32;
Expand Down Expand Up @@ -133,9 +133,8 @@ static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed)

static void __devinit init_hwif_atiixp(ide_hwif_t *hwif)
{
u8 udma_mode = 0;
u8 ch = hwif->channel;
struct pci_dev *pdev = hwif->pci_dev;
struct pci_dev *pdev = to_pci_dev(hwif->dev);
u8 udma_mode = 0, ch = hwif->channel;

hwif->set_pio_mode = &atiixp_set_pio_mode;
hwif->set_dma_mode = &atiixp_set_dma_mode;
Expand Down
14 changes: 7 additions & 7 deletions drivers/ide/pci/cmd64x.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static u8 quantize_timing(int timing, int quant)
*/
static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_time)
{
struct pci_dev *dev = HWIF(drive)->pci_dev;
struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
int clock_time = 1000 / system_bus_clock();
u8 cycle_count, active_count, recovery_count, drwtim;
static const u8 recovery_values[] =
Expand Down Expand Up @@ -118,7 +118,7 @@ static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_
static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio)
{
ide_hwif_t *hwif = HWIF(drive);
struct pci_dev *dev = hwif->pci_dev;
struct pci_dev *dev = to_pci_dev(hwif->dev);
unsigned int cycle_time;
u8 setup_count, arttim = 0;

Expand Down Expand Up @@ -183,7 +183,7 @@ static void cmd64x_set_pio_mode(ide_drive_t *drive, const u8 pio)
static void cmd64x_set_dma_mode(ide_drive_t *drive, const u8 speed)
{
ide_hwif_t *hwif = HWIF(drive);
struct pci_dev *dev = hwif->pci_dev;
struct pci_dev *dev = to_pci_dev(hwif->dev);
u8 unit = drive->dn & 0x01;
u8 regU = 0, pciU = hwif->channel ? UDIDETCR1 : UDIDETCR0;

Expand Down Expand Up @@ -245,7 +245,7 @@ static int cmd648_ide_dma_end (ide_drive_t *drive)
static int cmd64x_ide_dma_end (ide_drive_t *drive)
{
ide_hwif_t *hwif = HWIF(drive);
struct pci_dev *dev = hwif->pci_dev;
struct pci_dev *dev = to_pci_dev(hwif->dev);
int irq_reg = hwif->channel ? ARTTIM23 : CFR;
u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 :
CFR_INTR_CH0;
Expand Down Expand Up @@ -285,7 +285,7 @@ static int cmd648_ide_dma_test_irq (ide_drive_t *drive)
static int cmd64x_ide_dma_test_irq (ide_drive_t *drive)
{
ide_hwif_t *hwif = HWIF(drive);
struct pci_dev *dev = hwif->pci_dev;
struct pci_dev *dev = to_pci_dev(hwif->dev);
int irq_reg = hwif->channel ? ARTTIM23 : CFR;
u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 :
CFR_INTR_CH0;
Expand Down Expand Up @@ -375,7 +375,7 @@ static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const cha

static u8 __devinit ata66_cmd64x(ide_hwif_t *hwif)
{
struct pci_dev *dev = hwif->pci_dev;
struct pci_dev *dev = to_pci_dev(hwif->dev);
u8 bmidecsr = 0, mask = hwif->channel ? 0x02 : 0x01;

switch (dev->device) {
Expand All @@ -390,7 +390,7 @@ static u8 __devinit ata66_cmd64x(ide_hwif_t *hwif)

static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif)
{
struct pci_dev *dev = hwif->pci_dev;
struct pci_dev *dev = to_pci_dev(hwif->dev);

hwif->set_pio_mode = &cmd64x_set_pio_mode;
hwif->set_dma_mode = &cmd64x_set_dma_mode;
Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/pci/cs5520.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static struct pio_clocks cs5520_pio_clocks[]={
static void cs5520_set_pio_mode(ide_drive_t *drive, const u8 pio)
{
ide_hwif_t *hwif = HWIF(drive);
struct pci_dev *pdev = hwif->pci_dev;
struct pci_dev *pdev = to_pci_dev(hwif->dev);
int controller = drive->dn > 1 ? 1 : 0;

/* FIXME: if DMA = 1 do we need to set the DMA bit here ? */
Expand Down
4 changes: 3 additions & 1 deletion drivers/ide/pci/cs5535.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,15 @@ static u8 __devinit cs5535_cable_detect(struct pci_dev *dev)
*/
static void __devinit init_hwif_cs5535(ide_hwif_t *hwif)
{
struct pci_dev *dev = to_pci_dev(hwif->dev);

hwif->set_pio_mode = &cs5535_set_pio_mode;
hwif->set_dma_mode = &cs5535_set_dma_mode;

if (hwif->dma_base == 0)
return;

hwif->cbl = cs5535_cable_detect(hwif->pci_dev);
hwif->cbl = cs5535_cable_detect(dev);
}

static const struct ide_port_info cs5535_chipset __devinitdata = {
Expand Down
5 changes: 3 additions & 2 deletions drivers/ide/pci/cy82c693.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode)
static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio)
{
ide_hwif_t *hwif = HWIF(drive);
struct pci_dev *dev = hwif->pci_dev;
struct pci_dev *dev = to_pci_dev(hwif->dev);
pio_clocks_t pclk;
unsigned int addrCtrl;

Expand Down Expand Up @@ -397,8 +397,9 @@ static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif)
static void __devinit init_iops_cy82c693(ide_hwif_t *hwif)
{
static ide_hwif_t *primary;
struct pci_dev *dev = to_pci_dev(hwif->dev);

if (PCI_FUNC(hwif->pci_dev->devfn) == 1)
if (PCI_FUNC(dev->devfn) == 1)
primary = hwif;
else {
hwif->mate = primary;
Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/pci/delkin_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
return -ENODEV;
}
pci_set_drvdata(dev, hwif);
hwif->pci_dev = dev;
hwif->dev = &dev->dev;
drive = &hwif->drives[0];
if (drive->present) {
drive->io_32bit = 1;
Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/pci/hpt34x.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

static void hpt34x_set_mode(ide_drive_t *drive, const u8 speed)
{
struct pci_dev *dev = HWIF(drive)->pci_dev;
struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
u32 reg1= 0, tmp1 = 0, reg2 = 0, tmp2 = 0;
u8 hi_speed, lo_speed;

Expand Down
Loading

0 comments on commit 3650165

Please sign in to comment.