Skip to content

Commit 1ad6344

Browse files
jbeulichDavid Vrabel
authored andcommitted
xen-pciback: drop superfluous variables
req_start is simply an alias of the "offset" function parameter, and req_end is being used just once in each function. (And both variables were loop invariant anyway, so should at least have got initialized outside the loop.) Signed-off-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
1 parent ee87d6d commit 1ad6344

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

‎drivers/xen/xen-pciback/conf_space.c‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ int xen_pcibk_config_read(struct pci_dev *dev, int offset, int size,
148148
struct xen_pcibk_dev_data *dev_data = pci_get_drvdata(dev);
149149
const struct config_field_entry *cfg_entry;
150150
const struct config_field *field;
151-
int req_start, req_end, field_start, field_end;
151+
int field_start, field_end;
152152
/* if read fails for any reason, return 0
153153
* (as if device didn't respond) */
154154
u32 value = 0, tmp_val;
@@ -178,20 +178,18 @@ int xen_pcibk_config_read(struct pci_dev *dev, int offset, int size,
178178
list_for_each_entry(cfg_entry, &dev_data->config_fields, list) {
179179
field = cfg_entry->field;
180180

181-
req_start = offset;
182-
req_end = offset + size;
183181
field_start = OFFSET(cfg_entry);
184182
field_end = OFFSET(cfg_entry) + field->size;
185183

186-
if (req_end > field_start && field_end > req_start) {
184+
if (offset + size > field_start && field_end > offset) {
187185
err = conf_space_read(dev, cfg_entry, field_start,
188186
&tmp_val);
189187
if (err)
190188
goto out;
191189

192190
value = merge_value(value, tmp_val,
193191
get_mask(field->size),
194-
field_start - req_start);
192+
field_start - offset);
195193
}
196194
}
197195

@@ -211,7 +209,7 @@ int xen_pcibk_config_write(struct pci_dev *dev, int offset, int size, u32 value)
211209
const struct config_field_entry *cfg_entry;
212210
const struct config_field *field;
213211
u32 tmp_val;
214-
int req_start, req_end, field_start, field_end;
212+
int field_start, field_end;
215213

216214
if (unlikely(verbose_request))
217215
printk(KERN_DEBUG
@@ -224,19 +222,17 @@ int xen_pcibk_config_write(struct pci_dev *dev, int offset, int size, u32 value)
224222
list_for_each_entry(cfg_entry, &dev_data->config_fields, list) {
225223
field = cfg_entry->field;
226224

227-
req_start = offset;
228-
req_end = offset + size;
229225
field_start = OFFSET(cfg_entry);
230226
field_end = OFFSET(cfg_entry) + field->size;
231227

232-
if (req_end > field_start && field_end > req_start) {
228+
if (offset + size > field_start && field_end > offset) {
233229
err = conf_space_read(dev, cfg_entry, field_start,
234230
&tmp_val);
235231
if (err)
236232
break;
237233

238234
tmp_val = merge_value(tmp_val, value, get_mask(size),
239-
req_start - field_start);
235+
offset - field_start);
240236

241237
err = conf_space_write(dev, cfg_entry, field_start,
242238
tmp_val);

0 commit comments

Comments
 (0)