Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: core: Add support for writing 64 bit attrs

Prior to this patch it was only possible to read 64 bit integers.

Signed-off-by: Sam Winchenbach <swinchenbach@arka.org>
Link: https://patch.msgid.link/20250328174831.227202-6-sam.winchenbach@framepointer.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Sam Winchenbach and committed by
Jonathan Cameron
c31752b1 d542db70

+13
+13
drivers/iio/industrialio-core.c
··· 26 26 #include <linux/sched.h> 27 27 #include <linux/slab.h> 28 28 #include <linux/wait.h> 29 + #include <linux/wordpart.h> 29 30 30 31 #include <linux/iio/buffer.h> 31 32 #include <linux/iio/buffer_impl.h> ··· 967 966 struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); 968 967 int ret, fract_mult = 100000; 969 968 int integer, fract = 0; 969 + long long integer64; 970 970 bool is_char = false; 971 971 bool scale_db = false; 972 + bool is_64bit = false; 972 973 973 974 /* Assumes decimal - precision based on number of digits */ 974 975 if (!indio_dev->info->write_raw) ··· 994 991 case IIO_VAL_CHAR: 995 992 is_char = true; 996 993 break; 994 + case IIO_VAL_INT_64: 995 + is_64bit = true; 996 + break; 997 997 default: 998 998 return -EINVAL; 999 999 } ··· 1007 1001 if (sscanf(buf, "%c", &ch) != 1) 1008 1002 return -EINVAL; 1009 1003 integer = ch; 1004 + } else if (is_64bit) { 1005 + ret = kstrtoll(buf, 0, &integer64); 1006 + if (ret) 1007 + return ret; 1008 + 1009 + fract = upper_32_bits(integer64); 1010 + integer = lower_32_bits(integer64); 1010 1011 } else { 1011 1012 ret = __iio_str_to_fixpoint(buf, fract_mult, &integer, &fract, 1012 1013 scale_db);