Commit 2830a6d20139df2198d63235df7957712adb28e5

Authored by Vincent Palatin
Committed by Linus Torvalds
1 parent 179a502f8c

rtc: recycle id when unloading a rtc driver

When calling rtc_device_unregister, we are not freeing the id used by the
driver.  So when doing a unload/load cycle for a RTC driver (e.g.  rmmod
rtc_cmos && modprobe rtc_cmos), its id is incremented by one.  As a
consequence, we no longer have neither an rtc0 driver nor a
/proc/driver/rtc (as it only exists for the first driver).

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 1 additions and 0 deletions Side-by-side Diff

... ... @@ -238,6 +238,7 @@
238 238 rtc_proc_del_device(rtc);
239 239 device_unregister(&rtc->dev);
240 240 rtc->ops = NULL;
  241 + ida_simple_remove(&rtc_ida, rtc->id);
241 242 mutex_unlock(&rtc->ops_lock);
242 243 put_device(&rtc->dev);
243 244 }