Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp62730ybt; Tue, 7 Jul 2020 16:08:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwx0Lcq7ptX/eT4aty+SLLTXveL+8+g5Tbv/Ixy2XAl5Ys5Ds9r1R/TZdaWngQj+5q3t2hI X-Received: by 2002:a50:d942:: with SMTP id u2mr62836955edj.225.1594163280948; Tue, 07 Jul 2020 16:08:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594163280; cv=none; d=google.com; s=arc-20160816; b=TM1/J8WoQc6FIQIg7jlXq6y4x7MxhxHTusQuzGQHZAqvrqY1a0o123+h2Y1XXJEU2f T8RmyetXUuav+ut+AiqkvSzfNIVLgeGuGFwdUmoVTuaxnjlB92bcLMBJHagel1kAWuoQ gh33kPBqDmt0gmvcBwV6MD6D1+MVW8K6ct1V0rJoPIpxcEfMBPT0fdu5UqDGDuAjwhTk JOLH3Dm27HHqeTBaADl48UgcnKwUFha0YR47cGbWTm8Y3v/WNOXFEBju7toXSPAf8LE7 EYYJh+oHUHS3mJOaU05yXsi1+LwKbrcKFf/SsUWqWObVMRZ2L0f00HWinHHMLZxbwzGo aemA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=e4G/JDoHnmGcmiWO+UuUF925AfFaFCnVB7/GokdCrOY=; b=D+q5QilKNZNTaGVdcKIvGrFlGwOuYMviFB2q3Ol2Y65OMTcNQhUtT0htz9y7v+CCRg trPHtbRKEJI0tbecj2s3wXe+Nd+VApRnfgr1ZWXODCzX879WJ9pnBXvL6c16tFwoXRQy p4872TZIBTOkcqnpBCkHvbU5yu2uV2HDFx0jT/jijqgbWgkHg6UztV/X3WQSHmxly+1O FyTl5Y0uzFCnZXeTlw+3VGHjDqYPsOc9Zr7prgGhlU5/z6wjIw5LXHzzV69UmkN/6HtV sNb8a/0kvJtff6C32javXUPPUvjmm8DHlmD7Glrr6p0Revs2qfSlAPgrYt5VqJ50FeOP TRwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AJbEd0Xq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rs2si15676762ejb.464.2020.07.07.16.07.38; Tue, 07 Jul 2020 16:08:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AJbEd0Xq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729132AbgGGXDx (ORCPT + 99 others); Tue, 7 Jul 2020 19:03:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729085AbgGGXDv (ORCPT ); Tue, 7 Jul 2020 19:03:51 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44EA2C061755; Tue, 7 Jul 2020 16:03:51 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id n26so34521040ejx.0; Tue, 07 Jul 2020 16:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=e4G/JDoHnmGcmiWO+UuUF925AfFaFCnVB7/GokdCrOY=; b=AJbEd0XqvMDu+0bE7N9RmjLOcr0Og7QcFpFp4MUIslagtlDEHgID+7gQjqwiscgzGQ UOj49BA0anS6lCCRP7qIzyM9iwXu8Ac9jhUfgW/dbBjH0Rbz5e+v6YH/9yQXtziXRf9q z7liwPyqRfbSD+mWIn/SYWtVuuaFsHEvS9Sf5qDAShA7HkRn5/K2KIJBTgCJsMAsJegm EZREP6gbXfPoOX9sJWg6yNUdouum4rh63F2S0UCJ0ySG+hx46sNNRjGknMq175wp3iZ2 7wJtSXlKWXzI0ZWnre9ZTLoPWpaQAa/d1lfnMKkyVSPhhpnLZqLKoXH0hmk1V3ZQ3dT9 HFkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=e4G/JDoHnmGcmiWO+UuUF925AfFaFCnVB7/GokdCrOY=; b=tqzQe1db8XS0TB/Y4CSv6CRJ5p52OiKUTtzjGukSgpZhY2ABMznMWdMVqstsZr7TPu ++y+esuH2U2pefWMuiAsCbq6ulpJBr8Y4hf36MLCSltkJXqWD8DD/ZqUjJQicUx2KTL5 L8+06n9Z0nTXCKNBSOjB8WRLttGg58ZQZtCqMU1Ks+xCZ0TY+vv78VhQ2wYHt/wG3fTl GsE24H2WB7d07PnwgE5vnENC8kfabf6NaIncJybvot67yRYU/FIp4n+1CxyFgc13NqsL srO25HzzpW7jfu/hTNFDPIbccM8LZ7BjTJpcXJi1Wgrv4dgxeOnzd9+S+N212sXhK8DR J/oQ== X-Gm-Message-State: AOAM531czt0Yo7tTq42jlQOP+3o6xbazar/a0Le1wGVkyyckWn/mro8C tw4zHQUVJ2VmYAlp5yKnuqc= X-Received: by 2002:a17:906:4942:: with SMTP id f2mr51414548ejt.125.1594163030039; Tue, 07 Jul 2020 16:03:50 -0700 (PDT) Received: from net.saheed (54007186.dsl.pool.telekom.hu. [84.0.113.134]) by smtp.gmail.com with ESMTPSA id f10sm27096310edx.5.2020.07.07.16.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 16:03:49 -0700 (PDT) From: Saheed Olayemi Bolarinwa To: helgaas@kernel.org Cc: Bolarinwa Olayemi Saheed , bjorn@helgaas.com, skhan@linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/13] PCI: pciehp: Make "Power On" the default Date: Wed, 8 Jul 2020 00:03:17 +0200 Message-Id: <20200707220324.8425-7-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200707220324.8425-1-refactormyself@gmail.com> References: <20200707220324.8425-1-refactormyself@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bolarinwa Olayemi Saheed The default case of the switch statement is redundant since PCI_EXP_SLTCTL_PCC is only a single bit. pcie_capability_read_word() currently causes "On" value to be set if it fails. Patch 13/13 changes the behaviour of pcie_capability_read_word() so on failure the "Off" value will be set. Make the function set status to "Power On" by default and only set to Set "Power Off" only if pcie_capability_read_word() is successful and (slot_ctrl & PCI_EXP_SLTCTL_PCC) == PCI_EXP_SLTCTL_PWR_OFF. Suggested-by: Bjorn Helgaas Signed-off-by: Bolarinwa Olayemi Saheed --- drivers/pci/hotplug/pciehp_hpc.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 0b691e37fd04..78f806a9c6f1 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -399,22 +399,16 @@ void pciehp_get_power_status(struct controller *ctrl, u8 *status) { struct pci_dev *pdev = ctrl_dev(ctrl); u16 slot_ctrl; + int ret; - pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &slot_ctrl); + *status = 1; /* On */ + ret = pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &slot_ctrl); ctrl_dbg(ctrl, "%s: SLOTCTRL %x value read %x\n", __func__, pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, slot_ctrl); - switch (slot_ctrl & PCI_EXP_SLTCTL_PCC) { - case PCI_EXP_SLTCTL_PWR_ON: - *status = 1; /* On */ - break; - case PCI_EXP_SLTCTL_PWR_OFF: + if (!ret && + ((slot_ctrl & PCI_EXP_SLTCTL_PCC) == PCI_EXP_SLTCTL_PWR_OFF)) *status = 0; /* Off */ - break; - default: - *status = 0xFF; - break; - } } void pciehp_get_latch_status(struct controller *ctrl, u8 *status) -- 2.18.2