You've already forked hexagonrpc
mirror of
https://github.com/linux-msm/hexagonrpc.git
synced 2026-02-25 13:13:52 -08:00
fastrpc: hexagonfs: mapped: add sysfs variant with fixed size
The remote processor expects a non-zero size for sysfs files, but the mainline kernel sets the real file's size to zero. Add a variant of the mapped file type that fixes up the size.
This commit is contained in:
@@ -45,11 +45,11 @@
|
||||
.u.phys = path, \
|
||||
}
|
||||
|
||||
#define DEFINE_SYSFILE(dirname, func) \
|
||||
(struct hexagonfs_dirent) { \
|
||||
.name = dirname, \
|
||||
.ops = &hexagonfs_sysfs_ops, \
|
||||
.u.func = func, \
|
||||
#define DEFINE_SYSFILE(dirname, path) \
|
||||
(struct hexagonfs_dirent) { \
|
||||
.name = dirname, \
|
||||
.ops = &hexagonfs_mapped_sysfs_ops, \
|
||||
.u.phys = path, \
|
||||
}
|
||||
|
||||
static struct hexagonfs_dirent root_dir = DEFINE_VIRT_DIR("/",
|
||||
@@ -70,21 +70,21 @@ static struct hexagonfs_dirent root_dir = DEFINE_VIRT_DIR("/",
|
||||
&DEFINE_VIRT_DIR("sys",
|
||||
&DEFINE_VIRT_DIR("devices",
|
||||
&DEFINE_VIRT_DIR("soc0",
|
||||
&DEFINE_MAPPED("hw_platform",
|
||||
"/sys/kernel/debug/qcom_socinfo/hardware_platform"),
|
||||
&DEFINE_SYSFILE("hw_platform",
|
||||
"/sys/kernel/debug/qcom_socinfo/hardware_platform"),
|
||||
&(struct hexagonfs_dirent) {
|
||||
.name = "platform_subtype",
|
||||
.ops = &hexagonfs_plat_subtype_name_ops,
|
||||
.u.phys = "/sys/kernel/debug/qcom_socinfo/hardware_platform_subtype",
|
||||
},
|
||||
&DEFINE_MAPPED("platform_subtype_id",
|
||||
"/sys/kernel/debug/qcom_socinfo/hardware_platform_subtype"),
|
||||
&DEFINE_MAPPED("platform_version",
|
||||
"/sys/kernel/debug/qcom_socinfo/platform_version"),
|
||||
&DEFINE_MAPPED("revision",
|
||||
"/sys/devices/soc0/revision"),
|
||||
&DEFINE_MAPPED("soc_id",
|
||||
"/sys/devices/soc0/soc_id"),
|
||||
&DEFINE_SYSFILE("platform_subtype_id",
|
||||
"/sys/kernel/debug/qcom_socinfo/hardware_platform_subtype"),
|
||||
&DEFINE_SYSFILE("platform_version",
|
||||
"/sys/kernel/debug/qcom_socinfo/platform_version"),
|
||||
&DEFINE_SYSFILE("revision",
|
||||
"/sys/devices/soc0/revision"),
|
||||
&DEFINE_SYSFILE("soc_id",
|
||||
"/sys/devices/soc0/soc_id"),
|
||||
NULL,
|
||||
),
|
||||
NULL,
|
||||
|
||||
@@ -63,6 +63,7 @@ struct hexagonfs_fd {
|
||||
};
|
||||
|
||||
extern struct hexagonfs_file_ops hexagonfs_mapped_ops;
|
||||
extern struct hexagonfs_file_ops hexagonfs_mapped_sysfs_ops;
|
||||
extern struct hexagonfs_file_ops hexagonfs_plat_subtype_name_ops;
|
||||
extern struct hexagonfs_file_ops hexagonfs_virt_dir_ops;
|
||||
|
||||
|
||||
@@ -216,6 +216,29 @@ static int mapped_stat(struct hexagonfs_fd *fd, struct stat *stats)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the sysfs variant of the stat function.
|
||||
*
|
||||
* The remote processor expects a non-zero size if the file is not empty, even
|
||||
* if a size cannot be determined without reading. The size is 256 on
|
||||
* downstream kernels, so set it to that.
|
||||
*
|
||||
* Otherwise, the existing stat() function can be used.
|
||||
*/
|
||||
static int mapped_sysfs_stat(struct hexagonfs_fd *fd, struct stat *stats)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = mapped_stat(fd, stats);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!(stats->st_mode & S_IFDIR))
|
||||
stats->st_size = 256;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct hexagonfs_file_ops hexagonfs_mapped_ops = {
|
||||
.close = mapped_close,
|
||||
.from_dirent = mapped_from_dirent,
|
||||
@@ -225,3 +248,13 @@ struct hexagonfs_file_ops hexagonfs_mapped_ops = {
|
||||
.seek = mapped_seek,
|
||||
.stat = mapped_stat,
|
||||
};
|
||||
|
||||
struct hexagonfs_file_ops hexagonfs_mapped_sysfs_ops = {
|
||||
.close = mapped_close,
|
||||
.from_dirent = mapped_from_dirent,
|
||||
.openat = mapped_openat,
|
||||
.read = mapped_read,
|
||||
.readdir = mapped_readdir,
|
||||
.seek = mapped_seek,
|
||||
.stat = mapped_sysfs_stat,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user