• Ivan Orlov's avatar
    USB: make usb class a const structure · 015fbdde
    Ivan Orlov authored
    Now that the driver core allows for struct class to be in read-only
    memory, remove the usb_class structure and create the usbmisc_class
    const class structure declared at build time which places it into
    read-only memory, instead of having it to be dynamically allocated
    at load time.
    
    Additionally, now we register usb class at startup and unregister it
    when shutting down, so we don't have to count uses of the class.
    Therefore we don't need the 'usb_class' structure anymore. Due to this
    fact, remove all static functions related to class initialization and
    deinitialization. We can't use them in 'usb.c' since they are static
    and we don't really need them anymore.
    
    Since we have to register the class in usb_init function in 'usb.c'
    and use it in 'file.c' as well, declare the usbmisc_class structure
    as 'export' in the 'usb.h' file.
    
    Debatable moment: the class registration and unregistration functions
    could be extracted to the 'file.c'. I think we don't want to do this
    since it would be one-line functions. They would make the code paths
    more confusing and add calling overhead.
    Suggested-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: default avatarIvan Orlov <ivan.orlov0322@gmail.com>
    Link: https://lore.kernel.org/r/20230621202514.1223670-1-ivan.orlov0322@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    015fbdde
usb.h 7.48 KB