• Wolfram Sang's avatar
    device_attributes: add sysfs_attr_init() for dynamic attributes · 12765517
    Wolfram Sang authored
    Made necessary by 6992f533 ("sysfs: Use
    one lockdep class per sysfs attribute").
    
    Prevents further "key xxx not in .data" bug-reports.  Although some
    attributes could probably be converted to static ones, this is left for
    people having hardware to test.
    
    Found by this semantic patch:
    
    @ init @
    type T;
    identifier A;
    @@
    
            T {
                    ...
                    struct device_attribute A;
                    ...
            };
    
    @ main extends init @
    expression E;
    statement S;
    identifier err;
    T *name;
    @@
    
            ... when != sysfs_attr_init(&name->A.attr);
    (
    +       sysfs_attr_init(&name->A.attr);
            if (device_create_file(E, &name->A))
                    S
    |
    +       sysfs_attr_init(&name->A.attr);
            err = device_create_file(E, &name->A);
    )
    
    While reviewing, I put the initialization to apropriate places.
    Signed-off-by: default avatarWolfram Sang <w.sang@pengutronix.de>
    Cc: Eric W. Biederman <ebiederm@xmission.com>
    Cc: Greg KH <gregkh@suse.de>
    Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Cc: Grant Likely <grant.likely@secretlab.ca>
    Cc: Mike Isely <isely@pobox.com>
    Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
    Cc: Sujith Thomas <sujith.thomas@intel.com>
    Cc: Matthew Garrett <mjg@redhat.com>
    Cc: Len Brown <len.brown@intel.com>
    Cc: Krzysztof Helt <krzysztof.h1@wp.pl>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    12765517
fsl-diu-fb.c 44.3 KB