summaryrefslogtreecommitdiff
path: root/sound/core/memory.c
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.com>2025-03-26 13:42:07 +0100
committerJiri Kosina <jkosina@suse.com>2025-03-26 13:42:07 +0100
commitb3cc7428a32202936904b5b07cf9f135025bafd6 (patch)
treed4a1a6180ac5939fccd92acd6f8d7d1388575c4a /sound/core/memory.c
parentdb52926fb0be40e1d588a346df73f5ea3a34a4c6 (diff)
parent01601fdd40ecf4467c8ae4d215dbb7d2a0599a2c (diff)
Merge branch 'for-6.15/amd_sfh' into for-linus
From: Mario Limonciello <mario.limonciello@amd.com> Some platforms include a human presence detection (HPD) sensor. When enabled and a user is detected a wake event will be emitted from the sensor fusion hub that software can react to. Example use cases are "wake from suspend on approach" or to "lock when leaving". This is currently enabled by default on supported systems, but users can't control it. This essentially means that wake on approach is enabled which is a really surprising behavior to users that don't expect it. Instead of defaulting to enabled add a sysfs knob that users can use to enable the feature if desirable and set it to disabled by default.
Diffstat (limited to 'sound/core/memory.c')
-rw-r--r--sound/core/memory.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/sound/core/memory.c b/sound/core/memory.c
index 2d2d0094c897c..d683442b4c978 100644
--- a/sound/core/memory.c
+++ b/sound/core/memory.c
@@ -27,38 +27,43 @@ int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size
if (import_ubuf(ITER_DEST, dst, count, &iter))
return -EFAULT;
- return copy_to_iter_fromio(&iter, (const void __iomem *)src, count);
+ if (copy_to_iter_fromio((const void __iomem *)src, count, &iter) != count)
+ return -EFAULT;
+ return 0;
}
EXPORT_SYMBOL(copy_to_user_fromio);
/**
* copy_to_iter_fromio - copy data from mmio-space to iov_iter
- * @dst: the destination iov_iter
* @src: the source pointer on mmio
* @count: the data size to copy in bytes
+ * @dst: the destination iov_iter
*
* Copies the data from mmio-space to iov_iter.
*
- * Return: Zero if successful, or non-zero on failure.
+ * Return: number of bytes to be copied
*/
-int copy_to_iter_fromio(struct iov_iter *dst, const void __iomem *src,
- size_t count)
+size_t copy_to_iter_fromio(const void __iomem *src, size_t count,
+ struct iov_iter *dst)
{
#if defined(__i386__) || defined(CONFIG_SPARC32)
- return copy_to_iter((const void __force *)src, count, dst) == count ? 0 : -EFAULT;
+ return copy_to_iter((const void __force *)src, count, dst);
#else
char buf[256];
+ size_t res = 0;
+
while (count) {
size_t c = count;
if (c > sizeof(buf))
c = sizeof(buf);
memcpy_fromio(buf, (void __iomem *)src, c);
if (copy_to_iter(buf, c, dst) != c)
- return -EFAULT;
+ return res;
count -= c;
src += c;
+ res += c;
}
- return 0;
+ return res;
#endif
}
EXPORT_SYMBOL(copy_to_iter_fromio);
@@ -79,37 +84,43 @@ int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size
if (import_ubuf(ITER_SOURCE, (void __user *)src, count, &iter))
return -EFAULT;
- return copy_from_iter_toio((void __iomem *)dst, &iter, count);
+ if (copy_from_iter_toio((void __iomem *)dst, count, &iter) != count)
+ return -EFAULT;
+ return 0;
}
EXPORT_SYMBOL(copy_from_user_toio);
/**
* copy_from_iter_toio - copy data from iov_iter to mmio-space
* @dst: the destination pointer on mmio-space
- * @src: the source iov_iter
* @count: the data size to copy in bytes
+ * @src: the source iov_iter
*
* Copies the data from iov_iter to mmio-space.
*
- * Return: Zero if successful, or non-zero on failure.
+ * Return: number of bytes to be copied
*/
-int copy_from_iter_toio(void __iomem *dst, struct iov_iter *src, size_t count)
+size_t copy_from_iter_toio(void __iomem *dst, size_t count,
+ struct iov_iter *src)
{
#if defined(__i386__) || defined(CONFIG_SPARC32)
- return copy_from_iter((void __force *)dst, count, src) == count ? 0 : -EFAULT;
+ return copy_from_iter((void __force *)dst, count, src);
#else
char buf[256];
+ size_t res = 0;
+
while (count) {
size_t c = count;
if (c > sizeof(buf))
c = sizeof(buf);
if (copy_from_iter(buf, c, src) != c)
- return -EFAULT;
+ return res;
memcpy_toio(dst, buf, c);
count -= c;
dst += c;
+ res += c;
}
- return 0;
+ return res;
#endif
}
EXPORT_SYMBOL(copy_from_iter_toio);