mmc: core: Added support for LED trigger only when SD card is connected
PATCH 1/1 mmc: core: Added support for LED trigger only when SD card is connected
led_trigger_event() is always called.
In this case, if the LED trigger is set to the SD Card, the trigger will occur even when the SD card is not connected and the LED will blink.
In case of SD Card, it is judged based on Card Detection information and changes to generate LED trigger only when SD Card is connected.
Board tested: NXP i.MX 8M board
--- drivers/mmc/core/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/mmc/core/core.c +5 -1
@@ -352,7 +352,11 @@ int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)if (err)return err; -led_trigger_event (host->led,LED_FULL ); +if (host->ops->get_cd) + host->ops->get_cd (host) ?led_trigger_event (host->led,LED_FULL ) :NULL ; +else +led_trigger_event (host->led,LED_FULL ); +__mmc_start_request (host, mrq);return 0 ;
Signature · 1 line
2.17.1
Quoted 20 lines · Kwon Tae-young
led_trigger_event()is always called.
In this case, if the LED trigger is set to the SD Card, the trigger will occur even when the SD card is not connected and the LED will blink.In case of SD Card, it is judged based on Card Detection information and changes to generate LED trigger only when SD Card is connected.
Board tested: NXP i.MX 8M board
Signed-off-by Kwon Tae-young <[email protected]>--- drivers/mmc/core/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/mmc/core/core.c +0
-0
drivers/mmc/core/core.c int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) · line 355
Quoted 5 lines
drivers/mmc/core/core.c +1
-1@@ -352,7 +352,11 @@ int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)if (err)return err; -led_trigger_event (host->led,LED_FULL ); +if (host->ops->get_cd)
No, this is not the right thing to do. Invoking the ->get_cd() callback, for every request is suboptimal and would likely have effects on performance.
Moreover, I wonder how big an issue it is to use the led here. If the card is being removed, the request will fail anyway, so the led should soon stop flashing anyway, right?
Quoted 10 lines
drivers/mmc/core/core.c +4
-1+ host->ops->get_cd (host) ?led_trigger_event (host->led,LED_FULL ) :NULL ; + else + led_trigger_event(host->led, LED_FULL); +__mmc_start_request (host, mrq);return 0 ; --2.17.1
Kind regards
Uffe
Quoted 12 lines
drivers/mmc/core/core.c int mmc_start_request(struct mmc_host *host,
Quoted 5 lines
drivers/mmc/core/core.c index renamed from drivers/mmc/core/core.c +0
-0
f194940c5974..b3156f6c5cfa100644drivers/mmc/core/core.c +0
-0@@ -352,7 +352,11 @@ int mmc_start_request(struct mmc_host *host,struct
mmc_request*mrq)drivers/mmc/core/core.c int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) · line 355
Quoted 5 lines
drivers/mmc/core/core.c +1
-1if (err)return err; -led_trigger_event (host->led,LED_FULL ); +if (host->ops->get_cd)
Quoted 7 lines
No, this is not the right thing to do. Invoking the ->get_cd() callback, for every request is suboptimal and would likely have effects on performance.
Moreover, I wonder how big an issue it is to use the led here. If the card is being removed, the request will fail anyway, so the led should soon stop flashing anyway, right?
Thanks for the feedback.
When I think about it, it seems that an error should be returned from the mmc_card_removed() function when the SD card is removed. However, in my current board, no error is returned from mmc_card_removed().
I'm guessing it's because of the NULL in the mmc_sd_remove() function in drivers/mmc/core/sd.c , but I'm not sure. I think it was clumsy because I was a newbie unfamiliar with mmc drivers. :)
I'll take a closer look.
Regards,
Kwon
Quoted 4 lines
I'm guessing it's because of the NULL in the
mmc_sd_remove()function indrivers/mmc/core/sd.c, but I'm not sure.
I think it was clumsy because I was a newbie unfamiliar with mmc drivers. :) I'll take a closer look.
This was a hardware issue.
The CD pins on my hardware kept vibrating. :)