qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 05/16] pci/shpc: pass PCIDevice pointer to shpc_slot_comma


From: Anton Kuchin
Subject: Re: [PATCH v4 05/16] pci/shpc: pass PCIDevice pointer to shpc_slot_command()
Date: Tue, 14 Feb 2023 21:35:27 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1

On 13/02/2023 16:00, Vladimir Sementsov-Ogievskiy wrote:
We'll need it in further patch to report bridge in QAPI event.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
  hw/pci/shpc.c | 18 ++++++++++--------
  1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c
index 959dc470f3..9f964b1d70 100644
--- a/hw/pci/shpc.c
+++ b/hw/pci/shpc.c
@@ -263,9 +263,10 @@ static bool shpc_slot_is_off(uint8_t state, uint8_t power, 
uint8_t attn)
      return state == SHPC_STATE_DISABLED && power == SHPC_LED_OFF;
  }
-static void shpc_slot_command(SHPCDevice *shpc, uint8_t target,
+static void shpc_slot_command(PCIDevice *d, uint8_t target,
                                uint8_t state, uint8_t power, uint8_t attn)
  {
+    SHPCDevice *shpc = d->shpc;
      int slot = SHPC_LOGICAL_TO_IDX(target);
      uint8_t old_state = shpc_get_status(shpc, slot, SHPC_SLOT_STATE_MASK);
      uint8_t old_power = shpc_get_status(shpc, slot, SHPC_SLOT_PWR_LED_MASK);
@@ -314,8 +315,9 @@ static void shpc_slot_command(SHPCDevice *shpc, uint8_t 
target,
      }
  }
-static void shpc_command(SHPCDevice *shpc)
+static void shpc_command(PCIDevice *d)
  {
+    SHPCDevice *shpc = d->shpc;
      uint8_t code = pci_get_byte(shpc->config + SHPC_CMD_CODE);
      uint8_t speed;
      uint8_t target;
@@ -336,7 +338,7 @@ static void shpc_command(SHPCDevice *shpc)
          state = (code & SHPC_SLOT_STATE_MASK) >> SHPC_SLOT_STATE_SHIFT;
          power = (code & SHPC_SLOT_PWR_LED_MASK) >> SHPC_SLOT_PWR_LED_SHIFT;
          attn = (code & SHPC_SLOT_ATTN_LED_MASK) >> SHPC_SLOT_ATTN_LED_SHIFT;
-        shpc_slot_command(shpc, target, state, power, attn);
+        shpc_slot_command(d, target, state, power, attn);
          break;
      case 0x40 ... 0x47:
          speed = code & SHPC_SEC_BUS_MASK;
@@ -354,10 +356,10 @@ static void shpc_command(SHPCDevice *shpc)
          }
          for (i = 0; i < shpc->nslots; ++i) {
              if (!(shpc_get_status(shpc, i, SHPC_SLOT_STATUS_MRL_OPEN))) {
-                shpc_slot_command(shpc, i + SHPC_CMD_TRGT_MIN,
+                shpc_slot_command(d, i + SHPC_CMD_TRGT_MIN,
                                    SHPC_STATE_PWRONLY, SHPC_LED_ON, 
SHPC_LED_NO);
              } else {
-                shpc_slot_command(shpc, i + SHPC_CMD_TRGT_MIN,
+                shpc_slot_command(d, i + SHPC_CMD_TRGT_MIN,
                                    SHPC_STATE_NO, SHPC_LED_OFF, SHPC_LED_NO);
              }
          }
@@ -375,10 +377,10 @@ static void shpc_command(SHPCDevice *shpc)
          }
          for (i = 0; i < shpc->nslots; ++i) {
              if (!(shpc_get_status(shpc, i, SHPC_SLOT_STATUS_MRL_OPEN))) {
-                shpc_slot_command(shpc, i + SHPC_CMD_TRGT_MIN,
+                shpc_slot_command(d, i + SHPC_CMD_TRGT_MIN,
                                    SHPC_STATE_ENABLED, SHPC_LED_ON, 
SHPC_LED_NO);
              } else {
-                shpc_slot_command(shpc, i + SHPC_CMD_TRGT_MIN,
+                shpc_slot_command(d, i + SHPC_CMD_TRGT_MIN,
                                    SHPC_STATE_NO, SHPC_LED_OFF, SHPC_LED_NO);
              }
          }
@@ -410,7 +412,7 @@ static void shpc_write(PCIDevice *d, unsigned addr, 
uint64_t val, int l)
          shpc->config[a] &= ~(val & w1cmask); /* W1C: Write 1 to Clear */
      }
      if (ranges_overlap(addr, l, SHPC_CMD_CODE, 2)) {
-        shpc_command(shpc);
+        shpc_command(d);
      }
      shpc_interrupt_update(d);
  }
Reviewed-by: Anton Kuchin <antonkuchin@yandex-team.ru>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]