Lines Matching full:cell

344 	struct nvmem_cell *cell = NULL;  in nvmem_cell_attr_read()  local
349 cell = nvmem_create_cell(entry, entry->name, 0); in nvmem_cell_attr_read()
350 if (IS_ERR(cell)) in nvmem_cell_attr_read()
351 return PTR_ERR(cell); in nvmem_cell_attr_read()
353 if (!cell) in nvmem_cell_attr_read()
356 content = nvmem_cell_read(cell, &cell_sz); in nvmem_cell_attr_read()
367 kfree_const(cell->id); in nvmem_cell_attr_read()
368 kfree(cell); in nvmem_cell_attr_read()
486 /* Initialize each attribute to take the name and size of the cell */ in nvmem_populate_sysfs_cells()
551 static void nvmem_cell_entry_drop(struct nvmem_cell_entry *cell) in nvmem_cell_entry_drop() argument
553 blocking_notifier_call_chain(&nvmem_notifier, NVMEM_CELL_REMOVE, cell); in nvmem_cell_entry_drop()
555 list_del(&cell->node); in nvmem_cell_entry_drop()
557 of_node_put(cell->np); in nvmem_cell_entry_drop()
558 kfree_const(cell->name); in nvmem_cell_entry_drop()
559 kfree(cell); in nvmem_cell_entry_drop()
564 struct nvmem_cell_entry *cell, *p; in nvmem_device_remove_all_cells() local
566 list_for_each_entry_safe(cell, p, &nvmem->cells, node) in nvmem_device_remove_all_cells()
567 nvmem_cell_entry_drop(cell); in nvmem_device_remove_all_cells()
570 static void nvmem_cell_entry_add(struct nvmem_cell_entry *cell) in nvmem_cell_entry_add() argument
573 list_add_tail(&cell->node, &cell->nvmem->cells); in nvmem_cell_entry_add()
575 blocking_notifier_call_chain(&nvmem_notifier, NVMEM_CELL_ADD, cell); in nvmem_cell_entry_add()
580 struct nvmem_cell_entry *cell) in nvmem_cell_info_to_nvmem_cell_entry_nodup() argument
582 cell->nvmem = nvmem; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
583 cell->offset = info->offset; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
584 cell->raw_len = info->raw_len ?: info->bytes; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
585 cell->bytes = info->bytes; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
586 cell->name = info->name; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
587 cell->read_post_process = info->read_post_process; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
588 cell->priv = info->priv; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
590 cell->bit_offset = info->bit_offset; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
591 cell->nbits = info->nbits; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
592 cell->np = info->np; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
594 if (cell->nbits) { in nvmem_cell_info_to_nvmem_cell_entry_nodup()
595 cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset, in nvmem_cell_info_to_nvmem_cell_entry_nodup()
597 cell->raw_len = ALIGN(cell->bytes, nvmem->word_size); in nvmem_cell_info_to_nvmem_cell_entry_nodup()
600 if (!IS_ALIGNED(cell->offset, nvmem->stride)) { in nvmem_cell_info_to_nvmem_cell_entry_nodup()
602 "cell %s unaligned to nvmem stride %d\n", in nvmem_cell_info_to_nvmem_cell_entry_nodup()
603 cell->name ?: "<unknown>", nvmem->stride); in nvmem_cell_info_to_nvmem_cell_entry_nodup()
607 if (!IS_ALIGNED(cell->raw_len, nvmem->word_size)) { in nvmem_cell_info_to_nvmem_cell_entry_nodup()
609 "cell %s raw len %zd unaligned to nvmem word size %d\n", in nvmem_cell_info_to_nvmem_cell_entry_nodup()
610 cell->name ?: "<unknown>", cell->raw_len, in nvmem_cell_info_to_nvmem_cell_entry_nodup()
616 cell->raw_len = ALIGN(cell->raw_len, nvmem->word_size); in nvmem_cell_info_to_nvmem_cell_entry_nodup()
624 struct nvmem_cell_entry *cell) in nvmem_cell_info_to_nvmem_cell_entry() argument
628 err = nvmem_cell_info_to_nvmem_cell_entry_nodup(nvmem, info, cell); in nvmem_cell_info_to_nvmem_cell_entry()
632 cell->name = kstrdup_const(info->name, GFP_KERNEL); in nvmem_cell_info_to_nvmem_cell_entry()
633 if (!cell->name) in nvmem_cell_info_to_nvmem_cell_entry()
640 * nvmem_add_one_cell() - Add one cell information to an nvmem device
643 * @info: nvmem cell info to add to the device
650 struct nvmem_cell_entry *cell; in nvmem_add_one_cell() local
653 cell = kzalloc_obj(*cell); in nvmem_add_one_cell()
654 if (!cell) in nvmem_add_one_cell()
657 rval = nvmem_cell_info_to_nvmem_cell_entry(nvmem, info, cell); in nvmem_add_one_cell()
659 kfree(cell); in nvmem_add_one_cell()
663 nvmem_cell_entry_add(cell); in nvmem_add_one_cell()
670 * nvmem_add_cells() - Add cell information to an nvmem device
673 * @info: nvmem cell info to add to the device
722 struct nvmem_cell_entry *iter, *cell = NULL; in nvmem_find_cell_entry_by_name() local
727 cell = iter; in nvmem_find_cell_entry_by_name()
733 return cell; in nvmem_find_cell_entry_by_name()
1127 "could not increase module refcount for cell %s\n", in __nvmem_device_get()
1295 struct nvmem_cell *cell; in nvmem_create_cell() local
1298 cell = kzalloc_obj(*cell); in nvmem_create_cell()
1299 if (!cell) in nvmem_create_cell()
1305 kfree(cell); in nvmem_create_cell()
1310 cell->id = name; in nvmem_create_cell()
1311 cell->entry = entry; in nvmem_create_cell()
1312 cell->index = index; in nvmem_create_cell()
1314 return cell; in nvmem_create_cell()
1321 struct nvmem_cell *cell = ERR_PTR(-ENOENT); in nvmem_cell_get_from_lookup() local
1341 cell = ERR_CAST(nvmem); in nvmem_cell_get_from_lookup()
1349 cell = ERR_PTR(-ENOENT); in nvmem_cell_get_from_lookup()
1351 cell = nvmem_create_cell(cell_entry, con_id, 0); in nvmem_cell_get_from_lookup()
1352 if (IS_ERR(cell)) in nvmem_cell_get_from_lookup()
1360 return cell; in nvmem_cell_get_from_lookup()
1373 struct nvmem_cell_entry *iter, *cell = NULL; in nvmem_find_cell_entry_by_node() local
1378 cell = iter; in nvmem_find_cell_entry_by_node()
1384 return cell; in nvmem_find_cell_entry_by_node()
1400 * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
1402 * @np: Device tree node that uses the nvmem cell.
1403 * @id: nvmem cell name from nvmem-cell-names property, or NULL
1404 * for the cell at index 0 (the lone cell with no accompanying
1405 * nvmem-cell-names property).
1416 struct nvmem_cell *cell; in of_nvmem_cell_get() local
1422 /* if cell name exists, find index to the name */ in of_nvmem_cell_get()
1424 index = of_property_match_string(np, "nvmem-cell-names", id); in of_nvmem_cell_get()
1427 "#nvmem-cell-cells", in of_nvmem_cell_get()
1479 cell = nvmem_create_cell(cell_entry, id, cell_index); in of_nvmem_cell_get()
1480 if (IS_ERR(cell)) { in of_nvmem_cell_get()
1485 return cell; in of_nvmem_cell_get()
1491 * nvmem_cell_get() - Get nvmem cell of device from a given cell name
1493 * @dev: Device that requests the nvmem cell.
1494 * @id: nvmem cell name to get (this corresponds with the name from the
1495 * nvmem-cell-names property for DT systems and with the con_id from
1504 struct nvmem_cell *cell; in nvmem_cell_get() local
1507 cell = of_nvmem_cell_get(dev->of_node, id); in nvmem_cell_get()
1508 if (!IS_ERR(cell) || PTR_ERR(cell) == -EPROBE_DEFER) in nvmem_cell_get()
1509 return cell; in nvmem_cell_get()
1512 /* NULL cell id only allowed for device tree; invalid otherwise */ in nvmem_cell_get()
1526 * devm_nvmem_cell_get() - Get nvmem cell of device from a given id
1528 * @dev: Device that requests the nvmem cell.
1529 * @id: nvmem cell name id to get.
1537 struct nvmem_cell **ptr, *cell; in devm_nvmem_cell_get() local
1543 cell = nvmem_cell_get(dev, id); in devm_nvmem_cell_get()
1544 if (!IS_ERR(cell)) { in devm_nvmem_cell_get()
1545 *ptr = cell; in devm_nvmem_cell_get()
1551 return cell; in devm_nvmem_cell_get()
1566 * devm_nvmem_cell_put() - Release previously allocated nvmem cell
1569 * @dev: Device that requests the nvmem cell.
1570 * @cell: Previously allocated nvmem cell by devm_nvmem_cell_get().
1572 void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell) in devm_nvmem_cell_put() argument
1577 devm_nvmem_cell_match, cell); in devm_nvmem_cell_put()
1584 * nvmem_cell_put() - Release previously allocated nvmem cell.
1586 * @cell: Previously allocated nvmem cell by nvmem_cell_get().
1588 void nvmem_cell_put(struct nvmem_cell *cell) in nvmem_cell_put() argument
1590 struct nvmem_device *nvmem = cell->entry->nvmem; in nvmem_cell_put()
1592 if (cell->id) in nvmem_cell_put()
1593 kfree_const(cell->id); in nvmem_cell_put()
1595 kfree(cell); in nvmem_cell_put()
1601 static void nvmem_shift_read_buffer_in_place(struct nvmem_cell_entry *cell, void *buf) in nvmem_shift_read_buffer_in_place() argument
1605 int bit_offset = cell->bit_offset; in nvmem_shift_read_buffer_in_place()
1618 for (i = 1; i < cell->bytes; i++) { in nvmem_shift_read_buffer_in_place()
1625 memmove(p, b, cell->bytes - bytes_offset); in nvmem_shift_read_buffer_in_place()
1626 p += cell->bytes - 1; in nvmem_shift_read_buffer_in_place()
1629 p += cell->bytes - 1; in nvmem_shift_read_buffer_in_place()
1633 extra = cell->bytes - DIV_ROUND_UP(cell->nbits, BITS_PER_BYTE); in nvmem_shift_read_buffer_in_place()
1638 if (cell->nbits % BITS_PER_BYTE) in nvmem_shift_read_buffer_in_place()
1639 *p &= GENMASK((cell->nbits % BITS_PER_BYTE) - 1, 0); in nvmem_shift_read_buffer_in_place()
1643 struct nvmem_cell_entry *cell, in __nvmem_cell_read() argument
1648 rc = nvmem_reg_read(nvmem, cell->offset, buf, cell->raw_len); in __nvmem_cell_read()
1654 if (cell->bit_offset || cell->nbits) in __nvmem_cell_read()
1655 nvmem_shift_read_buffer_in_place(cell, buf); in __nvmem_cell_read()
1657 if (cell->read_post_process) { in __nvmem_cell_read()
1658 rc = cell->read_post_process(cell->priv, id, index, in __nvmem_cell_read()
1659 cell->offset, buf, cell->raw_len); in __nvmem_cell_read()
1665 *len = cell->bytes; in __nvmem_cell_read()
1671 * nvmem_cell_read() - Read a given nvmem cell
1673 * @cell: nvmem cell to be read.
1674 * @len: pointer to length of cell which will be populated on successful read;
1680 void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len) in nvmem_cell_read() argument
1682 struct nvmem_cell_entry *entry = cell->entry; in nvmem_cell_read()
1694 rc = __nvmem_cell_read(nvmem, cell->entry, buf, len, cell->id, cell->index); in nvmem_cell_read()
1704 static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell_entry *cell, in nvmem_cell_prepare_write_buffer() argument
1707 struct nvmem_device *nvmem = cell->nvmem; in nvmem_cell_prepare_write_buffer()
1708 int i, rc, nbits, bit_offset = cell->bit_offset; in nvmem_cell_prepare_write_buffer()
1711 nbits = cell->nbits; in nvmem_cell_prepare_write_buffer()
1712 buf = kzalloc(cell->bytes, GFP_KERNEL); in nvmem_cell_prepare_write_buffer()
1724 rc = nvmem_reg_read(nvmem, cell->offset, &v, 1); in nvmem_cell_prepare_write_buffer()
1730 for (i = 1; i < cell->bytes; i++) { in nvmem_cell_prepare_write_buffer()
1744 cell->offset + cell->bytes - 1, &v, 1); in nvmem_cell_prepare_write_buffer()
1757 static int __nvmem_cell_entry_write(struct nvmem_cell_entry *cell, void *buf, size_t len) in __nvmem_cell_entry_write() argument
1759 struct nvmem_device *nvmem = cell->nvmem; in __nvmem_cell_entry_write()
1763 (cell->bit_offset == 0 && len != cell->bytes)) in __nvmem_cell_entry_write()
1771 if (cell->read_post_process) in __nvmem_cell_entry_write()
1774 if (cell->bit_offset || cell->nbits) { in __nvmem_cell_entry_write()
1775 if (len != BITS_TO_BYTES(cell->nbits) && len != cell->bytes) in __nvmem_cell_entry_write()
1777 buf = nvmem_cell_prepare_write_buffer(cell, buf, len); in __nvmem_cell_entry_write()
1782 rc = nvmem_reg_write(nvmem, cell->offset, buf, cell->bytes); in __nvmem_cell_entry_write()
1785 if (cell->bit_offset || cell->nbits) in __nvmem_cell_entry_write()
1795 * nvmem_cell_write() - Write to a given nvmem cell
1797 * @cell: nvmem cell to be written.
1799 * @len: length of buffer to be written to nvmem cell.
1803 int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len) in nvmem_cell_write() argument
1805 return __nvmem_cell_entry_write(cell->entry, buf, len); in nvmem_cell_write()
1813 struct nvmem_cell *cell; in nvmem_cell_read_common() local
1817 cell = nvmem_cell_get(dev, cell_id); in nvmem_cell_read_common()
1818 if (IS_ERR(cell)) in nvmem_cell_read_common()
1819 return PTR_ERR(cell); in nvmem_cell_read_common()
1821 buf = nvmem_cell_read(cell, &len); in nvmem_cell_read_common()
1823 nvmem_cell_put(cell); in nvmem_cell_read_common()
1828 nvmem_cell_put(cell); in nvmem_cell_read_common()
1833 nvmem_cell_put(cell); in nvmem_cell_read_common()
1839 * nvmem_cell_read_u8() - Read a cell value as a u8
1841 * @dev: Device that requests the nvmem cell.
1842 * @cell_id: Name of nvmem cell to read.
1854 * nvmem_cell_read_u16() - Read a cell value as a u16
1856 * @dev: Device that requests the nvmem cell.
1857 * @cell_id: Name of nvmem cell to read.
1869 * nvmem_cell_read_u32() - Read a cell value as a u32
1871 * @dev: Device that requests the nvmem cell.
1872 * @cell_id: Name of nvmem cell to read.
1884 * nvmem_cell_read_u64() - Read a cell value as a u64
1886 * @dev: Device that requests the nvmem cell.
1887 * @cell_id: Name of nvmem cell to read.
1902 struct nvmem_cell *cell; in nvmem_cell_read_variable_common() local
1906 cell = nvmem_cell_get(dev, cell_id); in nvmem_cell_read_variable_common()
1907 if (IS_ERR(cell)) in nvmem_cell_read_variable_common()
1908 return cell; in nvmem_cell_read_variable_common()
1910 nbits = cell->entry->nbits; in nvmem_cell_read_variable_common()
1911 buf = nvmem_cell_read(cell, len); in nvmem_cell_read_variable_common()
1912 nvmem_cell_put(cell); in nvmem_cell_read_variable_common()
1934 * @dev: Device that requests the nvmem cell.
1935 * @cell_id: Name of nvmem cell to read.
1965 * @dev: Device that requests the nvmem cell.
1966 * @cell_id: Name of nvmem cell to read.
1994 * nvmem_device_cell_read() - Read a given nvmem device and cell
1997 * @info: nvmem cell info to be read.
2006 struct nvmem_cell_entry cell; in nvmem_device_cell_read() local
2013 rc = nvmem_cell_info_to_nvmem_cell_entry_nodup(nvmem, info, &cell); in nvmem_device_cell_read()
2017 rc = __nvmem_cell_read(nvmem, &cell, buf, &len, NULL, 0); in nvmem_device_cell_read()
2026 * nvmem_device_cell_write() - Write cell to a given nvmem device
2029 * @info: nvmem cell info to be written.
2030 * @buf: buffer to be written to cell.
2037 struct nvmem_cell_entry cell; in nvmem_device_cell_write() local
2043 rc = nvmem_cell_info_to_nvmem_cell_entry_nodup(nvmem, info, &cell); in nvmem_device_cell_write()
2047 return __nvmem_cell_entry_write(&cell, buf, cell.bytes); in nvmem_device_cell_write()
2081 * nvmem_device_write() - Write cell to a given nvmem device
2110 * nvmem_add_cell_lookups() - register a list of cell lookup entries
2112 * @entries: array of cell lookup entries
2113 * @nentries: number of cell lookup entries in the array
2127 * nvmem_del_cell_lookups() - remove a list of previously added cell lookup
2130 * @entries: array of cell lookup entries
2131 * @nentries: number of cell lookup entries in the array