Re: [PATCH v12 3/3] usb: typec: anx7411: Add Analogix PD ANX7411 support

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

 



Hi greg k-h, I'll add return value checking.
Thanks,
Xin

On Tue, Jun 28, 2022 at 08:26:07AM +0200, Greg Kroah-Hartman wrote:
> On Tue, Jun 28, 2022 at 12:48:42PM +0800, Xin Ji wrote:
> > +static int anx7411_process_cmd(struct anx7411_data *ctx)
> > +{
> > +	struct device *dev = &ctx->spi_client->dev;
> > +	struct fw_msg *msg = &ctx->recv_msg;
> > +	u8 len;
> > +	u8 crc;
> > +	int ret;
> > +
> > +	/* Read message from firmware */
> > +	ret = anx7411_reg_block_read(ctx->spi_client, CMD_RECV_BUF,
> > +				     MSG_LEN, (u8 *)msg);
> > +	if (ret < 0)
> > +		return 0;
> > +
> > +	if (!msg->msg_len)
> > +		return 0;
> > +
> > +	anx7411_reg_write(ctx->spi_client, CMD_RECV_BUF, 0);
> 
> Again, you are not checking the return value here.  What happens if this
> failed?
> 
> > +
> > +	len = msg->msg_len & MSG_LEN_MASK;
> > +	crc = checksum(dev, (u8 *)msg, len + HEADER_LEN);
> > +	if (crc) {
> > +		dev_err(dev, "message error crc(0x%.02x)\n", crc);
> > +		return -ERANGE;
> > +	}
> > +
> > +	return anx7411_parse_cmd(ctx, msg->msg_type, msg->buf, len - 1);
> > +}
> > +
> > +static void anx7411_translate_payload(struct device *dev, __le32 *payload,
> > +				      u32 *pdo, int nr, const char *type)
> > +{
> > +	int i;
> > +
> > +	if (nr > PDO_MAX_OBJECTS) {
> > +		dev_err(dev, "nr(%d) exceed PDO_MAX_OBJECTS(%d)\n",
> > +			nr, PDO_MAX_OBJECTS);
> > +
> > +		return;
> > +	}
> > +
> > +	for (i = 0; i < nr; i++)
> > +		payload[i] = cpu_to_le32(pdo[i]);
> > +}
> > +
> > +static void anx7411_config(struct anx7411_data *ctx)
> > +{
> > +	struct device *dev = &ctx->spi_client->dev;
> > +	struct typec_params *typecp = &ctx->typec;
> > +	__le32 payload[PDO_MAX_OBJECTS];
> > +
> > +	/* Config PD FW work under PD 2.0 */
> > +	anx7411_reg_write(ctx->spi_client, PD_REV_INIT, PD_REV20);
> > +	anx7411_reg_write(ctx->tcpc_client, FW_CTRL_0,
> > +			  UNSTRUCT_VDM_EN | DELAY_200MS |
> > +			  VSAFE1 | FRS_EN);
> > +	anx7411_reg_write(ctx->spi_client, FW_CTRL_1,
> > +			  AUTO_PD_EN | FORCE_SEND_RDO);
> 
> Same with all of these, what happens if this fails?
> 
> thanks,
> 
> greg k-h



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

  Powered by Linux