#include <generated/utsrelease.h>
 
 #include <linux/device.h>
+#include <linux/idr.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/string.h>
 };
 ATTRIBUTE_GROUPS(linedisp);
 
+static DEFINE_IDA(linedisp_id);
+
 static void linedisp_release(struct device *dev)
 {
        struct linedisp *linedisp = container_of(dev, struct linedisp, dev);
 
        kfree(linedisp->message);
+       ida_free(&linedisp_id, linedisp->id);
 }
 
 static const struct device_type linedisp_type = {
                      unsigned int num_chars, char *buf,
                      void (*update)(struct linedisp *linedisp))
 {
-       static atomic_t linedisp_id = ATOMIC_INIT(-1);
        int err;
 
        memset(linedisp, 0, sizeof(*linedisp));
        linedisp->num_chars = num_chars;
        linedisp->scroll_rate = DEFAULT_SCROLL_RATE;
 
+       err = ida_alloc(&linedisp_id, GFP_KERNEL);
+       if (err < 0)
+               return err;
+       linedisp->id = err;
+
        device_initialize(&linedisp->dev);
-       dev_set_name(&linedisp->dev, "linedisp.%lu",
-                    (unsigned long)atomic_inc_return(&linedisp_id));
+       dev_set_name(&linedisp->dev, "linedisp.%u", linedisp->id);
 
        /* initialise a timer for scrolling the message */
        timer_setup(&linedisp->timer, linedisp_scroll, 0);
 
  * @message_len: the length of the @message string
  * @scroll_pos: index of the first character of @message currently displayed
  * @scroll_rate: scroll interval in jiffies
+ * @id: instance id of this display
  */
 struct linedisp {
        struct device dev;
        unsigned int message_len;
        unsigned int scroll_pos;
        unsigned int scroll_rate;
+       unsigned int id;
 };
 
 int linedisp_register(struct linedisp *linedisp, struct device *parent,