lkml.org 
[lkml]   [2022]   [Apr]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] platform/chrome: cros_ec_proto: Add peripheral charger count API
On Apr 18 16:16, Stephen Boyd wrote:
> Quoting Prashant Malani (2022-04-18 16:08:39)
> > On Apr 14 17:32, Stephen Boyd wrote:
> > > diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
> > > index c4caf2e2de82..42269703ca6c 100644
> > > --- a/drivers/platform/chrome/cros_ec_proto.c
> > > +++ b/drivers/platform/chrome/cros_ec_proto.c
> > > @@ -832,6 +832,37 @@ bool cros_ec_check_features(struct cros_ec_dev *ec, int feature)
> > > }
> > > EXPORT_SYMBOL_GPL(cros_ec_check_features);
> > >
> > > +/**
> > > + * cros_ec_pchg_port_count() - Return the number of peripheral charger ports.
> > > + * @ec: EC device.
> > > + *
> > > + * Return: Number of peripheral charger ports, or 0 in case of error.
> > > + */
> > > +unsigned int cros_ec_pchg_port_count(struct cros_ec_dev *ec)
> > > +{
> > > + struct cros_ec_command *msg;
> > > + const struct ec_response_pchg_count *rsp;
> > > + struct cros_ec_device *ec_dev = ec->ec_dev;
> > > + int ret, count = 0;
> > > +
> > > + msg = kzalloc(sizeof(*msg) + sizeof(*rsp), GFP_KERNEL);
> > > + if (!msg)
> > > + return 0;
> > > +
> > > + msg->command = EC_CMD_PCHG_COUNT + ec->cmd_offset;
> > > + msg->insize = sizeof(*rsp);
> > > +
> > > + ret = cros_ec_cmd_xfer_status(ec_dev, msg);
> > > + if (ret >= 0) {
> > > + rsp = (const struct ec_response_pchg_count *)msg->data;
> > > + count = rsp->port_count;
> > > + }
> > > + kfree(msg);
> >
> > Can we use the wrapper function cros_ec_command() [1] here, which does
> > the kzalloc and msg construction?
> >
>
> Sure. I take it that I can drop this function entirely then?

Yeah, if it's a simple response, should be fine.

> BTW, why is
> that function name the same as a struct name? It confuses my ctags.

Yeahhh, didn't think about ctags... :/
Topic for another series: probably can be renamed to cros_ec_cmd() (just to keep ctags happy) ?

Best regards,

-Prashant

\
 
 \ /
  Last update: 2022-04-19 01:22    [W:0.036 / U:17.952 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site