• Luis R. Rodriguez's avatar
    firmware: use const for remaining firmware names · e0fd9b1d
    Luis R. Rodriguez authored
    We currently use flexible arrays with a char at the
    end for the remaining internal firmware name uses.
    There are two limitations with the way we use this.
    Since we're using a flexible array for a string on the
    struct if we wanted to use two strings it means we'd
    have a disjoint means of handling the strings, one
    using the flexible array, and another a char * pointer.
    We're also currently not using 'const' for the string.
    
    We wish to later extend some firmware data structures
    with other string/char pointers, but we also want to be
    very pedantic about const usage. Since we're going to
    change things to use 'const' we might as well also address
    unified way to use multiple strings on the structs.
    
    Replace the flexible array practice for strings with
    kstrdup_const() and kfree_const(), this will avoid
    allocations when the vmlinux .rodata is used, and just
    allocate a new proper string for us when needed. This
    also means we can simplify the struct allocations by
    removing the string length from the allocation size
    computation, which would otherwise get even more
    complicated when supporting multiple strings.
    
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Rusty Russell <rusty@rustcorp.com.au>
    Cc: David Howells <dhowells@redhat.com>
    Cc: Ming Lei <ming.lei@canonical.com>
    Cc: Seth Forshee <seth.forshee@canonical.com>
    Cc: Kyle McMartin <kyle@kernel.org>
    Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@suse.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    e0fd9b1d
firmware_class.c 39.6 KB