aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2009-12-16 15:38:26 -0500
committerJean Delvare <khali@linux-fr.org>2009-12-16 15:38:26 -0500
commit3ecf44b312758d10be20539b06b2df5d77d59cdb (patch)
tree93b27c2f2463064efbe07be9799b575868f8a28a /drivers/hwmon
parenta0e92d70f35b5fd7da8ec2160cda78b98e2113bc (diff)
hwmon: (smsc47m1) Fail module loading on error
If an error occurs during probing, there's no point in keeping the module in memory. Better fail the module loading early to make the problem more visible. Signed-off-by: Jean Delvare <khali@linux-fr.org> Tested-by: Sean Fidler <fidlersean@gmail.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/smsc47m1.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index bfef22395772..92cca512b38e 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -139,8 +139,7 @@ struct smsc47m1_sio_data {
139}; 139};
140 140
141 141
142static int smsc47m1_probe(struct platform_device *pdev); 142static int __exit smsc47m1_remove(struct platform_device *pdev);
143static int __devexit smsc47m1_remove(struct platform_device *pdev);
144static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, 143static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
145 int init); 144 int init);
146 145
@@ -160,8 +159,7 @@ static struct platform_driver smsc47m1_driver = {
160 .owner = THIS_MODULE, 159 .owner = THIS_MODULE,
161 .name = DRVNAME, 160 .name = DRVNAME,
162 }, 161 },
163 .probe = smsc47m1_probe, 162 .remove = __exit_p(smsc47m1_remove),
164 .remove = __devexit_p(smsc47m1_remove),
165}; 163};
166 164
167static ssize_t get_fan(struct device *dev, struct device_attribute 165static ssize_t get_fan(struct device *dev, struct device_attribute
@@ -562,7 +560,7 @@ static int smsc47m1_handle_resources(unsigned short address, enum chips type,
562 return 0; 560 return 0;
563} 561}
564 562
565static int __devinit smsc47m1_probe(struct platform_device *pdev) 563static int __init smsc47m1_probe(struct platform_device *pdev)
566{ 564{
567 struct device *dev = &pdev->dev; 565 struct device *dev = &pdev->dev;
568 struct smsc47m1_sio_data *sio_data = dev->platform_data; 566 struct smsc47m1_sio_data *sio_data = dev->platform_data;
@@ -720,7 +718,7 @@ error_release:
720 return err; 718 return err;
721} 719}
722 720
723static int __devexit smsc47m1_remove(struct platform_device *pdev) 721static int __exit smsc47m1_remove(struct platform_device *pdev)
724{ 722{
725 struct smsc47m1_data *data = platform_get_drvdata(pdev); 723 struct smsc47m1_data *data = platform_get_drvdata(pdev);
726 struct resource *res; 724 struct resource *res;
@@ -845,27 +843,27 @@ static int __init sm_smsc47m1_init(void)
845 if (smsc47m1_find(&address, &sio_data)) 843 if (smsc47m1_find(&address, &sio_data))
846 return -ENODEV; 844 return -ENODEV;
847 845
848 err = platform_driver_register(&smsc47m1_driver); 846 /* Sets global pdev as a side effect */
847 err = smsc47m1_device_add(address, &sio_data);
849 if (err) 848 if (err)
850 goto exit; 849 goto exit;
851 850
852 /* Sets global pdev as a side effect */ 851 err = platform_driver_probe(&smsc47m1_driver, smsc47m1_probe);
853 err = smsc47m1_device_add(address, &sio_data);
854 if (err) 852 if (err)
855 goto exit_driver; 853 goto exit_device;
856 854
857 return 0; 855 return 0;
858 856
859exit_driver: 857exit_device:
860 platform_driver_unregister(&smsc47m1_driver); 858 platform_device_unregister(pdev);
861exit: 859exit:
862 return err; 860 return err;
863} 861}
864 862
865static void __exit sm_smsc47m1_exit(void) 863static void __exit sm_smsc47m1_exit(void)
866{ 864{
867 platform_device_unregister(pdev);
868 platform_driver_unregister(&smsc47m1_driver); 865 platform_driver_unregister(&smsc47m1_driver);
866 platform_device_unregister(pdev);
869} 867}
870 868
871MODULE_AUTHOR("Mark D. Studebaker <mdsxyz123@yahoo.com>"); 869MODULE_AUTHOR("Mark D. Studebaker <mdsxyz123@yahoo.com>");