Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1332300

Re: [PATCH v1 2/6] mfd: cros_ec: Add MKBP event support

From Gwendal Grignou <gwendal@chromium.org>
Newsgroups linux.kernel
Subject Re: [PATCH v1 2/6] mfd: cros_ec: Add MKBP event support
Date 2016-02-11 19:50 +0100
Message-ID <r14ts-4eC-33@gated-at.bofh.it> (permalink)
References <qYOMa-P6-5@gated-at.bofh.it> <qYOMa-P6-19@gated-at.bofh.it> <r10ST-1KU-35@gated-at.bofh.it> <r10ST-1KU-33@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Feb 11, 2016 at 6:52 AM, Tomeu Vizoso
<tomeu.vizoso@collabora.com> wrote:
>
> On 02/05/2016 06:24 PM, Gwendal Grignou wrote:
> > We should not used kmalloc when get events, these functions are called
> > quite often.
> > Gwendal.
> >
> > On Fri, Feb 5, 2016 at 5:32 AM, Tomeu Vizoso <tomeu.vizoso@collabora.com
> > <mailto:tomeu.vizoso@collabora.com>> wrote:
> >
> >     +static int cros_ec_get_host_command_version_mask(struct
> >     cros_ec_device *ec_dev,
> >     +       u16 cmd, u32 *mask)
> >     +{
> >     +       struct ec_params_get_cmd_versions *pver;
> >     +       struct ec_response_get_cmd_versions *rver;
> >     +       struct cros_ec_command *msg;
> >     +       int ret;
> >     +
> >     +       msg = kmalloc(sizeof(*msg) + max(sizeof(rver), sizeof(pver)),
> >     +                     GFP_KERNEL);
> >     +       if (!msg)
> >     +               return -ENOMEM;
> >
> >  Victor's version in https://chromium-review.googlesource.com/272954
> > looks cleaner: no malloc, no need to cast rver.
>
> I agree that it looks cleaner, but how would you allocate the payload at
> build time if it has to be max(sizeof(*pver), sizeof(*rver))?
For this one, given cros_ec_get_host_command_version_mask() is called
once, a kmalloc is fine.

Gwendal.

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: [PATCH v1 2/6] mfd: cros_ec: Add MKBP event support Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2016-02-11 16:00 +0100
  Re: [PATCH v1 2/6] mfd: cros_ec: Add MKBP event support Gwendal Grignou <gwendal@chromium.org> - 2016-02-11 19:50 +0100

csiph-web