[SCSI] SCSI aic94xx: handle sysfs errors

Handle and unwind from errors returned by driver model functions.

Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by Jeff Garzik and committed by James Bottomley bb076620 13026a6b

+33 -8
+33 -8
drivers/scsi/aic94xx/aic94xx_init.c
··· 310 } 311 static DEVICE_ATTR(pcba_sn, S_IRUGO, asd_show_dev_pcba_sn, NULL); 312 313 - static void asd_create_dev_attrs(struct asd_ha_struct *asd_ha) 314 { 315 - device_create_file(&asd_ha->pcidev->dev, &dev_attr_revision); 316 - device_create_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); 317 - device_create_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); 318 } 319 320 static void asd_remove_dev_attrs(struct asd_ha_struct *asd_ha) ··· 664 } 665 ASD_DPRINTK("escbs posted\n"); 666 667 - asd_create_dev_attrs(asd_ha); 668 669 err = asd_register_sas_ha(asd_ha); 670 if (err) ··· 689 asd_unregister_sas_ha(asd_ha); 690 Err_reg_sas: 691 asd_remove_dev_attrs(asd_ha); 692 Err_escbs: 693 asd_disable_ints(asd_ha); 694 free_irq(dev->irq, asd_ha); ··· 776 } 777 static DRIVER_ATTR(version, S_IRUGO, asd_version_show, NULL); 778 779 - static void asd_create_driver_attrs(struct device_driver *driver) 780 { 781 - driver_create_file(driver, &driver_attr_version); 782 } 783 784 static void asd_remove_driver_attrs(struct device_driver *driver) ··· 856 if (err) 857 goto out_release_transport; 858 859 - asd_create_driver_attrs(&aic94xx_pci_driver.driver); 860 861 return err; 862 863 out_release_transport: 864 sas_release_transport(aic94xx_transport_template); 865 out_destroy_caches:
··· 310 } 311 static DEVICE_ATTR(pcba_sn, S_IRUGO, asd_show_dev_pcba_sn, NULL); 312 313 + static int asd_create_dev_attrs(struct asd_ha_struct *asd_ha) 314 { 315 + int err; 316 + 317 + err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_revision); 318 + if (err) 319 + return err; 320 + 321 + err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); 322 + if (err) 323 + goto err_rev; 324 + 325 + err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn); 326 + if (err) 327 + goto err_biosb; 328 + 329 + return 0; 330 + 331 + err_biosb: 332 + device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build); 333 + err_rev: 334 + device_remove_file(&asd_ha->pcidev->dev, &dev_attr_revision); 335 + return err; 336 } 337 338 static void asd_remove_dev_attrs(struct asd_ha_struct *asd_ha) ··· 646 } 647 ASD_DPRINTK("escbs posted\n"); 648 649 + err = asd_create_dev_attrs(asd_ha); 650 + if (err) 651 + goto Err_dev_attrs; 652 653 err = asd_register_sas_ha(asd_ha); 654 if (err) ··· 669 asd_unregister_sas_ha(asd_ha); 670 Err_reg_sas: 671 asd_remove_dev_attrs(asd_ha); 672 + Err_dev_attrs: 673 Err_escbs: 674 asd_disable_ints(asd_ha); 675 free_irq(dev->irq, asd_ha); ··· 755 } 756 static DRIVER_ATTR(version, S_IRUGO, asd_version_show, NULL); 757 758 + static int asd_create_driver_attrs(struct device_driver *driver) 759 { 760 + return driver_create_file(driver, &driver_attr_version); 761 } 762 763 static void asd_remove_driver_attrs(struct device_driver *driver) ··· 835 if (err) 836 goto out_release_transport; 837 838 + err = asd_create_driver_attrs(&aic94xx_pci_driver.driver); 839 + if (err) 840 + goto out_unregister_pcidrv; 841 842 return err; 843 844 + out_unregister_pcidrv: 845 + pci_unregister_driver(&aic94xx_pci_driver); 846 out_release_transport: 847 sas_release_transport(aic94xx_transport_template); 848 out_destroy_caches: