函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:kernel\irq\chip.c Create Date:2022-07-27 11:11:47
首页 Copyright©Brick

982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
static void
__irq_do_set_handler(struct irq_desc *desc, irq_flow_handler_t handle,
             int is_chained, const char *name)
{
    if (!handle) {
        handle = handle_bad_irq;
    } else {
        struct irq_data *irq_data = &desc->irq_data;
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
        /*
         * With hierarchical domains we might run into a
         * situation where the outermost chip is not yet set
         * up, but the inner chips are there.  Instead of
         * bailing we install the handler, but obviously we
         * cannot enable/startup the interrupt at this point.
         */
        while (irq_data) {
            if (irq_data->chip != &no_irq_chip)
                break;
            /*
             * Bail out if the outer chip is not set up
             * and the interrupt supposed to be started
             * right away.
             */
            if (WARN_ON(is_chained))
                return;
            /* Try the parent */
            irq_data = irq_data->parent_data;
        }
#endif
        if (WARN_ON(!irq_data || irq_data->chip == &no_irq_chip))
            return;
    }
 
    /* Uninstall? */
    if (handle == handle_bad_irq) {
        if (desc->irq_data.chip != &no_irq_chip)
            mask_ack_irq(desc);
        irq_state_set_disabled(desc);
        if (is_chained)
            desc->action = NULL;
        desc->depth = 1;
    }
    desc->handle_irq = handle;
    desc->name = name;
 
    if (handle != handle_bad_irq && is_chained) {
        unsigned int type = irqd_get_trigger_type(&desc->irq_data);
 
        /*
         * We're about to start this interrupt immediately,
         * hence the need to set the trigger configuration.
         * But the .set_type callback may have overridden the
         * flow handler, ignoring that we're dealing with a
         * chained interrupt. Reset it immediately because we
         * do know better.
         */
        if (type != IRQ_TYPE_NONE) {
            __irq_set_trigger(desc, type);
            desc->handle_irq = handle;
        }
 
        irq_settings_set_noprobe(desc);
        irq_settings_set_norequest(desc);
        irq_settings_set_nothread(desc);
        desc->action = &chained_action;
        irq_activate_and_startup(desc, IRQ_RESEND);
    }
}