diff options
author | Mika Westerberg <mika.westerberg@linux.intel.com> | 2022-09-03 10:43:25 +0300 |
---|---|---|
committer | Mika Westerberg <mika.westerberg@linux.intel.com> | 2022-09-07 09:06:51 +0300 |
commit | 8b02b2da77c89d9b9031f522e50af9eb2270585a (patch) | |
tree | ddea9f9efcbfbc51209e7d2ea8cc3af6886be43b | |
parent | 7bfafaa5185be3088e57f046956d6db0155ddc17 (diff) | |
download | linux-8b02b2da77c89d9b9031f522e50af9eb2270585a.tar.xz |
thunderbolt: Provide tb_retimer_nvm_read() analogous to tb_switch_nvm_read()
As we are moving the NVM vendor specifics into nvm.c we need to deal
witht he retimer NVM formats too. For this reason provide retimer
specific function that can be used to read the contents of the NVM and
rename the internal ones accordingly analogous to what we do with
routers.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
-rw-r--r-- | drivers/thunderbolt/retimer.c | 28 | ||||
-rw-r--r-- | drivers/thunderbolt/tb.h | 2 |
2 files changed, 23 insertions, 7 deletions
diff --git a/drivers/thunderbolt/retimer.c b/drivers/thunderbolt/retimer.c index dc0fc90e81cf..bec02ad4cb3b 100644 --- a/drivers/thunderbolt/retimer.c +++ b/drivers/thunderbolt/retimer.c @@ -16,8 +16,23 @@ #define TB_MAX_RETIMER_INDEX 6 -static int tb_retimer_nvm_read(void *priv, unsigned int offset, void *val, - size_t bytes) +/** + * tb_retimer_nvm_read() - Read contents of retimer NVM + * @rt: Retimer device + * @address: NVM address (in bytes) to start reading + * @buf: Data read from NVM is stored here + * @size: Number of bytes to read + * + * Reads retimer NVM and copies the contents to @buf. Returns %0 if the + * read was successful and negative errno in case of failure. + */ +int tb_retimer_nvm_read(struct tb_retimer *rt, unsigned int address, void *buf, + size_t size) +{ + return usb4_port_retimer_nvm_read(rt->port, rt->index, address, buf, size); +} + +static int nvm_read(void *priv, unsigned int offset, void *val, size_t bytes) { struct tb_nvm *nvm = priv; struct tb_retimer *rt = tb_to_retimer(nvm->dev); @@ -30,7 +45,7 @@ static int tb_retimer_nvm_read(void *priv, unsigned int offset, void *val, goto out; } - ret = usb4_port_retimer_nvm_read(rt->port, rt->index, offset, val, bytes); + ret = tb_retimer_nvm_read(rt, offset, val, bytes); mutex_unlock(&rt->tb->lock); out: @@ -40,8 +55,7 @@ out: return ret; } -static int tb_retimer_nvm_write(void *priv, unsigned int offset, void *val, - size_t bytes) +static int nvm_write(void *priv, unsigned int offset, void *val, size_t bytes) { struct tb_nvm *nvm = priv; struct tb_retimer *rt = tb_to_retimer(nvm->dev); @@ -82,11 +96,11 @@ static int tb_retimer_nvm_add(struct tb_retimer *rt) nvm_size = (SZ_1M << (val & 7)) / 8; nvm_size = (nvm_size - SZ_16K) / 2; - ret = tb_nvm_add_active(nvm, nvm_size, tb_retimer_nvm_read); + ret = tb_nvm_add_active(nvm, nvm_size, nvm_read); if (ret) goto err_nvm; - ret = tb_nvm_add_non_active(nvm, NVM_MAX_SIZE, tb_retimer_nvm_write); + ret = tb_nvm_add_non_active(nvm, NVM_MAX_SIZE, nvm_write); if (ret) goto err_nvm; diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h index f797adf8c7f4..75b6ad5923ad 100644 --- a/drivers/thunderbolt/tb.h +++ b/drivers/thunderbolt/tb.h @@ -1144,6 +1144,8 @@ static inline struct tb_switch *tb_xdomain_parent(struct tb_xdomain *xd) return tb_to_switch(xd->dev.parent); } +int tb_retimer_nvm_read(struct tb_retimer *rt, unsigned int address, void *buf, + size_t size); int tb_retimer_scan(struct tb_port *port, bool add); void tb_retimer_remove_all(struct tb_port *port); |