Skip to content

Commit 24587e9

Browse files
author
Fox Snowpatch
committed
1 parent 1ecdccb commit 24587e9

File tree

7 files changed

+11
-38
lines changed

7 files changed

+11
-38
lines changed

arch/powerpc/platforms/powernv/opal.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ static int opal_add_one_export(struct kobject *parent, const char *export_name,
818818
sysfs_bin_attr_init(attr);
819819
attr->attr.name = name;
820820
attr->attr.mode = 0400;
821-
attr->read = sysfs_bin_attr_simple_read;
821+
attr->read_new = sysfs_bin_attr_simple_read;
822822
attr->private = __va(vals[0]);
823823
attr->size = vals[1];
824824

drivers/platform/x86/wmi-bmof.c

+2-10
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ struct bmof_priv {
2525
struct bin_attribute bmof_bin_attr;
2626
};
2727

28-
static ssize_t read_bmof(struct file *filp, struct kobject *kobj, struct bin_attribute *attr,
29-
char *buf, loff_t off, size_t count)
30-
{
31-
struct bmof_priv *priv = container_of(attr, struct bmof_priv, bmof_bin_attr);
32-
33-
return memory_read_from_buffer(buf, count, &off, priv->bmofdata->buffer.pointer,
34-
priv->bmofdata->buffer.length);
35-
}
36-
3728
static int wmi_bmof_probe(struct wmi_device *wdev, const void *context)
3829
{
3930
struct bmof_priv *priv;
@@ -60,7 +51,8 @@ static int wmi_bmof_probe(struct wmi_device *wdev, const void *context)
6051
sysfs_bin_attr_init(&priv->bmof_bin_attr);
6152
priv->bmof_bin_attr.attr.name = "bmof";
6253
priv->bmof_bin_attr.attr.mode = 0400;
63-
priv->bmof_bin_attr.read = read_bmof;
54+
priv->bmof_bin_attr.read_new = sysfs_bin_attr_simple_read;
55+
priv->bmof_bin_attr.private = priv->bmofdata->buffer.pointer;
6456
priv->bmof_bin_attr.size = priv->bmofdata->buffer.length;
6557

6658
ret = device_create_bin_file(&wdev->dev, &priv->bmof_bin_attr);

fs/sysfs/file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ EXPORT_SYMBOL_GPL(sysfs_emit_at);
817817
* Returns number of bytes written to @buf.
818818
*/
819819
ssize_t sysfs_bin_attr_simple_read(struct file *file, struct kobject *kobj,
820-
struct bin_attribute *attr, char *buf,
820+
const struct bin_attribute *attr, char *buf,
821821
loff_t off, size_t count)
822822
{
823823
memcpy(buf, attr->private + off, count);

include/linux/sysfs.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ __printf(3, 4)
511511
int sysfs_emit_at(char *buf, int at, const char *fmt, ...);
512512

513513
ssize_t sysfs_bin_attr_simple_read(struct file *file, struct kobject *kobj,
514-
struct bin_attribute *attr, char *buf,
514+
const struct bin_attribute *attr, char *buf,
515515
loff_t off, size_t count);
516516

517517
#else /* CONFIG_SYSFS */
@@ -774,7 +774,7 @@ static inline int sysfs_emit_at(char *buf, int at, const char *fmt, ...)
774774

775775
static inline ssize_t sysfs_bin_attr_simple_read(struct file *file,
776776
struct kobject *kobj,
777-
struct bin_attribute *attr,
777+
const struct bin_attribute *attr,
778778
char *buf, loff_t off,
779779
size_t count)
780780
{

kernel/bpf/btf.c

+2-13
Original file line numberDiff line numberDiff line change
@@ -7870,17 +7870,6 @@ struct btf_module {
78707870
static LIST_HEAD(btf_modules);
78717871
static DEFINE_MUTEX(btf_module_mutex);
78727872

7873-
static ssize_t
7874-
btf_module_read(struct file *file, struct kobject *kobj,
7875-
struct bin_attribute *bin_attr,
7876-
char *buf, loff_t off, size_t len)
7877-
{
7878-
const struct btf *btf = bin_attr->private;
7879-
7880-
memcpy(buf, btf->data + off, len);
7881-
return len;
7882-
}
7883-
78847873
static void purge_cand_cache(struct btf *btf);
78857874

78867875
static int btf_module_notify(struct notifier_block *nb, unsigned long op,
@@ -7941,8 +7930,8 @@ static int btf_module_notify(struct notifier_block *nb, unsigned long op,
79417930
attr->attr.name = btf->name;
79427931
attr->attr.mode = 0444;
79437932
attr->size = btf->data_size;
7944-
attr->private = btf;
7945-
attr->read = btf_module_read;
7933+
attr->private = btf->data;
7934+
attr->read_new = sysfs_bin_attr_simple_read;
79467935

79477936
err = sysfs_create_bin_file(btf_kobj, attr);
79487937
if (err) {

kernel/bpf/sysfs_btf.c

+2-10
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,16 @@
1212
extern char __start_BTF[];
1313
extern char __stop_BTF[];
1414

15-
static ssize_t
16-
btf_vmlinux_read(struct file *file, struct kobject *kobj,
17-
struct bin_attribute *bin_attr,
18-
char *buf, loff_t off, size_t len)
19-
{
20-
memcpy(buf, __start_BTF + off, len);
21-
return len;
22-
}
23-
2415
static struct bin_attribute bin_attr_btf_vmlinux __ro_after_init = {
2516
.attr = { .name = "vmlinux", .mode = 0444, },
26-
.read = btf_vmlinux_read,
17+
.read_new = sysfs_bin_attr_simple_read,
2718
};
2819

2920
struct kobject *btf_kobj;
3021

3122
static int __init btf_vmlinux_init(void)
3223
{
24+
bin_attr_btf_vmlinux.private = __start_BTF;
3325
bin_attr_btf_vmlinux.size = __stop_BTF - __start_BTF;
3426

3527
if (bin_attr_btf_vmlinux.size == 0)

kernel/module/sysfs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static int add_notes_attrs(struct module *mod, const struct load_info *info)
196196
nattr->attr.mode = 0444;
197197
nattr->size = info->sechdrs[i].sh_size;
198198
nattr->private = (void *)info->sechdrs[i].sh_addr;
199-
nattr->read = sysfs_bin_attr_simple_read;
199+
nattr->read_new = sysfs_bin_attr_simple_read;
200200
++nattr;
201201
}
202202
++loaded;

0 commit comments

Comments
 (0)