Skip to content

Commit fc23368

Browse files
hakehuangcfriedt
authored andcommitted
driver: display: fix a return error on display_hx8394
hx8394_mipi_tx will return write size, so this can not used to return init call. fixes: #96547 Signed-off-by: Hake Huang <[email protected]>
1 parent 6e7db46 commit fc23368

File tree

1 file changed

+81
-74
lines changed

1 file changed

+81
-74
lines changed

drivers/display/display_hx8394.c

Lines changed: 81 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ static int hx8394_init(const struct device *dev)
537537
{
538538
const struct hx8394_config *config = dev->config;
539539
int ret;
540+
ssize_t ret_tx;
540541
struct mipi_dsi_device mdev;
541542
uint8_t param[2];
542543
uint8_t setmipi[7] = {
@@ -588,68 +589,71 @@ static int hx8394_init(const struct device *dev)
588589
k_sleep(K_MSEC(50));
589590
}
590591
/* Enable extended commands */
591-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
592+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
592593
enable_extension, sizeof(enable_extension));
593-
if (ret < 0) {
594-
return ret;
594+
if (ret_tx < 0) {
595+
LOG_ERR("hx8394_mipi_tx error, %d", ret_tx);
596+
return -EIO;
595597
}
596598

597599
/* Set the number of lanes to DSISETUP0 parameter */
598600
setmipi[1] |= (config->num_of_lanes - 1);
599-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
601+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
600602
setmipi, sizeof(setmipi));
601-
if (ret < 0) {
602-
return ret;
603+
if (ret_tx < 0) {
604+
LOG_ERR("hx8394_mipi_tx error, %d", ret_tx);
605+
return -EIO;
603606
}
604607

605608
/* Set scan direction */
606-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
609+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
607610
address_config, sizeof(address_config));
608-
if (ret < 0) {
609-
return ret;
611+
if (ret_tx < 0) {
612+
LOG_ERR("hx8394_mipi_tx error, %d", ret_tx);
613+
return -EIO;
610614
}
611615

612616
/* Set voltage and current targets */
613-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
617+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
614618
power_config, sizeof(power_config));
615-
if (ret < 0) {
616-
return ret;
619+
if (ret_tx < 0) {
620+
return -EIO;
617621
}
618622

619623
/* Setup display line count and front/back porch size */
620-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
624+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
621625
line_config, sizeof(line_config));
622-
if (ret < 0) {
623-
return ret;
626+
if (ret_tx < 0) {
627+
return -EIO;
624628
}
625629

626630
/* Setup display cycle counts (in counts of TCON CLK) */
627-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
631+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
628632
cycle_config, sizeof(cycle_config));
629-
if (ret < 0) {
630-
return ret;
633+
if (ret_tx < 0) {
634+
return -EIO;
631635
}
632636

633637
/* Set group delay values */
634-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
638+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
635639
gip0_config, sizeof(gip0_config));
636-
if (ret < 0) {
637-
return ret;
640+
if (ret_tx < 0) {
641+
return -EIO;
638642
}
639643

640644

641645
/* Set group clock selections */
642-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
646+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
643647
gip1_config, sizeof(gip1_config));
644-
if (ret < 0) {
645-
return ret;
648+
if (ret_tx < 0) {
649+
return -EIO;
646650
}
647651

648652
/* Set group clock selections for GS mode */
649-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
653+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
650654
gip2_config, sizeof(gip2_config));
651-
if (ret < 0) {
652-
return ret;
655+
if (ret_tx < 0) {
656+
return -EIO;
653657
}
654658

655659
/* Delay for a moment before setting VCOM. It is not clear
@@ -658,116 +662,119 @@ static int hx8394_init(const struct device *dev)
658662
*/
659663
k_msleep(1);
660664
/* Set VCOM voltage config */
661-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
665+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
662666
vcom_config, sizeof(vcom_config));
663-
if (ret < 0) {
664-
return ret;
667+
if (ret_tx < 0) {
668+
return -EIO;
665669
}
666670

667671
/* Set manufacturer supplied gamma values */
668-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
672+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
669673
gamma_config, sizeof(gamma_config));
670-
if (ret < 0) {
671-
return ret;
674+
if (ret_tx < 0) {
675+
return -EIO;
672676
}
673677

674678
/* This command is not documented in datasheet, but is included
675679
* in the display initialization done by MCUXpresso SDK
676680
*/
677-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
681+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
678682
hx8394_cmd1, sizeof(hx8394_cmd1));
679-
if (ret < 0) {
680-
return ret;
683+
if (ret_tx < 0) {
684+
return -EIO;
681685
}
682686

683687
/* Set panel to BGR mode, and reverse colors */
684-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
688+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
685689
panel_config, sizeof(panel_config));
686-
if (ret < 0) {
687-
return ret;
690+
if (ret_tx < 0) {
691+
return -EIO;
688692
}
689693

690694
/* This command is not documented in datasheet, but is included
691695
* in the display initialization done by MCUXpresso SDK
692696
*/
693-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
697+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
694698
hx8394_cmd2, sizeof(hx8394_cmd2));
695-
if (ret < 0) {
696-
return ret;
699+
if (ret_tx < 0) {
700+
return -EIO;
697701
}
698702

699703
/* Write values to manufacturer register banks */
700704
param[0] = HX8394_SETBANK;
701705
param[1] = 0x2;
702-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
706+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
703707
param, 2);
704-
if (ret < 0) {
705-
return ret;
708+
if (ret_tx < 0) {
709+
return -EIO;
706710
}
707-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
711+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
708712
hx8394_bank2, sizeof(hx8394_bank2));
709-
if (ret < 0) {
710-
return ret;
713+
if (ret_tx < 0) {
714+
return -EIO;
711715
}
712716
param[1] = 0x0;
713-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
717+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
714718
param, 2);
715-
if (ret < 0) {
716-
return ret;
719+
if (ret_tx < 0) {
720+
return -EIO;
717721
}
718722
/* Select bank 1 */
719723
param[1] = 0x1;
720-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
724+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
721725
param, 2);
722-
if (ret < 0) {
723-
return ret;
726+
if (ret_tx < 0) {
727+
return -EIO;
724728
}
725-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
729+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
726730
hx8394_bank1, sizeof(hx8394_bank1));
727-
if (ret < 0) {
728-
return ret;
731+
if (ret_tx < 0) {
732+
return -EIO;
729733
}
730734
/* Select bank 0 */
731735
param[1] = 0x0;
732-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
736+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
733737
param, 2);
734-
if (ret < 0) {
735-
return ret;
738+
if (ret_tx < 0) {
739+
return -EIO;
736740
}
737-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
741+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
738742
hx8394_bank0, sizeof(hx8394_bank0));
739-
if (ret < 0) {
740-
return ret;
743+
if (ret_tx < 0) {
744+
return -EIO;
741745
}
742746

743747
/* This command is not documented in datasheet, but is included
744748
* in the display initialization done by MCUXpresso SDK
745749
*/
746-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
750+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
747751
hx8394_cmd3, sizeof(hx8394_cmd3));
748-
if (ret < 0) {
749-
return ret;
752+
if (ret_tx < 0) {
753+
return -EIO;
750754
}
751755

752-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
756+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
753757
tear_config, sizeof(tear_config));
754-
if (ret < 0) {
755-
return ret;
758+
if (ret_tx < 0) {
759+
return -EIO;
756760
}
757761

758762
param[0] = MIPI_DCS_EXIT_SLEEP_MODE;
759763

760-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
764+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
761765
param, 1);
762-
if (ret < 0) {
763-
return ret;
766+
if (ret_tx < 0) {
767+
return -EIO;
764768
}
765769
/* We must delay 120ms after exiting sleep mode per datasheet */
766770
k_sleep(K_MSEC(120));
767771

768772
param[0] = MIPI_DCS_SET_DISPLAY_ON;
769-
ret = hx8394_mipi_tx(config->mipi_dsi, config->channel,
773+
ret_tx = hx8394_mipi_tx(config->mipi_dsi, config->channel,
770774
param, 1);
775+
if (ret_tx != 1) {
776+
return -EIO;
777+
}
771778

772779
if (config->bl_gpio.port != NULL) {
773780
ret = gpio_pin_configure_dt(&config->bl_gpio, GPIO_OUTPUT_ACTIVE);
@@ -777,7 +784,7 @@ static int hx8394_init(const struct device *dev)
777784
}
778785
}
779786

780-
return ret;
787+
return 0;
781788
}
782789

783790
#define HX8394_PANEL(id) \

0 commit comments

Comments
 (0)