@@ -206,7 +206,6 @@ enum atmci_pdc_buf {
206
206
* @bus_width: Number of data lines wired up the slot
207
207
* @detect_pin: GPIO pin wired to the card detect switch
208
208
* @wp_pin: GPIO pin wired to the write protect sensor
209
- * @detect_is_active_high: The state of the detect pin when it is active
210
209
* @non_removable: The slot is not removable, only detect once
211
210
*
212
211
* If a given slot is not present on the board, @bus_width should be
@@ -222,7 +221,6 @@ struct mci_slot_pdata {
222
221
unsigned int bus_width ;
223
222
struct gpio_desc * detect_pin ;
224
223
struct gpio_desc * wp_pin ;
225
- bool detect_is_active_high ;
226
224
bool non_removable ;
227
225
};
228
226
@@ -405,7 +403,6 @@ struct atmel_mci {
405
403
* available.
406
404
* @wp_pin: GPIO pin used for card write protect sending, or negative
407
405
* if not available.
408
- * @detect_is_active_high: The state of the detect pin when it is active.
409
406
* @detect_timer: Timer used for debouncing @detect_pin interrupts.
410
407
*/
411
408
struct atmel_mci_slot {
@@ -426,7 +423,6 @@ struct atmel_mci_slot {
426
423
427
424
struct gpio_desc * detect_pin ;
428
425
struct gpio_desc * wp_pin ;
429
- bool detect_is_active_high ;
430
426
431
427
struct timer_list detect_timer ;
432
428
};
@@ -644,6 +640,7 @@ atmci_of_init(struct platform_device *pdev)
644
640
struct device_node * cnp ;
645
641
struct mci_platform_data * pdata ;
646
642
u32 slot_id ;
643
+ int err ;
647
644
648
645
if (!np ) {
649
646
dev_err (& pdev -> dev , "device node not found\n" );
@@ -675,20 +672,25 @@ atmci_of_init(struct platform_device *pdev)
675
672
pdata -> slot [slot_id ].detect_pin =
676
673
devm_fwnode_gpiod_get (& pdev -> dev , of_fwnode_handle (cnp ),
677
674
"cd" , GPIOD_IN , "cd-gpios" );
678
- if (IS_ERR (pdata -> slot [slot_id ].detect_pin ))
675
+ err = PTR_ERR_OR_ZERO (pdata -> slot [slot_id ].detect_pin );
676
+ if (err ) {
677
+ if (err != - ENOENT )
678
+ return ERR_PTR (err );
679
679
pdata -> slot [slot_id ].detect_pin = NULL ;
680
-
681
- pdata -> slot [slot_id ].detect_is_active_high =
682
- of_property_read_bool (cnp , "cd-inverted" );
680
+ }
683
681
684
682
pdata -> slot [slot_id ].non_removable =
685
683
of_property_read_bool (cnp , "non-removable" );
686
684
687
685
pdata -> slot [slot_id ].wp_pin =
688
686
devm_fwnode_gpiod_get (& pdev -> dev , of_fwnode_handle (cnp ),
689
687
"wp" , GPIOD_IN , "wp-gpios" );
690
- if (IS_ERR (pdata -> slot [slot_id ].wp_pin ))
688
+ err = PTR_ERR_OR_ZERO (pdata -> slot [slot_id ].wp_pin );
689
+ if (err ) {
690
+ if (err != - ENOENT )
691
+ return ERR_PTR (err );
691
692
pdata -> slot [slot_id ].wp_pin = NULL ;
693
+ }
692
694
}
693
695
694
696
return pdata ;
@@ -1566,8 +1568,7 @@ static int atmci_get_cd(struct mmc_host *mmc)
1566
1568
struct atmel_mci_slot * slot = mmc_priv (mmc );
1567
1569
1568
1570
if (slot -> detect_pin ) {
1569
- present = !(gpiod_get_raw_value (slot -> detect_pin ) ^
1570
- slot -> detect_is_active_high );
1571
+ present = gpiod_get_value_cansleep (slot -> detect_pin );
1571
1572
dev_dbg (& mmc -> class_dev , "card is %spresent\n" ,
1572
1573
present ? "" : "not " );
1573
1574
}
@@ -1680,8 +1681,7 @@ static void atmci_detect_change(struct timer_list *t)
1680
1681
return ;
1681
1682
1682
1683
enable_irq (gpiod_to_irq (slot -> detect_pin ));
1683
- present = !(gpiod_get_raw_value (slot -> detect_pin ) ^
1684
- slot -> detect_is_active_high );
1684
+ present = gpiod_get_value_cansleep (slot -> detect_pin );
1685
1685
present_old = test_bit (ATMCI_CARD_PRESENT , & slot -> flags );
1686
1686
1687
1687
dev_vdbg (& slot -> mmc -> class_dev , "detect change: %d (was %d)\n" ,
@@ -2272,15 +2272,14 @@ static int atmci_init_slot(struct atmel_mci *host,
2272
2272
slot -> host = host ;
2273
2273
slot -> detect_pin = slot_data -> detect_pin ;
2274
2274
slot -> wp_pin = slot_data -> wp_pin ;
2275
- slot -> detect_is_active_high = slot_data -> detect_is_active_high ;
2276
2275
slot -> sdc_reg = sdc_reg ;
2277
2276
slot -> sdio_irq = sdio_irq ;
2278
2277
2279
2278
dev_dbg (& mmc -> class_dev ,
2280
2279
"slot[%u]: bus_width=%u, detect_pin=%d, "
2281
2280
"detect_is_active_high=%s, wp_pin=%d\n" ,
2282
2281
id , slot_data -> bus_width , desc_to_gpio (slot_data -> detect_pin ),
2283
- slot_data -> detect_is_active_high ? "true" : "false" ,
2282
+ ! gpiod_is_active_low ( slot_data -> detect_pin ) ? "true" : "false" ,
2284
2283
desc_to_gpio (slot_data -> wp_pin ));
2285
2284
2286
2285
mmc -> ops = & atmci_ops ;
@@ -2318,10 +2317,8 @@ static int atmci_init_slot(struct atmel_mci *host,
2318
2317
/* Assume card is present initially */
2319
2318
set_bit (ATMCI_CARD_PRESENT , & slot -> flags );
2320
2319
if (slot -> detect_pin ) {
2321
- if (gpiod_get_raw_value (slot -> detect_pin ) ^
2322
- slot -> detect_is_active_high ) {
2320
+ if (!gpiod_get_value_cansleep (slot -> detect_pin ))
2323
2321
clear_bit (ATMCI_CARD_PRESENT , & slot -> flags );
2324
- }
2325
2322
} else {
2326
2323
dev_dbg (& mmc -> class_dev , "no detect pin available\n" );
2327
2324
}
0 commit comments