Skip to content
/ linux Public

Commit b10dc16

Browse files
ISCAS-VulabSasha Levin
authored andcommitted
power: supply: bq27xxx: fix wrong errno when bus ops are unsupported
[ Upstream commit 688364a ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 2026d07 commit b10dc16

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/power/supply/bq27xxx_battery.c

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

11641164
if (!di->bus.write)
1165-
return -EPERM;
1165+
return -EOPNOTSUPP;
11661166

11671167
ret = di->bus.write(di, di->regs[reg_index], value, single);
11681168
if (ret < 0)
@@ -1181,7 +1181,7 @@ static inline int bq27xxx_read_block(struct bq27xxx_device_info *di, int reg_ind
11811181
return -EINVAL;
11821182

11831183
if (!di->bus.read_bulk)
1184-
return -EPERM;
1184+
return -EOPNOTSUPP;
11851185

11861186
ret = di->bus.read_bulk(di, di->regs[reg_index], data, len);
11871187
if (ret < 0)
@@ -1200,7 +1200,7 @@ static inline int bq27xxx_write_block(struct bq27xxx_device_info *di, int reg_in
12001200
return -EINVAL;
12011201

12021202
if (!di->bus.write_bulk)
1203-
return -EPERM;
1203+
return -EOPNOTSUPP;
12041204

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

0 commit comments

Comments
 (0)