* [PATCH 0/2] usb: typec: cros-ec-ucsi: A couple small cleanups
@ 2025-01-09 22:06 Stephen Boyd
2025-01-09 22:06 ` [PATCH 1/2] usb: typec: cros-ec-ucsi: Add newlines to printk messages Stephen Boyd
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Stephen Boyd @ 2025-01-09 22:06 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-kernel, patches, Benson Leung, chrome-platform, linux-usb,
Pavan Holla, Abhishek Pandit-Subedi, Łukasz Bartosik
A couple small cleanups to the cros-ec-ucsi driver that was recently
introduced. Patches on top of next-20250109.
Stephen Boyd (2):
usb: typec: cros-ec-ucsi: Add newlines to printk messages
usb: typec: cros-ec-ucsi: Mark cros_ucsi_ops static/const
drivers/usb/typec/ucsi/cros_ec_ucsi.c | 30 ++++++++++++---------------
1 file changed, 13 insertions(+), 17 deletions(-)
base-commit: 6ecd20965bdc21b265a0671ccf36d9ad8043f5ab
--
https://chromeos.dev
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 1/2] usb: typec: cros-ec-ucsi: Add newlines to printk messages 2025-01-09 22:06 [PATCH 0/2] usb: typec: cros-ec-ucsi: A couple small cleanups Stephen Boyd @ 2025-01-09 22:06 ` Stephen Boyd 2025-01-10 13:41 ` Łukasz Bartosik 2025-01-09 22:06 ` [PATCH 2/2] usb: typec: cros-ec-ucsi: Mark cros_ucsi_ops static/const Stephen Boyd 2025-01-10 13:38 ` [PATCH 0/2] usb: typec: cros-ec-ucsi: A couple small cleanups Łukasz Bartosik 2 siblings, 1 reply; 6+ messages in thread From: Stephen Boyd @ 2025-01-09 22:06 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: linux-kernel, patches, Benson Leung, chrome-platform, linux-usb, Pavan Holla, Abhishek Pandit-Subedi, Łukasz Bartosik These printks need newlines. Add them and convert to dev_err_probe() in cros_ucsi_probe() to simplify code. Cc: Pavan Holla <pholla@chromium.org> Cc: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Cc: Łukasz Bartosik <ukaszb@chromium.org> Signed-off-by: Stephen Boyd <swboyd@chromium.org> --- drivers/usb/typec/ucsi/cros_ec_ucsi.c | 28 ++++++++++++--------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi/cros_ec_ucsi.c index db8324b71ee9..75646a8d55be 100644 --- a/drivers/usb/typec/ucsi/cros_ec_ucsi.c +++ b/drivers/usb/typec/ucsi/cros_ec_ucsi.c @@ -58,14 +58,14 @@ static int cros_ucsi_read(struct ucsi *ucsi, unsigned int offset, void *val, int ret; if (val_len > MAX_EC_DATA_SIZE) { - dev_err(udata->dev, "Can't read %zu bytes. Too big.", val_len); + dev_err(udata->dev, "Can't read %zu bytes. Too big.\n", val_len); return -EINVAL; } ret = cros_ec_cmd(udata->ec, 0, EC_CMD_UCSI_PPM_GET, &req, sizeof(req), val, val_len); if (ret < 0) { - dev_warn(udata->dev, "Failed to send EC message UCSI_PPM_GET: error=%d", ret); + dev_warn(udata->dev, "Failed to send EC message UCSI_PPM_GET: error=%d\n", ret); return ret; } return 0; @@ -99,7 +99,7 @@ static int cros_ucsi_async_control(struct ucsi *ucsi, u64 cmd) ret = cros_ec_cmd(udata->ec, 0, EC_CMD_UCSI_PPM_SET, req, sizeof(ec_buf), NULL, 0); if (ret < 0) { - dev_warn(udata->dev, "Failed to send EC message UCSI_PPM_SET: error=%d", ret); + dev_warn(udata->dev, "Failed to send EC message UCSI_PPM_SET: error=%d\n", ret); return ret; } return 0; @@ -161,7 +161,7 @@ static void cros_ucsi_write_timeout(struct work_struct *work) if (cros_ucsi_read(udata->ucsi, UCSI_CCI, &cci, sizeof(cci))) { dev_err(udata->dev, - "Reading CCI failed; no write timeout recovery possible."); + "Reading CCI failed; no write timeout recovery possible.\n"); return; } @@ -173,7 +173,7 @@ static void cros_ucsi_write_timeout(struct work_struct *work) msecs_to_jiffies(WRITE_TMO_MS)); else dev_err(udata->dev, - "PPM unresponsive - too many write timeouts."); + "PPM unresponsive - too many write timeouts.\n"); return; } @@ -208,7 +208,7 @@ static int cros_ucsi_event(struct notifier_block *nb, if (!(host_event & PD_EVENT_PPM)) return NOTIFY_OK; - dev_dbg(udata->dev, "UCSI notification received"); + dev_dbg(udata->dev, "UCSI notification received\n"); flush_work(&udata->work); schedule_work(&udata->work); @@ -237,10 +237,8 @@ static int cros_ucsi_probe(struct platform_device *pdev) udata->dev = dev; udata->ec = ec_data->ec_dev; - if (!udata->ec) { - dev_err(dev, "couldn't find parent EC device"); - return -ENODEV; - } + if (!udata->ec) + return dev_err_probe(dev, -ENODEV, "couldn't find parent EC device\n"); platform_set_drvdata(pdev, udata); @@ -249,24 +247,22 @@ static int cros_ucsi_probe(struct platform_device *pdev) init_completion(&udata->complete); udata->ucsi = ucsi_create(dev, &cros_ucsi_ops); - if (IS_ERR(udata->ucsi)) { - dev_err(dev, "failed to allocate UCSI instance"); - return PTR_ERR(udata->ucsi); - } + if (IS_ERR(udata->ucsi)) + return dev_err_probe(dev, PTR_ERR(udata->ucsi), "failed to allocate UCSI instance\n"); ucsi_set_drvdata(udata->ucsi, udata); udata->nb.notifier_call = cros_ucsi_event; ret = cros_usbpd_register_notify(&udata->nb); if (ret) { - dev_err(dev, "failed to register notifier: error=%d", ret); + dev_err_probe(dev, ret, "failed to register notifier\n"); ucsi_destroy(udata->ucsi); return ret; } ret = ucsi_register(udata->ucsi); if (ret) { - dev_err(dev, "failed to register UCSI: error=%d", ret); + dev_err_probe(dev, ret, "failed to register UCSI\n"); cros_ucsi_destroy(udata); return ret; } -- https://chromeos.dev ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] usb: typec: cros-ec-ucsi: Add newlines to printk messages 2025-01-09 22:06 ` [PATCH 1/2] usb: typec: cros-ec-ucsi: Add newlines to printk messages Stephen Boyd @ 2025-01-10 13:41 ` Łukasz Bartosik 0 siblings, 0 replies; 6+ messages in thread From: Łukasz Bartosik @ 2025-01-10 13:41 UTC (permalink / raw) To: Stephen Boyd Cc: Greg Kroah-Hartman, linux-kernel, patches, Benson Leung, chrome-platform, linux-usb, Pavan Holla, Abhishek Pandit-Subedi On Thu, Jan 9, 2025 at 11:06 PM Stephen Boyd <swboyd@chromium.org> wrote: > > These printks need newlines. Add them and convert to dev_err_probe() in > cros_ucsi_probe() to simplify code. > > Cc: Pavan Holla <pholla@chromium.org> > Cc: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Cc: Łukasz Bartosik <ukaszb@chromium.org> > Signed-off-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Łukasz Bartosik <ukaszb@chromium.org> > --- > drivers/usb/typec/ucsi/cros_ec_ucsi.c | 28 ++++++++++++--------------- > 1 file changed, 12 insertions(+), 16 deletions(-) > > diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi/cros_ec_ucsi.c > index db8324b71ee9..75646a8d55be 100644 > --- a/drivers/usb/typec/ucsi/cros_ec_ucsi.c > +++ b/drivers/usb/typec/ucsi/cros_ec_ucsi.c > @@ -58,14 +58,14 @@ static int cros_ucsi_read(struct ucsi *ucsi, unsigned int offset, void *val, > int ret; > > if (val_len > MAX_EC_DATA_SIZE) { > - dev_err(udata->dev, "Can't read %zu bytes. Too big.", val_len); > + dev_err(udata->dev, "Can't read %zu bytes. Too big.\n", val_len); > return -EINVAL; > } > > ret = cros_ec_cmd(udata->ec, 0, EC_CMD_UCSI_PPM_GET, > &req, sizeof(req), val, val_len); > if (ret < 0) { > - dev_warn(udata->dev, "Failed to send EC message UCSI_PPM_GET: error=%d", ret); > + dev_warn(udata->dev, "Failed to send EC message UCSI_PPM_GET: error=%d\n", ret); > return ret; > } > return 0; > @@ -99,7 +99,7 @@ static int cros_ucsi_async_control(struct ucsi *ucsi, u64 cmd) > ret = cros_ec_cmd(udata->ec, 0, EC_CMD_UCSI_PPM_SET, > req, sizeof(ec_buf), NULL, 0); > if (ret < 0) { > - dev_warn(udata->dev, "Failed to send EC message UCSI_PPM_SET: error=%d", ret); > + dev_warn(udata->dev, "Failed to send EC message UCSI_PPM_SET: error=%d\n", ret); > return ret; > } > return 0; > @@ -161,7 +161,7 @@ static void cros_ucsi_write_timeout(struct work_struct *work) > > if (cros_ucsi_read(udata->ucsi, UCSI_CCI, &cci, sizeof(cci))) { > dev_err(udata->dev, > - "Reading CCI failed; no write timeout recovery possible."); > + "Reading CCI failed; no write timeout recovery possible.\n"); > return; > } > > @@ -173,7 +173,7 @@ static void cros_ucsi_write_timeout(struct work_struct *work) > msecs_to_jiffies(WRITE_TMO_MS)); > else > dev_err(udata->dev, > - "PPM unresponsive - too many write timeouts."); > + "PPM unresponsive - too many write timeouts.\n"); > > return; > } > @@ -208,7 +208,7 @@ static int cros_ucsi_event(struct notifier_block *nb, > if (!(host_event & PD_EVENT_PPM)) > return NOTIFY_OK; > > - dev_dbg(udata->dev, "UCSI notification received"); > + dev_dbg(udata->dev, "UCSI notification received\n"); > flush_work(&udata->work); > schedule_work(&udata->work); > > @@ -237,10 +237,8 @@ static int cros_ucsi_probe(struct platform_device *pdev) > udata->dev = dev; > > udata->ec = ec_data->ec_dev; > - if (!udata->ec) { > - dev_err(dev, "couldn't find parent EC device"); > - return -ENODEV; > - } > + if (!udata->ec) > + return dev_err_probe(dev, -ENODEV, "couldn't find parent EC device\n"); > > platform_set_drvdata(pdev, udata); > > @@ -249,24 +247,22 @@ static int cros_ucsi_probe(struct platform_device *pdev) > init_completion(&udata->complete); > > udata->ucsi = ucsi_create(dev, &cros_ucsi_ops); > - if (IS_ERR(udata->ucsi)) { > - dev_err(dev, "failed to allocate UCSI instance"); > - return PTR_ERR(udata->ucsi); > - } > + if (IS_ERR(udata->ucsi)) > + return dev_err_probe(dev, PTR_ERR(udata->ucsi), "failed to allocate UCSI instance\n"); > > ucsi_set_drvdata(udata->ucsi, udata); > > udata->nb.notifier_call = cros_ucsi_event; > ret = cros_usbpd_register_notify(&udata->nb); > if (ret) { > - dev_err(dev, "failed to register notifier: error=%d", ret); > + dev_err_probe(dev, ret, "failed to register notifier\n"); > ucsi_destroy(udata->ucsi); > return ret; > } > > ret = ucsi_register(udata->ucsi); > if (ret) { > - dev_err(dev, "failed to register UCSI: error=%d", ret); > + dev_err_probe(dev, ret, "failed to register UCSI\n"); > cros_ucsi_destroy(udata); > return ret; > } > -- > https://chromeos.dev > ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] usb: typec: cros-ec-ucsi: Mark cros_ucsi_ops static/const 2025-01-09 22:06 [PATCH 0/2] usb: typec: cros-ec-ucsi: A couple small cleanups Stephen Boyd 2025-01-09 22:06 ` [PATCH 1/2] usb: typec: cros-ec-ucsi: Add newlines to printk messages Stephen Boyd @ 2025-01-09 22:06 ` Stephen Boyd 2025-01-10 13:47 ` Łukasz Bartosik 2025-01-10 13:38 ` [PATCH 0/2] usb: typec: cros-ec-ucsi: A couple small cleanups Łukasz Bartosik 2 siblings, 1 reply; 6+ messages in thread From: Stephen Boyd @ 2025-01-09 22:06 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: linux-kernel, patches, Benson Leung, chrome-platform, linux-usb, Pavan Holla, Abhishek Pandit-Subedi, Łukasz Bartosik This structure isn't used outside this file and can be marked const so that it gets moved to read-only memory. Cc: Pavan Holla <pholla@chromium.org> Cc: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Cc: Łukasz Bartosik <ukaszb@chromium.org> Signed-off-by: Stephen Boyd <swboyd@chromium.org> --- drivers/usb/typec/ucsi/cros_ec_ucsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi/cros_ec_ucsi.c index 75646a8d55be..c605c8616726 100644 --- a/drivers/usb/typec/ucsi/cros_ec_ucsi.c +++ b/drivers/usb/typec/ucsi/cros_ec_ucsi.c @@ -133,7 +133,7 @@ static int cros_ucsi_sync_control(struct ucsi *ucsi, u64 cmd) return ret; } -struct ucsi_operations cros_ucsi_ops = { +static const struct ucsi_operations cros_ucsi_ops = { .read_version = cros_ucsi_read_version, .read_cci = cros_ucsi_read_cci, .read_message_in = cros_ucsi_read_message_in, -- https://chromeos.dev ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] usb: typec: cros-ec-ucsi: Mark cros_ucsi_ops static/const 2025-01-09 22:06 ` [PATCH 2/2] usb: typec: cros-ec-ucsi: Mark cros_ucsi_ops static/const Stephen Boyd @ 2025-01-10 13:47 ` Łukasz Bartosik 0 siblings, 0 replies; 6+ messages in thread From: Łukasz Bartosik @ 2025-01-10 13:47 UTC (permalink / raw) To: Stephen Boyd Cc: Greg Kroah-Hartman, linux-kernel, patches, Benson Leung, chrome-platform, linux-usb, Pavan Holla, Abhishek Pandit-Subedi On Thu, Jan 9, 2025 at 11:07 PM Stephen Boyd <swboyd@chromium.org> wrote: > > This structure isn't used outside this file and can be marked const so > that it gets moved to read-only memory. > > Cc: Pavan Holla <pholla@chromium.org> > Cc: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Cc: Łukasz Bartosik <ukaszb@chromium.org> > Signed-off-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Łukasz Bartosik <ukaszb@chromium.org> > --- > drivers/usb/typec/ucsi/cros_ec_ucsi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi/cros_ec_ucsi.c > index 75646a8d55be..c605c8616726 100644 > --- a/drivers/usb/typec/ucsi/cros_ec_ucsi.c > +++ b/drivers/usb/typec/ucsi/cros_ec_ucsi.c > @@ -133,7 +133,7 @@ static int cros_ucsi_sync_control(struct ucsi *ucsi, u64 cmd) > return ret; > } > > -struct ucsi_operations cros_ucsi_ops = { > +static const struct ucsi_operations cros_ucsi_ops = { > .read_version = cros_ucsi_read_version, > .read_cci = cros_ucsi_read_cci, > .read_message_in = cros_ucsi_read_message_in, > -- > https://chromeos.dev > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] usb: typec: cros-ec-ucsi: A couple small cleanups 2025-01-09 22:06 [PATCH 0/2] usb: typec: cros-ec-ucsi: A couple small cleanups Stephen Boyd 2025-01-09 22:06 ` [PATCH 1/2] usb: typec: cros-ec-ucsi: Add newlines to printk messages Stephen Boyd 2025-01-09 22:06 ` [PATCH 2/2] usb: typec: cros-ec-ucsi: Mark cros_ucsi_ops static/const Stephen Boyd @ 2025-01-10 13:38 ` Łukasz Bartosik 2 siblings, 0 replies; 6+ messages in thread From: Łukasz Bartosik @ 2025-01-10 13:38 UTC (permalink / raw) To: Stephen Boyd Cc: Greg Kroah-Hartman, linux-kernel, patches, Benson Leung, chrome-platform, linux-usb, Pavan Holla, Abhishek Pandit-Subedi On Thu, Jan 9, 2025 at 11:06 PM Stephen Boyd <swboyd@chromium.org> wrote: > > A couple small cleanups to the cros-ec-ucsi driver that was recently > introduced. Patches on top of next-20250109. > > Stephen Boyd (2): > usb: typec: cros-ec-ucsi: Add newlines to printk messages > usb: typec: cros-ec-ucsi: Mark cros_ucsi_ops static/const > > drivers/usb/typec/ucsi/cros_ec_ucsi.c | 30 ++++++++++++--------------- > 1 file changed, 13 insertions(+), 17 deletions(-) > Thank you Stephen for the updates. Regards, Łukasz > > base-commit: 6ecd20965bdc21b265a0671ccf36d9ad8043f5ab > -- > https://chromeos.dev > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-01-10 13:47 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-01-09 22:06 [PATCH 0/2] usb: typec: cros-ec-ucsi: A couple small cleanups Stephen Boyd 2025-01-09 22:06 ` [PATCH 1/2] usb: typec: cros-ec-ucsi: Add newlines to printk messages Stephen Boyd 2025-01-10 13:41 ` Łukasz Bartosik 2025-01-09 22:06 ` [PATCH 2/2] usb: typec: cros-ec-ucsi: Mark cros_ucsi_ops static/const Stephen Boyd 2025-01-10 13:47 ` Łukasz Bartosik 2025-01-10 13:38 ` [PATCH 0/2] usb: typec: cros-ec-ucsi: A couple small cleanups Łukasz Bartosik
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®