Skip to content

Commit 2f51a9b

Browse files
vzapolskiydavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 951debb commit 2f51a9b

File tree

1 file changed

+0
-22
lines changed

1 file changed

+0
-22
lines changed

drivers/net/phy/spi_ks8995.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,6 @@ static int ks8995_reset(struct ks8995_switch *ks)
209209
return ks8995_start(ks);
210210
}
211211

212-
/* ------------------------------------------------------------------------ */
213-
214212
static ssize_t ks8995_registers_read(struct file *filp, struct kobject *kobj,
215213
struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
216214
{
@@ -220,19 +218,9 @@ static ssize_t ks8995_registers_read(struct file *filp, struct kobject *kobj,
220218
dev = container_of(kobj, struct device, kobj);
221219
ks8995 = dev_get_drvdata(dev);
222220

223-
if (unlikely(off > ks8995->regs_attr.size))
224-
return 0;
225-
226-
if ((off + count) > ks8995->regs_attr.size)
227-
count = ks8995->regs_attr.size - off;
228-
229-
if (unlikely(!count))
230-
return count;
231-
232221
return ks8995_read(ks8995, buf, off, count);
233222
}
234223

235-
236224
static ssize_t ks8995_registers_write(struct file *filp, struct kobject *kobj,
237225
struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
238226
{
@@ -242,19 +230,9 @@ static ssize_t ks8995_registers_write(struct file *filp, struct kobject *kobj,
242230
dev = container_of(kobj, struct device, kobj);
243231
ks8995 = dev_get_drvdata(dev);
244232

245-
if (unlikely(off >= ks8995->regs_attr.size))
246-
return -EFBIG;
247-
248-
if ((off + count) > ks8995->regs_attr.size)
249-
count = ks8995->regs_attr.size - off;
250-
251-
if (unlikely(!count))
252-
return count;
253-
254233
return ks8995_write(ks8995, buf, off, count);
255234
}
256235

257-
258236
static const struct bin_attribute ks8995_registers_attr = {
259237
.attr = {
260238
.name = "registers",

0 commit comments

Comments
 (0)