diff options
| author | Sudip Mukherjee <sudipm.mukherjee@gmail.com> | 2015-10-05 20:23:08 -0400 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2015-10-05 20:34:57 -0400 |
| commit | c65cf815653ec64e73d40819806c2d1aed91681e (patch) | |
| tree | 2faaee571d3826d9a4e9bf8e51b0ba709981b4a8 /drivers/input/joystick | |
| parent | c36906c53ccff0f43310fac9606976440a71c742 (diff) | |
Input: turbografx - store object in correct index
The variable i is used to check the port to attach to and we are
supposed to save the reference of struct tgfx in the location given by
tgfx_base[i]. But after finding out the index, i is getting modified
again so we saved in a wrong index.
Fixes: 4de27a638a99 ("Input: turbografx - use parallel port device model")
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/joystick')
| -rw-r--r-- | drivers/input/joystick/turbografx.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c index 01e8ea92b9ad..9f5bca26bd2f 100644 --- a/drivers/input/joystick/turbografx.c +++ b/drivers/input/joystick/turbografx.c | |||
| @@ -162,27 +162,29 @@ static void tgfx_attach(struct parport *pp) | |||
| 162 | struct tgfx *tgfx; | 162 | struct tgfx *tgfx; |
| 163 | struct input_dev *input_dev; | 163 | struct input_dev *input_dev; |
| 164 | struct pardevice *pd; | 164 | struct pardevice *pd; |
| 165 | int i, j; | 165 | int i, j, port_idx; |
| 166 | int *n_buttons, n_devs; | 166 | int *n_buttons, n_devs; |
| 167 | struct pardev_cb tgfx_parport_cb; | 167 | struct pardev_cb tgfx_parport_cb; |
| 168 | 168 | ||
| 169 | for (i = 0; i < TGFX_MAX_PORTS; i++) { | 169 | for (port_idx = 0; port_idx < TGFX_MAX_PORTS; port_idx++) { |
| 170 | if (tgfx_cfg[i].nargs == 0 || tgfx_cfg[i].args[0] < 0) | 170 | if (tgfx_cfg[port_idx].nargs == 0 || |
| 171 | tgfx_cfg[port_idx].args[0] < 0) | ||
| 171 | continue; | 172 | continue; |
| 172 | if (tgfx_cfg[i].args[0] == pp->number) | 173 | if (tgfx_cfg[port_idx].args[0] == pp->number) |
| 173 | break; | 174 | break; |
| 174 | } | 175 | } |
| 175 | 176 | ||
| 176 | if (i == TGFX_MAX_PORTS) { | 177 | if (port_idx == TGFX_MAX_PORTS) { |
| 177 | pr_debug("Not using parport%d.\n", pp->number); | 178 | pr_debug("Not using parport%d.\n", pp->number); |
| 178 | return; | 179 | return; |
| 179 | } | 180 | } |
| 180 | n_buttons = tgfx_cfg[i].args + 1; | 181 | n_buttons = tgfx_cfg[port_idx].args + 1; |
| 181 | n_devs = tgfx_cfg[i].nargs - 1; | 182 | n_devs = tgfx_cfg[port_idx].nargs - 1; |
| 182 | 183 | ||
| 183 | tgfx_parport_cb.flags = PARPORT_FLAG_EXCL; | 184 | tgfx_parport_cb.flags = PARPORT_FLAG_EXCL; |
| 184 | 185 | ||
| 185 | pd = parport_register_dev_model(pp, "turbografx", &tgfx_parport_cb, i); | 186 | pd = parport_register_dev_model(pp, "turbografx", &tgfx_parport_cb, |
| 187 | port_idx); | ||
| 186 | if (!pd) { | 188 | if (!pd) { |
| 187 | pr_err("parport busy already - lp.o loaded?\n"); | 189 | pr_err("parport busy already - lp.o loaded?\n"); |
| 188 | return; | 190 | return; |
| @@ -250,7 +252,7 @@ static void tgfx_attach(struct parport *pp) | |||
| 250 | goto err_free_tgfx; | 252 | goto err_free_tgfx; |
| 251 | } | 253 | } |
| 252 | 254 | ||
| 253 | tgfx_base[i] = tgfx; | 255 | tgfx_base[port_idx] = tgfx; |
| 254 | return; | 256 | return; |
| 255 | 257 | ||
| 256 | err_free_dev: | 258 | err_free_dev: |
