--- zzzz-none-000/linux-4.9.276/drivers/ata/libata-core.c 2021-07-20 14:21:16.000000000 +0000 +++ falcon-5530-750/linux-4.9.276/drivers/ata/libata-core.c 2023-04-05 08:19:00.000000000 +0000 @@ -730,6 +730,19 @@ return block; } +#ifdef CONFIG_ATA_LEDS +#define LIBATA_BLINK_DELAY 20 /* ms */ +static inline void ata_led_act(struct ata_port *ap) +{ + unsigned long led_delay = LIBATA_BLINK_DELAY; + + if (unlikely(!ap->ledtrig)) + return; + + led_trigger_blink_oneshot(ap->ledtrig, &led_delay, &led_delay, 0); +} +#endif + /** * ata_build_rw_tf - Build ATA taskfile for given read/write request * @tf: Target ATA taskfile @@ -4999,6 +5012,9 @@ if (tag < 0) return NULL; } +#ifdef CONFIG_ATA_LEDS + ata_led_act(ap); +#endif qc = __ata_qc_from_tag(ap, tag); qc->tag = tag; @@ -5902,6 +5918,9 @@ ap->stats.unhandled_irq = 1; ap->stats.idle_irq = 1; #endif +#ifdef CONFIG_ATA_LEDS + ap->ledtrig = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); +#endif ata_sff_port_init(ap); return ap; @@ -5923,6 +5942,12 @@ kfree(ap->pmp_link); kfree(ap->slave_link); +#ifdef CONFIG_ATA_LEDS + if (ap->ledtrig) { + led_trigger_unregister(ap->ledtrig); + kfree(ap->ledtrig); + }; +#endif kfree(ap); host->ports[i] = NULL; } @@ -6369,7 +6394,23 @@ host->ports[i]->print_id = atomic_inc_return(&ata_print_id); host->ports[i]->local_port_no = i + 1; } +#ifdef CONFIG_ATA_LEDS + for (i = 0; i < host->n_ports; i++) { + if (unlikely(!host->ports[i]->ledtrig)) + continue; + snprintf(host->ports[i]->ledtrig_name, + sizeof(host->ports[i]->ledtrig_name), "ata%u", + host->ports[i]->print_id); + + host->ports[i]->ledtrig->name = host->ports[i]->ledtrig_name; + + if (led_trigger_register(host->ports[i]->ledtrig)) { + kfree(host->ports[i]->ledtrig); + host->ports[i]->ledtrig = NULL; + } + } +#endif /* Create associated sysfs transport objects */ for (i = 0; i < host->n_ports; i++) { rc = ata_tport_add(host->dev,host->ports[i]);