| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) International Business Machines Corp., 2006 |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 5 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 6 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 7 | | - * (at your option) any later version. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
|---|
| 12 | | - * the GNU General Public License for more details. |
|---|
| 13 | | - * |
|---|
| 14 | | - * You should have received a copy of the GNU General Public License |
|---|
| 15 | | - * along with this program; if not, write to the Free Software |
|---|
| 16 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 17 | 4 | * |
|---|
| 18 | 5 | * Author: Artem Bityutskiy (Битюцкий Артём) |
|---|
| 19 | 6 | */ |
|---|
| .. | .. |
|---|
| 69 | 56 | { |
|---|
| 70 | 57 | int ret; |
|---|
| 71 | 58 | struct ubi_volume *vol = container_of(dev, struct ubi_volume, dev); |
|---|
| 72 | | - struct ubi_device *ubi; |
|---|
| 73 | | - |
|---|
| 74 | | - ubi = ubi_get_device(vol->ubi->ubi_num); |
|---|
| 75 | | - if (!ubi) |
|---|
| 76 | | - return -ENODEV; |
|---|
| 59 | + struct ubi_device *ubi = vol->ubi; |
|---|
| 77 | 60 | |
|---|
| 78 | 61 | spin_lock(&ubi->volumes_lock); |
|---|
| 79 | 62 | if (!ubi->volumes[vol->vol_id]) { |
|---|
| 80 | 63 | spin_unlock(&ubi->volumes_lock); |
|---|
| 81 | | - ubi_put_device(ubi); |
|---|
| 82 | 64 | return -ENODEV; |
|---|
| 83 | 65 | } |
|---|
| 84 | 66 | /* Take a reference to prevent volume removal */ |
|---|
| .. | .. |
|---|
| 116 | 98 | vol->ref_count -= 1; |
|---|
| 117 | 99 | ubi_assert(vol->ref_count >= 0); |
|---|
| 118 | 100 | spin_unlock(&ubi->volumes_lock); |
|---|
| 119 | | - ubi_put_device(ubi); |
|---|
| 120 | 101 | return ret; |
|---|
| 121 | 102 | } |
|---|
| 122 | 103 | |
|---|
| .. | .. |
|---|
| 328 | 309 | ubi->volumes[vol_id] = NULL; |
|---|
| 329 | 310 | ubi->vol_count -= 1; |
|---|
| 330 | 311 | spin_unlock(&ubi->volumes_lock); |
|---|
| 331 | | - ubi_eba_destroy_table(eba_tbl); |
|---|
| 332 | 312 | out_acc: |
|---|
| 333 | 313 | spin_lock(&ubi->volumes_lock); |
|---|
| 334 | 314 | ubi->rsvd_pebs -= vol->reserved_pebs; |
|---|