From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Rob Barnes <robbarnes@google.com>
Cc: chrome-platform@lists.linux.dev, dnojiri@chromium.org,
groweck@chromium.org, gwendal@chromium.org
Subject: Re: [PATCH] platform/chrome: cros_ec: Separate logic for getting panic info
Date: Fri, 7 Apr 2023 10:33:47 +0800 [thread overview]
Message-ID: <ZC+BC062FGL5ylMb@google.com> (raw)
In-Reply-To: <20230406095423.1.I8e3c16fbecd17956b0a44fc486a8ede3ddb13eec@changeid>
On Thu, Apr 06, 2023 at 04:14:14PM +0000, Rob Barnes wrote:
> -static int cros_ec_create_panicinfo(struct cros_ec_debugfs *debug_info)
> +/**
> + * Returns the size of the panicinfo data fetched from the EC
> + */
> +static int cros_ec_get_panicinfo(struct cros_ec_device *ec_dev, uint8_t *data,
> + int data_size)
> {
> - struct cros_ec_device *ec_dev = debug_info->ec->ec_dev;
> - int ret;
> + int ret = 0;
`ret` doesn't need to be initialized. It will be overridden soon anyway.
> - insize = ec_dev->max_response;
> + if (!data || data_size <= 0)
> + return -EINVAL;
How about `data_size > ec_dev->max_response`?
> - msg = devm_kzalloc(debug_info->ec->dev,
> - sizeof(*msg) + insize, GFP_KERNEL);
> + msg = devm_kzalloc(ec_dev->dev, sizeof(*msg) + data_size, GFP_KERNEL);
In the case, it doesn't have to be devm anymore.
> ret = cros_ec_cmd_xfer_status(ec_dev, msg);
> +
> + if (ret < 0)
> + goto free;
If possible, please remove the extra blank line to make them look as a whole.
> +free:
> + devm_kfree(ec_dev->dev, msg);
Given that the function controls the memory's lifecycle, it doesn't have to
be devm.
> +static int cros_ec_create_panicinfo(struct cros_ec_debugfs *debug_info)
> +{
> + struct cros_ec_device *ec_dev = debug_info->ec->ec_dev;
[...]
> + ret = cros_ec_get_panicinfo(ec_dev, data, ec_dev->max_response);
> +
> if (ret < 0) {
> ret = 0;
> goto free;
Ditto, please remove the extra blank line if possible.
next prev parent reply other threads:[~2023-04-07 2:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-06 16:14 [PATCH] platform/chrome: cros_ec: Separate logic for getting panic info Rob Barnes
2023-04-07 2:33 ` Tzung-Bi Shih [this message]
2023-04-10 16:58 ` [PATCH v2] " Rob Barnes
2023-04-11 3:00 ` patchwork-bot+chrome-platform
2023-04-11 5:00 ` patchwork-bot+chrome-platform
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=ZC+BC062FGL5ylMb@google.com \
--to=tzungbi@kernel.org \
--cc=chrome-platform@lists.linux.dev \
--cc=dnojiri@chromium.org \
--cc=groweck@chromium.org \
--cc=gwendal@chromium.org \
--cc=robbarnes@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.