Linux USB
 help / color / mirror / Atom feed
From: Xin Ji <xji@analogixsemi.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	bliang@analogixsemi.com, qwen@analogixsemi.com,
	jli@analogixsemi.com, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH v12 3/3] usb: typec: anx7411: Add Analogix PD ANX7411 support
Date: Tue, 5 Jul 2022 10:55:50 +0800	[thread overview]
Message-ID: <20220705025550.GC2303286@anxtwsw-Precision-3640-Tower> (raw)
In-Reply-To: <Yrqe/3Mpnmw4sfyx@kroah.com>

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

  reply	other threads:[~2022-07-05  2:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28  4:48 [PATCH v12 1/3] usb: typec: tcpci: move tcpci.h to include/linux/usb/ Xin Ji
2022-06-28  4:48 ` [PATCH v12 2/3] dt-bindings: usb: Add analogix anx7411 PD binding Xin Ji
2022-06-29 10:12   ` Krzysztof Kozlowski
2022-07-05  2:53     ` Xin Ji
2022-06-28  4:48 ` [PATCH v12 3/3] usb: typec: anx7411: Add Analogix PD ANX7411 support Xin Ji
2022-06-28  6:19   ` Greg Kroah-Hartman
2022-06-28  6:26   ` Greg Kroah-Hartman
2022-07-05  2:55     ` Xin Ji [this message]
2022-06-28 10:48   ` Heikki Krogerus
2022-07-05  2:57     ` Xin Ji

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220705025550.GC2303286@anxtwsw-Precision-3640-Tower \
    --to=xji@analogixsemi.com \
    --cc=bliang@analogixsemi.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jli@analogixsemi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=qwen@analogixsemi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox