Lines Matching refs:cell

433 static void nvmem_cell_entry_drop(struct nvmem_cell_entry *cell)  in nvmem_cell_entry_drop()  argument
435 blocking_notifier_call_chain(&nvmem_notifier, NVMEM_CELL_REMOVE, cell); in nvmem_cell_entry_drop()
437 list_del(&cell->node); in nvmem_cell_entry_drop()
439 of_node_put(cell->np); in nvmem_cell_entry_drop()
440 kfree_const(cell->name); in nvmem_cell_entry_drop()
441 kfree(cell); in nvmem_cell_entry_drop()
446 struct nvmem_cell_entry *cell, *p; in nvmem_device_remove_all_cells() local
448 list_for_each_entry_safe(cell, p, &nvmem->cells, node) in nvmem_device_remove_all_cells()
449 nvmem_cell_entry_drop(cell); in nvmem_device_remove_all_cells()
452 static void nvmem_cell_entry_add(struct nvmem_cell_entry *cell) in nvmem_cell_entry_add() argument
455 list_add_tail(&cell->node, &cell->nvmem->cells); in nvmem_cell_entry_add()
457 blocking_notifier_call_chain(&nvmem_notifier, NVMEM_CELL_ADD, cell); in nvmem_cell_entry_add()
462 struct nvmem_cell_entry *cell) in nvmem_cell_info_to_nvmem_cell_entry_nodup() argument
464 cell->nvmem = nvmem; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
465 cell->offset = info->offset; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
466 cell->bytes = info->bytes; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
467 cell->name = info->name; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
469 cell->bit_offset = info->bit_offset; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
470 cell->nbits = info->nbits; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
471 cell->np = info->np; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
473 if (cell->nbits) in nvmem_cell_info_to_nvmem_cell_entry_nodup()
474 cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset, in nvmem_cell_info_to_nvmem_cell_entry_nodup()
477 if (!IS_ALIGNED(cell->offset, nvmem->stride)) { in nvmem_cell_info_to_nvmem_cell_entry_nodup()
480 cell->name ?: "<unknown>", nvmem->stride); in nvmem_cell_info_to_nvmem_cell_entry_nodup()
489 struct nvmem_cell_entry *cell) in nvmem_cell_info_to_nvmem_cell_entry() argument
493 err = nvmem_cell_info_to_nvmem_cell_entry_nodup(nvmem, info, cell); in nvmem_cell_info_to_nvmem_cell_entry()
497 cell->name = kstrdup_const(info->name, GFP_KERNEL); in nvmem_cell_info_to_nvmem_cell_entry()
498 if (!cell->name) in nvmem_cell_info_to_nvmem_cell_entry()
515 struct nvmem_cell_entry *cell; in nvmem_add_one_cell() local
518 cell = kzalloc(sizeof(*cell), GFP_KERNEL); in nvmem_add_one_cell()
519 if (!cell) in nvmem_add_one_cell()
522 rval = nvmem_cell_info_to_nvmem_cell_entry(nvmem, info, cell); in nvmem_add_one_cell()
524 kfree(cell); in nvmem_add_one_cell()
528 nvmem_cell_entry_add(cell); in nvmem_add_one_cell()
588 struct nvmem_cell_entry *cell; in nvmem_add_cells_from_table() local
597 cell = kzalloc(sizeof(*cell), GFP_KERNEL); in nvmem_add_cells_from_table()
598 if (!cell) { in nvmem_add_cells_from_table()
603 rval = nvmem_cell_info_to_nvmem_cell_entry(nvmem, info, cell); in nvmem_add_cells_from_table()
605 kfree(cell); in nvmem_add_cells_from_table()
609 nvmem_cell_entry_add(cell); in nvmem_add_cells_from_table()
622 struct nvmem_cell_entry *iter, *cell = NULL; in nvmem_find_cell_entry_by_name() local
627 cell = iter; in nvmem_find_cell_entry_by_name()
633 return cell; in nvmem_find_cell_entry_by_name()
1117 struct nvmem_cell *cell; in nvmem_create_cell() local
1120 cell = kzalloc(sizeof(*cell), GFP_KERNEL); in nvmem_create_cell()
1121 if (!cell) in nvmem_create_cell()
1127 kfree(cell); in nvmem_create_cell()
1132 cell->id = name; in nvmem_create_cell()
1133 cell->entry = entry; in nvmem_create_cell()
1134 cell->index = index; in nvmem_create_cell()
1136 return cell; in nvmem_create_cell()
1143 struct nvmem_cell *cell = ERR_PTR(-ENOENT); in nvmem_cell_get_from_lookup() local
1163 cell = ERR_CAST(nvmem); in nvmem_cell_get_from_lookup()
1171 cell = ERR_PTR(-ENOENT); in nvmem_cell_get_from_lookup()
1173 cell = nvmem_create_cell(cell_entry, con_id, 0); in nvmem_cell_get_from_lookup()
1174 if (IS_ERR(cell)) in nvmem_cell_get_from_lookup()
1182 return cell; in nvmem_cell_get_from_lookup()
1189 struct nvmem_cell_entry *iter, *cell = NULL; in nvmem_find_cell_entry_by_node() local
1194 cell = iter; in nvmem_find_cell_entry_by_node()
1200 return cell; in nvmem_find_cell_entry_by_node()
1220 struct nvmem_cell *cell; in of_nvmem_cell_get() local
1263 cell = nvmem_create_cell(cell_entry, id, cell_index); in of_nvmem_cell_get()
1264 if (IS_ERR(cell)) in of_nvmem_cell_get()
1267 return cell; in of_nvmem_cell_get()
1286 struct nvmem_cell *cell; in nvmem_cell_get() local
1289 cell = of_nvmem_cell_get(dev->of_node, id); in nvmem_cell_get()
1290 if (!IS_ERR(cell) || PTR_ERR(cell) == -EPROBE_DEFER) in nvmem_cell_get()
1291 return cell; in nvmem_cell_get()
1319 struct nvmem_cell **ptr, *cell; in devm_nvmem_cell_get() local
1325 cell = nvmem_cell_get(dev, id); in devm_nvmem_cell_get()
1326 if (!IS_ERR(cell)) { in devm_nvmem_cell_get()
1327 *ptr = cell; in devm_nvmem_cell_get()
1333 return cell; in devm_nvmem_cell_get()
1354 void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell) in devm_nvmem_cell_put() argument
1359 devm_nvmem_cell_match, cell); in devm_nvmem_cell_put()
1370 void nvmem_cell_put(struct nvmem_cell *cell) in nvmem_cell_put() argument
1372 struct nvmem_device *nvmem = cell->entry->nvmem; in nvmem_cell_put()
1374 if (cell->id) in nvmem_cell_put()
1375 kfree_const(cell->id); in nvmem_cell_put()
1377 kfree(cell); in nvmem_cell_put()
1382 static void nvmem_shift_read_buffer_in_place(struct nvmem_cell_entry *cell, void *buf) in nvmem_shift_read_buffer_in_place() argument
1385 int i, extra, bit_offset = cell->bit_offset; in nvmem_shift_read_buffer_in_place()
1393 for (i = 1; i < cell->bytes; i++) { in nvmem_shift_read_buffer_in_place()
1402 p += cell->bytes - 1; in nvmem_shift_read_buffer_in_place()
1406 extra = cell->bytes - DIV_ROUND_UP(cell->nbits, BITS_PER_BYTE); in nvmem_shift_read_buffer_in_place()
1411 if (cell->nbits % BITS_PER_BYTE) in nvmem_shift_read_buffer_in_place()
1412 *p &= GENMASK((cell->nbits % BITS_PER_BYTE) - 1, 0); in nvmem_shift_read_buffer_in_place()
1416 struct nvmem_cell_entry *cell, in __nvmem_cell_read() argument
1421 rc = nvmem_reg_read(nvmem, cell->offset, buf, cell->bytes); in __nvmem_cell_read()
1427 if (cell->bit_offset || cell->nbits) in __nvmem_cell_read()
1428 nvmem_shift_read_buffer_in_place(cell, buf); in __nvmem_cell_read()
1432 cell->offset, buf, cell->bytes); in __nvmem_cell_read()
1438 *len = cell->bytes; in __nvmem_cell_read()
1453 void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len) in nvmem_cell_read() argument
1455 struct nvmem_device *nvmem = cell->entry->nvmem; in nvmem_cell_read()
1462 buf = kzalloc(cell->entry->bytes, GFP_KERNEL); in nvmem_cell_read()
1466 rc = __nvmem_cell_read(nvmem, cell->entry, buf, len, cell->id, cell->index); in nvmem_cell_read()
1476 static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell_entry *cell, in nvmem_cell_prepare_write_buffer() argument
1479 struct nvmem_device *nvmem = cell->nvmem; in nvmem_cell_prepare_write_buffer()
1480 int i, rc, nbits, bit_offset = cell->bit_offset; in nvmem_cell_prepare_write_buffer()
1483 nbits = cell->nbits; in nvmem_cell_prepare_write_buffer()
1484 buf = kzalloc(cell->bytes, GFP_KERNEL); in nvmem_cell_prepare_write_buffer()
1496 rc = nvmem_reg_read(nvmem, cell->offset, &v, 1); in nvmem_cell_prepare_write_buffer()
1502 for (i = 1; i < cell->bytes; i++) { in nvmem_cell_prepare_write_buffer()
1516 cell->offset + cell->bytes - 1, &v, 1); in nvmem_cell_prepare_write_buffer()
1529 static int __nvmem_cell_entry_write(struct nvmem_cell_entry *cell, void *buf, size_t len) in __nvmem_cell_entry_write() argument
1531 struct nvmem_device *nvmem = cell->nvmem; in __nvmem_cell_entry_write()
1535 (cell->bit_offset == 0 && len != cell->bytes)) in __nvmem_cell_entry_write()
1538 if (cell->bit_offset || cell->nbits) { in __nvmem_cell_entry_write()
1539 buf = nvmem_cell_prepare_write_buffer(cell, buf, len); in __nvmem_cell_entry_write()
1544 rc = nvmem_reg_write(nvmem, cell->offset, buf, cell->bytes); in __nvmem_cell_entry_write()
1547 if (cell->bit_offset || cell->nbits) in __nvmem_cell_entry_write()
1565 int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len) in nvmem_cell_write() argument
1567 return __nvmem_cell_entry_write(cell->entry, buf, len); in nvmem_cell_write()
1575 struct nvmem_cell *cell; in nvmem_cell_read_common() local
1579 cell = nvmem_cell_get(dev, cell_id); in nvmem_cell_read_common()
1580 if (IS_ERR(cell)) in nvmem_cell_read_common()
1581 return PTR_ERR(cell); in nvmem_cell_read_common()
1583 buf = nvmem_cell_read(cell, &len); in nvmem_cell_read_common()
1585 nvmem_cell_put(cell); in nvmem_cell_read_common()
1590 nvmem_cell_put(cell); in nvmem_cell_read_common()
1595 nvmem_cell_put(cell); in nvmem_cell_read_common()
1664 struct nvmem_cell *cell; in nvmem_cell_read_variable_common() local
1668 cell = nvmem_cell_get(dev, cell_id); in nvmem_cell_read_variable_common()
1669 if (IS_ERR(cell)) in nvmem_cell_read_variable_common()
1670 return cell; in nvmem_cell_read_variable_common()
1672 nbits = cell->entry->nbits; in nvmem_cell_read_variable_common()
1673 buf = nvmem_cell_read(cell, len); in nvmem_cell_read_variable_common()
1674 nvmem_cell_put(cell); in nvmem_cell_read_variable_common()
1768 struct nvmem_cell_entry cell; in nvmem_device_cell_read() local
1775 rc = nvmem_cell_info_to_nvmem_cell_entry_nodup(nvmem, info, &cell); in nvmem_device_cell_read()
1779 rc = __nvmem_cell_read(nvmem, &cell, buf, &len, NULL, 0); in nvmem_device_cell_read()
1799 struct nvmem_cell_entry cell; in nvmem_device_cell_write() local
1805 rc = nvmem_cell_info_to_nvmem_cell_entry_nodup(nvmem, info, &cell); in nvmem_device_cell_write()
1809 return __nvmem_cell_entry_write(&cell, buf, cell.bytes); in nvmem_device_cell_write()