Lines Matching refs:cell

302 static void nvmem_cell_drop(struct nvmem_cell *cell)  in nvmem_cell_drop()  argument
305 list_del(&cell->node); in nvmem_cell_drop()
307 kfree(cell); in nvmem_cell_drop()
312 struct nvmem_cell *cell; in nvmem_device_remove_all_cells() local
316 cell = list_entry(p, struct nvmem_cell, node); in nvmem_device_remove_all_cells()
317 if (cell->nvmem == nvmem) in nvmem_device_remove_all_cells()
318 nvmem_cell_drop(cell); in nvmem_device_remove_all_cells()
322 static void nvmem_cell_add(struct nvmem_cell *cell) in nvmem_cell_add() argument
325 list_add_tail(&cell->node, &nvmem_cells); in nvmem_cell_add()
331 struct nvmem_cell *cell) in nvmem_cell_info_to_nvmem_cell() argument
333 cell->nvmem = nvmem; in nvmem_cell_info_to_nvmem_cell()
334 cell->offset = info->offset; in nvmem_cell_info_to_nvmem_cell()
335 cell->bytes = info->bytes; in nvmem_cell_info_to_nvmem_cell()
336 cell->name = info->name; in nvmem_cell_info_to_nvmem_cell()
338 cell->bit_offset = info->bit_offset; in nvmem_cell_info_to_nvmem_cell()
339 cell->nbits = info->nbits; in nvmem_cell_info_to_nvmem_cell()
341 if (cell->nbits) in nvmem_cell_info_to_nvmem_cell()
342 cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset, in nvmem_cell_info_to_nvmem_cell()
345 if (!IS_ALIGNED(cell->offset, nvmem->stride)) { in nvmem_cell_info_to_nvmem_cell()
348 cell->name, nvmem->stride); in nvmem_cell_info_to_nvmem_cell()
636 struct nvmem_cell *cell = nvmem_find_cell(cell_id); in __nvmem_device_get() local
638 if (cell) { in __nvmem_device_get()
639 nvmem = cell->nvmem; in __nvmem_device_get()
640 *cellp = cell; in __nvmem_device_get()
815 struct nvmem_cell *cell = NULL; in nvmem_cell_get_from_list() local
818 nvmem = __nvmem_device_get(NULL, &cell, cell_id); in nvmem_cell_get_from_list()
822 return cell; in nvmem_cell_get_from_list()
842 struct nvmem_cell *cell; in of_nvmem_cell_get() local
873 cell = kzalloc(sizeof(*cell), GFP_KERNEL); in of_nvmem_cell_get()
874 if (!cell) { in of_nvmem_cell_get()
879 cell->nvmem = nvmem; in of_nvmem_cell_get()
880 cell->offset = be32_to_cpup(addr++); in of_nvmem_cell_get()
881 cell->bytes = be32_to_cpup(addr); in of_nvmem_cell_get()
882 cell->name = cell_np->name; in of_nvmem_cell_get()
886 cell->bit_offset = be32_to_cpup(addr++); in of_nvmem_cell_get()
887 cell->nbits = be32_to_cpup(addr); in of_nvmem_cell_get()
890 if (cell->nbits) in of_nvmem_cell_get()
891 cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset, in of_nvmem_cell_get()
894 if (!IS_ALIGNED(cell->offset, nvmem->stride)) { in of_nvmem_cell_get()
897 cell->name, nvmem->stride); in of_nvmem_cell_get()
902 nvmem_cell_add(cell); in of_nvmem_cell_get()
904 return cell; in of_nvmem_cell_get()
907 kfree(cell); in of_nvmem_cell_get()
929 struct nvmem_cell *cell; in nvmem_cell_get() local
932 cell = of_nvmem_cell_get(dev->of_node, cell_id); in nvmem_cell_get()
933 if (!IS_ERR(cell) || PTR_ERR(cell) == -EPROBE_DEFER) in nvmem_cell_get()
934 return cell; in nvmem_cell_get()
962 struct nvmem_cell **ptr, *cell; in devm_nvmem_cell_get() local
968 cell = nvmem_cell_get(dev, id); in devm_nvmem_cell_get()
969 if (!IS_ERR(cell)) { in devm_nvmem_cell_get()
970 *ptr = cell; in devm_nvmem_cell_get()
976 return cell; in devm_nvmem_cell_get()
997 void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell) in devm_nvmem_cell_put() argument
1002 devm_nvmem_cell_match, cell); in devm_nvmem_cell_put()
1013 void nvmem_cell_put(struct nvmem_cell *cell) in nvmem_cell_put() argument
1015 struct nvmem_device *nvmem = cell->nvmem; in nvmem_cell_put()
1018 nvmem_cell_drop(cell); in nvmem_cell_put()
1022 static void nvmem_shift_read_buffer_in_place(struct nvmem_cell *cell, void *buf) in nvmem_shift_read_buffer_in_place() argument
1025 int i, bit_offset = cell->bit_offset; in nvmem_shift_read_buffer_in_place()
1033 for (i = 1; i < cell->bytes; i++) { in nvmem_shift_read_buffer_in_place()
1042 if (cell->bytes != DIV_ROUND_UP(cell->nbits, BITS_PER_BYTE)) in nvmem_shift_read_buffer_in_place()
1046 *p &= GENMASK((cell->nbits%BITS_PER_BYTE) - 1, 0); in nvmem_shift_read_buffer_in_place()
1050 struct nvmem_cell *cell, in __nvmem_cell_read() argument
1055 rc = nvmem_reg_read(nvmem, cell->offset, buf, cell->bytes); in __nvmem_cell_read()
1061 if (cell->bit_offset || cell->nbits) in __nvmem_cell_read()
1062 nvmem_shift_read_buffer_in_place(cell, buf); in __nvmem_cell_read()
1065 *len = cell->bytes; in __nvmem_cell_read()
1080 void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len) in nvmem_cell_read() argument
1082 struct nvmem_device *nvmem = cell->nvmem; in nvmem_cell_read()
1089 buf = kzalloc(cell->bytes, GFP_KERNEL); in nvmem_cell_read()
1093 rc = __nvmem_cell_read(nvmem, cell, buf, len); in nvmem_cell_read()
1103 static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell, in nvmem_cell_prepare_write_buffer() argument
1106 struct nvmem_device *nvmem = cell->nvmem; in nvmem_cell_prepare_write_buffer()
1107 int i, rc, nbits, bit_offset = cell->bit_offset; in nvmem_cell_prepare_write_buffer()
1110 nbits = cell->nbits; in nvmem_cell_prepare_write_buffer()
1111 buf = kzalloc(cell->bytes, GFP_KERNEL); in nvmem_cell_prepare_write_buffer()
1123 rc = nvmem_reg_read(nvmem, cell->offset, &v, 1); in nvmem_cell_prepare_write_buffer()
1129 for (i = 1; i < cell->bytes; i++) { in nvmem_cell_prepare_write_buffer()
1143 cell->offset + cell->bytes - 1, &v, 1); in nvmem_cell_prepare_write_buffer()
1165 int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len) in nvmem_cell_write() argument
1167 struct nvmem_device *nvmem = cell->nvmem; in nvmem_cell_write()
1171 (cell->bit_offset == 0 && len != cell->bytes)) in nvmem_cell_write()
1174 if (cell->bit_offset || cell->nbits) { in nvmem_cell_write()
1175 buf = nvmem_cell_prepare_write_buffer(cell, buf, len); in nvmem_cell_write()
1180 rc = nvmem_reg_write(nvmem, cell->offset, buf, cell->bytes); in nvmem_cell_write()
1183 if (cell->bit_offset || cell->nbits) in nvmem_cell_write()
1204 struct nvmem_cell *cell; in nvmem_cell_read_u32() local
1208 cell = nvmem_cell_get(dev, cell_id); in nvmem_cell_read_u32()
1209 if (IS_ERR(cell)) in nvmem_cell_read_u32()
1210 return PTR_ERR(cell); in nvmem_cell_read_u32()
1212 buf = nvmem_cell_read(cell, &len); in nvmem_cell_read_u32()
1214 nvmem_cell_put(cell); in nvmem_cell_read_u32()
1219 nvmem_cell_put(cell); in nvmem_cell_read_u32()
1225 nvmem_cell_put(cell); in nvmem_cell_read_u32()
1243 struct nvmem_cell cell; in nvmem_device_cell_read() local
1250 rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell); in nvmem_device_cell_read()
1254 rc = __nvmem_cell_read(nvmem, &cell, buf, &len); in nvmem_device_cell_read()
1274 struct nvmem_cell cell; in nvmem_device_cell_write() local
1280 rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell); in nvmem_device_cell_write()
1284 return nvmem_cell_write(&cell, buf, cell.bytes); in nvmem_device_cell_write()