Skip to content

Commit 688364a

Browse files
ISCAS-Vulabsre
authored andcommitted
power: supply: bq27xxx: fix wrong errno when bus ops are unsupported
bq27xxx_write(), bq27xxx_read_block(), and bq27xxx_write_block() return -EPERM when the bus callback pointer is NULL. A NULL callback indicates the operation is not supported by the bus/driver, not that permission is denied. Return -EOPNOTSUPP instead of -EPERM when di->bus.write/ read_bulk/write_bulk is NULL. Fixes: 14073f6 ("power: supply: bq27xxx: Add bulk transfer bus methods") Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn> Reviewed-by: Matt Ranostay <matt@ranostay.sg> Link: https://patch.msgid.link/20251204083436.1367-1-vulab@iscas.ac.cn Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
1 parent 36b0562 commit 688364a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/power/supply/bq27xxx_battery.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ static inline int bq27xxx_write(struct bq27xxx_device_info *di, int reg_index,
11721172
return -EINVAL;
11731173

11741174
if (!di->bus.write)
1175-
return -EPERM;
1175+
return -EOPNOTSUPP;
11761176

11771177
ret = di->bus.write(di, di->regs[reg_index], value, single);
11781178
if (ret < 0)
@@ -1191,7 +1191,7 @@ static inline int bq27xxx_read_block(struct bq27xxx_device_info *di, int reg_ind
11911191
return -EINVAL;
11921192

11931193
if (!di->bus.read_bulk)
1194-
return -EPERM;
1194+
return -EOPNOTSUPP;
11951195

11961196
ret = di->bus.read_bulk(di, di->regs[reg_index], data, len);
11971197
if (ret < 0)
@@ -1210,7 +1210,7 @@ static inline int bq27xxx_write_block(struct bq27xxx_device_info *di, int reg_in
12101210
return -EINVAL;
12111211

12121212
if (!di->bus.write_bulk)
1213-
return -EPERM;
1213+
return -EOPNOTSUPP;
12141214

12151215
ret = di->bus.write_bulk(di, di->regs[reg_index], data, len);
12161216
if (ret < 0)

0 commit comments

Comments
 (0)