]> git.baikalelectronics.ru Git - kernel.git/commit
floppy: cleanup: do not iterate on current_fdc in do_floppy_init()
authorWilly Tarreau <w@1wt.eu>
Fri, 10 Apr 2020 09:30:23 +0000 (11:30 +0200)
committerDenis Efremov <efremov@linux.com>
Tue, 12 May 2020 16:34:56 +0000 (19:34 +0300)
commit41c7e31e3c84590ade326b1b687e9efc2ed8368b
tree5f505d006fe72ef358370510b04d811ffa60d12a
parentc8c234cf659a051f069cd58fb29c53963ef88319
floppy: cleanup: do not iterate on current_fdc in do_floppy_init()

There's no need to iterate on current_fdc in do_floppy_init() anymore,
in the first case it's only used as an array index to access fdc_state[],
so let's get rid of this confusing assignment. The second case is a bit
trickier because user_reset_fdc() needs to already know current_fdc when
called with drive==-1 due to this call chain:

    user_reset_fdc()
      lock_fdc()
        set_fdc()
           drive<0 ==> new_fdc = current_fdc

Note that current_drive is not used in this code part and may even not
match a unit belonging to current_fdc. Instead of passing -1 we can
simply pass the first drive of the FDC being initialized, which is even
cleaner as it will allow the function chain above to consistently assign
both variables.

Link: https://lore.kernel.org/r/20200410093023.14499-1-w@1wt.eu
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Denis Efremov <efremov@linux.com>
drivers/block/floppy.c