Changeset 20

Show
Ignore:
Timestamp:
12/02/98 01:47:37 (15 years ago)
Author:
frodo
Message:

Bug-fixes: lm78.c is now working!

Yes, our first chip driver is now fully operative. Some parts of it can
still be moved to sensors.o and reused by other drivers, but this can be
done later.

Bug fixes:
* i2c-core.c: Corrected previous patch (a client was now unloaded twice,

which caused problems, as could be expected).

* lm78.c, sensors.c: some minor typos, which caused the crashes
* lm78.c: FAN_DIV only has two fields (fan 3 is not changable)
* sensors.c: ISA/SMBus addresses are prefixed with zeros in directory names

Location:
lm-sensors/trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/TODO

    r19 r20  
    44* Make it SMP-safe: there are no spinlocks yet. They are needed at many 
    55  places, probably (everywhere where global vars are accessed). 
     6* Extend sensors.c with a file /proc/sys/dev/sensors/chips, which lists 
     7  all directories under /proc/sys/dev/sensors with their SYSCTL id 
     8  (needed for good sysctl access). 
    69* Write smbus_access_i2c in smbus.c 
    710* Write piix4_* in piix4.c 
    8 * Complete lm78 driver 
    9 * Extend dev interface for SMBus 
    10 * Create entries in /proc/bus: a list of all registered busses, and for 
    11   each bus, a file with registered clients (partially done) 
     11* Make lm78.c detect 'double hits', (same chip connected to both SMBus and 
     12  ISA). 
     13* Check whether some lm78 functionality is chip-generic and can be moved to 
     14  sensors.c. 
     15* Rename i2c-proc.c to i2c-user.c, and extend it with /dev entries; 
     16  or, create a better i2c-dev.c, that understands SMBus commands. 
    1217* Write all other drivers 
    1318* How to make drivers detect thing *not*; for example, if a Winbond is  
    1419  present, the LM75 driver should not try to access its simulated 
    15   LM75 chips! 
     20  LM75 chips (in this case, simply disable them - but what if the LM75 
     21  driver was loaded first?). 
    1622* Write a userland-library for SMBus/i2c access (through the /dev interface) 
    1723* Write a userland detection program for busses (clients are less important; 
  • lm-sensors/trunk/i2c/i2c-core.c

    r19 r20  
    1818    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */ 
    1919/* ------------------------------------------------------------------------- */ 
    20 #define RCSID "$Id: i2c-core.c,v 1.4 1998/11/27 22:02:09 frodo Exp $" 
     20#define RCSID "$Id: i2c-core.c,v 1.5 1998/12/01 21:11:32 frodo Exp $" 
    2121/* ------------------------------------------------------------------------- */ 
    2222 
     
    249249                                DEB2(printk("i2c:   detaching client %s:\n", 
    250250                                        client->name)); 
    251                                 i2c_detach_client(client); 
     251                                /* i2c_detach_client(client); */ 
    252252                                driver->detach_client(client); 
    253253                        } 
  • lm-sensors/trunk/kernel/chips/lm78.c

    r19 r20  
    9292#define LM78_INIT_IN_6 -500 
    9393 
    94 #define LM78_INIT_IN_PERCENTAGE 100 
     94#define LM78_INIT_IN_PERCENTAGE 10 
    9595 
    9696#define LM78_INIT_IN_MIN_0 \ 
     
    257257  { LM78_SYSCTL_IN6, "in6", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
    258258  { LM78_SYSCTL_FAN1, "fan1", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
    259   { LM78_SYSCTL_FAN2, "fan1", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
    260   { LM78_SYSCTL_FAN3, "fan1", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
     259  { LM78_SYSCTL_FAN2, "fan2", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
     260  { LM78_SYSCTL_FAN3, "fan3", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
    261261  { LM78_SYSCTL_TEMP, "temp", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
    262262  { LM78_SYSCTL_VID, "vid", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
    263263  { LM78_SYSCTL_FAN_DIV, "fan_div", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
    264  
    265   { LM78_SYSCTL_ALARMS, "alarms", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl } 
     264  { LM78_SYSCTL_ALARMS, "alarms", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
     265  { 0 } 
    266266}; 
    267267 
     
    338338    /* Register a new directory entry with module sensors */ 
    339339    if ((err = sensors_register_entry((struct i2c_client *) new_client,"lm78", 
    340                                       lm78_dir_table_template) < 0)) 
     340                                      lm78_dir_table_template)) < 0) 
    341341      goto ERROR4; 
    342342    ((struct lm78_data *) (new_client->data)) -> sysctl_id = err; 
     
    381381  } 
    382382  lm78_remove_client((struct i2c_client *) client); 
     383  release_region(client->isa_addr,LM78_EXTENT); 
    383384  kfree(client); 
    384   release_region(client->isa_addr,LM78_EXTENT); 
    385385  return 0; 
    386386} 
     
    423423    /* Register a new directory entry with module sensors */ 
    424424    if ((err = sensors_register_entry(new_client,"lm78", 
    425                                       lm78_dir_table_template) < 0)) 
     425                                      lm78_dir_table_template)) < 0) 
    426426      goto ERROR4; 
    427427    ((struct lm78_data *) (new_client->data))->sysctl_id = err; 
     
    593593void lm78_update_client(struct i2c_client *client) 
    594594{ 
    595   struct lm78_data *data =  client->data; 
     595  struct lm78_data *data = client->data; 
    596596  int i; 
    597597 
     
    601601      (jiffies < data->last_updated) || ! data->valid) { 
    602602 
     603#ifdef DEBUG 
     604    printk("Starting lm78 update\n"); 
     605#endif 
    603606    for (i = 0; i <= 6; i++) { 
    604607      data->in[i]     = lm78_read_value(client,LM78_REG_IN(i)); 
     
    651654      mag=2; 
    652655      break; 
    653     case LM78_SYSCTL_FAN_DIV: case LM78_SYSCTL_TEMP: 
     656    case LM78_SYSCTL_TEMP: 
    654657      nrels=3; 
    655658      mag=0; 
    656659      break; 
    657660    case LM78_SYSCTL_FAN1: case LM78_SYSCTL_FAN2: case LM78_SYSCTL_FAN3: 
     661    case LM78_SYSCTL_FAN_DIV: 
    658662      nrels=2; 
    659663      mag=0; 
     
    737741    case LM78_SYSCTL_IN0: case LM78_SYSCTL_IN1: case LM78_SYSCTL_IN2:  
    738742    case LM78_SYSCTL_IN3: case LM78_SYSCTL_IN4: case LM78_SYSCTL_IN5:  
    739     case LM78_SYSCTL_IN6: case LM78_SYSCTL_TEMP: case LM78_SYSCTL_FAN_DIV: 
     743    case LM78_SYSCTL_IN6: case LM78_SYSCTL_TEMP:  
    740744      nrels=3; 
    741745      break; 
    742746    case LM78_SYSCTL_FAN1: case LM78_SYSCTL_FAN2: case LM78_SYSCTL_FAN3: 
     747    case LM78_SYSCTL_FAN_DIV: 
    743748      nrels=2; 
    744749      break; 
     
    826831  struct lm78_data *data = client->data; 
    827832  results[0] = IN_FROM_REG(data->in_min[nr],nr); 
    828   results[1] = IN_FROM_REG(data->in_min[nr],nr); 
    829   results[2] = IN_FROM_REG(data->in_min[nr],nr); 
     833  results[1] = IN_FROM_REG(data->in_max[nr],nr); 
     834  results[2] = IN_FROM_REG(data->in[nr],nr); 
    830835} 
    831836 
  • lm-sensors/trunk/kernel/sensors.c

    r19 r20  
    6363  int id; 
    6464  if (i2c_is_isa_adapter(adapter))  
    65     sprintf(name_buffer,"%s-isa-%d",prefix,addr); 
     65    sprintf(name_buffer,"%s-isa-%04x",prefix,addr); 
    6666  else { 
    6767    if ((id = i2c_adapter_id(adapter)) < 0); 
    6868      return -ENOENT; 
    69     sprintf(name_buffer,"%s-i2c-%d-%d",prefix,id,addr); 
     69    sprintf(name_buffer,"%s-i2c-%d-%02x",prefix,id,addr); 
    7070  } 
    7171  *name = kmalloc(strlen(name_buffer)+1,GFP_KERNEL); 
     
    9595    return res; 
    9696 
    97   for (id = 0; id < SENSORS_ENTRY_MAX; i++) 
     97  for (id = 0; id < SENSORS_ENTRY_MAX; id++) 
    9898    if (! sensors_entries[id]) { 
    9999      break; 
     
    130130  } 
    131131 
    132   sensors_entries[i] = new_header; 
     132  sensors_entries[id-256] = new_header; 
    133133 
    134134  return id; 
     
    142142    table = sensors_entries[id]->ctl_table; 
    143143    unregister_sysctl_table(sensors_entries[id]); 
    144     kfree((void *) (table->procname)); 
     144    kfree((void *) (table[4].procname)); 
    145145    kfree(table); 
    146146    sensors_entries[id] = 0; 
  • lm-sensors/trunk/src/lm78.c

    r19 r20  
    9292#define LM78_INIT_IN_6 -500 
    9393 
    94 #define LM78_INIT_IN_PERCENTAGE 100 
     94#define LM78_INIT_IN_PERCENTAGE 10 
    9595 
    9696#define LM78_INIT_IN_MIN_0 \ 
     
    257257  { LM78_SYSCTL_IN6, "in6", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
    258258  { LM78_SYSCTL_FAN1, "fan1", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
    259   { LM78_SYSCTL_FAN2, "fan1", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
    260   { LM78_SYSCTL_FAN3, "fan1", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
     259  { LM78_SYSCTL_FAN2, "fan2", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
     260  { LM78_SYSCTL_FAN3, "fan3", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
    261261  { LM78_SYSCTL_TEMP, "temp", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
    262262  { LM78_SYSCTL_VID, "vid", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
    263263  { LM78_SYSCTL_FAN_DIV, "fan_div", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
    264  
    265   { LM78_SYSCTL_ALARMS, "alarms", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl } 
     264  { LM78_SYSCTL_ALARMS, "alarms", NULL, 0, 0644, NULL, &lm78_proc, &lm78_sysctl }, 
     265  { 0 } 
    266266}; 
    267267 
     
    338338    /* Register a new directory entry with module sensors */ 
    339339    if ((err = sensors_register_entry((struct i2c_client *) new_client,"lm78", 
    340                                       lm78_dir_table_template) < 0)) 
     340                                      lm78_dir_table_template)) < 0) 
    341341      goto ERROR4; 
    342342    ((struct lm78_data *) (new_client->data)) -> sysctl_id = err; 
     
    381381  } 
    382382  lm78_remove_client((struct i2c_client *) client); 
     383  release_region(client->isa_addr,LM78_EXTENT); 
    383384  kfree(client); 
    384   release_region(client->isa_addr,LM78_EXTENT); 
    385385  return 0; 
    386386} 
     
    423423    /* Register a new directory entry with module sensors */ 
    424424    if ((err = sensors_register_entry(new_client,"lm78", 
    425                                       lm78_dir_table_template) < 0)) 
     425                                      lm78_dir_table_template)) < 0) 
    426426      goto ERROR4; 
    427427    ((struct lm78_data *) (new_client->data))->sysctl_id = err; 
     
    593593void lm78_update_client(struct i2c_client *client) 
    594594{ 
    595   struct lm78_data *data =  client->data; 
     595  struct lm78_data *data = client->data; 
    596596  int i; 
    597597 
     
    601601      (jiffies < data->last_updated) || ! data->valid) { 
    602602 
     603#ifdef DEBUG 
     604    printk("Starting lm78 update\n"); 
     605#endif 
    603606    for (i = 0; i <= 6; i++) { 
    604607      data->in[i]     = lm78_read_value(client,LM78_REG_IN(i)); 
     
    651654      mag=2; 
    652655      break; 
    653     case LM78_SYSCTL_FAN_DIV: case LM78_SYSCTL_TEMP: 
     656    case LM78_SYSCTL_TEMP: 
    654657      nrels=3; 
    655658      mag=0; 
    656659      break; 
    657660    case LM78_SYSCTL_FAN1: case LM78_SYSCTL_FAN2: case LM78_SYSCTL_FAN3: 
     661    case LM78_SYSCTL_FAN_DIV: 
    658662      nrels=2; 
    659663      mag=0; 
     
    737741    case LM78_SYSCTL_IN0: case LM78_SYSCTL_IN1: case LM78_SYSCTL_IN2:  
    738742    case LM78_SYSCTL_IN3: case LM78_SYSCTL_IN4: case LM78_SYSCTL_IN5:  
    739     case LM78_SYSCTL_IN6: case LM78_SYSCTL_TEMP: case LM78_SYSCTL_FAN_DIV: 
     743    case LM78_SYSCTL_IN6: case LM78_SYSCTL_TEMP:  
    740744      nrels=3; 
    741745      break; 
    742746    case LM78_SYSCTL_FAN1: case LM78_SYSCTL_FAN2: case LM78_SYSCTL_FAN3: 
     747    case LM78_SYSCTL_FAN_DIV: 
    743748      nrels=2; 
    744749      break; 
     
    826831  struct lm78_data *data = client->data; 
    827832  results[0] = IN_FROM_REG(data->in_min[nr],nr); 
    828   results[1] = IN_FROM_REG(data->in_min[nr],nr); 
    829   results[2] = IN_FROM_REG(data->in_min[nr],nr); 
     833  results[1] = IN_FROM_REG(data->in_max[nr],nr); 
     834  results[2] = IN_FROM_REG(data->in[nr],nr); 
    830835} 
    831836 
  • lm-sensors/trunk/src/sensors.c

    r19 r20  
    6363  int id; 
    6464  if (i2c_is_isa_adapter(adapter))  
    65     sprintf(name_buffer,"%s-isa-%d",prefix,addr); 
     65    sprintf(name_buffer,"%s-isa-%04x",prefix,addr); 
    6666  else { 
    6767    if ((id = i2c_adapter_id(adapter)) < 0); 
    6868      return -ENOENT; 
    69     sprintf(name_buffer,"%s-i2c-%d-%d",prefix,id,addr); 
     69    sprintf(name_buffer,"%s-i2c-%d-%02x",prefix,id,addr); 
    7070  } 
    7171  *name = kmalloc(strlen(name_buffer)+1,GFP_KERNEL); 
     
    9595    return res; 
    9696 
    97   for (id = 0; id < SENSORS_ENTRY_MAX; i++) 
     97  for (id = 0; id < SENSORS_ENTRY_MAX; id++) 
    9898    if (! sensors_entries[id]) { 
    9999      break; 
     
    130130  } 
    131131 
    132   sensors_entries[i] = new_header; 
     132  sensors_entries[id-256] = new_header; 
    133133 
    134134  return id; 
     
    142142    table = sensors_entries[id]->ctl_table; 
    143143    unregister_sysctl_table(sensors_entries[id]); 
    144     kfree((void *) (table->procname)); 
     144    kfree((void *) (table[4].procname)); 
    145145    kfree(table); 
    146146    sensors_entries[id] = 0;