Lines Matching full:cell

347 	struct nvmem_cell *cell = NULL;  in nvmem_cell_attr_read()  local
352 cell = nvmem_create_cell(entry, entry->name, 0); in nvmem_cell_attr_read()
353 if (IS_ERR(cell)) in nvmem_cell_attr_read()
354 return PTR_ERR(cell); in nvmem_cell_attr_read()
356 if (!cell) in nvmem_cell_attr_read()
359 content = nvmem_cell_read(cell, &cell_sz); in nvmem_cell_attr_read()
370 kfree_const(cell->id); in nvmem_cell_attr_read()
371 kfree(cell); in nvmem_cell_attr_read()
489 /* Initialize each attribute to take the name and size of the cell */ in nvmem_populate_sysfs_cells()
554 static void nvmem_cell_entry_drop(struct nvmem_cell_entry *cell) in nvmem_cell_entry_drop() argument
556 blocking_notifier_call_chain(&nvmem_notifier, NVMEM_CELL_REMOVE, cell); in nvmem_cell_entry_drop()
558 list_del(&cell->node); in nvmem_cell_entry_drop()
560 of_node_put(cell->np); in nvmem_cell_entry_drop()
561 kfree_const(cell->name); in nvmem_cell_entry_drop()
562 kfree(cell); in nvmem_cell_entry_drop()
567 struct nvmem_cell_entry *cell, *p; in nvmem_device_remove_all_cells() local
569 list_for_each_entry_safe(cell, p, &nvmem->cells, node) in nvmem_device_remove_all_cells()
570 nvmem_cell_entry_drop(cell); in nvmem_device_remove_all_cells()
573 static void nvmem_cell_entry_add(struct nvmem_cell_entry *cell) in nvmem_cell_entry_add() argument
576 list_add_tail(&cell->node, &cell->nvmem->cells); in nvmem_cell_entry_add()
578 blocking_notifier_call_chain(&nvmem_notifier, NVMEM_CELL_ADD, cell); in nvmem_cell_entry_add()
583 struct nvmem_cell_entry *cell) in nvmem_cell_info_to_nvmem_cell_entry_nodup() argument
585 cell->nvmem = nvmem; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
586 cell->offset = info->offset; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
587 cell->raw_len = info->raw_len ?: info->bytes; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
588 cell->bytes = info->bytes; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
589 cell->name = info->name; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
590 cell->read_post_process = info->read_post_process; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
591 cell->priv = info->priv; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
593 cell->bit_offset = info->bit_offset; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
594 cell->nbits = info->nbits; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
595 cell->np = info->np; in nvmem_cell_info_to_nvmem_cell_entry_nodup()
597 if (cell->nbits) { in nvmem_cell_info_to_nvmem_cell_entry_nodup()
598 cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset, in nvmem_cell_info_to_nvmem_cell_entry_nodup()
600 cell->raw_len = ALIGN(cell->bytes, nvmem->word_size); in nvmem_cell_info_to_nvmem_cell_entry_nodup()
603 if (!IS_ALIGNED(cell->offset, nvmem->stride)) { in nvmem_cell_info_to_nvmem_cell_entry_nodup()
605 "cell %s unaligned to nvmem stride %d\n", in nvmem_cell_info_to_nvmem_cell_entry_nodup()
606 cell->name ?: "<unknown>", nvmem->stride); in nvmem_cell_info_to_nvmem_cell_entry_nodup()
610 if (!IS_ALIGNED(cell->raw_len, nvmem->word_size)) { in nvmem_cell_info_to_nvmem_cell_entry_nodup()
612 "cell %s raw len %zd unaligned to nvmem word size %d\n", in nvmem_cell_info_to_nvmem_cell_entry_nodup()
613 cell->name ?: "<unknown>", cell->raw_len, in nvmem_cell_info_to_nvmem_cell_entry_nodup()
619 cell->raw_len = ALIGN(cell->raw_len, nvmem->word_size); in nvmem_cell_info_to_nvmem_cell_entry_nodup()
627 struct nvmem_cell_entry *cell) in nvmem_cell_info_to_nvmem_cell_entry() argument
631 err = nvmem_cell_info_to_nvmem_cell_entry_nodup(nvmem, info, cell); in nvmem_cell_info_to_nvmem_cell_entry()
635 cell->name = kstrdup_const(info->name, GFP_KERNEL); in nvmem_cell_info_to_nvmem_cell_entry()
636 if (!cell->name) in nvmem_cell_info_to_nvmem_cell_entry()
643 * nvmem_add_one_cell() - Add one cell information to an nvmem device
646 * @info: nvmem cell info to add to the device
653 struct nvmem_cell_entry *cell; in nvmem_add_one_cell() local
656 cell = kzalloc(sizeof(*cell), GFP_KERNEL); in nvmem_add_one_cell()
657 if (!cell) in nvmem_add_one_cell()
660 rval = nvmem_cell_info_to_nvmem_cell_entry(nvmem, info, cell); in nvmem_add_one_cell()
662 kfree(cell); in nvmem_add_one_cell()
666 nvmem_cell_entry_add(cell); in nvmem_add_one_cell()
673 * nvmem_add_cells() - Add cell information to an nvmem device
676 * @info: nvmem cell info to add to the device
726 struct nvmem_cell_entry *cell; in nvmem_add_cells_from_table() local
735 cell = kzalloc(sizeof(*cell), GFP_KERNEL); in nvmem_add_cells_from_table()
736 if (!cell) { in nvmem_add_cells_from_table()
741 rval = nvmem_cell_info_to_nvmem_cell_entry(nvmem, info, cell); in nvmem_add_cells_from_table()
743 kfree(cell); in nvmem_add_cells_from_table()
747 nvmem_cell_entry_add(cell); in nvmem_add_cells_from_table()
760 struct nvmem_cell_entry *iter, *cell = NULL; in nvmem_find_cell_entry_by_name() local
765 cell = iter; in nvmem_find_cell_entry_by_name()
771 return cell; in nvmem_find_cell_entry_by_name()
1172 "could not increase module refcount for cell %s\n", in __nvmem_device_get()
1340 struct nvmem_cell *cell; in nvmem_create_cell() local
1343 cell = kzalloc(sizeof(*cell), GFP_KERNEL); in nvmem_create_cell()
1344 if (!cell) in nvmem_create_cell()
1350 kfree(cell); in nvmem_create_cell()
1355 cell->id = name; in nvmem_create_cell()
1356 cell->entry = entry; in nvmem_create_cell()
1357 cell->index = index; in nvmem_create_cell()
1359 return cell; in nvmem_create_cell()
1366 struct nvmem_cell *cell = ERR_PTR(-ENOENT); in nvmem_cell_get_from_lookup() local
1386 cell = ERR_CAST(nvmem); in nvmem_cell_get_from_lookup()
1394 cell = ERR_PTR(-ENOENT); in nvmem_cell_get_from_lookup()
1396 cell = nvmem_create_cell(cell_entry, con_id, 0); in nvmem_cell_get_from_lookup()
1397 if (IS_ERR(cell)) in nvmem_cell_get_from_lookup()
1405 return cell; in nvmem_cell_get_from_lookup()
1418 struct nvmem_cell_entry *iter, *cell = NULL; in nvmem_find_cell_entry_by_node() local
1423 cell = iter; in nvmem_find_cell_entry_by_node()
1429 return cell; in nvmem_find_cell_entry_by_node()
1445 * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
1447 * @np: Device tree node that uses the nvmem cell.
1448 * @id: nvmem cell name from nvmem-cell-names property, or NULL
1449 * for the cell at index 0 (the lone cell with no accompanying
1450 * nvmem-cell-names property).
1461 struct nvmem_cell *cell; in of_nvmem_cell_get() local
1467 /* if cell name exists, find index to the name */ in of_nvmem_cell_get()
1469 index = of_property_match_string(np, "nvmem-cell-names", id); in of_nvmem_cell_get()
1472 "#nvmem-cell-cells", in of_nvmem_cell_get()
1524 cell = nvmem_create_cell(cell_entry, id, cell_index); in of_nvmem_cell_get()
1525 if (IS_ERR(cell)) { in of_nvmem_cell_get()
1530 return cell; in of_nvmem_cell_get()
1536 * nvmem_cell_get() - Get nvmem cell of device form a given cell name
1538 * @dev: Device that requests the nvmem cell.
1539 * @id: nvmem cell name to get (this corresponds with the name from the
1540 * nvmem-cell-names property for DT systems and with the con_id from
1549 struct nvmem_cell *cell; in nvmem_cell_get() local
1552 cell = of_nvmem_cell_get(dev->of_node, id); in nvmem_cell_get()
1553 if (!IS_ERR(cell) || PTR_ERR(cell) == -EPROBE_DEFER) in nvmem_cell_get()
1554 return cell; in nvmem_cell_get()
1557 /* NULL cell id only allowed for device tree; invalid otherwise */ in nvmem_cell_get()
1571 * devm_nvmem_cell_get() - Get nvmem cell of device form a given id
1573 * @dev: Device that requests the nvmem cell.
1574 * @id: nvmem cell name id to get.
1582 struct nvmem_cell **ptr, *cell; in devm_nvmem_cell_get() local
1588 cell = nvmem_cell_get(dev, id); in devm_nvmem_cell_get()
1589 if (!IS_ERR(cell)) { in devm_nvmem_cell_get()
1590 *ptr = cell; in devm_nvmem_cell_get()
1596 return cell; in devm_nvmem_cell_get()
1611 * devm_nvmem_cell_put() - Release previously allocated nvmem cell
1614 * @dev: Device that requests the nvmem cell.
1615 * @cell: Previously allocated nvmem cell by devm_nvmem_cell_get().
1617 void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell) in devm_nvmem_cell_put() argument
1622 devm_nvmem_cell_match, cell); in devm_nvmem_cell_put()
1629 * nvmem_cell_put() - Release previously allocated nvmem cell.
1631 * @cell: Previously allocated nvmem cell by nvmem_cell_get().
1633 void nvmem_cell_put(struct nvmem_cell *cell) in nvmem_cell_put() argument
1635 struct nvmem_device *nvmem = cell->entry->nvmem; in nvmem_cell_put()
1637 if (cell->id) in nvmem_cell_put()
1638 kfree_const(cell->id); in nvmem_cell_put()
1640 kfree(cell); in nvmem_cell_put()
1646 static void nvmem_shift_read_buffer_in_place(struct nvmem_cell_entry *cell, void *buf) in nvmem_shift_read_buffer_in_place() argument
1650 int bit_offset = cell->bit_offset; in nvmem_shift_read_buffer_in_place()
1663 for (i = 1; i < cell->bytes; i++) { in nvmem_shift_read_buffer_in_place()
1670 memmove(p, b, cell->bytes - bytes_offset); in nvmem_shift_read_buffer_in_place()
1671 p += cell->bytes - 1; in nvmem_shift_read_buffer_in_place()
1674 p += cell->bytes - 1; in nvmem_shift_read_buffer_in_place()
1678 extra = cell->bytes - DIV_ROUND_UP(cell->nbits, BITS_PER_BYTE); in nvmem_shift_read_buffer_in_place()
1683 if (cell->nbits % BITS_PER_BYTE) in nvmem_shift_read_buffer_in_place()
1684 *p &= GENMASK((cell->nbits % BITS_PER_BYTE) - 1, 0); in nvmem_shift_read_buffer_in_place()
1688 struct nvmem_cell_entry *cell, in __nvmem_cell_read() argument
1693 rc = nvmem_reg_read(nvmem, cell->offset, buf, cell->raw_len); in __nvmem_cell_read()
1699 if (cell->bit_offset || cell->nbits) in __nvmem_cell_read()
1700 nvmem_shift_read_buffer_in_place(cell, buf); in __nvmem_cell_read()
1702 if (cell->read_post_process) { in __nvmem_cell_read()
1703 rc = cell->read_post_process(cell->priv, id, index, in __nvmem_cell_read()
1704 cell->offset, buf, cell->raw_len); in __nvmem_cell_read()
1710 *len = cell->bytes; in __nvmem_cell_read()
1716 * nvmem_cell_read() - Read a given nvmem cell
1718 * @cell: nvmem cell to be read.
1719 * @len: pointer to length of cell which will be populated on successful read;
1725 void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len) in nvmem_cell_read() argument
1727 struct nvmem_cell_entry *entry = cell->entry; in nvmem_cell_read()
1739 rc = __nvmem_cell_read(nvmem, cell->entry, buf, len, cell->id, cell->index); in nvmem_cell_read()
1749 static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell_entry *cell, in nvmem_cell_prepare_write_buffer() argument
1752 struct nvmem_device *nvmem = cell->nvmem; in nvmem_cell_prepare_write_buffer()
1753 int i, rc, nbits, bit_offset = cell->bit_offset; in nvmem_cell_prepare_write_buffer()
1756 nbits = cell->nbits; in nvmem_cell_prepare_write_buffer()
1757 buf = kzalloc(cell->bytes, GFP_KERNEL); in nvmem_cell_prepare_write_buffer()
1769 rc = nvmem_reg_read(nvmem, cell->offset, &v, 1); in nvmem_cell_prepare_write_buffer()
1775 for (i = 1; i < cell->bytes; i++) { in nvmem_cell_prepare_write_buffer()
1789 cell->offset + cell->bytes - 1, &v, 1); in nvmem_cell_prepare_write_buffer()
1802 static int __nvmem_cell_entry_write(struct nvmem_cell_entry *cell, void *buf, size_t len) in __nvmem_cell_entry_write() argument
1804 struct nvmem_device *nvmem = cell->nvmem; in __nvmem_cell_entry_write()
1808 (cell->bit_offset == 0 && len != cell->bytes)) in __nvmem_cell_entry_write()
1816 if (cell->read_post_process) in __nvmem_cell_entry_write()
1819 if (cell->bit_offset || cell->nbits) { in __nvmem_cell_entry_write()
1820 if (len != BITS_TO_BYTES(cell->nbits) && len != cell->bytes) in __nvmem_cell_entry_write()
1822 buf = nvmem_cell_prepare_write_buffer(cell, buf, len); in __nvmem_cell_entry_write()
1827 rc = nvmem_reg_write(nvmem, cell->offset, buf, cell->bytes); in __nvmem_cell_entry_write()
1830 if (cell->bit_offset || cell->nbits) in __nvmem_cell_entry_write()
1840 * nvmem_cell_write() - Write to a given nvmem cell
1842 * @cell: nvmem cell to be written.
1844 * @len: length of buffer to be written to nvmem cell.
1848 int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len) in nvmem_cell_write() argument
1850 return __nvmem_cell_entry_write(cell->entry, buf, len); in nvmem_cell_write()
1858 struct nvmem_cell *cell; in nvmem_cell_read_common() local
1862 cell = nvmem_cell_get(dev, cell_id); in nvmem_cell_read_common()
1863 if (IS_ERR(cell)) in nvmem_cell_read_common()
1864 return PTR_ERR(cell); in nvmem_cell_read_common()
1866 buf = nvmem_cell_read(cell, &len); in nvmem_cell_read_common()
1868 nvmem_cell_put(cell); in nvmem_cell_read_common()
1873 nvmem_cell_put(cell); in nvmem_cell_read_common()
1878 nvmem_cell_put(cell); in nvmem_cell_read_common()
1884 * nvmem_cell_read_u8() - Read a cell value as a u8
1886 * @dev: Device that requests the nvmem cell.
1887 * @cell_id: Name of nvmem cell to read.
1899 * nvmem_cell_read_u16() - Read a cell value as a u16
1901 * @dev: Device that requests the nvmem cell.
1902 * @cell_id: Name of nvmem cell to read.
1914 * nvmem_cell_read_u32() - Read a cell value as a u32
1916 * @dev: Device that requests the nvmem cell.
1917 * @cell_id: Name of nvmem cell to read.
1929 * nvmem_cell_read_u64() - Read a cell value as a u64
1931 * @dev: Device that requests the nvmem cell.
1932 * @cell_id: Name of nvmem cell to read.
1947 struct nvmem_cell *cell; in nvmem_cell_read_variable_common() local
1951 cell = nvmem_cell_get(dev, cell_id); in nvmem_cell_read_variable_common()
1952 if (IS_ERR(cell)) in nvmem_cell_read_variable_common()
1953 return cell; in nvmem_cell_read_variable_common()
1955 nbits = cell->entry->nbits; in nvmem_cell_read_variable_common()
1956 buf = nvmem_cell_read(cell, len); in nvmem_cell_read_variable_common()
1957 nvmem_cell_put(cell); in nvmem_cell_read_variable_common()
1979 * @dev: Device that requests the nvmem cell.
1980 * @cell_id: Name of nvmem cell to read.
2010 * @dev: Device that requests the nvmem cell.
2011 * @cell_id: Name of nvmem cell to read.
2039 * nvmem_device_cell_read() - Read a given nvmem device and cell
2042 * @info: nvmem cell info to be read.
2051 struct nvmem_cell_entry cell; in nvmem_device_cell_read() local
2058 rc = nvmem_cell_info_to_nvmem_cell_entry_nodup(nvmem, info, &cell); in nvmem_device_cell_read()
2062 rc = __nvmem_cell_read(nvmem, &cell, buf, &len, NULL, 0); in nvmem_device_cell_read()
2071 * nvmem_device_cell_write() - Write cell to a given nvmem device
2074 * @info: nvmem cell info to be written.
2075 * @buf: buffer to be written to cell.
2082 struct nvmem_cell_entry cell; in nvmem_device_cell_write() local
2088 rc = nvmem_cell_info_to_nvmem_cell_entry_nodup(nvmem, info, &cell); in nvmem_device_cell_write()
2092 return __nvmem_cell_entry_write(&cell, buf, cell.bytes); in nvmem_device_cell_write()
2126 * nvmem_device_write() - Write cell to a given nvmem device
2155 * nvmem_add_cell_table() - register a table of cell info entries
2157 * @table: table of cell info entries
2168 * nvmem_del_cell_table() - remove a previously registered cell info table
2170 * @table: table of cell info entries
2181 * nvmem_add_cell_lookups() - register a list of cell lookup entries
2183 * @entries: array of cell lookup entries
2184 * @nentries: number of cell lookup entries in the array
2198 * nvmem_del_cell_lookups() - remove a list of previously added cell lookup
2201 * @entries: array of cell lookup entries
2202 * @nentries: number of cell lookup entries in the array