Skip to content

Commit

Permalink
PCI: Remove assignment from complicated "if" conditions
Browse files Browse the repository at this point in the history
The modifications effectively change the value of len_tmp
in the case where the first condition is not met.

Signed-off-by: Quentin Lambert <lambert.quentin@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
  • Loading branch information
Quentin Lambert authored and Bjorn Helgaas committed Sep 24, 2014
1 parent 79e50e7 commit 2f4096e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions drivers/pci/hotplug/ibmphp_res.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
/* found our range */
if (!res_prev) {
/* first time in the loop */
if ((res_cur->start != range->start) && ((len_tmp = res_cur->start - 1 - range->start) >= res->len)) {
len_tmp = res_cur->start - 1 - range->start;

if ((res_cur->start != range->start) && (len_tmp >= res->len)) {
debug ("len_tmp = %x\n", len_tmp);

if ((len_tmp < len_cur) || (len_cur == 0)) {
Expand Down Expand Up @@ -1084,7 +1086,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
}
if (!res_cur->next) {
/* last device on the range */
if ((range->end != res_cur->end) && ((len_tmp = range->end - (res_cur->end + 1)) >= res->len)) {
len_tmp = range->end - (res_cur->end + 1);

if ((range->end != res_cur->end) && (len_tmp >= res->len)) {
debug ("len_tmp = %x\n", len_tmp);
if ((len_tmp < len_cur) || (len_cur == 0)) {

Expand Down Expand Up @@ -1123,8 +1127,9 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
if (res_prev) {
if (res_prev->rangeno != res_cur->rangeno) {
/* 1st device on this range */
if ((res_cur->start != range->start) &&
((len_tmp = res_cur->start - 1 - range->start) >= res->len)) {
len_tmp = res_cur->start - 1 - range->start;

if ((res_cur->start != range->start) && (len_tmp >= res->len)) {
if ((len_tmp < len_cur) || (len_cur == 0)) {
if ((range->start % tmp_divide) == 0) {
/* just perfect, starting address is divisible by length */
Expand Down

0 comments on commit 2f4096e

Please sign in to comment.