Skip to content
  • Okash Khawaja's avatar
    staging: speakup: safely register and unregister ldisc · e23a9b43
    Okash Khawaja authored
    
    
    This patch makes use of functions added in the previous patch. It
    registers ldisc during init of main speakup module and unregisters it
    during exit. It also removes the code to register ldisc every time a
    synth module is loaded. This way we only register the ldisc once when
    main speakup module is loaded. Since main speakup module is required by
    all synth modules, it is only unloaded when all synths have been
    unloaded. Therefore we unregister the ldisc once, when all speakup
    related references to the ldisc have returned. In unlikely scenario of
    something outside speakup using the ldisc, the ldisc refcount check in
    tty_unregister_ldisc will ensure that it is not unregistered while in
    use.
    
    The function to register ldisc doesn't cause speakup init function to
    fail. That is different from current behaviour where failure to register
    ldisc results in failure to load the specific synth module. This is
    because speakup module is also required by those synths which don't use
    tty and ldisc. We don't want to prevent those modules from loading when
    ldisc fails to register. The synth modules will correctly fail when
    trying to set N_SPEAKUP to tty, if ldisc registrationi had failed.
    
    Signed-off-by: default avatarOkash Khawaja <okash.khawaja@gmail.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    e23a9b43