Skip to content

Commit 00ab6e9

Browse files
t-8chgregkh
authored andcommitted
nvmem: core: calculate bin_attribute size through bin_size()
Stop abusing the is_bin_visible() callback to calculate the attribute size. Instead use the new, dedicated bin_size() one. Signed-off-by: Thomas Weißschuh <[email protected]> Acked-by: Krzysztof Wilczyński <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a1ab720 commit 00ab6e9

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/nvmem/core.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,19 @@ static umode_t nvmem_bin_attr_is_visible(struct kobject *kobj,
303303
struct device *dev = kobj_to_dev(kobj);
304304
struct nvmem_device *nvmem = to_nvmem_device(dev);
305305

306-
attr->size = nvmem->size;
307-
308306
return nvmem_bin_attr_get_umode(nvmem);
309307
}
310308

309+
static size_t nvmem_bin_attr_size(struct kobject *kobj,
310+
const struct bin_attribute *attr,
311+
int i)
312+
{
313+
struct device *dev = kobj_to_dev(kobj);
314+
struct nvmem_device *nvmem = to_nvmem_device(dev);
315+
316+
return nvmem->size;
317+
}
318+
311319
static umode_t nvmem_attr_is_visible(struct kobject *kobj,
312320
struct attribute *attr, int i)
313321
{
@@ -383,6 +391,7 @@ static const struct attribute_group nvmem_bin_group = {
383391
.bin_attrs = nvmem_bin_attributes,
384392
.attrs = nvmem_attrs,
385393
.is_bin_visible = nvmem_bin_attr_is_visible,
394+
.bin_size = nvmem_bin_attr_size,
386395
.is_visible = nvmem_attr_is_visible,
387396
};
388397

0 commit comments

Comments
 (0)