diff --git a/drivers/virt/tegra/hvc_sysfs.c b/drivers/virt/tegra/hvc_sysfs.c index dc24a19a..31512e63 100644 --- a/drivers/virt/tegra/hvc_sysfs.c +++ b/drivers/virt/tegra/hvc_sysfs.c @@ -88,7 +88,12 @@ static int nvlog_buffer_mmap(struct file *fp, struct kobject *ko, } static ssize_t nvlog_region_size_read(struct file *fp, struct kobject *ko, - struct bin_attribute *attr, char *buf, loff_t pos, size_t size) +#if defined(NV_BIN_ATTRIBUTE_STRUCT_READWRITE_HAS_CONST_BIN_ATTRIBUTE_ARG) + const struct bin_attribute *attr, +#else + struct bin_attribute *attr, +#endif + char *buf, loff_t pos, size_t size) { struct nvlog_shmem_info *info = container_of(attr, struct nvlog_shmem_info, region_size_attr); @@ -97,7 +102,12 @@ static ssize_t nvlog_region_size_read(struct file *fp, struct kobject *ko, } static ssize_t nvlog_buffer_size_read(struct file *fp, struct kobject *ko, - struct bin_attribute *attr, char *buf, loff_t pos, size_t size) +#if defined(NV_BIN_ATTRIBUTE_STRUCT_READWRITE_HAS_CONST_BIN_ATTRIBUTE_ARG) + const struct bin_attribute *attr, +#else + struct bin_attribute *attr, +#endif + char *buf, loff_t pos, size_t size) { struct nvlog_shmem_info *info = container_of(attr, struct nvlog_shmem_info, buf_size_attr); @@ -106,7 +116,12 @@ static ssize_t nvlog_buffer_size_read(struct file *fp, struct kobject *ko, } static ssize_t nvlog_buffer_count_read(struct file *fp, struct kobject *ko, - struct bin_attribute *attr, char *buf, loff_t pos, size_t size) +#if defined(NV_BIN_ATTRIBUTE_STRUCT_READWRITE_HAS_CONST_BIN_ATTRIBUTE_ARG) + const struct bin_attribute *attr, +#else + struct bin_attribute *attr, +#endif + char *buf, loff_t pos, size_t size) { struct nvlog_shmem_info *info = container_of(attr, struct nvlog_shmem_info, buf_count_attr); @@ -296,7 +311,12 @@ static int hvc_create_sysfs( } static ssize_t log_mask_read(struct file *fp, struct kobject *ko, - struct bin_attribute *attr, char *buf, loff_t pos, size_t size) +#if defined(NV_BIN_ATTRIBUTE_STRUCT_READWRITE_HAS_CONST_BIN_ATTRIBUTE_ARG) + const struct bin_attribute *attr, +#else + struct bin_attribute *attr, +#endif + char *buf, loff_t pos, size_t size) { uint64_t value = 0; @@ -312,7 +332,12 @@ static ssize_t log_mask_read(struct file *fp, struct kobject *ko, } static ssize_t log_mask_write(struct file *fp, struct kobject *ko, - struct bin_attribute *attr, char *buf, loff_t pos, size_t size) +#if defined(NV_BIN_ATTRIBUTE_STRUCT_READWRITE_HAS_CONST_BIN_ATTRIBUTE_ARG) + const struct bin_attribute *attr, +#else + struct bin_attribute *attr, +#endif + char *buf, loff_t pos, size_t size) { uint64_t type, value; diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index b9903f84..5b9d2407 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -93,6 +93,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += __alloc_pages_bulk_has_no_page_list_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += __assign_str_has_no_src_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += aperture_remove_all_conflicting_devices NV_CONFTEST_FUNCTION_COMPILE_TESTS += bin_attribute_struct_mmap_has_const_bin_attribute_arg +NV_CONFTEST_FUNCTION_COMPILE_TESTS += bin_attribute_struct_readwrite_has_const_bin_attribute_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += blk_execute_rq_has_no_gendisk_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += blk_mq_alloc_disk_for_queue NV_CONFTEST_FUNCTION_COMPILE_TESTS += blk_mq_alloc_queue diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index a463b386..469c1c6a 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -6588,6 +6588,26 @@ compile_test() { "NV_BIN_ATTRIBUTE_STRUCT_MMAP_HAS_CONST_BIN_ATTRIBUTE_ARG" "" "types" ;; + bin_attribute_struct_readwrite_has_const_bin_attribute_arg) + # + # Determine if the 'bin_attribute' structure 'read' and 'write' + # function pointers have a const 'struct bin_attribute' argument. + # + # This change was made in Linux v6.16 by commit 97d06802d10a + # ("sysfs: constify bin_attribute argument of bin_attribute::read/write()"). + # + CODE=" + #include + void conftest(struct bin_attribute *attr) { + ssize_t (*fn)(struct file *, struct kobject *, + const struct bin_attribute *, + char *, loff_t, size_t) = attr->read; + }" + + compile_check_conftest "$CODE" \ + "NV_BIN_ATTRIBUTE_STRUCT_READWRITE_HAS_CONST_BIN_ATTRIBUTE_ARG" "" "types" + ;; + blk_execute_rq_has_no_gendisk_arg) # # Determine if the function blk_execute_rq() has an argument of