Changeset 2445

Show
Ignore:
Timestamp:
04/17/04 19:20:01 (9 years ago)
Author:
khali
Message:

Backport memory allocation reworking from Linux 2.6.

Location:
lm-sensors/trunk/kernel/chips
Files:
45 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/kernel/chips/adm1021.c

    r2395 r2445  
    8787/* Each client has this additional data */ 
    8888struct adm1021_data { 
     89        struct i2c_client client; 
    8990        int sysctl_id; 
    9091        enum chips type; 
     
    212213           But it allows us to access adm1021_{read,write}_value. */ 
    213214 
    214         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    215                                    sizeof(struct adm1021_data), 
    216                                    GFP_KERNEL))) { 
     215        if (!(data = kmalloc(sizeof(struct adm1021_data), GFP_KERNEL))) { 
    217216                err = -ENOMEM; 
    218217                goto error0; 
    219218        } 
    220219 
    221         data = (struct adm1021_data *) (new_client + 1); 
     220        new_client = &data->client; 
    222221        new_client->addr = address; 
    223222        new_client->data = data; 
     
    322321      error3: 
    323322      error1: 
    324         kfree(new_client); 
     323        kfree(data); 
    325324      error0: 
    326325        return err; 
     
    338337static int adm1021_detach_client(struct i2c_client *client) 
    339338{ 
    340  
    341339        int err; 
    342340 
     
    350348        } 
    351349 
    352         kfree(client); 
     350        kfree(client->data); 
    353351 
    354352        return 0; 
    355  
    356353} 
    357354 
  • lm-sensors/trunk/kernel/chips/adm1024.c

    r2386 r2445  
    149149   allocated. */ 
    150150struct adm1024_data { 
     151        struct i2c_client client; 
    151152        int sysctl_id; 
    152153        enum chips type; 
     
    326327           But it allows us to access adm1024_{read,write}_value. */ 
    327328 
    328         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    329                                    sizeof(struct adm1024_data), 
    330                                    GFP_KERNEL))) { 
     329        if (!(data = kmalloc(sizeof(struct adm1024_data), GFP_KERNEL))) { 
    331330                err = -ENOMEM; 
    332331                goto ERROR0; 
    333332        } 
    334333 
    335         data = (struct adm1024_data *) (new_client + 1); 
     334        new_client = &data->client; 
    336335        new_client->addr = address; 
    337336        new_client->data = data; 
     
    405404      ERROR3: 
    406405      ERROR1: 
    407         kfree(new_client); 
     406        kfree(data); 
    408407      ERROR0: 
    409408        return err; 
     
    423422        } 
    424423 
    425         kfree(client); 
     424        kfree(client->data); 
    426425 
    427426        return 0; 
    428  
    429427} 
    430428 
  • lm-sensors/trunk/kernel/chips/adm1025.c

    r2386 r2445  
    118118   allocated. */ 
    119119struct adm1025_data { 
     120        struct i2c_client client; 
    120121        int sysctl_id; 
    121122        enum chips type; 
     
    260261           But it allows us to access adm1025_{read,write}_value. */ 
    261262 
    262         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    263                                    sizeof(struct adm1025_data), 
    264                                    GFP_KERNEL))) { 
     263        if (!(data = kmalloc(sizeof(struct adm1025_data), GFP_KERNEL))) { 
    265264                err = -ENOMEM; 
    266265                goto ERROR0; 
    267266        } 
    268267 
    269         data = (struct adm1025_data *) (new_client + 1); 
     268        new_client = &data->client; 
    270269        new_client->addr = address; 
    271270        new_client->data = data; 
     
    351350      ERROR3: 
    352351      ERROR1: 
    353         kfree(new_client); 
     352        kfree(data); 
    354353      ERROR0: 
    355354        return err; 
     
    369368        } 
    370369 
    371         kfree(client); 
     370        kfree(client->data); 
    372371 
    373372        return 0; 
    374  
    375373} 
    376374 
  • lm-sensors/trunk/kernel/chips/adm1026.c

    r2349 r2445  
    299299 
    300300struct adm1026_data { 
     301        struct i2c_client client; 
    301302        struct semaphore lock; 
    302303        int sysctl_id; 
     
    638639           But it allows us to access adm1026_{read,write}_value. */ 
    639640 
    640         if (!(new_client = kmalloc((sizeof(struct i2c_client)) + 
    641                                    sizeof(struct adm1026_data), 
    642                                    GFP_KERNEL))) { 
     641        if (!(data = kmalloc(sizeof(struct adm1026_data), GFP_KERNEL))) { 
    643642                err = -ENOMEM; 
    644643                goto ERROR0; 
    645644        } 
    646645 
    647         data = (struct adm1026_data *) (new_client + 1); 
     646        new_client = &data->client; 
    648647        new_client->addr = address; 
    649648        new_client->data = data; 
     
    768767        i2c_detach_client(new_client); 
    769768    ERROR1: 
    770         kfree(new_client); 
     769        kfree(data); 
    771770    ERROR0: 
    772771        return err; 
     
    787786        } 
    788787 
    789         kfree(client); 
     788        kfree(client->data); 
    790789 
    791790        return 0; 
  • lm-sensors/trunk/kernel/chips/adm9240.c

    r2386 r2445  
    165165   allocated. */ 
    166166struct adm9240_data { 
     167        struct i2c_client client; 
    167168        int sysctl_id; 
    168169        enum chips type; 
     
    324325           But it allows us to access adm9240_{read,write}_value. */ 
    325326 
    326         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    327                                    sizeof(struct adm9240_data), 
    328                                    GFP_KERNEL))) { 
     327        if (!(data = kmalloc(sizeof(struct adm9240_data), GFP_KERNEL))) { 
    329328                err = -ENOMEM; 
    330329                goto ERROR0; 
    331330        } 
    332331 
    333         data = (struct adm9240_data *) (new_client + 1); 
     332 
     333        new_client = &data->client; 
    334334        new_client->addr = address; 
    335335        new_client->data = data; 
     
    418418      ERROR3: 
    419419      ERROR1: 
    420         kfree(new_client); 
     420        kfree(data); 
    421421      ERROR0: 
    422422        return err; 
     
    436436        } 
    437437 
    438         kfree(client); 
     438        kfree(client->data); 
    439439 
    440440        return 0; 
    441  
    442441} 
    443442 
  • lm-sensors/trunk/kernel/chips/bt869.c

    r1705 r2445  
    6161/* Each client has this additional data */ 
    6262struct bt869_data { 
     63        struct i2c_client client; 
    6364        int sysctl_id; 
    6465 
     
    504505           client structure, even though we cannot fill it completely yet. 
    505506           But it allows us to access bt869_{read,write}_value. */ 
    506         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    507                                    sizeof(struct bt869_data), 
    508                                    GFP_KERNEL))) { 
     507        if (!(data = kmalloc(sizeof(struct bt869_data), GFP_KERNEL))) { 
    509508                err = -ENOMEM; 
    510509                goto ERROR0; 
    511510        } 
    512511 
    513         data = 
    514             (struct bt869_data *) (((struct i2c_client *) new_client) + 1); 
     512        new_client = &data->client; 
    515513        new_client->addr = address; 
    516514        new_client->data = data; 
     
    568566      ERROR3: 
    569567      ERROR1: 
    570         kfree(new_client); 
     568        kfree(data); 
    571569      ERROR0: 
    572570        return err; 
     
    586584        } 
    587585 
    588         kfree(client); 
     586        kfree(client->data); 
    589587 
    590588        return 0; 
  • lm-sensors/trunk/kernel/chips/ddcmon.c

    r2410 r2445  
    7575/* Each client has this additional data */ 
    7676struct ddcmon_data { 
     77        struct i2c_client client; 
    7778        int sysctl_id; 
    7879 
     
    216217           client structure, even though we cannot fill it completely yet. 
    217218           But it allows us to access ddcmon_{read,write}_value. */ 
    218         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    219                                    sizeof(struct ddcmon_data), 
    220                                    GFP_KERNEL))) { 
     219        if (!(data = kmalloc(sizeof(struct ddcmon_data), GFP_KERNEL))) { 
    221220                err = -ENOMEM; 
    222221                goto ERROR0; 
    223222        } 
    224223 
    225         data = (struct ddcmon_data *) (new_client + 1); 
     224        new_client = &data->client; 
    226225        memset(data->data, 0xff, DDCMON_SIZE); 
    227226        new_client->addr = address; 
     
    284283      ERROR3: 
    285284      ERROR1: 
    286         kfree(new_client); 
     285        kfree(data); 
    287286      ERROR0: 
    288287        return err; 
     
    300299                return err; 
    301300        } 
    302         kfree(client); 
     301        kfree(client->data); 
    303302        return 0; 
    304303} 
  • lm-sensors/trunk/kernel/chips/ds1621.c

    r2437 r2445  
    8181/* Each client has this additional data */ 
    8282struct ds1621_data { 
     83        struct i2c_client client; 
    8384        int sysctl_id; 
    8485 
     
    190191           client structure, even though we cannot fill it completely yet. 
    191192           But it allows us to access ds1621_{read,write}_value. */ 
    192         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    193                                    sizeof(struct ds1621_data), 
    194                                    GFP_KERNEL))) { 
     193        if (!(data = kmalloc(sizeof(struct ds1621_data), GFP_KERNEL))) { 
    195194                err = -ENOMEM; 
    196195                goto ERROR0; 
    197196        } 
    198197 
    199         data = (struct ds1621_data *) (new_client + 1); 
     198        new_client = &data->client; 
    200199        new_client->addr = address; 
    201200        new_client->data = data; 
     
    257256      ERROR3: 
    258257      ERROR1: 
    259         kfree(new_client); 
     258        kfree(data); 
    260259      ERROR0: 
    261260        return err; 
     
    275274        } 
    276275 
    277         kfree(client); 
     276        kfree(client->data); 
    278277 
    279278        return 0; 
  • lm-sensors/trunk/kernel/chips/eeprom.c

    r2401 r2445  
    6464/* Each client has this additional data */ 
    6565struct eeprom_data { 
     66        struct i2c_client client; 
    6667        int sysctl_id; 
    6768 
     
    195196           client structure, even though we cannot fill it completely yet. 
    196197           But it allows us to access eeprom_{read,write}_value. */ 
    197         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    198                                    sizeof(struct eeprom_data), 
    199                                    GFP_KERNEL))) { 
     198        if (!(data = kmalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { 
    200199                err = -ENOMEM; 
    201200                goto ERROR0; 
    202201        } 
    203202 
    204         data = (struct eeprom_data *) (new_client + 1); 
     203        new_client = &data->client; 
    205204        memset(data->data, 0xff, EEPROM_SIZE); 
    206205        new_client->addr = address; 
     
    279278      ERROR3: 
    280279      ERROR1: 
    281         kfree(new_client); 
     280        kfree(data); 
    282281      ERROR0: 
    283282        return err; 
     
    297296        } 
    298297 
    299         kfree(client); 
     298        kfree(client->data); 
    300299 
    301300        return 0; 
  • lm-sensors/trunk/kernel/chips/fscher.c

    r2298 r2445  
    109109   allocated. */ 
    110110struct fscher_data { 
     111  struct i2c_client client; 
    111112  int sysctl_id; 
    112113 
     
    267268     client structure, even though we cannot fill it completely yet. 
    268269     But it allows us to access fscher_{read,write}_value. */ 
    269   if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    270                              sizeof(struct fscher_data), 
    271                              GFP_KERNEL))) { 
     270  if (!(data = kmalloc(sizeof(struct fscher_data), GFP_KERNEL))) { 
    272271    err = -ENOMEM; 
    273272    goto ERROR0; 
    274273  } 
    275274 
    276   data = (struct fscher_data *) (new_client + 1); 
     275  new_client = &data->client; 
    277276  new_client->addr = address; 
    278277  new_client->data = data; 
     
    325324 ERROR3: 
    326325 ERROR1: 
    327   kfree(new_client); 
     326  kfree(data); 
    328327 ERROR0: 
    329328  return err; 
     
    341340  } 
    342341 
    343   kfree(client); 
     342  kfree(client->data); 
    344343 
    345344  return 0; 
  • lm-sensors/trunk/kernel/chips/fscpos.c

    r2286 r2445  
    113113   allocated. */ 
    114114struct fscpos_data { 
     115        struct i2c_client client; 
    115116        int sysctl_id; 
    116117 
     
    251252           client structure, even though we cannot fill it completely yet. 
    252253           But it allows us to access fscpos_{read,write}_value. */ 
    253         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    254                                    sizeof(struct fscpos_data), 
    255                                    GFP_KERNEL))) { 
     254        if (!(data = kmalloc(sizeof(struct fscpos_data), GFP_KERNEL))) { 
    256255                err = -ENOMEM; 
    257256                goto ERROR0; 
    258257        } 
    259258 
    260         data = (struct fscpos_data *) (new_client + 1); 
     259        new_client = &data->client; 
    261260        new_client->addr = address; 
    262261        new_client->data = data; 
     
    308307      ERROR3: 
    309308      ERROR1: 
    310         kfree(new_client); 
     309        kfree(data); 
    311310      ERROR0: 
    312311        return err; 
     
    326325        } 
    327326 
    328         kfree(client); 
     327        kfree(client->data); 
    329328 
    330329        return 0; 
  • lm-sensors/trunk/kernel/chips/fscscy.c

    r2286 r2445  
    157157   allocated. */ 
    158158struct fscscy_data { 
     159        struct i2c_client client; 
    159160        int sysctl_id; 
    160161 
     
    330331           client structure, even though we cannot fill it completely yet. 
    331332           But it allows us to access fscscy_{read,write}_value. */ 
    332         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    333                                    sizeof(struct fscscy_data), 
    334                                    GFP_KERNEL))) { 
     333        if (!(data = kmalloc(sizeof(struct fscscy_data), GFP_KERNEL))) { 
    335334                err = -ENOMEM; 
    336335                goto ERROR0; 
    337336        } 
    338337 
    339         data = (struct fscscy_data *) (new_client + 1); 
     338        new_client = &data->client; 
    340339        new_client->addr = address; 
    341340        new_client->data = data; 
     
    387386      ERROR3: 
    388387      ERROR1: 
    389         kfree(new_client); 
     388        kfree(data); 
    390389      ERROR0: 
    391390        return err; 
     
    405404        } 
    406405 
    407         kfree(client); 
     406        kfree(client->data); 
    408407 
    409408        return 0; 
  • lm-sensors/trunk/kernel/chips/gl518sm.c

    r2437 r2445  
    112112/* Each client has this additional data */ 
    113113struct gl518_data { 
     114        struct i2c_client client; 
    114115        int sysctl_id; 
    115116        enum chips type; 
     
    279280           But it allows us to access gl518_{read,write}_value. */ 
    280281 
    281         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    282                                    sizeof(struct gl518_data), 
    283                                    GFP_KERNEL))) { 
     282        if (!(data = kmalloc(sizeof(struct gl518_data), GFP_KERNEL))) { 
    284283                err = -ENOMEM; 
    285284                goto ERROR0; 
    286285        } 
    287286 
    288         data = (struct gl518_data *) (new_client + 1); 
     287        new_client = &data->client; 
    289288        new_client->addr = address; 
    290289        new_client->data = data; 
     
    389388      ERROR2: 
    390389      ERROR1: 
    391         kfree(new_client); 
     390        kfree(data); 
    392391      ERROR0: 
    393392        return err; 
     
    441440        } 
    442441 
    443         kfree(client); 
     442        kfree(client->data); 
    444443 
    445444        return 0; 
  • lm-sensors/trunk/kernel/chips/gl520sm.c

    r2437 r2445  
    117117/* Each client has this additional data */ 
    118118struct gl520_data { 
     119        struct i2c_client client; 
    119120        int sysctl_id; 
    120121        enum chips type; 
     
    283284           But it allows us to access gl520_{read,write}_value. */ 
    284285 
    285         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    286                                    sizeof(struct gl520_data), 
    287                                    GFP_KERNEL))) { 
     286        if (!(data = kmalloc(sizeof(struct gl520_data), GFP_KERNEL))) { 
    288287                err = -ENOMEM; 
    289288                goto ERROR0; 
    290289        } 
    291290 
    292         data = (struct gl520_data *) (new_client + 1); 
     291        new_client = &data->client; 
    293292        new_client->addr = address; 
    294293        new_client->data = data; 
     
    355354      ERROR3: 
    356355      ERROR1: 
    357         kfree(new_client); 
     356        kfree(data); 
    358357      ERROR0: 
    359358        return err; 
     
    392391        } 
    393392 
    394         kfree(client); 
     393        kfree(client->data); 
    395394 
    396395        return 0; 
  • lm-sensors/trunk/kernel/chips/icspll.c

    r1705 r2445  
    5454/* Each client has this additional data */ 
    5555struct icspll_data { 
     56        struct i2c_client client; 
    5657        int sysctl_id; 
    5758        struct semaphore update_lock; 
     
    134135 
    135136        /* Allocate space for a new client structure */ 
    136         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    137                                    sizeof(struct icspll_data), 
    138                                    GFP_KERNEL))) { 
     137        if (!(data = kmalloc(sizeof(struct icspll_data), GFP_KERNEL))) { 
    139138                err = -ENOMEM; 
    140139                goto ERROR0; 
     
    142141 
    143142        /* Fill the new client structure with data */ 
    144         data = (struct icspll_data *) (new_client + 1); 
     143        new_data = &data->client; 
    145144        new_client->data = data; 
    146145        new_client->id = icspll_id++; 
     
    179178      ERROR2: 
    180179      ERROR1: 
    181         kfree(new_client); 
     180        kfree(data); 
    182181      ERROR0: 
    183182        return err; 
     
    197196        } 
    198197 
    199         kfree(client); 
     198        kfree(client->data); 
    200199        return 0; 
    201200} 
  • lm-sensors/trunk/kernel/chips/it87.c

    r2431 r2445  
    224224   allocated. */ 
    225225struct it87_data { 
     226        struct i2c_client client; 
    226227        struct semaphore lock; 
    227228        int sysctl_id; 
     
    499500           But it allows us to access it87_{read,write}_value. */ 
    500501 
    501         if (!(new_client = kmalloc((sizeof(struct i2c_client)) + 
    502                                    sizeof(struct it87_data), 
    503                                    GFP_KERNEL))) { 
     502        if (!(data = kmalloc(sizeof(struct it87_data), GFP_KERNEL))) { 
    504503                err = -ENOMEM; 
    505504                goto ERROR0; 
    506505        } 
    507506 
    508         data = (struct it87_data *) (new_client + 1); 
     507        new_client = &data->client; 
    509508        if (is_isa) 
    510509                init_MUTEX(&data->lock); 
     
    595594                release_region(address, IT87_EXTENT); 
    596595      ERROR1: 
    597         kfree(new_client); 
     596        kfree(data); 
    598597      ERROR0: 
    599598        return err; 
     
    615614        if(i2c_is_isa_client(client)) 
    616615                release_region(client->addr, IT87_EXTENT); 
    617         kfree(client); 
     616        kfree(client->data); 
    618617 
    619618        return 0; 
  • lm-sensors/trunk/kernel/chips/lm75.c

    r2437 r2445  
    4646/* Each client has this additional data */ 
    4747struct lm75_data { 
     48        struct i2c_client client; 
    4849        int sysctl_id; 
    4950 
     
    129130           client structure, even though we cannot fill it completely yet. 
    130131           But it allows us to access lm75_{read,write}_value. */ 
    131         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    132                                    sizeof(struct lm75_data), 
    133                                    GFP_KERNEL))) { 
     132        if (!(data = kmalloc(sizeof(struct lm75_data), GFP_KERNEL))) { 
    134133                err = -ENOMEM; 
    135134                goto error0; 
    136135        } 
    137136 
    138         data = (struct lm75_data *) (new_client + 1); 
     137        new_client = &data->client; 
    139138        new_client->addr = address; 
    140139        new_client->data = data; 
     
    203202      error3: 
    204203      error1: 
    205         kfree(new_client); 
     204        kfree(data); 
    206205      error0: 
    207206        return err; 
     
    214213        i2c_deregister_entry(data->sysctl_id); 
    215214        i2c_detach_client(client); 
    216         kfree(client); 
     215        kfree(client->data); 
    217216        return 0; 
    218217} 
  • lm-sensors/trunk/kernel/chips/lm78.c

    r2286 r2445  
    119119   allocated. */ 
    120120struct lm78_data { 
     121        struct i2c_client client; 
    121122        struct semaphore lock; 
    122123        int sysctl_id; 
     
    313314           But it allows us to access lm78_{read,write}_value. */ 
    314315 
    315         if (!(new_client = kmalloc((sizeof(struct i2c_client)) + 
    316                                    sizeof(struct lm78_data), 
    317                                    GFP_KERNEL))) { 
     316        if (!(data = kmalloc(sizeof(struct lm78_data), GFP_KERNEL))) { 
    318317                err = -ENOMEM; 
    319318                goto ERROR0; 
    320319        } 
    321320 
    322         data = (struct lm78_data *) (new_client + 1); 
     321        new_client = &data->client; 
    323322        if (is_isa) 
    324323                init_MUTEX(&data->lock); 
     
    413412                release_region(address, LM78_EXTENT); 
    414413      ERROR1: 
    415         kfree(new_client); 
     414        kfree(data); 
    416415      ERROR0: 
    417416        return err; 
     
    433432        if(i2c_is_isa_client(client)) 
    434433                release_region(client->addr, LM78_EXTENT); 
    435         kfree(client); 
     434        kfree(client->data); 
    436435 
    437436        return 0; 
  • lm-sensors/trunk/kernel/chips/lm80.c

    r2284 r2445  
    110110 
    111111struct lm80_data { 
     112        struct i2c_client client; 
    112113        int sysctl_id; 
    113114 
     
    262263           client structure, even though we cannot fill it completely yet. 
    263264           But it allows us to access lm80_{read,write}_value. */ 
    264         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    265                                    sizeof(struct lm80_data), 
    266                                    GFP_KERNEL))) { 
     265        if (!(data = kmalloc(sizeof(struct lm80_data), GFP_KERNEL))) { 
    267266                err = -ENOMEM; 
    268267                goto ERROR0; 
    269268        } 
    270269 
    271         data = (struct lm80_data *) (new_client + 1); 
     270        new_client = &data->client; 
    272271        new_client->addr = address; 
    273272        new_client->data = data; 
     
    331330      ERROR3: 
    332331      ERROR1: 
    333         kfree(new_client); 
     332        kfree(data); 
    334333      ERROR0: 
    335334        return err; 
     
    349348        } 
    350349 
    351         kfree(client); 
     350        kfree(client->data); 
    352351 
    353352        return 0; 
  • lm-sensors/trunk/kernel/chips/lm83.c

    r2192 r2445  
    143143struct lm83_data 
    144144{ 
     145        struct i2c_client client; 
    145146        int sysctl_id; 
    146147 
     
    245246        } 
    246247 
    247         if (!(new_client = kmalloc(sizeof(struct i2c_client) + sizeof(struct 
    248                 lm83_data), GFP_KERNEL))) 
     248        if (!(data = kmalloc(sizeof(struct lm83_data), GFP_KERNEL))) 
    249249        { 
    250250                printk("lm83.o: Out of memory in lm83_detect (new_client).\n"); 
     
    253253 
    254254        /* 
    255          * The LM83-specific data is placed right after the common I2C 
    256          * client data, and is pointed to by the data field from the I2C 
    257          * client data. 
     255         * The common I2C client data is placed right before the 
     256         * LM83-specific data. The LM83-specific data is pointed to by the 
     257         * data field from the I2C client data. 
    258258         */ 
    259259 
     260        new_client = &data->client; 
    260261        new_client->addr = address; 
    261         new_client->data = data = (struct lm83_data *) (new_client + 1); 
     262        new_client->data = data; 
    262263        new_client->adapter = adapter; 
    263264        new_client->driver = &lm83_driver; 
     
    369370        i2c_detach_client(new_client); 
    370371        ERROR1: 
    371         kfree(new_client); 
     372        kfree(data); 
    372373        return err; 
    373374} 
     
    385386        } 
    386387 
    387         kfree(client); 
     388        kfree(client->data); 
    388389        return 0; 
    389390} 
  • lm-sensors/trunk/kernel/chips/lm85.c

    r2286 r2445  
    385385 
    386386struct lm85_data { 
     387        struct i2c_client client; 
    387388        struct semaphore lock; 
    388389        int sysctl_id; 
     
    739740           But it allows us to access lm85_{read,write}_value. */ 
    740741 
    741         if (!(new_client = kmalloc((sizeof(struct i2c_client)) + 
    742                                    sizeof(struct lm85_data), 
    743                                    GFP_KERNEL))) { 
     742        if (!(data = kmalloc(sizeof(struct lm85_data), GFP_KERNEL))) { 
    744743                err = -ENOMEM; 
    745744                goto ERROR0; 
    746745        } 
    747746 
    748         data = (struct lm85_data *) (new_client + 1); 
     747        new_client = &data->client; 
    749748        new_client->addr = address; 
    750749        new_client->data = data; 
     
    922921        i2c_detach_client(new_client); 
    923922    ERROR1: 
    924         kfree(new_client); 
     923        kfree(data); 
    925924    ERROR0: 
    926925        return err; 
     
    941940        } 
    942941 
    943         kfree(client); 
     942        kfree(client->data); 
    944943 
    945944        return 0; 
  • lm-sensors/trunk/kernel/chips/lm87.c

    r2386 r2445  
    196196   allocated. */ 
    197197struct lm87_data { 
     198        struct i2c_client client; 
    198199        int sysctl_id; 
    199200        enum chips type; 
     
    418419           But it allows us to access LM87_{read,write}_value. */ 
    419420 
    420         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    421                                    sizeof(struct lm87_data), 
    422                                    GFP_KERNEL))) { 
     421        if (!(data = kmalloc(sizeof(struct lm87_data), GFP_KERNEL))) { 
    423422                err = -ENOMEM; 
    424423                goto ERROR0; 
    425424        } 
    426425 
    427         data = (struct lm87_data *) (new_client + 1); 
     426        new_client = &data->client; 
    428427        new_client->addr = address; 
    429428        new_client->data = data; 
     
    475474      ERROR3: 
    476475      ERROR1: 
    477         kfree(new_client); 
     476        kfree(data); 
    478477      ERROR0: 
    479478        return err; 
     
    493492        } 
    494493 
    495         kfree(client); 
     494        kfree(client->data); 
    496495 
    497496        return 0; 
    498  
    499497} 
    500498 
  • lm-sensors/trunk/kernel/chips/lm90.c

    r2298 r2445  
    161161struct lm90_data 
    162162{ 
     163        struct i2c_client client; 
    163164        int sysctl_id; 
    164165 
     
    266267        } 
    267268 
    268         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    269                 sizeof(struct lm90_data), GFP_KERNEL))) 
     269        if (!(data = kmalloc(sizeof(struct lm90_data), GFP_KERNEL))) 
    270270        { 
    271271                printk("lm90.o: Out of memory in lm90_detect (new_client).\n"); 
     
    274274 
    275275        /* 
    276          * The LM90-specific data is placed right after the common I2C 
    277          * client data, and is pointed to by the data field from the I2C 
    278          * client data. 
     276         * The common I2C client data is placed right before the 
     277         * LM90-specific data. The LM90-specific data is pointed to by the 
     278         * data field from the I2C client data. 
    279279         */ 
    280280 
     281        new_client = &data->client; 
    281282        new_client->addr = address; 
    282         new_client->data = data = (struct lm90_data *) (new_client + 1); 
     283        new_client->data = data; 
    283284        new_client->adapter = adapter; 
    284285        new_client->driver = &lm90_driver; 
     
    413414        i2c_detach_client(new_client); 
    414415        ERROR1: 
    415         kfree(new_client); 
     416        kfree(data); 
    416417        return err; 
    417418} 
     
    446447        } 
    447448 
    448         kfree(client); 
     449        kfree(client->data); 
    449450        return 0; 
    450451} 
  • lm-sensors/trunk/kernel/chips/lm92.c

    r2440 r2445  
    8484/* NOTE: all temperatures are degrees centigrade * 16 */ 
    8585typedef struct { 
     86        struct i2c_client client; 
    8687        int sysctl_id; 
    8788        unsigned long timestamp; 
     
    308309                return (-ENODEV); 
    309310 
    310         if ((client = kmalloc (sizeof (struct i2c_client) + sizeof (lm92_t),GFP_KERNEL)) == NULL) 
     311        if (!(data = kmalloc(sizeof(lm92_t), GFP_KERNEL))) 
    311312                return (-ENOMEM); 
    312313 
    313         data = (lm92_t *) (client + 1); 
     314        client = &data->client; 
    314315        client->addr = address; 
    315316        client->data = data; 
     
    320321 
    321322        if (down_interruptible (&mutex)) { 
    322                 kfree (client); 
    323                 return (-ERESTARTSYS); 
     323                result = -ERESTARTSYS; 
     324                goto ERROR1; 
    324325        } 
    325326 
     
    331332                        /* Is it a MAX6635/MAX6635/MAX6635? */ 
    332333                        if (!max6635_check(client)) { 
    333                                 kfree (client); 
    334                                 up (&mutex); 
    335                                 return (-ENODEV); 
     334                                result = -ENODEV; 
     335                                goto ERROR2; 
    336336                        } 
    337337                } 
     
    339339 
    340340        if ((result = i2c_attach_client (client))) { 
    341                 kfree (client); 
    342                 up (&mutex); 
    343                 return (result); 
     341                goto ERROR2; 
    344342        } 
    345343 
    346344        if ((result = i2c_register_entry (client,client->name,lm92_dir_table)) < 0) { 
    347                 i2c_detach_client (client); 
    348                 kfree (client); 
    349                 up (&mutex); 
    350                 return (result); 
     345                goto ERROR3; 
    351346        } 
    352347        data->sysctl_id = result; 
    353348 
    354349        if ((result = lm92_init_client (client)) < 0) { 
    355                 i2c_deregister_entry (data->sysctl_id); 
    356                 i2c_detach_client (client); 
    357                 kfree (client); 
    358                 up (&mutex); 
    359                 return (result); 
     350                goto ERROR4; 
    360351        } 
    361352 
     
    365356 
    366357        return (0); 
     358 
     359ERROR4: 
     360        i2c_deregister_entry(data->sysctl_id); 
     361ERROR3: 
     362        i2c_detach_client(client); 
     363ERROR2: 
     364        up(&mutex); 
     365ERROR1: 
     366        kfree(data); 
     367        return result; 
    367368} 
    368369 
     
    395396                return (result); 
    396397 
    397         kfree (client); 
     398        kfree(client->data); 
    398399 
    399400        return (0); 
  • lm-sensors/trunk/kernel/chips/ltc1710.c

    r2386 r2445  
    6969/* Each client has this additional data */ 
    7070struct ltc1710_data { 
     71        struct i2c_client client; 
    7172        int sysctl_id; 
    7273 
     
    153154           client structure, even though we cannot fill it completely yet. 
    154155           But it allows us to access ltc1710_{read,write}_value. */ 
    155         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    156                                    sizeof(struct ltc1710_data), 
    157                                    GFP_KERNEL))) { 
     156        if (!(data = kmalloc(sizeof(struct ltc1710_data), GFP_KERNEL))) { 
    158157                err = -ENOMEM; 
    159158                goto ERROR0; 
    160159        } 
    161160 
    162         data = (struct ltc1710_data *) (new_client + 1); 
     161        new_client = &data->client; 
    163162        new_client->addr = address; 
    164163        new_client->data = data; 
     
    213212      ERROR3: 
    214213      ERROR1: 
    215         kfree(new_client); 
     214        kfree(data); 
    216215      ERROR0: 
    217216        return err; 
     
    232231        } 
    233232 
    234         kfree(client); 
     233        kfree(client->data); 
    235234 
    236235        return 0; 
  • lm-sensors/trunk/kernel/chips/matorb.c

    r1705 r2445  
    4646/* Each client has this additional data */ 
    4747struct matorb_data { 
     48        struct i2c_client client; 
    4849        int sysctl_id; 
    4950 
     
    128129           client structure, even though we cannot fill it completely yet. 
    129130           But it allows us to access matorb_{read,write}_value. */ 
    130         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    131                                    sizeof(struct matorb_data), 
    132                                    GFP_KERNEL))) { 
     131        if (!(data = kmalloc(sizeof(struct matorb_data), GFP_KERNEL))) { 
    133132                err = -ENOMEM; 
    134133                goto ERROR0; 
    135134        } 
    136135 
    137         data = (struct matorb_data *) (new_client + 1); 
     136        new_client = &data->client; 
    138137        new_client->addr = address; 
    139138        new_client->data = data; 
     
    175174        i2c_detach_client(new_client); 
    176175      ERROR3: 
    177         kfree(new_client); 
     176        kfree(data); 
    178177      ERROR0: 
    179178        return err; 
     
    193192        } 
    194193 
    195         kfree(client); 
     194        kfree(client->data); 
    196195 
    197196        return 0; 
  • lm-sensors/trunk/kernel/chips/max6650.c

    r2298 r2445  
    129129struct max6650_data 
    130130{ 
     131        struct i2c_client client; 
    131132    int sysctl_id; 
    132133    struct semaphore update_lock; 
     
    220221    } 
    221222 
    222     if (!(new_client = kmalloc(sizeof(struct i2c_client) + sizeof(struct 
    223                 max6650_data), GFP_KERNEL))) { 
     223    if (!(data = kmalloc(sizeof(struct max6650_data), GFP_KERNEL))) { 
    224224        printk("max6650.o: Out of memory in max6650_detect (new_client).\n"); 
    225225        return -ENOMEM; 
     
    227227 
    228228    /* 
    229      * The max6650-specific data is placed right after the common I2C 
    230      * client data, and is pointed to by the data field from the I2C 
    231      * client data. 
     229     * The common I2C client data is placed right before the 
     230     * max6650-specific data. The max6650-specific data is pointed to by the 
     231         * data field from the I2C client data. 
    232232     */ 
    233233 
     234        new_client = &data->client; 
    234235    new_client->addr = address; 
    235     new_client->data = data = (struct max6650_data *) (new_client + 1); 
     236    new_client->data = data; 
    236237    new_client->adapter = adapter; 
    237238    new_client->driver = &max6650_driver; 
     
    329330    i2c_detach_client(new_client); 
    330331ERROR1: 
    331     kfree(new_client); 
     332    kfree(data); 
    332333    return err; 
    333334} 
     
    349350    } 
    350351 
    351     kfree(client); 
     352    kfree(client->data); 
    352353    return 0; 
    353354} 
  • lm-sensors/trunk/kernel/chips/maxilife.c

    r2286 r2445  
    239239   SMBus and not on the ISA bus. */ 
    240240struct maxi_data { 
     241        struct i2c_client client; 
    241242        struct semaphore lock; 
    242243        int sysctl_id; 
     
    440441           client structure, even though we cannot fill it completely yet. 
    441442           But it allows us to access maxi_{read,write}_value. */ 
    442         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    443                                    sizeof(struct maxi_data), 
    444                                    GFP_KERNEL))) { 
     443        if (!(data = kmalloc(sizeof(struct maxi_data), GFP_KERNEL))) { 
    445444                err = -ENOMEM; 
    446445                goto ERROR0; 
     
    448447 
    449448        /* Fill the new client structure with data */ 
    450         data = (struct maxi_data *) (new_client + 1); 
     449        new_client = &data->client; 
    451450        new_client->addr = address; 
    452451        new_client->data = data; 
     
    630629        i2c_detach_client(new_client); 
    631630      ERROR2: 
    632         kfree(new_client); 
     631        kfree(data); 
    633632      ERROR0: 
    634633        return err; 
     
    651650                return err; 
    652651        } 
    653         kfree(client); 
     652        kfree(client->data); 
    654653        return 0; 
    655654} 
  • lm-sensors/trunk/kernel/chips/mtp008.c

    r2286 r2445  
    194194 */ 
    195195struct mtp008_data { 
     196        struct i2c_client client; 
    196197        int sysctl_id; 
    197198        enum chips type; 
     
    403404         * allows us to use mtp008_(read|write)_value(). 
    404405         */ 
    405         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    406                                    sizeof(struct mtp008_data), 
    407                                    GFP_KERNEL))) { 
     406        if (!(data = kmalloc(sizeof(struct mtp008_data), GFP_KERNEL))) { 
    408407                err = -ENOMEM; 
    409408                goto ERROR0; 
    410409        } 
    411         data = (struct mtp008_data *) (new_client + 1); 
     410 
     411        new_client = &data->client; 
    412412        new_client->addr = address; 
    413413        new_client->data = data; 
     
    464464        i2c_detach_client(new_client); 
    465465      ERROR1: 
    466         kfree(new_client); 
     466        kfree(data); 
    467467 
    468468      ERROR0: 
     
    482482                return err; 
    483483        } 
    484         kfree(client); 
     484        kfree(client->data); 
    485485 
    486486        return 0; 
  • lm-sensors/trunk/kernel/chips/pc87360.c

    r2429 r2445  
    110110 
    111111struct pc87360_data { 
     112        struct i2c_client client; 
    112113        struct semaphore lock; 
    113114        int sysctl_id; 
     
    277278        } 
    278279 
    279         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    280                                    sizeof(struct pc87360_data), 
    281                                    GFP_KERNEL))) { 
     280        if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL))) { 
    282281                return -ENOMEM; 
    283282        } 
    284283 
    285         data = (struct pc87360_data *) (new_client + 1); 
     284        new_client = &data->client; 
    286285        new_client->addr = address; 
    287286        init_MUTEX(&data->lock); 
     
    338337      ERROR1: 
    339338        release_region(address, PC87360_EXTENT); 
    340         kfree(new_client); 
     339        kfree(data); 
    341340        return err; 
    342341} 
     
    355354 
    356355        release_region(client->addr, PC87360_EXTENT); 
    357         kfree(client); 
     356        kfree(client->data); 
    358357 
    359358        return 0; 
  • lm-sensors/trunk/kernel/chips/pca9540.c

    r2366 r2445  
    4949/* Each client has this additional data */ 
    5050struct pca9540_data { 
     51        struct i2c_client client; 
    5152        int sysctl_id; 
    5253 
     
    108109        /* OK. For now, we presume we have a valid client. We now create the 
    109110           client structure, even though we cannot fill it completely yet. */ 
    110         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    111                                    sizeof(struct pca9540_data), 
    112                                    GFP_KERNEL))) { 
     111        if (!(data = kmalloc(sizeof(struct pca9540_data), GFP_KERNEL))) { 
    113112                err = -ENOMEM; 
    114113                goto ERROR0; 
    115114        } 
    116115 
    117         data = (struct pca9540_data *) (new_client + 1); 
     116        new_client = &data->client; 
    118117        new_client->addr = address; 
    119118        new_client->data = data; 
     
    160159        i2c_detach_client(new_client); 
    161160      ERROR1: 
    162         kfree(new_client); 
     161        kfree(data); 
    163162      ERROR0: 
    164163        return err; 
     
    177176        } 
    178177 
    179         kfree(client); 
     178        kfree(client->data); 
    180179 
    181180        return 0; 
    182  
    183181} 
    184182 
  • lm-sensors/trunk/kernel/chips/pcf8574.c

    r2362 r2445  
    6666/* Each client has this additional data */ 
    6767struct pcf8574_data { 
     68        struct i2c_client client; 
    6869        int sysctl_id; 
    6970 
     
    147148        /* OK. For now, we presume we have a valid client. We now create the 
    148149           client structure, even though we cannot fill it completely yet. */ 
    149         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    150                                    sizeof(struct pcf8574_data), 
    151                                    GFP_KERNEL))) { 
     150        if (!(data = kmalloc(sizeof(struct pcf8574_data), GFP_KERNEL))) { 
    152151                err = -ENOMEM; 
    153152                goto ERROR0; 
    154153        } 
    155154 
    156         data = (struct pcf8574_data *) (new_client + 1); 
     155        new_client = &data->client; 
    157156        new_client->addr = address; 
    158157        new_client->data = data; 
     
    208207        i2c_detach_client(new_client); 
    209208      ERROR1: 
    210         kfree(new_client); 
     209        kfree(data); 
    211210      ERROR0: 
    212211        return err; 
     
    226225        } 
    227226 
    228         kfree(client); 
     227        kfree(client->data); 
    229228 
    230229        return 0; 
    231  
    232230} 
    233231 
  • lm-sensors/trunk/kernel/chips/pcf8591.c

    r2397 r2445  
    7171 
    7272struct pcf8591_data { 
     73        struct i2c_client client; 
    7374        int sysctl_id; 
    7475 
     
    184185        /* OK. For now, we presume we have a valid client. We now create the 
    185186           client structure, even though we cannot fill it completely yet. */ 
    186         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    187                                    sizeof(struct pcf8591_data), 
    188                                    GFP_KERNEL))) { 
     187        if (!(data = kmalloc(sizeof(struct pcf8591_data), GFP_KERNEL))) { 
    189188                err = -ENOMEM; 
    190189                goto ERROR0; 
    191190        } 
    192191 
    193         data = (struct pcf8591_data *) (new_client + 1); 
     192        new_client = &data->client; 
    194193        new_client->addr = address; 
    195194        new_client->data = data; 
     
    238237        i2c_detach_client(new_client); 
    239238      ERROR3: 
    240         kfree(new_client); 
     239        kfree(data); 
    241240      ERROR0: 
    242241        return err; 
     
    256255        } 
    257256 
    258         kfree(client); 
     257        kfree(client->data); 
    259258 
    260259        return 0; 
  • lm-sensors/trunk/kernel/chips/saa1064.c

    r2386 r2445  
    122122/* Each client has this additional data */ 
    123123struct saa1064_data { 
     124        struct i2c_client client; 
    124125        int sysctl_id; 
    125126 
     
    219220           client structure, even though we cannot fill it completely yet. 
    220221           But it allows us to access i2c_smbus_read_byte */ 
    221         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    222                                    sizeof(struct saa1064_data), 
    223                                    GFP_KERNEL))) { 
     222        if (!(data = kmalloc(sizeof(struct saa1064_data), GFP_KERNEL))) { 
    224223                err = -ENOMEM; 
    225224                goto ERROR0; 
    226225        } 
    227226 
    228         data = (struct saa1064_data *) (new_client + 1); 
     227        new_client = &data->client; 
    229228        new_client->addr = address; 
    230229        new_client->data = data; 
     
    280279        i2c_detach_client(new_client); 
    281280      ERROR3: 
    282                         ERROR1: 
    283         kfree(new_client); 
     281      ERROR1: 
     282        kfree(data); 
    284283      ERROR0: 
    285284        return err; 
     
    300299        } 
    301300 
    302         kfree(client); 
     301        kfree(client->data); 
    303302 
    304303        return 0; 
  • lm-sensors/trunk/kernel/chips/sis5595.c

    r2286 r2445  
    171171   allocated. */ 
    172172struct sis5595_data { 
     173        struct i2c_client client; 
    173174        struct semaphore lock; 
    174175        int sysctl_id; 
     
    387388        } 
    388389 
    389         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    390                                    sizeof(struct sis5595_data), 
    391                                    GFP_KERNEL))) { 
     390        if (!(data = kmalloc(sizeof(struct sis5595_data), GFP_KERNEL))) { 
    392391                return -ENOMEM; 
    393392        } 
    394393 
    395         data = (struct sis5595_data *) (new_client + 1); 
     394        new_client = &data->client; 
    396395        new_client->addr = address; 
    397396        init_MUTEX(&data->lock); 
     
    446445      ERROR3: 
    447446        release_region(address, SIS5595_EXTENT); 
    448         kfree(new_client); 
     447        kfree(data); 
    449448        return err; 
    450449} 
     
    464463 
    465464        release_region(client->addr, SIS5595_EXTENT); 
    466         kfree(client); 
     465        kfree(client->data); 
    467466 
    468467        return 0; 
  • lm-sensors/trunk/kernel/chips/smartbatt.c

    r2437 r2445  
    7373/* Each client has this additional data */ 
    7474struct smartbatt_data { 
     75        struct i2c_client client; 
    7576        int sysctl_id; 
    7677 
     
    244245           client structure, even though we cannot fill it completely yet. 
    245246           But it allows us to access smartbatt_{read,write}_value. */ 
    246         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    247                                    sizeof(struct smartbatt_data), 
    248                                    GFP_KERNEL))) { 
     247        if (!(data = kmalloc(sizeof(struct smartbatt_data), GFP_KERNEL))) { 
    249248                err = -ENOMEM; 
    250249                goto ERROR0; 
    251250        } 
    252251 
    253         data = (struct smartbatt_data *) (new_client + 1); 
     252        new_client = &data->client; 
    254253        new_client->addr = address; 
    255254        new_client->data = data; 
     
    298297      ERROR3: 
    299298      ERROR1: 
    300         kfree(new_client); 
     299        kfree(data); 
    301300      ERROR0: 
    302301        return err; 
     
    316315        } 
    317316 
    318         kfree(client); 
     317        kfree(client->data); 
    319318 
    320319        return 0; 
  • lm-sensors/trunk/kernel/chips/smbus-arp.c

    r1802 r2445  
    106106/* Each client has this additional data */ 
    107107struct arp_data { 
     108        struct i2c_client client; 
    108109        int sysctl_id; 
    109110 
     
    191192                return(0); 
    192193 
    193         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    194                                    sizeof(struct arp_data), 
    195                                    GFP_KERNEL))) { 
     194        if (!(data = kmalloc(sizeof(struct arp_data), GFP_KERNEL))) { 
    196195                return(-ENOMEM); 
    197196        } 
    198197 
    199         data = (struct arp_data *) (new_client + 1); 
     198        new_client = &data->client; 
    200199        new_client->addr = address; 
    201200        new_client->data = data; 
     
    232231        i2c_detach_client(new_client); 
    233232      ERROR1: 
    234         kfree(new_client); 
     233        kfree(data); 
    235234        return err; 
    236235} 
     
    249248        } 
    250249 
    251         kfree(client); 
     250        kfree(client->data); 
    252251 
    253252        return 0; 
  • lm-sensors/trunk/kernel/chips/smsc47m1.c

    r2363 r2445  
    122122 
    123123struct smsc47m1_data { 
     124        struct i2c_client client; 
    124125        struct semaphore lock; 
    125126        int sysctl_id; 
     
    260261        } 
    261262 
    262         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    263                                    sizeof(struct smsc47m1_data), 
    264                                    GFP_KERNEL))) { 
     263        if (!(data = kmalloc(sizeof(struct smsc47m1_data), GFP_KERNEL))) { 
    265264                return -ENOMEM; 
    266265        } 
    267266 
    268         data = (struct smsc47m1_data *) (new_client + 1); 
     267        new_client = &data->client; 
    269268        new_client->addr = address; 
    270269        init_MUTEX(&data->lock); 
     
    299298      ERROR3: 
    300299        release_region(address, SMSC_EXTENT); 
    301         kfree(new_client); 
     300        kfree(data); 
    302301        return err; 
    303302} 
     
    317316 
    318317        release_region(client->addr, SMSC_EXTENT); 
    319         kfree(client); 
     318        kfree(client->data); 
    320319 
    321320        return 0; 
  • lm-sensors/trunk/kernel/chips/thmc50.c

    r2434 r2445  
    7474/* Each client has this additional data */ 
    7575struct thmc50_data { 
     76        struct i2c_client client; 
    7677        int sysctl_id; 
    7778 
     
    191192           client structure, even though we cannot fill it completely yet. 
    192193           But it allows us to access thmc50_{read,write}_value. */ 
    193         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    194                                    sizeof(struct thmc50_data), 
    195                                    GFP_KERNEL))) { 
     194        if (!(data = kmalloc(sizeof(struct thmc50_data), GFP_KERNEL))) { 
    196195                err = -ENOMEM; 
    197196                goto ERROR0; 
    198197        } 
    199198 
    200         data = 
    201             (struct thmc50_data *) (((struct i2c_client *) new_client) + 
    202                                     1); 
     199        new_client = &data->client; 
    203200        new_client->addr = address; 
    204201        new_client->data = data; 
     
    263260      ERROR3: 
    264261      ERROR1: 
    265         kfree(new_client); 
     262        kfree(data); 
    266263      ERROR0: 
    267264        return err; 
     
    281278        } 
    282279 
    283         kfree(client); 
     280        kfree(client->data); 
    284281 
    285282        return 0; 
  • lm-sensors/trunk/kernel/chips/via686a.c

    r2436 r2445  
    335335   via686a client is allocated. */ 
    336336struct via686a_data { 
     337        struct i2c_client client; 
    337338        struct semaphore lock; 
    338339        int sysctl_id; 
     
    517518        } 
    518519 
    519         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    520                                    sizeof(struct via686a_data), 
    521                                    GFP_KERNEL))) { 
     520        if (!(data = kmalloc(sizeof(struct via686a_data), GFP_KERNEL))) { 
    522521                err = -ENOMEM; 
    523522                goto ERROR0; 
    524523        } 
    525524 
    526         data = (struct via686a_data *) (new_client + 1); 
     525        new_client = &data->client; 
    527526        new_client->addr = address; 
    528527        init_MUTEX(&data->lock); 
     
    563562      ERROR3: 
    564563        release_region(address, VIA686A_EXTENT); 
    565         kfree(new_client); 
     564        kfree(data); 
    566565      ERROR0: 
    567566        return err; 
     
    582581 
    583582        release_region(client->addr, VIA686A_EXTENT); 
    584         kfree(client); 
     583        kfree(client->data); 
    585584 
    586585        return 0; 
  • lm-sensors/trunk/kernel/chips/vt1211.c

    r2304 r2445  
    176176 
    177177struct vt1211_data { 
     178        struct i2c_client client; 
    178179        struct semaphore lock; 
    179180        int sysctl_id; 
     
    410411        superio_exit(); 
    411412 
    412         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    413                                    sizeof(struct vt1211_data), 
    414                                    GFP_KERNEL))) { 
     413        if (!(data = kmalloc(sizeof(struct vt1211_data), GFP_KERNEL))) { 
    415414                return -ENOMEM; 
    416415        } 
    417416 
    418         data = (struct vt1211_data *) (new_client + 1); 
     417        new_client = &data->client; 
    419418        new_client->addr = address; 
    420419        init_MUTEX(&data->lock); 
     
    449448      ERROR3: 
    450449        release_region(address, VT1211_EXTENT); 
    451         kfree(new_client); 
     450        kfree(data); 
    452451        return err; 
    453452} 
     
    467466 
    468467        release_region(client->addr, VT1211_EXTENT); 
    469         kfree(client); 
     468        kfree(client->data); 
    470469 
    471470        return 0; 
  • lm-sensors/trunk/kernel/chips/vt8231.c

    r2319 r2445  
    135135 
    136136struct vt8231_data { 
     137        struct i2c_client client; 
    137138        struct semaphore lock; 
    138139        int sysctl_id; 
     
    374375        } 
    375376 
    376         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    377                                    sizeof(struct vt8231_data), 
    378                                    GFP_KERNEL))) { 
     377        if (!(data = kmalloc(sizeof(struct vt8231_data), GFP_KERNEL))) { 
    379378                err = -ENOMEM; 
    380379                goto ERROR0; 
    381380        } 
    382381 
    383         data = (struct vt8231_data *) (new_client + 1); 
     382        new_client = &data->client; 
    384383        new_client->addr = address; 
    385384        init_MUTEX(&data->lock); 
     
    419418      ERROR3: 
    420419        release_region(address, VIA686A_EXTENT); 
    421         kfree(new_client); 
     420        kfree(data); 
    422421      ERROR0: 
    423422        return err; 
     
    438437 
    439438        release_region(client->addr, VIA686A_EXTENT); 
    440         kfree(client); 
     439        kfree(client->data); 
    441440 
    442441        return 0; 
  • lm-sensors/trunk/kernel/chips/w83627hf.c

    r2302 r2445  
    278278   dynamically allocated, at the same time when a new client is allocated. */ 
    279279struct w83627hf_data { 
     280        struct i2c_client client; 
    280281        struct semaphore lock; 
    281282        int sysctl_id; 
     
    661662           But it allows us to access w83627hf_{read,write}_value. */ 
    662663 
    663         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    664                                    sizeof(struct w83627hf_data), 
    665                                    GFP_KERNEL))) { 
     664        if (!(data = kmalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) { 
    666665                err = -ENOMEM; 
    667666                goto ERROR0; 
    668667        } 
    669668 
    670         data = (struct w83627hf_data *) (new_client + 1); 
     669        new_client = &data->client; 
    671670        new_client->addr = address; 
    672671        init_MUTEX(&data->lock); 
     
    734733        release_region(address, WINB_EXTENT); 
    735734      ERROR1: 
    736         kfree(new_client); 
     735        kfree(data); 
    737736      ERROR0: 
    738737        return err; 
     
    753752 
    754753        release_region(client->addr, WINB_EXTENT); 
    755         kfree(client); 
     754        kfree(client->data); 
    756755 
    757756        return 0; 
  • lm-sensors/trunk/kernel/chips/w83l785ts.c

    r2334 r2445  
    102102 
    103103struct w83l785ts_data { 
     104        struct i2c_client client; 
    104105        int sysctl_id; 
    105106 
     
    167168        } 
    168169 
    169         if (!(new_client = kmalloc(sizeof(struct i2c_client) + sizeof(struct w83l785ts_data), 
    170             GFP_KERNEL))) { 
     170        if (!(data = kmalloc(sizeof(struct w83l785ts_data), GFP_KERNEL))) { 
    171171                printk(KERN_ERR "w83l785ts.o: Out of memory in w83l785ts_detect " 
    172172                        "(new_client).\n"); 
     
    175175 
    176176        /* 
    177          * The W83L785TS-specific data is placed right after the common I2C 
    178          * client data, and is pointed to by the data field from the I2C 
    179          * client data. 
    180          */ 
    181  
     177         * The common I2C client data is placed right after the 
     178         * W83L785TS-specific. The W83L785TS-specific data is pointed to by the 
     179         * data field from the I2C client data. 
     180         */ 
     181 
     182        new_client = &data->client; 
    182183        new_client->addr = address; 
    183         new_client->data = data = (struct w83l785ts_data *) (new_client + 1); 
     184        new_client->data = data; 
    184185        new_client->adapter = adapter; 
    185186        new_client->driver = &w83l785ts_driver; 
     
    280281        i2c_detach_client(new_client); 
    281282        ERROR1: 
    282         kfree(new_client); 
     283        kfree(data); 
    283284        return err; 
    284285} 
     
    295296        } 
    296297 
    297         kfree(client); 
     298        kfree(client->data); 
    298299        return 0; 
    299300} 
  • lm-sensors/trunk/kernel/chips/xeontemp.c

    r2336 r2445  
    7979/* Each client has this additional data */ 
    8080struct xeontemp_data { 
     81        struct i2c_client client; 
    8182        int sysctl_id; 
    8283        enum chips type; 
     
    168169           But it allows us to access xeontemp_{read,write}_value. */ 
    169170 
    170         if (!(new_client = kmalloc(sizeof(struct i2c_client) + 
    171                                    sizeof(struct xeontemp_data), 
    172                                    GFP_KERNEL))) { 
     171        if (!(data = kmalloc(sizeof(struct xeontemp_data), GFP_KERNEL))) { 
    173172                err = -ENOMEM; 
    174173                goto error0; 
    175174        } 
    176175 
    177         data = (struct xeontemp_data *) (new_client + 1); 
     176        new_client = &data->client; 
    178177        new_client->addr = address; 
    179178        new_client->data = data; 
     
    227226      error3: 
    228227      error1: 
    229         kfree(new_client); 
     228        kfree(data); 
    230229      error0: 
    231230        return err; 
     
    254253        } 
    255254 
    256         kfree(client); 
     255        kfree(client->data); 
    257256 
    258257        return 0;