Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: typec: tipd: Fix error handling in cd321x_read_data_status

Right now cd321x_read_data_status always returns true even if it
encounters any errors: tps6598x_read_data_status returns a boolean but
we treated it as an errno and then we have a bunch of dev_errs in case
tps6598x_block_read fails but just continue along and return true.
Fix that to correctly report errors to the callee.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-usb/aMvWJo3IkClmFoAA@stanley.mountain/
Signed-off-by: Sven Peter <sven@kernel.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20250920-tipd-fix-v1-1-49886d4f081d@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Sven Peter and committed by
Greg Kroah-Hartman
1c1b2a24 0e61e715

+10 -4
+10 -4
drivers/usb/typec/tipd/core.c
··· 577 577 int ret; 578 578 579 579 ret = tps6598x_read_data_status(tps); 580 - if (ret < 0) 580 + if (!ret) 581 581 return false; 582 582 583 583 if (tps->data_status & TPS_DATA_STATUS_DP_CONNECTION) { 584 584 ret = tps6598x_block_read(tps, TPS_REG_DP_SID_STATUS, 585 585 &cd321x->dp_sid_status, sizeof(cd321x->dp_sid_status)); 586 - if (ret) 586 + if (ret) { 587 587 dev_err(tps->dev, "Failed to read DP SID Status: %d\n", 588 588 ret); 589 + return false; 590 + } 589 591 } 590 592 591 593 if (tps->data_status & TPS_DATA_STATUS_TBT_CONNECTION) { 592 594 ret = tps6598x_block_read(tps, TPS_REG_INTEL_VID_STATUS, 593 595 &cd321x->intel_vid_status, sizeof(cd321x->intel_vid_status)); 594 - if (ret) 596 + if (ret) { 595 597 dev_err(tps->dev, "Failed to read Intel VID Status: %d\n", ret); 598 + return false; 599 + } 596 600 } 597 601 598 602 if (tps->data_status & CD321X_DATA_STATUS_USB4_CONNECTION) { 599 603 ret = tps6598x_block_read(tps, TPS_REG_USB4_STATUS, 600 604 &cd321x->usb4_status, sizeof(cd321x->usb4_status)); 601 - if (ret) 605 + if (ret) { 602 606 dev_err(tps->dev, 603 607 "Failed to read USB4 Status: %d\n", ret); 608 + return false; 609 + } 604 610 } 605 611 606 612 return true;