diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-03-23 00:14:36 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-03-23 00:14:36 -0500 |
commit | 50106c5a0366c9e02bf872e85c672732aa517fb4 (patch) | |
tree | 089a1730359cb5191f1173e6d775d7b4baa9b977 /drivers/scsi/sata_uli.c | |
parent | 02cbd926e9acdc03574d26803050cd2664f59ada (diff) |
[libata sata_uli] kill scr_addr abuse
sata_uli was storing PCI config addresses in a variable intended for
port addresses, a variable soon to become void __iomem *.
Update the driver to store the SCR address, found in PCI config space,
in the driver-private data area.
Diffstat (limited to 'drivers/scsi/sata_uli.c')
-rw-r--r-- | drivers/scsi/sata_uli.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c index 8f5025733def..7ac5a5f5a905 100644 --- a/drivers/scsi/sata_uli.c +++ b/drivers/scsi/sata_uli.c | |||
@@ -44,6 +44,8 @@ enum { | |||
44 | uli_5287 = 1, | 44 | uli_5287 = 1, |
45 | uli_5281 = 2, | 45 | uli_5281 = 2, |
46 | 46 | ||
47 | uli_max_ports = 4, | ||
48 | |||
47 | /* PCI configuration registers */ | 49 | /* PCI configuration registers */ |
48 | ULI5287_BASE = 0x90, /* sata0 phy SCR registers */ | 50 | ULI5287_BASE = 0x90, /* sata0 phy SCR registers */ |
49 | ULI5287_OFFS = 0x10, /* offset from sata0->sata1 phy regs */ | 51 | ULI5287_OFFS = 0x10, /* offset from sata0->sata1 phy regs */ |
@@ -51,6 +53,10 @@ enum { | |||
51 | ULI5281_OFFS = 0x60, /* offset from sata0->sata1 phy regs */ | 53 | ULI5281_OFFS = 0x60, /* offset from sata0->sata1 phy regs */ |
52 | }; | 54 | }; |
53 | 55 | ||
56 | struct uli_priv { | ||
57 | unsigned int scr_cfg_addr[uli_max_ports]; | ||
58 | }; | ||
59 | |||
54 | static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); | 60 | static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); |
55 | static u32 uli_scr_read (struct ata_port *ap, unsigned int sc_reg); | 61 | static u32 uli_scr_read (struct ata_port *ap, unsigned int sc_reg); |
56 | static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); | 62 | static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); |
@@ -137,7 +143,8 @@ MODULE_VERSION(DRV_VERSION); | |||
137 | 143 | ||
138 | static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg) | 144 | static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg) |
139 | { | 145 | { |
140 | return ap->ioaddr.scr_addr + (4 * sc_reg); | 146 | struct uli_priv *hpriv = ap->host_set->private_data; |
147 | return hpriv->scr_cfg_addr[ap->port_no] + (4 * sc_reg); | ||
141 | } | 148 | } |
142 | 149 | ||
143 | static u32 uli_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg) | 150 | static u32 uli_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg) |
@@ -182,6 +189,7 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
182 | int rc; | 189 | int rc; |
183 | unsigned int board_idx = (unsigned int) ent->driver_data; | 190 | unsigned int board_idx = (unsigned int) ent->driver_data; |
184 | int pci_dev_busy = 0; | 191 | int pci_dev_busy = 0; |
192 | struct uli_priv *hpriv; | ||
185 | 193 | ||
186 | if (!printed_version++) | 194 | if (!printed_version++) |
187 | dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); | 195 | dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); |
@@ -210,10 +218,18 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
210 | goto err_out_regions; | 218 | goto err_out_regions; |
211 | } | 219 | } |
212 | 220 | ||
221 | hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL); | ||
222 | if (!hpriv) { | ||
223 | rc = -ENOMEM; | ||
224 | goto err_out_probe_ent; | ||
225 | } | ||
226 | |||
227 | probe_ent->private_data = hpriv; | ||
228 | |||
213 | switch (board_idx) { | 229 | switch (board_idx) { |
214 | case uli_5287: | 230 | case uli_5287: |
215 | probe_ent->port[0].scr_addr = ULI5287_BASE; | 231 | hpriv->scr_cfg_addr[0] = ULI5287_BASE; |
216 | probe_ent->port[1].scr_addr = ULI5287_BASE + ULI5287_OFFS; | 232 | hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS; |
217 | probe_ent->n_ports = 4; | 233 | probe_ent->n_ports = 4; |
218 | 234 | ||
219 | probe_ent->port[2].cmd_addr = pci_resource_start(pdev, 0) + 8; | 235 | probe_ent->port[2].cmd_addr = pci_resource_start(pdev, 0) + 8; |
@@ -221,27 +237,27 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
221 | probe_ent->port[2].ctl_addr = | 237 | probe_ent->port[2].ctl_addr = |
222 | (pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS) + 4; | 238 | (pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS) + 4; |
223 | probe_ent->port[2].bmdma_addr = pci_resource_start(pdev, 4) + 16; | 239 | probe_ent->port[2].bmdma_addr = pci_resource_start(pdev, 4) + 16; |
224 | probe_ent->port[2].scr_addr = ULI5287_BASE + ULI5287_OFFS*4; | 240 | hpriv->scr_cfg_addr[2] = ULI5287_BASE + ULI5287_OFFS*4; |
225 | 241 | ||
226 | probe_ent->port[3].cmd_addr = pci_resource_start(pdev, 2) + 8; | 242 | probe_ent->port[3].cmd_addr = pci_resource_start(pdev, 2) + 8; |
227 | probe_ent->port[3].altstatus_addr = | 243 | probe_ent->port[3].altstatus_addr = |
228 | probe_ent->port[3].ctl_addr = | 244 | probe_ent->port[3].ctl_addr = |
229 | (pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS) + 4; | 245 | (pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS) + 4; |
230 | probe_ent->port[3].bmdma_addr = pci_resource_start(pdev, 4) + 24; | 246 | probe_ent->port[3].bmdma_addr = pci_resource_start(pdev, 4) + 24; |
231 | probe_ent->port[3].scr_addr = ULI5287_BASE + ULI5287_OFFS*5; | 247 | hpriv->scr_cfg_addr[3] = ULI5287_BASE + ULI5287_OFFS*5; |
232 | 248 | ||
233 | ata_std_ports(&probe_ent->port[2]); | 249 | ata_std_ports(&probe_ent->port[2]); |
234 | ata_std_ports(&probe_ent->port[3]); | 250 | ata_std_ports(&probe_ent->port[3]); |
235 | break; | 251 | break; |
236 | 252 | ||
237 | case uli_5289: | 253 | case uli_5289: |
238 | probe_ent->port[0].scr_addr = ULI5287_BASE; | 254 | hpriv->scr_cfg_addr[0] = ULI5287_BASE; |
239 | probe_ent->port[1].scr_addr = ULI5287_BASE + ULI5287_OFFS; | 255 | hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS; |
240 | break; | 256 | break; |
241 | 257 | ||
242 | case uli_5281: | 258 | case uli_5281: |
243 | probe_ent->port[0].scr_addr = ULI5281_BASE; | 259 | hpriv->scr_cfg_addr[0] = ULI5281_BASE; |
244 | probe_ent->port[1].scr_addr = ULI5281_BASE + ULI5281_OFFS; | 260 | hpriv->scr_cfg_addr[1] = ULI5281_BASE + ULI5281_OFFS; |
245 | break; | 261 | break; |
246 | 262 | ||
247 | default: | 263 | default: |
@@ -258,9 +274,10 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
258 | 274 | ||
259 | return 0; | 275 | return 0; |
260 | 276 | ||
277 | err_out_probe_ent: | ||
278 | kfree(probe_ent); | ||
261 | err_out_regions: | 279 | err_out_regions: |
262 | pci_release_regions(pdev); | 280 | pci_release_regions(pdev); |
263 | |||
264 | err_out: | 281 | err_out: |
265 | if (!pci_dev_busy) | 282 | if (!pci_dev_busy) |
266 | pci_disable_device(pdev); | 283 | pci_disable_device(pdev); |