Ticket #2353: hwmon-dme1737-no-vid-on-sch311x.patch

File hwmon-dme1737-no-vid-on-sch311x.patch, 2.8 KB (added by khali, 5 years ago)

Proposed fix

  • drivers/hwmon/dme1737.c

    From: Jean Delvare <khali@linux-fr.org>
    Subject: hwmon: (dme1737) No vid attributes for SCH311x
    
    The SCH311x chips do not have VID inputs, so the cpu0_vid and vrm
    attributes shouldn't be created for them.
    
    This fixes lm-sensors ticket #2353:
    http://www.lm-sensors.org/ticket/2353
    
    Signed-off-by: Jean Delvare <khali@linux-fr.org>
    Tested-by: Udo van den Heuvel <udovdh@xs4all.n>
    Cc: Juerg Haefliger <juergh@gmail.com>
    ---
     drivers/hwmon/dme1737.c |   29 ++++++++++++++++++++++++-----
     1 file changed, 24 insertions(+), 5 deletions(-)
    
    old new  
    572572 
    573573        /* Sample register contents every 1 sec */ 
    574574        if (time_after(jiffies, data->last_update + HZ) || !data->valid) { 
    575                 if (data->type != sch5027) { 
     575                if (data->type == dme1737) { 
    576576                        data->vid = dme1737_read(data, DME1737_REG_VID) & 
    577577                                0x3f; 
    578578                } 
     
    16211621        &sensor_dev_attr_zone1_auto_point1_temp_hyst.dev_attr.attr, 
    16221622        &sensor_dev_attr_zone2_auto_point1_temp_hyst.dev_attr.attr, 
    16231623        &sensor_dev_attr_zone3_auto_point1_temp_hyst.dev_attr.attr, 
    1624         /* Misc */ 
    1625         &dev_attr_vrm.attr, 
    1626         &dev_attr_cpu0_vid.attr, 
    16271624        NULL 
    16281625}; 
    16291626 
     
    16311628        .attrs = dme1737_misc_attr, 
    16321629}; 
    16331630 
     1631/* The following struct holds VID-related attributes. Their creation 
     1632   depends on the chip type which is determined during module load. */ 
     1633static struct attribute *dme1737_vid_attr[] = { 
     1634        &dev_attr_vrm.attr, 
     1635        &dev_attr_cpu0_vid.attr, 
     1636        NULL 
     1637}; 
     1638 
     1639static const struct attribute_group dme1737_vid_group = { 
     1640        .attrs = dme1737_vid_attr, 
     1641}; 
     1642 
    16341643/* The following structs hold the PWM attributes, some of which are optional. 
    16351644 * Their creation depends on the chip configuration which is determined during 
    16361645 * module load. */ 
     
    19021911        if (data->type != sch5027) { 
    19031912                sysfs_remove_group(&dev->kobj, &dme1737_misc_group); 
    19041913        } 
     1914        if (data->type == dme1737) { 
     1915                sysfs_remove_group(&dev->kobj, &dme1737_vid_group); 
     1916        } 
    19051917 
    19061918        sysfs_remove_group(&dev->kobj, &dme1737_group); 
    19071919 
     
    19331945                goto exit_remove; 
    19341946        } 
    19351947 
     1948        /* Create VID-related sysfs attributes */ 
     1949        if ((data->type == dme1737) && 
     1950            (err = sysfs_create_group(&dev->kobj, 
     1951                                      &dme1737_vid_group))) { 
     1952                goto exit_remove; 
     1953        } 
     1954 
    19361955        /* Create fan sysfs attributes */ 
    19371956        for (ix = 0; ix < ARRAY_SIZE(dme1737_fan_group); ix++) { 
    19381957                if (data->has_fan & (1 << ix)) { 
     
    21272146        data->pwm_acz[2] = 4;   /* pwm3 -> zone3 */ 
    21282147 
    21292148        /* Set VRM */ 
    2130         if (data->type != sch5027) { 
     2149        if (data->type == dme1737) { 
    21312150                data->vrm = vid_which_vrm(); 
    21322151        } 
    21332152