usb: typec: tps6598x: Check mode of operation
Quoted 13 lines · Sergei Shtylyov
Quoted 11 lines · Heikki Krogerus
Quoted 11 lines
Quoted 10 lines
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+static int tps6598x_check_mode(struct tps6598x *tps) +{ + char mode[5] = { }; + int ret; + + ret = tps6598x_read32(tps, TPS_REG_MODE, (void *)mode);Casting pointers to 'void *' happens automagically, doesn't i?
The third parameter in
tps6598x_read32()is 'u32 *'.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Then why cast to 'void *'?
Because if we don't cast:
drivers/usb/typec/tps6598x.c:408:43: error: passing argument 3 of ‘tps6598x_read32’ from incompatible pointer typeWhy not cast to 'u32 *', I meant?
I always prefer (void *) in cases like this, and I believe I'm not the only one. Though in this case, even if we later had to change the tps6598x_read32() parameter to 'void *' from 'u32 *', it would not be an issue to convert callers like this, but as a general rule, we should not need to do that.
thanks,