Re: [PATCH] usb: typec: tps6598x: Check mode of operation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 14, 2019 at 06:29:43PM +0300, Sergei Shtylyov wrote:
> On 02/14/2019 06:28 PM, Heikki Krogerus wrote:
> 
> >>>>> +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 *'.
> >>
> >>    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 type
> 
>    Why 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,

-- 
heikki



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux