| 98 | } |
| 99 | |
| 100 | static int get_cmos_value(const struct nvram_accessor *nvram, u32 bitnum, u32 len, void *valptr) |
| 101 | { |
| 102 | u8 *value = valptr; |
| 103 | int offs = 0; |
| 104 | u32 addr, bit; |
| 105 | u8 reg8; |
| 106 | |
| 107 | /* Convert to byte borders */ |
| 108 | addr=(bitnum / 8); |
| 109 | bit=(bitnum % 8); |
| 110 | |
| 111 | /* Handle single byte or less */ |
| 112 | if(len <= 8) { |
| 113 | reg8 = nvram->read(addr); |
| 114 | reg8 >>= bit; |
| 115 | value[0] = reg8 & ((1 << len) -1); |
| 116 | return 0; |
| 117 | } |
| 118 | |
| 119 | /* When handling more than a byte, copy whole bytes */ |
| 120 | while (len > 0) { |
| 121 | len -= 8; |
| 122 | value[offs++]=nvram->read(addr++); |
| 123 | } |
| 124 | |
| 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | static int set_cmos_value(const struct nvram_accessor *nvram, u32 bitnum, u32 len, const void *valptr) |
| 129 | { |