lkml.org 
[lkml]   [2018]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v5 5/5] typec: tcpm: Add support for sink PPS related messages
Date
On 22 March 2018 03:53, Guenter Roeck wrote:

> > +static void tcpm_pd_ext_msg_request(struct tcpm_port *port,
> > + const struct pd_message *msg)
> > +{
> > + enum pd_ext_msg_type type = pd_header_type_le(msg->header);
> > + unsigned int data_size = pd_ext_header_data_size_le(msg-
> >ext_msg.header);
> > + u8 *data;
> > +
> > + if (!(msg->ext_msg.header && PD_EXT_HDR_CHUNKED)) {
> > + tcpm_log(port, "Unchunked extended messages unsupported");
> > + return;
> > + }
> > +
> > + if (data_size > (PD_EXT_MAX_CHUNK_DATA)) {
> > + tcpm_log(port, "Chunk handling not yet supported");
> > + return;
> > + }
> > +
> > + data = kzalloc(data_size, GFP_KERNEL);
> > + if (!data) {
> > + tcpm_log(port, "Failed to allocate memory for ext msg data");
> > + return;
> > + }
> > + memcpy(data, msg->ext_msg.data, data_size);
> > +
> > + switch (type) {
> > + case PD_EXT_STATUS:
> > + /*
> > + * If PPS related events raised then get PPS status to clear
> > + * (see USB PD 3.0 Spec, 6.5.2.4)
> > + */
> > + if (data[USB_PD_EXT_SDB_EVENT_FLAGS] &
> USB_PD_EXT_SDB_PPS_EVENTS)
>
> This seems to be the only use of 'data'. Can you explain why it is needed
> in the first place ? Am I missing something ?

Actually it's a fair point. Right now it's not needed so will remove it and
directly reference the ext_msg.data array.
\
 
 \ /
  Last update: 2018-03-22 10:40    [W:1.264 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site