Skip to content

Commit

Permalink
net: phy: spi_ks8995: clean up ks8995_registers_read/write
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vladimir Zapolskiy authored and David S. Miller committed Jul 30, 2015
1 parent 951debb commit 2f51a9b
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions drivers/net/phy/spi_ks8995.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,6 @@ static int ks8995_reset(struct ks8995_switch *ks)
return ks8995_start(ks);
}

/* ------------------------------------------------------------------------ */

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)
{
Expand All @@ -220,19 +218,9 @@ static ssize_t ks8995_registers_read(struct file *filp, struct kobject *kobj,
dev = container_of(kobj, struct device, kobj);
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);
}


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)
{
Expand All @@ -242,19 +230,9 @@ static ssize_t ks8995_registers_write(struct file *filp, struct kobject *kobj,
dev = container_of(kobj, struct device, kobj);
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);
}


static const struct bin_attribute ks8995_registers_attr = {
.attr = {
.name = "registers",
Expand Down

0 comments on commit 2f51a9b

Please sign in to comment.