summaryrefslogtreecommitdiffstats
path: root/drivers/thunderbolt/dma_port.c
diff options
context:
space:
mode:
authorJani Nikula <jani.nikula@intel.com>2021-07-01 17:46:34 +0200
committerJani Nikula <jani.nikula@intel.com>2021-07-01 17:46:34 +0200
commite42c6c1bc8d5e70d7b2c8af534b0d33a2be48f0c (patch)
tree4b1109adc051c943ef3edd990f5a907a0836bdf8 /drivers/thunderbolt/dma_port.c
parentdrm/i915/display: Fix state mismatch in drm infoframe (diff)
parentMerge tag 'drm-intel-next-fixes-2021-06-29' of git://anongit.freedesktop.org/... (diff)
downloadlinux-e42c6c1bc8d5e70d7b2c8af534b0d33a2be48f0c.tar.xz
linux-e42c6c1bc8d5e70d7b2c8af534b0d33a2be48f0c.zip
Merge drm/drm-next into drm-intel-next
Bring drm-intel-next closer to drm-next and drm-intel-gt-next for a more feasible baseline for topic branches. Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Diffstat (limited to 'drivers/thunderbolt/dma_port.c')
-rw-r--r--drivers/thunderbolt/dma_port.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/thunderbolt/dma_port.c b/drivers/thunderbolt/dma_port.c
index 7288aaf01ae6..5631319f7b20 100644
--- a/drivers/thunderbolt/dma_port.c
+++ b/drivers/thunderbolt/dma_port.c
@@ -366,15 +366,15 @@ int dma_port_flash_read(struct tb_dma_port *dma, unsigned int address,
void *buf, size_t size)
{
unsigned int retries = DMA_PORT_RETRIES;
- unsigned int offset;
-
- offset = address & 3;
- address = address & ~3;
do {
- u32 nbytes = min_t(u32, size, MAIL_DATA_DWORDS * 4);
+ unsigned int offset;
+ size_t nbytes;
int ret;
+ offset = address & 3;
+ nbytes = min_t(size_t, size + offset, MAIL_DATA_DWORDS * 4);
+
ret = dma_port_flash_read_block(dma, address, dma->buf,
ALIGN(nbytes, 4));
if (ret) {
@@ -386,6 +386,7 @@ int dma_port_flash_read(struct tb_dma_port *dma, unsigned int address,
return ret;
}
+ nbytes -= offset;
memcpy(buf, dma->buf + offset, nbytes);
size -= nbytes;