hwmon: Use platform_device_add_data()
authorJean Delvare <khali@linux-fr.org>
Sat, 9 Jun 2007 14:11:16 +0000 (10:11 -0400)
committerMark M. Hoffman <mhoffman@lightlink.com>
Thu, 19 Jul 2007 18:22:12 +0000 (14:22 -0400)
Use platform_device_add_data() in hardware monitoring drivers. This
makes the code nicer and smaller too. Reported by David Hubbard.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: David Hubbard <david.c.hubbard@gmail.com>
drivers/hwmon/f71805f.c
drivers/hwmon/smsc47m1.c
drivers/hwmon/w83627hf.c

index cdbe309b8fc41275a64ee5bd906504f2bb808220..e8b15047a6d348c8e6072ff4dd8806331372b6fa 100644 (file)
@@ -1290,15 +1290,12 @@ static int __init f71805f_device_add(unsigned short address,
                goto exit_device_put;
        }
 
-       pdev->dev.platform_data = kmalloc(sizeof(struct f71805f_sio_data),
-                                         GFP_KERNEL);
-       if (!pdev->dev.platform_data) {
-               err = -ENOMEM;
+       err = platform_device_add_data(pdev, sio_data,
+                                      sizeof(struct f71805f_sio_data));
+       if (err) {
                printk(KERN_ERR DRVNAME ": Platform data allocation failed\n");
                goto exit_device_put;
        }
-       memcpy(pdev->dev.platform_data, sio_data,
-              sizeof(struct f71805f_sio_data));
 
        err = platform_device_add(pdev);
        if (err) {
index 1e21c8cc948f5902571ead518aeb36d9b59a2ffa..9bac3c2d84f9fbe9ea7b544604758417b8a4aa5f 100644 (file)
@@ -693,15 +693,12 @@ static int __init smsc47m1_device_add(unsigned short address,
                goto exit_device_put;
        }
 
-       pdev->dev.platform_data = kmalloc(sizeof(struct smsc47m1_sio_data),
-                                         GFP_KERNEL);
-       if (!pdev->dev.platform_data) {
-               err = -ENOMEM;
+       err = platform_device_add_data(pdev, sio_data,
+                                      sizeof(struct smsc47m1_sio_data));
+       if (err) {
                printk(KERN_ERR DRVNAME ": Platform data allocation failed\n");
                goto exit_device_put;
        }
-       memcpy(pdev->dev.platform_data, sio_data,
-              sizeof(struct smsc47m1_sio_data));
 
        err = platform_device_add(pdev);
        if (err) {
index 12cb40a975de90cd61218fe04d146021f79e149a..72aee3c0e8de145fc861e74e9d9c6d94917eb939 100644 (file)
@@ -1548,15 +1548,12 @@ static int __init w83627hf_device_add(unsigned short address,
                goto exit_device_put;
        }
 
-       pdev->dev.platform_data = kmalloc(sizeof(struct w83627hf_sio_data),
-                                         GFP_KERNEL);
-       if (!pdev->dev.platform_data) {
-               err = -ENOMEM;
+       err = platform_device_add_data(pdev, sio_data,
+                                      sizeof(struct w83627hf_sio_data));
+       if (err) {
                printk(KERN_ERR DRVNAME ": Platform data allocation failed\n");
                goto exit_device_put;
        }
-       memcpy(pdev->dev.platform_data, sio_data,
-              sizeof(struct w83627hf_sio_data));
 
        err = platform_device_add(pdev);
        if (err) {