root/trunk/patches/2.6.22/14-eeprom-new-notifier.patch

Revision 852, 6.4 kB (checked in by blaster8, 3 years ago)

Refresh patches

  • linux-2.6.22-rc1-arm/drivers/i2c/chips/eeprom.c

    old new  
    3333#include <linux/jiffies.h> 
    3434#include <linux/i2c.h> 
    3535#include <linux/mutex.h> 
     36#include <linux/notifier.h> 
     37#include <linux/eeprom.h> 
    3638 
    3739/* Addresses to scan */ 
    3840static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54, 
     
    4143/* Insmod parameters */ 
    4244I2C_CLIENT_INSMOD_1(eeprom); 
    4345 
    44  
    45 /* Size of EEPROM in bytes */ 
    46 #define EEPROM_SIZE             256 
    47  
    48 /* possible types of eeprom devices */ 
    49 enum eeprom_nature { 
    50         UNKNOWN, 
    51         VAIO, 
    52 }; 
    53  
    54 /* Each client has this additional data */ 
    55 struct eeprom_data { 
    56         struct i2c_client client; 
    57         struct mutex update_lock; 
    58         u8 valid;                       /* bitfield, bit!=0 if slice is valid */ 
    59         unsigned long last_updated[8];  /* In jiffies, 8 slices */ 
    60         u8 data[EEPROM_SIZE];           /* Register values */ 
    61         enum eeprom_nature nature; 
    62 }; 
    63  
     46ATOMIC_NOTIFIER_HEAD(eeprom_chain); 
    6447 
    6548static int eeprom_attach_adapter(struct i2c_adapter *adapter); 
    6649static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind); 
     
    189172        data->valid = 0; 
    190173        mutex_init(&data->update_lock); 
    191174        data->nature = UNKNOWN; 
     175        data->attr = &eeprom_attr; 
    192176 
    193177        /* Tell the I2C layer a new client has arrived */ 
    194178        if ((err = i2c_attach_client(new_client))) 
     
    212196        if (err) 
    213197                goto exit_detach; 
    214198 
     199        /* call the notifier chain */ 
     200        atomic_notifier_call_chain(&eeprom_chain, EEPROM_REGISTER, data); 
     201 
    215202        return 0; 
    216203 
    217204exit_detach: 
     
    237224        return 0; 
    238225} 
    239226 
     227/** 
     228 * register_eeprom_notifier - register a 'user' of EEPROM devices. 
     229 * @nb: pointer to notifier info structure 
     230 * 
     231 * Registers a callback function to be called upon detection 
     232 * of an EEPROM device.  Detection invokes the 'add' callback 
     233 * with the kobj of the mutex and a bin_attribute which allows 
     234 * read from the EEPROM.  The intention is that the notifier 
     235 * will be able to read system configuration from the notifier. 
     236 * 
     237 * Only EEPROMs detected *after* the addition of the notifier 
     238 * are notified.  I.e. EEPROMs already known to the system 
     239 * will not be notified - add the notifier from board level 
     240 * code! 
     241 */ 
     242int register_eeprom_notifier(struct notifier_block *nb) 
     243{ 
     244        return atomic_notifier_chain_register(&eeprom_chain, nb); 
     245} 
     246 
     247/** 
     248 *      unregister_eeprom_notifier - unregister a 'user' of EEPROM devices. 
     249 *      @old: pointer to notifier info structure 
     250 * 
     251 *      Removes a callback function from the list of 'users' to be 
     252 *      notified upon detection of EEPROM devices. 
     253 */ 
     254int unregister_eeprom_notifier(struct notifier_block *nb) 
     255{ 
     256        return atomic_notifier_chain_unregister(&eeprom_chain, nb); 
     257} 
     258 
     259EXPORT_SYMBOL_GPL(register_eeprom_notifier); 
     260EXPORT_SYMBOL_GPL(unregister_eeprom_notifier); 
     261 
    240262static int __init eeprom_init(void) 
    241263{ 
    242264        return i2c_add_driver(&eeprom_driver); 
  • /dev/null

    old new  
     1#ifndef _LINUX_EEPROM_H 
     2#define _LINUX_EEPROM_H 
     3/* 
     4 *  EEPROM notifier header 
     5 * 
     6 *  Copyright (C) 2006 John Bowler 
     7 */ 
     8 
     9/* 
     10 * This program is free software; you can redistribute it and/or modify 
     11 * it under the terms of the GNU General Public License as published by 
     12 * the Free Software Foundation; either version 2 of the License, or 
     13 * (at your option) any later version. 
     14 * 
     15 * This program is distributed in the hope that it will be useful, 
     16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     18 * GNU General Public License for more details. 
     19 * 
     20 * You should have received a copy of the GNU General Public License 
     21 * along with this program; if not, write to the Free Software 
     22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     23 */ 
     24 
     25#ifndef __KERNEL__ 
     26#error This is a kernel header 
     27#endif 
     28 
     29#include <linux/list.h> 
     30#include <linux/kobject.h> 
     31#include <linux/sysfs.h> 
     32 
     33/* Size of EEPROM in bytes */ 
     34#define EEPROM_SIZE             256 
     35 
     36/* possible types of eeprom devices */ 
     37enum eeprom_nature { 
     38        UNKNOWN, 
     39        VAIO, 
     40}; 
     41 
     42/* Each client has this additional data */ 
     43struct eeprom_data { 
     44        struct i2c_client client; 
     45        struct mutex update_lock; 
     46        u8 valid;                       /* bitfield, bit!=0 if slice is valid */ 
     47        unsigned long last_updated[8];  /* In jiffies, 8 slices */ 
     48        u8 data[EEPROM_SIZE];           /* Register values */ 
     49        enum eeprom_nature nature; 
     50        struct bin_attribute *attr; 
     51}; 
     52 
     53/* 
     54 * This is very basic. 
     55 * 
     56 * If an EEPROM is detected on the I2C bus (this only works for 
     57 * I2C EEPROMs) the notifier chain  is called with 
     58 * both the I2C information and the kobject for the sysfs 
     59 * device which has been registers.  It is then possible to 
     60 * read from the device via the bin_attribute::read method 
     61 * to extract configuration information. 
     62 * 
     63 * Register the notifier in the board level code, there is no 
     64 * need to unregister it but you can if you want (it will save 
     65 * a little bit or kernel memory to do so). 
     66 */ 
     67 
     68extern int register_eeprom_notifier(struct notifier_block *nb); 
     69extern int unregister_eeprom_notifier(struct notifier_block *nb); 
     70 
     71#endif /* _LINUX_EEPROM_H */ 
  • linux-2.6.22-rc1-arm/include/linux/notifier.h

    old new  
    209209#define CPU_DOWN_FAILED_FROZEN  (CPU_DOWN_FAILED | CPU_TASKS_FROZEN) 
    210210#define CPU_DEAD_FROZEN         (CPU_DEAD | CPU_TASKS_FROZEN) 
    211211 
     212/* eeprom notifier chain */ 
     213#define EEPROM_REGISTER         0x0001 
     214 
    212215#endif /* __KERNEL__ */ 
    213216#endif /* _LINUX_NOTIFIER_H */ 
Note: See TracBrowser for help on using the browser.