@@ -21,11 +21,7 @@ struct ucsi_acpi {
2121 struct device * dev ;
2222 struct ucsi * ucsi ;
2323 void * base ;
24- struct completion complete ;
25- unsigned long flags ;
26- #define UCSI_ACPI_COMMAND_PENDING 1
27- #define UCSI_ACPI_ACK_PENDING 2
28- #define UCSI_ACPI_CHECK_BOGUS_EVENT 3
24+ bool check_bogus_event ;
2925 guid_t guid ;
3026 u64 cmd ;
3127};
@@ -98,38 +94,11 @@ static int ucsi_acpi_async_control(struct ucsi *ucsi, u64 command)
9894 return ucsi_acpi_dsm (ua , UCSI_DSM_FUNC_WRITE );
9995}
10096
101- static int ucsi_acpi_sync_control (struct ucsi * ucsi , u64 command )
102- {
103- struct ucsi_acpi * ua = ucsi_get_drvdata (ucsi );
104- bool ack = UCSI_COMMAND (command ) == UCSI_ACK_CC_CI ;
105- int ret ;
106-
107- if (ack )
108- set_bit (UCSI_ACPI_ACK_PENDING , & ua -> flags );
109- else
110- set_bit (UCSI_ACPI_COMMAND_PENDING , & ua -> flags );
111-
112- ret = ucsi_acpi_async_control (ucsi , command );
113- if (ret )
114- goto out_clear_bit ;
115-
116- if (!wait_for_completion_timeout (& ua -> complete , 5 * HZ ))
117- ret = - ETIMEDOUT ;
118-
119- out_clear_bit :
120- if (ack )
121- clear_bit (UCSI_ACPI_ACK_PENDING , & ua -> flags );
122- else
123- clear_bit (UCSI_ACPI_COMMAND_PENDING , & ua -> flags );
124-
125- return ret ;
126- }
127-
12897static const struct ucsi_operations ucsi_acpi_ops = {
12998 .read_version = ucsi_acpi_read_version ,
13099 .read_cci = ucsi_acpi_read_cci ,
131100 .read_message_in = ucsi_acpi_read_message_in ,
132- .sync_control = ucsi_acpi_sync_control ,
101+ .sync_control = ucsi_sync_control_common ,
133102 .async_control = ucsi_acpi_async_control
134103};
135104
@@ -165,7 +134,7 @@ static const struct ucsi_operations ucsi_zenbook_ops = {
165134 .read_version = ucsi_acpi_read_version ,
166135 .read_cci = ucsi_zenbook_read_cci ,
167136 .read_message_in = ucsi_zenbook_read_message_in ,
168- .sync_control = ucsi_acpi_sync_control ,
137+ .sync_control = ucsi_sync_control_common ,
169138 .async_control = ucsi_acpi_async_control
170139};
171140
@@ -182,14 +151,14 @@ static int ucsi_gram_read_message_in(struct ucsi *ucsi, void *val, size_t val_le
182151 return ret ;
183152
184153 if (UCSI_COMMAND (ua -> cmd ) == UCSI_GET_CONNECTOR_STATUS &&
185- test_bit ( UCSI_ACPI_CHECK_BOGUS_EVENT , & ua -> flags ) ) {
154+ ua -> check_bogus_event ) {
186155 status = (struct ucsi_connector_status * )val ;
187156
188157 /* Clear the bogus change */
189158 if (status -> change == bogus_change )
190159 status -> change = 0 ;
191160
192- clear_bit ( UCSI_ACPI_CHECK_BOGUS_EVENT , & ua -> flags ) ;
161+ ua -> check_bogus_event = false ;
193162 }
194163
195164 return ret ;
@@ -200,14 +169,14 @@ static int ucsi_gram_sync_control(struct ucsi *ucsi, u64 command)
200169 struct ucsi_acpi * ua = ucsi_get_drvdata (ucsi );
201170 int ret ;
202171
203- ret = ucsi_acpi_sync_control (ucsi , command );
172+ ret = ucsi_sync_control_common (ucsi , command );
204173 if (ret < 0 )
205174 return ret ;
206175
207176 if (UCSI_COMMAND (ua -> cmd ) == UCSI_GET_PDOS &&
208177 ua -> cmd & UCSI_GET_PDOS_PARTNER_PDO (1 ) &&
209178 ua -> cmd & UCSI_GET_PDOS_SRC_PDOS )
210- set_bit ( UCSI_ACPI_CHECK_BOGUS_EVENT , & ua -> flags ) ;
179+ ua -> check_bogus_event = true ;
211180
212181 return ret ;
213182}
@@ -249,15 +218,7 @@ static void ucsi_acpi_notify(acpi_handle handle, u32 event, void *data)
249218 if (ret )
250219 return ;
251220
252- if (UCSI_CCI_CONNECTOR (cci ))
253- ucsi_connector_change (ua -> ucsi , UCSI_CCI_CONNECTOR (cci ));
254-
255- if (cci & UCSI_CCI_ACK_COMPLETE &&
256- test_bit (UCSI_ACPI_ACK_PENDING , & ua -> flags ))
257- complete (& ua -> complete );
258- if (cci & UCSI_CCI_COMMAND_COMPLETE &&
259- test_bit (UCSI_ACPI_COMMAND_PENDING , & ua -> flags ))
260- complete (& ua -> complete );
221+ ucsi_notify_common (ua -> ucsi , cci );
261222}
262223
263224static int ucsi_acpi_probe (struct platform_device * pdev )
@@ -291,7 +252,6 @@ static int ucsi_acpi_probe(struct platform_device *pdev)
291252 if (ret )
292253 return ret ;
293254
294- init_completion (& ua -> complete );
295255 ua -> dev = & pdev -> dev ;
296256
297257 id = dmi_first_match (ucsi_acpi_quirks );
0 commit comments