[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZhOnKWcNllls6gdA@google.com>
Date: Mon, 8 Apr 2024 16:13:29 +0800
From: Tzung-Bi Shih <tzungbi@...nel.org>
To: Pavan Holla <pholla@...omium.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Benson Leung <bleung@...omium.org>,
Guenter Roeck <groeck@...omium.org>, linux-kernel@...r.kernel.org,
linux-usb@...r.kernel.org,
Abhishek Pandit-Subedi <abhishekpandit@...omium.org>,
chrome-platform@...ts.linux.dev
Subject: Re: [PATCH v3 2/2] usb: typec: ucsi: Implement ChromeOS UCSI driver
On Wed, Apr 03, 2024 at 06:05:22PM +0000, Pavan Holla wrote:
> Implementation of a UCSI transport driver for ChromeOS.
> This driver will be loaded if the ChromeOS EC implements a PPM.
How this driver get probed? From drivers/mfd/cros_ec_dev.c? If so, there is
no "cros-ec-ucsi" in the MFD driver yet.
> diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi/cros_ec_ucsi.c
> [...]
> +static int cros_ucsi_async_write(struct ucsi *ucsi, unsigned int offset,
> + const void *val, size_t val_len)
> +{
> + struct cros_ucsi_data *udata = ucsi_get_drvdata(ucsi);
> + uint8_t ec_buffer[MAX_EC_DATA_SIZE + sizeof(struct ec_params_ucsi_ppm_set)];
> + struct ec_params_ucsi_ppm_set *req = (struct ec_params_ucsi_ppm_set *)ec_buffer;
> + int ret = 0;
The initialization is redundant. `ret` will be overridden soon.
> + if (val_len > MAX_EC_DATA_SIZE) {
> + dev_err(udata->dev, "Can't write %zu bytes. Too big.", val_len);
> + return -EINVAL;
> + }
> +
> + memset(req, 0, sizeof(ec_buffer));
The `memset` is redundant.
> + req->offset = offset;
> + memcpy(req->data, val, val_len);
> + ret = cros_ec_cmd(udata->ec, 0, EC_CMD_UCSI_PPM_SET,
> + req, sizeof(struct ec_params_ucsi_ppm_set) + val_len, NULL, 0);
`sizeof(*req)`.
> +static int cros_ucsi_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> [...]
> + udata->ucsi = ucsi_create(udata->dev, &cros_ucsi_ops);
`dev`.
> [...]
> +static const struct platform_device_id cros_ec_ucsi_id[] = {
To be consistent with other symbols, consider either:
- s/cros_ec_/cros_/ for the symbol.
or
- s/cros_ucsi_/cros_ec_ucsi_/g for echoing the file name.
> + { "cros-ec-ucsi"},
The driver has declared DRV_NAME, use it. `{ DRV_NAME, 0 },`.
> + {}
> +};
> +MODULE_DEVICE_TABLE(platform, cros_ec_ucsi_id);
Ditto.
> +static struct platform_driver cros_ucsi_driver = {
> + .driver = {
> + .name = DRV_NAME,
> + .pm = &cros_ucsi_pm_ops,
> + },
> + .id_table = cros_ec_ucsi_id,
Ditto.
Powered by blists - more mailing lists