• Home
  • Raw
  • Download

Lines Matching refs:eeprom

48 	struct eeprom_data *eeprom = i2c_get_clientdata(client);  in i2c_slave_eeprom_slave_cb()  local
52 if (eeprom->idx_write_cnt < eeprom->num_address_bytes) { in i2c_slave_eeprom_slave_cb()
53 if (eeprom->idx_write_cnt == 0) in i2c_slave_eeprom_slave_cb()
54 eeprom->buffer_idx = 0; in i2c_slave_eeprom_slave_cb()
55 eeprom->buffer_idx = *val | (eeprom->buffer_idx << 8); in i2c_slave_eeprom_slave_cb()
56 eeprom->idx_write_cnt++; in i2c_slave_eeprom_slave_cb()
58 if (!eeprom->read_only) { in i2c_slave_eeprom_slave_cb()
59 spin_lock(&eeprom->buffer_lock); in i2c_slave_eeprom_slave_cb()
60 eeprom->buffer[eeprom->buffer_idx++ & eeprom->address_mask] = *val; in i2c_slave_eeprom_slave_cb()
61 spin_unlock(&eeprom->buffer_lock); in i2c_slave_eeprom_slave_cb()
68 eeprom->buffer_idx++; in i2c_slave_eeprom_slave_cb()
71 spin_lock(&eeprom->buffer_lock); in i2c_slave_eeprom_slave_cb()
72 *val = eeprom->buffer[eeprom->buffer_idx & eeprom->address_mask]; in i2c_slave_eeprom_slave_cb()
73 spin_unlock(&eeprom->buffer_lock); in i2c_slave_eeprom_slave_cb()
83 eeprom->idx_write_cnt = 0; in i2c_slave_eeprom_slave_cb()
96 struct eeprom_data *eeprom; in i2c_slave_eeprom_bin_read() local
99 eeprom = dev_get_drvdata(kobj_to_dev(kobj)); in i2c_slave_eeprom_bin_read()
101 spin_lock_irqsave(&eeprom->buffer_lock, flags); in i2c_slave_eeprom_bin_read()
102 memcpy(buf, &eeprom->buffer[off], count); in i2c_slave_eeprom_bin_read()
103 spin_unlock_irqrestore(&eeprom->buffer_lock, flags); in i2c_slave_eeprom_bin_read()
111 struct eeprom_data *eeprom; in i2c_slave_eeprom_bin_write() local
114 eeprom = dev_get_drvdata(kobj_to_dev(kobj)); in i2c_slave_eeprom_bin_write()
116 spin_lock_irqsave(&eeprom->buffer_lock, flags); in i2c_slave_eeprom_bin_write()
117 memcpy(&eeprom->buffer[off], buf, count); in i2c_slave_eeprom_bin_write()
118 spin_unlock_irqrestore(&eeprom->buffer_lock, flags); in i2c_slave_eeprom_bin_write()
123 static int i2c_slave_init_eeprom_data(struct eeprom_data *eeprom, struct i2c_client *client, in i2c_slave_init_eeprom_data() argument
132 eeprom->buffer, size); in i2c_slave_init_eeprom_data()
138 memset(eeprom->buffer, 0xff, size); in i2c_slave_init_eeprom_data()
145 struct eeprom_data *eeprom; in i2c_slave_eeprom_probe() local
150 eeprom = devm_kzalloc(&client->dev, sizeof(struct eeprom_data) + size, GFP_KERNEL); in i2c_slave_eeprom_probe()
151 if (!eeprom) in i2c_slave_eeprom_probe()
154 eeprom->num_address_bytes = flag_addr16 ? 2 : 1; in i2c_slave_eeprom_probe()
155 eeprom->address_mask = size - 1; in i2c_slave_eeprom_probe()
156 eeprom->read_only = FIELD_GET(I2C_SLAVE_FLAG_RO, id->driver_data); in i2c_slave_eeprom_probe()
157 spin_lock_init(&eeprom->buffer_lock); in i2c_slave_eeprom_probe()
158 i2c_set_clientdata(client, eeprom); in i2c_slave_eeprom_probe()
160 ret = i2c_slave_init_eeprom_data(eeprom, client, size); in i2c_slave_eeprom_probe()
164 sysfs_bin_attr_init(&eeprom->bin); in i2c_slave_eeprom_probe()
165 eeprom->bin.attr.name = "slave-eeprom"; in i2c_slave_eeprom_probe()
166 eeprom->bin.attr.mode = S_IRUSR | S_IWUSR; in i2c_slave_eeprom_probe()
167 eeprom->bin.read = i2c_slave_eeprom_bin_read; in i2c_slave_eeprom_probe()
168 eeprom->bin.write = i2c_slave_eeprom_bin_write; in i2c_slave_eeprom_probe()
169 eeprom->bin.size = size; in i2c_slave_eeprom_probe()
171 ret = sysfs_create_bin_file(&client->dev.kobj, &eeprom->bin); in i2c_slave_eeprom_probe()
177 sysfs_remove_bin_file(&client->dev.kobj, &eeprom->bin); in i2c_slave_eeprom_probe()
186 struct eeprom_data *eeprom = i2c_get_clientdata(client); in i2c_slave_eeprom_remove() local
189 sysfs_remove_bin_file(&client->dev.kobj, &eeprom->bin); in i2c_slave_eeprom_remove()