lkml.org 
[lkml]   [2019]   [Dec]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.19 118/219] rfkill: allocate static minor
    Date
    From: Marcel Holtmann <marcel@holtmann.org>

    [ Upstream commit 8670b2b8b029a6650d133486be9d2ace146fd29a ]

    udev has a feature of creating /dev/<node> device-nodes if it finds
    a devnode:<node> modalias. This allows for auto-loading of modules that
    provide the node. This requires to use a statically allocated minor
    number for misc character devices.

    However, rfkill uses dynamic minor numbers and prevents auto-loading
    of the module. So allocate the next static misc minor number and use
    it for rfkill.

    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    Link: https://lore.kernel.org/r/20191024174042.19851-1-marcel@holtmann.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    include/linux/miscdevice.h | 1 +
    net/rfkill/core.c | 9 +++++++--
    2 files changed, 8 insertions(+), 2 deletions(-)

    diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
    index 3247a3dc7934..b06b75776a32 100644
    --- a/include/linux/miscdevice.h
    +++ b/include/linux/miscdevice.h
    @@ -57,6 +57,7 @@
    #define UHID_MINOR 239
    #define USERIO_MINOR 240
    #define VHOST_VSOCK_MINOR 241
    +#define RFKILL_MINOR 242
    #define MISC_DYNAMIC_MINOR 255

    struct device;
    diff --git a/net/rfkill/core.c b/net/rfkill/core.c
    index 1355f5ca8d22..7fbc8314f626 100644
    --- a/net/rfkill/core.c
    +++ b/net/rfkill/core.c
    @@ -1328,10 +1328,12 @@ static const struct file_operations rfkill_fops = {
    .llseek = no_llseek,
    };

    +#define RFKILL_NAME "rfkill"
    +
    static struct miscdevice rfkill_miscdev = {
    - .name = "rfkill",
    .fops = &rfkill_fops,
    - .minor = MISC_DYNAMIC_MINOR,
    + .name = RFKILL_NAME,
    + .minor = RFKILL_MINOR,
    };

    static int __init rfkill_init(void)
    @@ -1383,3 +1385,6 @@ static void __exit rfkill_exit(void)
    class_unregister(&rfkill_class);
    }
    module_exit(rfkill_exit);
    +
    +MODULE_ALIAS_MISCDEV(RFKILL_MINOR);
    +MODULE_ALIAS("devname:" RFKILL_NAME);
    --
    2.20.1


    \
     
     \ /
      Last update: 2019-12-29 18:33    [W:2.789 / U:0.072 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site