forked from Minki/linux
net: phy: spi_ks8995: clean up ks8995_registers_read/write
The change removes redundant sysfs binary file boundary checks, since this task is already done on caller side in fs/sysfs/file.c Signed-off-by: Vladimir Zapolskiy <vz@mleia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
951debb949
commit
2f51a9b8ad
@ -209,8 +209,6 @@ static int ks8995_reset(struct ks8995_switch *ks)
|
|||||||
return ks8995_start(ks);
|
return ks8995_start(ks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
static ssize_t ks8995_registers_read(struct file *filp, struct kobject *kobj,
|
static ssize_t ks8995_registers_read(struct file *filp, struct kobject *kobj,
|
||||||
struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
|
struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
|
||||||
{
|
{
|
||||||
@ -220,19 +218,9 @@ static ssize_t ks8995_registers_read(struct file *filp, struct kobject *kobj,
|
|||||||
dev = container_of(kobj, struct device, kobj);
|
dev = container_of(kobj, struct device, kobj);
|
||||||
ks8995 = dev_get_drvdata(dev);
|
ks8995 = dev_get_drvdata(dev);
|
||||||
|
|
||||||
if (unlikely(off > ks8995->regs_attr.size))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if ((off + count) > ks8995->regs_attr.size)
|
|
||||||
count = ks8995->regs_attr.size - off;
|
|
||||||
|
|
||||||
if (unlikely(!count))
|
|
||||||
return count;
|
|
||||||
|
|
||||||
return ks8995_read(ks8995, buf, off, count);
|
return ks8995_read(ks8995, buf, off, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ssize_t ks8995_registers_write(struct file *filp, struct kobject *kobj,
|
static ssize_t ks8995_registers_write(struct file *filp, struct kobject *kobj,
|
||||||
struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
|
struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
|
||||||
{
|
{
|
||||||
@ -242,19 +230,9 @@ static ssize_t ks8995_registers_write(struct file *filp, struct kobject *kobj,
|
|||||||
dev = container_of(kobj, struct device, kobj);
|
dev = container_of(kobj, struct device, kobj);
|
||||||
ks8995 = dev_get_drvdata(dev);
|
ks8995 = dev_get_drvdata(dev);
|
||||||
|
|
||||||
if (unlikely(off >= ks8995->regs_attr.size))
|
|
||||||
return -EFBIG;
|
|
||||||
|
|
||||||
if ((off + count) > ks8995->regs_attr.size)
|
|
||||||
count = ks8995->regs_attr.size - off;
|
|
||||||
|
|
||||||
if (unlikely(!count))
|
|
||||||
return count;
|
|
||||||
|
|
||||||
return ks8995_write(ks8995, buf, off, count);
|
return ks8995_write(ks8995, buf, off, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const struct bin_attribute ks8995_registers_attr = {
|
static const struct bin_attribute ks8995_registers_attr = {
|
||||||
.attr = {
|
.attr = {
|
||||||
.name = "registers",
|
.name = "registers",
|
||||||
|
Loading…
Reference in New Issue
Block a user