Lines Matching refs:nvm
110 const u8 *buf = sw->nvm->buf; in nvm_validate_and_write()
117 image_size = sw->nvm->buf_data_size; in nvm_validate_and_write()
273 if (!sw->nvm->buf) { in tb_switch_nvm_write()
274 sw->nvm->buf = vmalloc(NVM_MAX_SIZE); in tb_switch_nvm_write()
275 if (!sw->nvm->buf) { in tb_switch_nvm_write()
281 sw->nvm->buf_data_size = offset + bytes; in tb_switch_nvm_write()
282 memcpy(sw->nvm->buf + offset, val, bytes); in tb_switch_nvm_write()
321 struct tb_switch_nvm *nvm; in tb_switch_nvm_add() local
328 nvm = kzalloc(sizeof(*nvm), GFP_KERNEL); in tb_switch_nvm_add()
329 if (!nvm) in tb_switch_nvm_add()
332 nvm->id = ida_simple_get(&nvm_ida, 0, 0, GFP_KERNEL); in tb_switch_nvm_add()
356 nvm->major = val >> 16; in tb_switch_nvm_add()
357 nvm->minor = val >> 8; in tb_switch_nvm_add()
359 nvm_dev = register_nvmem(sw, nvm->id, nvm_size, true); in tb_switch_nvm_add()
364 nvm->active = nvm_dev; in tb_switch_nvm_add()
368 nvm_dev = register_nvmem(sw, nvm->id, NVM_MAX_SIZE, false); in tb_switch_nvm_add()
373 nvm->non_active = nvm_dev; in tb_switch_nvm_add()
376 sw->nvm = nvm; in tb_switch_nvm_add()
380 if (nvm->active) in tb_switch_nvm_add()
381 nvmem_unregister(nvm->active); in tb_switch_nvm_add()
383 ida_simple_remove(&nvm_ida, nvm->id); in tb_switch_nvm_add()
384 kfree(nvm); in tb_switch_nvm_add()
391 struct tb_switch_nvm *nvm; in tb_switch_nvm_remove() local
393 nvm = sw->nvm; in tb_switch_nvm_remove()
394 sw->nvm = NULL; in tb_switch_nvm_remove()
396 if (!nvm) in tb_switch_nvm_remove()
400 if (!nvm->authenticating) in tb_switch_nvm_remove()
403 if (nvm->non_active) in tb_switch_nvm_remove()
404 nvmem_unregister(nvm->non_active); in tb_switch_nvm_remove()
405 if (nvm->active) in tb_switch_nvm_remove()
406 nvmem_unregister(nvm->active); in tb_switch_nvm_remove()
407 ida_simple_remove(&nvm_ida, nvm->id); in tb_switch_nvm_remove()
408 vfree(nvm->buf); in tb_switch_nvm_remove()
409 kfree(nvm); in tb_switch_nvm_remove()
1218 if (!sw->nvm) { in nvm_authenticate_store()
1231 if (!sw->nvm->buf) { in nvm_authenticate_store()
1240 sw->nvm->authenticating = true; in nvm_authenticate_store()
1279 else if (!sw->nvm) in nvm_version_show()
1282 ret = sprintf(buf, "%x.%x\n", sw->nvm->major, sw->nvm->minor); in nvm_version_show()