diff options
author | Jean Delvare <khali@linux-fr.org> | 2009-12-16 15:38:26 -0500 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-12-16 15:38:26 -0500 |
commit | 3ecf44b312758d10be20539b06b2df5d77d59cdb (patch) | |
tree | 93b27c2f2463064efbe07be9799b575868f8a28a /drivers/hwmon/smsc47m1.c | |
parent | a0e92d70f35b5fd7da8ec2160cda78b98e2113bc (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/smsc47m1.c')
-rw-r--r-- | drivers/hwmon/smsc47m1.c | 24 |
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 | ||
142 | static int smsc47m1_probe(struct platform_device *pdev); | 142 | static int __exit smsc47m1_remove(struct platform_device *pdev); |
143 | static int __devexit smsc47m1_remove(struct platform_device *pdev); | ||
144 | static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, | 143 | static 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 | ||
167 | static ssize_t get_fan(struct device *dev, struct device_attribute | 165 | static 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 | ||
565 | static int __devinit smsc47m1_probe(struct platform_device *pdev) | 563 | static 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 | ||
723 | static int __devexit smsc47m1_remove(struct platform_device *pdev) | 721 | static 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 | ||
859 | exit_driver: | 857 | exit_device: |
860 | platform_driver_unregister(&smsc47m1_driver); | 858 | platform_device_unregister(pdev); |
861 | exit: | 859 | exit: |
862 | return err; | 860 | return err; |
863 | } | 861 | } |
864 | 862 | ||
865 | static void __exit sm_smsc47m1_exit(void) | 863 | static 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 | ||
871 | MODULE_AUTHOR("Mark D. Studebaker <mdsxyz123@yahoo.com>"); | 869 | MODULE_AUTHOR("Mark D. Studebaker <mdsxyz123@yahoo.com>"); |