[PATCH 1/2] usb: typec: tcpm: Call init callback only when provided

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The tcpc_dev structure lists a number of callbacks as required when
implementing a TCPM driver. tcpc_dev->init() is not listed as required.

Currently tcpc_dev->init() is called irrespective of whether or not the
callback is set. Let's conditionally call init() as with other non-required
callbacks such as get_current_limit() or set_current_limit().

Fixes: f0690a25a140b ("staging: typec: USB Type-C Port Manager (tcpm)")
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@xxxxxxxxxx>
---
 drivers/usb/typec/tcpm/tcpm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index c4fdc00a3bc8..355067e6d420 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -5657,7 +5657,8 @@ static void tcpm_init(struct tcpm_port *port)
 {
 	enum typec_cc_status cc1, cc2;
 
-	port->tcpc->init(port->tcpc);
+	if (port->tcpc->init)
+		port->tcpc->init(port->tcpc);
 
 	tcpm_reset_port(port);
 
-- 
2.30.1




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux