Lines Matching full:cell

416 static void nvmem_cell_entry_drop(struct nvmem_cell_entry *cell)  in nvmem_cell_entry_drop()  argument
418 blocking_notifier_call_chain(&nvmem_notifier, NVMEM_CELL_REMOVE, cell); in nvmem_cell_entry_drop()
420 list_del(&cell->node); in nvmem_cell_entry_drop()
422 of_node_put(cell->np); in nvmem_cell_entry_drop()
423 kfree_const(cell->name); in nvmem_cell_entry_drop()
424 kfree(cell); in nvmem_cell_entry_drop()
429 struct nvmem_cell_entry *cell, *p; in nvmem_device_remove_all_cells() local
431 list_for_each_entry_safe(cell, p, &nvmem->cells, node) in nvmem_device_remove_all_cells()
432 nvmem_cell_entry_drop(cell); in nvmem_device_remove_all_cells()
435 static void nvmem_cell_entry_add(struct nvmem_cell_entry *cell) in nvmem_cell_entry_add() argument
438 list_add_tail(&cell->node, &cell->nvmem->cells); in nvmem_cell_entry_add()
440 blocking_notifier_call_chain(&nvmem_notifier, NVMEM_CELL_ADD, cell); in nvmem_cell_entry_add()
445 struct nvmem_cell_entry *cell) in nvmem_cell_info_to_nvmem_cell_entry_nodup() argument
447 cell->nvmem = nvmem; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
448 cell->offset = info->offset; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
449 cell->raw_len = info->raw_len ?: info->bytes; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
450 cell->bytes = info->bytes; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
451 cell->name = info->name; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
452 cell->read_post_process = info->read_post_process; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
453 cell->priv = info->priv; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
455 cell->bit_offset = info->bit_offset; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
456 cell->nbits = info->nbits; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
457 cell->np = info->np; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
459 if (cell->nbits) in nvmem_cell_info_to_nvmem_cell_entry_nodup()
460 cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset, in nvmem_cell_info_to_nvmem_cell_entry_nodup()
463 if (!IS_ALIGNED(cell->offset, nvmem->stride)) { in nvmem_cell_info_to_nvmem_cell_entry_nodup()
465 "cell %s unaligned to nvmem stride %d\n", in nvmem_cell_info_to_nvmem_cell_entry_nodup()
466 cell->name ?: "<unknown>", nvmem->stride); in nvmem_cell_info_to_nvmem_cell_entry_nodup()
475 struct nvmem_cell_entry *cell) in nvmem_cell_info_to_nvmem_cell_entry() argument
479 err = nvmem_cell_info_to_nvmem_cell_entry_nodup(nvmem, info, cell); in nvmem_cell_info_to_nvmem_cell_entry()
483 cell->name = kstrdup_const(info->name, GFP_KERNEL); in nvmem_cell_info_to_nvmem_cell_entry()
484 if (!cell->name) in nvmem_cell_info_to_nvmem_cell_entry()
491 * nvmem_add_one_cell() - Add one cell information to an nvmem device
494 * @info: nvmem cell info to add to the device
501 struct nvmem_cell_entry *cell; in nvmem_add_one_cell() local
504 cell = kzalloc(sizeof(*cell), GFP_KERNEL); in nvmem_add_one_cell()
505 if (!cell) in nvmem_add_one_cell()
508 rval = nvmem_cell_info_to_nvmem_cell_entry(nvmem, info, cell); in nvmem_add_one_cell()
510 kfree(cell); in nvmem_add_one_cell()
514 nvmem_cell_entry_add(cell); in nvmem_add_one_cell()
521 * nvmem_add_cells() - Add cell information to an nvmem device
524 * @info: nvmem cell info to add to the device
574 struct nvmem_cell_entry *cell; in nvmem_add_cells_from_table() local
583 cell = kzalloc(sizeof(*cell), GFP_KERNEL); in nvmem_add_cells_from_table()
584 if (!cell) { in nvmem_add_cells_from_table()
589 rval = nvmem_cell_info_to_nvmem_cell_entry(nvmem, info, cell); in nvmem_add_cells_from_table()
591 kfree(cell); in nvmem_add_cells_from_table()
595 nvmem_cell_entry_add(cell); in nvmem_add_cells_from_table()
608 struct nvmem_cell_entry *iter, *cell = NULL; in nvmem_find_cell_entry_by_name() local
613 cell = iter; in nvmem_find_cell_entry_by_name()
619 return cell; in nvmem_find_cell_entry_by_name()
1098 "could not increase module refcount for cell %s\n", in __nvmem_device_get()
1266 struct nvmem_cell *cell; in nvmem_create_cell() local
1269 cell = kzalloc(sizeof(*cell), GFP_KERNEL); in nvmem_create_cell()
1270 if (!cell) in nvmem_create_cell()
1276 kfree(cell); in nvmem_create_cell()
1281 cell->id = name; in nvmem_create_cell()
1282 cell->entry = entry; in nvmem_create_cell()
1283 cell->index = index; in nvmem_create_cell()
1285 return cell; in nvmem_create_cell()
1292 struct nvmem_cell *cell = ERR_PTR(-ENOENT); in nvmem_cell_get_from_lookup() local
1312 cell = ERR_CAST(nvmem); in nvmem_cell_get_from_lookup()
1320 cell = ERR_PTR(-ENOENT); in nvmem_cell_get_from_lookup()
1322 cell = nvmem_create_cell(cell_entry, con_id, 0); in nvmem_cell_get_from_lookup()
1323 if (IS_ERR(cell)) in nvmem_cell_get_from_lookup()
1331 return cell; in nvmem_cell_get_from_lookup()
1338 struct nvmem_cell_entry *iter, *cell = NULL; in nvmem_find_cell_entry_by_node() local
1343 cell = iter; in nvmem_find_cell_entry_by_node()
1349 return cell; in nvmem_find_cell_entry_by_node()
1353 * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
1355 * @np: Device tree node that uses the nvmem cell.
1356 * @id: nvmem cell name from nvmem-cell-names property, or NULL
1357 * for the cell at index 0 (the lone cell with no accompanying
1358 * nvmem-cell-names property).
1369 struct nvmem_cell *cell; in of_nvmem_cell_get() local
1375 /* if cell name exists, find index to the name */ in of_nvmem_cell_get()
1377 index = of_property_match_string(np, "nvmem-cell-names", id); in of_nvmem_cell_get()
1380 "#nvmem-cell-cells", in of_nvmem_cell_get()
1421 cell = nvmem_create_cell(cell_entry, id, cell_index); in of_nvmem_cell_get()
1422 if (IS_ERR(cell)) in of_nvmem_cell_get()
1425 return cell; in of_nvmem_cell_get()
1431 * nvmem_cell_get() - Get nvmem cell of device form a given cell name
1433 * @dev: Device that requests the nvmem cell.
1434 * @id: nvmem cell name to get (this corresponds with the name from the
1435 * nvmem-cell-names property for DT systems and with the con_id from
1444 struct nvmem_cell *cell; in nvmem_cell_get() local
1447 cell = of_nvmem_cell_get(dev->of_node, id); in nvmem_cell_get()
1448 if (!IS_ERR(cell) || PTR_ERR(cell) == -EPROBE_DEFER) in nvmem_cell_get()
1449 return cell; in nvmem_cell_get()
1452 /* NULL cell id only allowed for device tree; invalid otherwise */ in nvmem_cell_get()
1466 * devm_nvmem_cell_get() - Get nvmem cell of device form a given id
1468 * @dev: Device that requests the nvmem cell.
1469 * @id: nvmem cell name id to get.
1477 struct nvmem_cell **ptr, *cell; in devm_nvmem_cell_get() local
1483 cell = nvmem_cell_get(dev, id); in devm_nvmem_cell_get()
1484 if (!IS_ERR(cell)) { in devm_nvmem_cell_get()
1485 *ptr = cell; in devm_nvmem_cell_get()
1491 return cell; in devm_nvmem_cell_get()
1506 * devm_nvmem_cell_put() - Release previously allocated nvmem cell
1509 * @dev: Device that requests the nvmem cell.
1510 * @cell: Previously allocated nvmem cell by devm_nvmem_cell_get().
1512 void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell) in devm_nvmem_cell_put() argument
1517 devm_nvmem_cell_match, cell); in devm_nvmem_cell_put()
1524 * nvmem_cell_put() - Release previously allocated nvmem cell.
1526 * @cell: Previously allocated nvmem cell by nvmem_cell_get().
1528 void nvmem_cell_put(struct nvmem_cell *cell) in nvmem_cell_put() argument
1530 struct nvmem_device *nvmem = cell->entry->nvmem; in nvmem_cell_put()
1532 if (cell->id) in nvmem_cell_put()
1533 kfree_const(cell->id); in nvmem_cell_put()
1535 kfree(cell); in nvmem_cell_put()
1540 static void nvmem_shift_read_buffer_in_place(struct nvmem_cell_entry *cell, void *buf) in nvmem_shift_read_buffer_in_place() argument
1543 int i, extra, bit_offset = cell->bit_offset; in nvmem_shift_read_buffer_in_place()
1551 for (i = 1; i < cell->bytes; i++) { in nvmem_shift_read_buffer_in_place()
1560 p += cell->bytes - 1; in nvmem_shift_read_buffer_in_place()
1564 extra = cell->bytes - DIV_ROUND_UP(cell->nbits, BITS_PER_BYTE); in nvmem_shift_read_buffer_in_place()
1569 if (cell->nbits % BITS_PER_BYTE) in nvmem_shift_read_buffer_in_place()
1570 *p &= GENMASK((cell->nbits % BITS_PER_BYTE) - 1, 0); in nvmem_shift_read_buffer_in_place()
1574 struct nvmem_cell_entry *cell, in __nvmem_cell_read() argument
1579 rc = nvmem_reg_read(nvmem, cell->offset, buf, cell->raw_len); in __nvmem_cell_read()
1585 if (cell->bit_offset || cell->nbits) in __nvmem_cell_read()
1586 nvmem_shift_read_buffer_in_place(cell, buf); in __nvmem_cell_read()
1588 if (cell->read_post_process) { in __nvmem_cell_read()
1589 rc = cell->read_post_process(cell->priv, id, index, in __nvmem_cell_read()
1590 cell->offset, buf, cell->raw_len); in __nvmem_cell_read()
1596 *len = cell->bytes; in __nvmem_cell_read()
1602 * nvmem_cell_read() - Read a given nvmem cell
1604 * @cell: nvmem cell to be read.
1605 * @len: pointer to length of cell which will be populated on successful read;
1611 void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len) in nvmem_cell_read() argument
1613 struct nvmem_cell_entry *entry = cell->entry; in nvmem_cell_read()
1625 rc = __nvmem_cell_read(nvmem, cell->entry, buf, len, cell->id, cell->index); in nvmem_cell_read()
1635 static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell_entry *cell, in nvmem_cell_prepare_write_buffer() argument
1638 struct nvmem_device *nvmem = cell->nvmem; in nvmem_cell_prepare_write_buffer()
1639 int i, rc, nbits, bit_offset = cell->bit_offset; in nvmem_cell_prepare_write_buffer()
1642 nbits = cell->nbits; in nvmem_cell_prepare_write_buffer()
1643 buf = kzalloc(cell->bytes, GFP_KERNEL); in nvmem_cell_prepare_write_buffer()
1655 rc = nvmem_reg_read(nvmem, cell->offset, &v, 1); in nvmem_cell_prepare_write_buffer()
1661 for (i = 1; i < cell->bytes; i++) { in nvmem_cell_prepare_write_buffer()
1675 cell->offset + cell->bytes - 1, &v, 1); in nvmem_cell_prepare_write_buffer()
1688 static int __nvmem_cell_entry_write(struct nvmem_cell_entry *cell, void *buf, size_t len) in __nvmem_cell_entry_write() argument
1690 struct nvmem_device *nvmem = cell->nvmem; in __nvmem_cell_entry_write()
1694 (cell->bit_offset == 0 && len != cell->bytes)) in __nvmem_cell_entry_write()
1702 if (cell->read_post_process) in __nvmem_cell_entry_write()
1705 if (cell->bit_offset || cell->nbits) { in __nvmem_cell_entry_write()
1706 if (len != BITS_TO_BYTES(cell->nbits) && len != cell->bytes) in __nvmem_cell_entry_write()
1708 buf = nvmem_cell_prepare_write_buffer(cell, buf, len); in __nvmem_cell_entry_write()
1713 rc = nvmem_reg_write(nvmem, cell->offset, buf, cell->bytes); in __nvmem_cell_entry_write()
1716 if (cell->bit_offset || cell->nbits) in __nvmem_cell_entry_write()
1726 * nvmem_cell_write() - Write to a given nvmem cell
1728 * @cell: nvmem cell to be written.
1730 * @len: length of buffer to be written to nvmem cell.
1734 int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len) in nvmem_cell_write() argument
1736 return __nvmem_cell_entry_write(cell->entry, buf, len); in nvmem_cell_write()
1744 struct nvmem_cell *cell; in nvmem_cell_read_common() local
1748 cell = nvmem_cell_get(dev, cell_id); in nvmem_cell_read_common()
1749 if (IS_ERR(cell)) in nvmem_cell_read_common()
1750 return PTR_ERR(cell); in nvmem_cell_read_common()
1752 buf = nvmem_cell_read(cell, &len); in nvmem_cell_read_common()
1754 nvmem_cell_put(cell); in nvmem_cell_read_common()
1759 nvmem_cell_put(cell); in nvmem_cell_read_common()
1764 nvmem_cell_put(cell); in nvmem_cell_read_common()
1770 * nvmem_cell_read_u8() - Read a cell value as a u8
1772 * @dev: Device that requests the nvmem cell.
1773 * @cell_id: Name of nvmem cell to read.
1785 * nvmem_cell_read_u16() - Read a cell value as a u16
1787 * @dev: Device that requests the nvmem cell.
1788 * @cell_id: Name of nvmem cell to read.
1800 * nvmem_cell_read_u32() - Read a cell value as a u32
1802 * @dev: Device that requests the nvmem cell.
1803 * @cell_id: Name of nvmem cell to read.
1815 * nvmem_cell_read_u64() - Read a cell value as a u64
1817 * @dev: Device that requests the nvmem cell.
1818 * @cell_id: Name of nvmem cell to read.
1833 struct nvmem_cell *cell; in nvmem_cell_read_variable_common() local
1837 cell = nvmem_cell_get(dev, cell_id); in nvmem_cell_read_variable_common()
1838 if (IS_ERR(cell)) in nvmem_cell_read_variable_common()
1839 return cell; in nvmem_cell_read_variable_common()
1841 nbits = cell->entry->nbits; in nvmem_cell_read_variable_common()
1842 buf = nvmem_cell_read(cell, len); in nvmem_cell_read_variable_common()
1843 nvmem_cell_put(cell); in nvmem_cell_read_variable_common()
1865 * @dev: Device that requests the nvmem cell.
1866 * @cell_id: Name of nvmem cell to read.
1896 * @dev: Device that requests the nvmem cell.
1897 * @cell_id: Name of nvmem cell to read.
1925 * nvmem_device_cell_read() - Read a given nvmem device and cell
1928 * @info: nvmem cell info to be read.
1937 struct nvmem_cell_entry cell; in nvmem_device_cell_read() local
1944 rc = nvmem_cell_info_to_nvmem_cell_entry_nodup(nvmem, info, &cell); in nvmem_device_cell_read()
1948 rc = __nvmem_cell_read(nvmem, &cell, buf, &len, NULL, 0); in nvmem_device_cell_read()
1957 * nvmem_device_cell_write() - Write cell to a given nvmem device
1960 * @info: nvmem cell info to be written.
1961 * @buf: buffer to be written to cell.
1968 struct nvmem_cell_entry cell; in nvmem_device_cell_write() local
1974 rc = nvmem_cell_info_to_nvmem_cell_entry_nodup(nvmem, info, &cell); in nvmem_device_cell_write()
1978 return __nvmem_cell_entry_write(&cell, buf, cell.bytes); in nvmem_device_cell_write()
2012 * nvmem_device_write() - Write cell to a given nvmem device
2041 * nvmem_add_cell_table() - register a table of cell info entries
2043 * @table: table of cell info entries
2054 * nvmem_del_cell_table() - remove a previously registered cell info table
2056 * @table: table of cell info entries
2067 * nvmem_add_cell_lookups() - register a list of cell lookup entries
2069 * @entries: array of cell lookup entries
2070 * @nentries: number of cell lookup entries in the array
2084 * nvmem_del_cell_lookups() - remove a list of previously added cell lookup
2087 * @entries: array of cell lookup entries
2088 * @nentries: number of cell lookup entries in the array