diff options
author | Tejun Heo <htejun@gmail.com> | 2007-01-20 02:00:28 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-09 17:39:37 -0500 |
commit | 24dc5f33ea4b504cfbd23fa159a4cacba8e4d800 (patch) | |
tree | d76de456157f555c9a65b83f426fd805fee1e846 /drivers/ata/sata_uli.c | |
parent | f0d36efdc624beb3d9e29b9ab9e9537bf0f25d5b (diff) |
libata: update libata LLDs to use devres
Update libata LLDs to use devres. Core layer is already converted to
support managed LLDs. This patch simplifies initialization and fixes
many resource related bugs in init failure and detach path. For
example, all converted drivers now handle ata_device_add() failure
gracefully without excessive resource rollback code.
As most resources are released automatically on driver detach, many
drivers don't need or can do with much simpler ->{port|host}_stop().
In general, stop callbacks are need iff port or host needs to be given
commands to shut it down. Note that freezing is enough in many cases
and ports are automatically frozen before being detached.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/sata_uli.c')
-rw-r--r-- | drivers/ata/sata_uli.c | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c index a43aec62d505..22eed6d07495 100644 --- a/drivers/ata/sata_uli.c +++ b/drivers/ata/sata_uli.c | |||
@@ -122,8 +122,6 @@ static const struct ata_port_operations uli_ops = { | |||
122 | .scr_write = uli_scr_write, | 122 | .scr_write = uli_scr_write, |
123 | 123 | ||
124 | .port_start = ata_port_start, | 124 | .port_start = ata_port_start, |
125 | .port_stop = ata_port_stop, | ||
126 | .host_stop = ata_host_stop, | ||
127 | }; | 125 | }; |
128 | 126 | ||
129 | static struct ata_port_info uli_port_info = { | 127 | static struct ata_port_info uli_port_info = { |
@@ -189,41 +187,36 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
189 | struct ata_port_info *ppi[2]; | 187 | struct ata_port_info *ppi[2]; |
190 | int rc; | 188 | int rc; |
191 | unsigned int board_idx = (unsigned int) ent->driver_data; | 189 | unsigned int board_idx = (unsigned int) ent->driver_data; |
192 | int pci_dev_busy = 0; | ||
193 | struct uli_priv *hpriv; | 190 | struct uli_priv *hpriv; |
194 | 191 | ||
195 | if (!printed_version++) | 192 | if (!printed_version++) |
196 | dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); | 193 | dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); |
197 | 194 | ||
198 | rc = pci_enable_device(pdev); | 195 | rc = pcim_enable_device(pdev); |
199 | if (rc) | 196 | if (rc) |
200 | return rc; | 197 | return rc; |
201 | 198 | ||
202 | rc = pci_request_regions(pdev, DRV_NAME); | 199 | rc = pci_request_regions(pdev, DRV_NAME); |
203 | if (rc) { | 200 | if (rc) { |
204 | pci_dev_busy = 1; | 201 | pcim_pin_device(pdev); |
205 | goto err_out; | 202 | return rc; |
206 | } | 203 | } |
207 | 204 | ||
208 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 205 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
209 | if (rc) | 206 | if (rc) |
210 | goto err_out_regions; | 207 | return rc; |
211 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | 208 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); |
212 | if (rc) | 209 | if (rc) |
213 | goto err_out_regions; | 210 | return rc; |
214 | 211 | ||
215 | ppi[0] = ppi[1] = &uli_port_info; | 212 | ppi[0] = ppi[1] = &uli_port_info; |
216 | probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); | 213 | probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); |
217 | if (!probe_ent) { | 214 | if (!probe_ent) |
218 | rc = -ENOMEM; | 215 | return -ENOMEM; |
219 | goto err_out_regions; | ||
220 | } | ||
221 | 216 | ||
222 | hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL); | 217 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); |
223 | if (!hpriv) { | 218 | if (!hpriv) |
224 | rc = -ENOMEM; | 219 | return -ENOMEM; |
225 | goto err_out_probe_ent; | ||
226 | } | ||
227 | 220 | ||
228 | probe_ent->private_data = hpriv; | 221 | probe_ent->private_data = hpriv; |
229 | 222 | ||
@@ -269,21 +262,11 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
269 | pci_set_master(pdev); | 262 | pci_set_master(pdev); |
270 | pci_intx(pdev, 1); | 263 | pci_intx(pdev, 1); |
271 | 264 | ||
272 | /* FIXME: check ata_device_add return value */ | 265 | if (!ata_device_add(probe_ent)) |
273 | ata_device_add(probe_ent); | 266 | return -ENODEV; |
274 | kfree(probe_ent); | ||
275 | 267 | ||
268 | devm_kfree(&pdev->dev, probe_ent); | ||
276 | return 0; | 269 | return 0; |
277 | |||
278 | err_out_probe_ent: | ||
279 | kfree(probe_ent); | ||
280 | err_out_regions: | ||
281 | pci_release_regions(pdev); | ||
282 | err_out: | ||
283 | if (!pci_dev_busy) | ||
284 | pci_disable_device(pdev); | ||
285 | return rc; | ||
286 | |||
287 | } | 270 | } |
288 | 271 | ||
289 | static int __init uli_init(void) | 272 | static int __init uli_init(void) |