aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJuerg Haefliger <juergh@gmail.com>2011-01-12 15:55:13 -0500
committerJean Delvare <khali@endymion.delvare>2011-01-12 15:55:13 -0500
commit06f3d9fb4a7d3528121446e94ee37b95bba4d106 (patch)
tree8b2b2088b7169463f3bb66ddcf63a58b3c288664 /drivers
parentd4b94e1fa6c69fd74abca5b7db1ab350d65ce89b (diff)
hwmon: (dme1737) Minor cleanups
Minor cleanups. Mostly removing assignments in if statements to get rid of checkpatch errors. Signed-off-by: Juerg Haefliger <juergh@gmail.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hwmon/dme1737.c121
1 files changed, 73 insertions, 48 deletions
diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c
index ec683eabd7ac..d9c592713919 100644
--- a/drivers/hwmon/dme1737.c
+++ b/drivers/hwmon/dme1737.c
@@ -1590,7 +1590,7 @@ static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); /* for ISA devices */
1590 * created unconditionally. The attributes that need modification of their 1590 * created unconditionally. The attributes that need modification of their
1591 * permissions are created read-only and write permissions are added or removed 1591 * permissions are created read-only and write permissions are added or removed
1592 * on the fly when required */ 1592 * on the fly when required */
1593static struct attribute *dme1737_attr[] ={ 1593static struct attribute *dme1737_attr[] = {
1594 /* Voltages */ 1594 /* Voltages */
1595 &sensor_dev_attr_in0_input.dev_attr.attr, 1595 &sensor_dev_attr_in0_input.dev_attr.attr,
1596 &sensor_dev_attr_in0_min.dev_attr.attr, 1596 &sensor_dev_attr_in0_min.dev_attr.attr,
@@ -1695,7 +1695,7 @@ static const struct attribute_group dme1737_zone3_group = {
1695}; 1695};
1696 1696
1697 1697
1698/* The following struct holds temp zone hysteresis related attributes, which 1698/* The following struct holds temp zone hysteresis related attributes, which
1699 * are not available in all chips. The following chips support them: 1699 * are not available in all chips. The following chips support them:
1700 * DME1737, SCH311x */ 1700 * DME1737, SCH311x */
1701static struct attribute *dme1737_zone_hyst_attr[] = { 1701static struct attribute *dme1737_zone_hyst_attr[] = {
@@ -2031,36 +2031,44 @@ static int dme1737_create_files(struct device *dev)
2031 int err, ix; 2031 int err, ix;
2032 2032
2033 /* Create a name attribute for ISA devices */ 2033 /* Create a name attribute for ISA devices */
2034 if (!data->client && 2034 if (!data->client) {
2035 (err = sysfs_create_file(&dev->kobj, &dev_attr_name.attr))) { 2035 err = sysfs_create_file(&dev->kobj, &dev_attr_name.attr);
2036 goto exit; 2036 if (err) {
2037 goto exit;
2038 }
2037 } 2039 }
2038 2040
2039 /* Create standard sysfs attributes */ 2041 /* Create standard sysfs attributes */
2040 if ((err = sysfs_create_group(&dev->kobj, &dme1737_group))) { 2042 err = sysfs_create_group(&dev->kobj, &dme1737_group);
2043 if (err) {
2041 goto exit_remove; 2044 goto exit_remove;
2042 } 2045 }
2043 2046
2044 /* Create chip-dependent sysfs attributes */ 2047 /* Create chip-dependent sysfs attributes */
2045 if ((data->has_features & HAS_TEMP_OFFSET) && 2048 if (data->has_features & HAS_TEMP_OFFSET) {
2046 (err = sysfs_create_group(&dev->kobj, 2049 err = sysfs_create_group(&dev->kobj,
2047 &dme1737_temp_offset_group))) { 2050 &dme1737_temp_offset_group);
2048 goto exit_remove; 2051 if (err) {
2052 goto exit_remove;
2053 }
2049 } 2054 }
2050 if ((data->has_features & HAS_VID) && 2055 if (data->has_features & HAS_VID) {
2051 (err = sysfs_create_group(&dev->kobj, 2056 err = sysfs_create_group(&dev->kobj, &dme1737_vid_group);
2052 &dme1737_vid_group))) { 2057 if (err) {
2053 goto exit_remove; 2058 goto exit_remove;
2059 }
2054 } 2060 }
2055 if ((data->has_features & HAS_ZONE3) && 2061 if (data->has_features & HAS_ZONE3) {
2056 (err = sysfs_create_group(&dev->kobj, 2062 err = sysfs_create_group(&dev->kobj, &dme1737_zone3_group);
2057 &dme1737_zone3_group))) { 2063 if (err) {
2058 goto exit_remove; 2064 goto exit_remove;
2065 }
2059 } 2066 }
2060 if ((data->has_features & HAS_ZONE_HYST) && 2067 if (data->has_features & HAS_ZONE_HYST) {
2061 (err = sysfs_create_group(&dev->kobj, 2068 err = sysfs_create_group(&dev->kobj, &dme1737_zone_hyst_group);
2062 &dme1737_zone_hyst_group))) { 2069 if (err) {
2063 goto exit_remove; 2070 goto exit_remove;
2071 }
2064 } 2072 }
2065 if (data->has_features & HAS_IN7) { 2073 if (data->has_features & HAS_IN7) {
2066 err = sysfs_create_group(&dev->kobj, &dme1737_in7_group); 2074 err = sysfs_create_group(&dev->kobj, &dme1737_in7_group);
@@ -2072,8 +2080,9 @@ static int dme1737_create_files(struct device *dev)
2072 /* Create fan sysfs attributes */ 2080 /* Create fan sysfs attributes */
2073 for (ix = 0; ix < ARRAY_SIZE(dme1737_fan_group); ix++) { 2081 for (ix = 0; ix < ARRAY_SIZE(dme1737_fan_group); ix++) {
2074 if (data->has_features & HAS_FAN(ix)) { 2082 if (data->has_features & HAS_FAN(ix)) {
2075 if ((err = sysfs_create_group(&dev->kobj, 2083 err = sysfs_create_group(&dev->kobj,
2076 &dme1737_fan_group[ix]))) { 2084 &dme1737_fan_group[ix]);
2085 if (err) {
2077 goto exit_remove; 2086 goto exit_remove;
2078 } 2087 }
2079 } 2088 }
@@ -2082,14 +2091,17 @@ static int dme1737_create_files(struct device *dev)
2082 /* Create PWM sysfs attributes */ 2091 /* Create PWM sysfs attributes */
2083 for (ix = 0; ix < ARRAY_SIZE(dme1737_pwm_group); ix++) { 2092 for (ix = 0; ix < ARRAY_SIZE(dme1737_pwm_group); ix++) {
2084 if (data->has_features & HAS_PWM(ix)) { 2093 if (data->has_features & HAS_PWM(ix)) {
2085 if ((err = sysfs_create_group(&dev->kobj, 2094 err = sysfs_create_group(&dev->kobj,
2086 &dme1737_pwm_group[ix]))) { 2095 &dme1737_pwm_group[ix]);
2096 if (err) {
2087 goto exit_remove; 2097 goto exit_remove;
2088 } 2098 }
2089 if ((data->has_features & HAS_PWM_MIN) && ix < 3 && 2099 if ((data->has_features & HAS_PWM_MIN) && (ix < 3)) {
2090 (err = sysfs_create_file(&dev->kobj, 2100 err = sysfs_create_file(&dev->kobj,
2091 dme1737_auto_pwm_min_attr[ix]))) { 2101 dme1737_auto_pwm_min_attr[ix]);
2092 goto exit_remove; 2102 if (err) {
2103 goto exit_remove;
2104 }
2093 } 2105 }
2094 } 2106 }
2095 } 2107 }
@@ -2319,8 +2331,9 @@ static int dme1737_i2c_get_features(int sio_cip, struct dme1737_data *data)
2319 dme1737_sio_outb(sio_cip, 0x07, 0x0a); 2331 dme1737_sio_outb(sio_cip, 0x07, 0x0a);
2320 2332
2321 /* Get the base address of the runtime registers */ 2333 /* Get the base address of the runtime registers */
2322 if (!(addr = (dme1737_sio_inb(sio_cip, 0x60) << 8) | 2334 addr = (dme1737_sio_inb(sio_cip, 0x60) << 8) |
2323 dme1737_sio_inb(sio_cip, 0x61))) { 2335 dme1737_sio_inb(sio_cip, 0x61);
2336 if (!addr) {
2324 err = -ENODEV; 2337 err = -ENODEV;
2325 goto exit; 2338 goto exit;
2326 } 2339 }
@@ -2401,13 +2414,15 @@ static int dme1737_i2c_probe(struct i2c_client *client,
2401 mutex_init(&data->update_lock); 2414 mutex_init(&data->update_lock);
2402 2415
2403 /* Initialize the DME1737 chip */ 2416 /* Initialize the DME1737 chip */
2404 if ((err = dme1737_init_device(dev))) { 2417 err = dme1737_init_device(dev);
2418 if (err) {
2405 dev_err(dev, "Failed to initialize device.\n"); 2419 dev_err(dev, "Failed to initialize device.\n");
2406 goto exit_kfree; 2420 goto exit_kfree;
2407 } 2421 }
2408 2422
2409 /* Create sysfs files */ 2423 /* Create sysfs files */
2410 if ((err = dme1737_create_files(dev))) { 2424 err = dme1737_create_files(dev);
2425 if (err) {
2411 dev_err(dev, "Failed to create sysfs files.\n"); 2426 dev_err(dev, "Failed to create sysfs files.\n");
2412 goto exit_kfree; 2427 goto exit_kfree;
2413 } 2428 }
@@ -2484,8 +2499,9 @@ static int __init dme1737_isa_detect(int sio_cip, unsigned short *addr)
2484 dme1737_sio_outb(sio_cip, 0x07, 0x0a); 2499 dme1737_sio_outb(sio_cip, 0x07, 0x0a);
2485 2500
2486 /* Get the base address of the runtime registers */ 2501 /* Get the base address of the runtime registers */
2487 if (!(base_addr = (dme1737_sio_inb(sio_cip, 0x60) << 8) | 2502 base_addr = (dme1737_sio_inb(sio_cip, 0x60) << 8) |
2488 dme1737_sio_inb(sio_cip, 0x61))) { 2503 dme1737_sio_inb(sio_cip, 0x61);
2504 if (!base_addr) {
2489 pr_err("Base address not set\n"); 2505 pr_err("Base address not set\n");
2490 err = -ENODEV; 2506 err = -ENODEV;
2491 goto exit; 2507 goto exit;
@@ -2514,18 +2530,21 @@ static int __init dme1737_isa_device_add(unsigned short addr)
2514 if (err) 2530 if (err)
2515 goto exit; 2531 goto exit;
2516 2532
2517 if (!(pdev = platform_device_alloc("dme1737", addr))) { 2533 pdev = platform_device_alloc("dme1737", addr);
2534 if (!pdev) {
2518 pr_err("Failed to allocate device\n"); 2535 pr_err("Failed to allocate device\n");
2519 err = -ENOMEM; 2536 err = -ENOMEM;
2520 goto exit; 2537 goto exit;
2521 } 2538 }
2522 2539
2523 if ((err = platform_device_add_resources(pdev, &res, 1))) { 2540 err = platform_device_add_resources(pdev, &res, 1);
2541 if (err) {
2524 pr_err("Failed to add device resource (err = %d)\n", err); 2542 pr_err("Failed to add device resource (err = %d)\n", err);
2525 goto exit_device_put; 2543 goto exit_device_put;
2526 } 2544 }
2527 2545
2528 if ((err = platform_device_add(pdev))) { 2546 err = platform_device_add(pdev);
2547 if (err) {
2529 pr_err("Failed to add device (err = %d)\n", err); 2548 pr_err("Failed to add device (err = %d)\n", err);
2530 goto exit_device_put; 2549 goto exit_device_put;
2531 } 2550 }
@@ -2552,11 +2571,12 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev)
2552 dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n", 2571 dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n",
2553 (unsigned short)res->start, 2572 (unsigned short)res->start,
2554 (unsigned short)res->start + DME1737_EXTENT - 1); 2573 (unsigned short)res->start + DME1737_EXTENT - 1);
2555 err = -EBUSY; 2574 err = -EBUSY;
2556 goto exit; 2575 goto exit;
2557 } 2576 }
2558 2577
2559 if (!(data = kzalloc(sizeof(struct dme1737_data), GFP_KERNEL))) { 2578 data = kzalloc(sizeof(struct dme1737_data), GFP_KERNEL);
2579 if (!data) {
2560 err = -ENOMEM; 2580 err = -ENOMEM;
2561 goto exit_release_region; 2581 goto exit_release_region;
2562 } 2582 }
@@ -2603,13 +2623,15 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev)
2603 data->type == sch5127 ? "SCH5127" : "SCH311x", data->addr); 2623 data->type == sch5127 ? "SCH5127" : "SCH311x", data->addr);
2604 2624
2605 /* Initialize the chip */ 2625 /* Initialize the chip */
2606 if ((err = dme1737_init_device(dev))) { 2626 err = dme1737_init_device(dev);
2627 if (err) {
2607 dev_err(dev, "Failed to initialize device.\n"); 2628 dev_err(dev, "Failed to initialize device.\n");
2608 goto exit_kfree; 2629 goto exit_kfree;
2609 } 2630 }
2610 2631
2611 /* Create sysfs files */ 2632 /* Create sysfs files */
2612 if ((err = dme1737_create_files(dev))) { 2633 err = dme1737_create_files(dev);
2634 if (err) {
2613 dev_err(dev, "Failed to create sysfs files.\n"); 2635 dev_err(dev, "Failed to create sysfs files.\n");
2614 goto exit_kfree; 2636 goto exit_kfree;
2615 } 2637 }
@@ -2666,7 +2688,8 @@ static int __init dme1737_init(void)
2666 int err; 2688 int err;
2667 unsigned short addr; 2689 unsigned short addr;
2668 2690
2669 if ((err = i2c_add_driver(&dme1737_i2c_driver))) { 2691 err = i2c_add_driver(&dme1737_i2c_driver);
2692 if (err) {
2670 goto exit; 2693 goto exit;
2671 } 2694 }
2672 2695
@@ -2679,12 +2702,14 @@ static int __init dme1737_init(void)
2679 return 0; 2702 return 0;
2680 } 2703 }
2681 2704
2682 if ((err = platform_driver_register(&dme1737_isa_driver))) { 2705 err = platform_driver_register(&dme1737_isa_driver);
2706 if (err) {
2683 goto exit_del_i2c_driver; 2707 goto exit_del_i2c_driver;
2684 } 2708 }
2685 2709
2686 /* Sets global pdev as a side effect */ 2710 /* Sets global pdev as a side effect */
2687 if ((err = dme1737_isa_device_add(addr))) { 2711 err = dme1737_isa_device_add(addr);
2712 if (err) {
2688 goto exit_del_isa_driver; 2713 goto exit_del_isa_driver;
2689 } 2714 }
2690 2715