Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp120324ybt; Thu, 9 Jul 2020 17:14:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOmhxpxOVOUdem2VHzWGg/oMnLNrwlJwOMhkLayZO0na4MgO5ac1fdRZ+i+RW6TR/0o6Mg X-Received: by 2002:aa7:c655:: with SMTP id z21mr75028248edr.330.1594340082083; Thu, 09 Jul 2020 17:14:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594340082; cv=none; d=google.com; s=arc-20160816; b=gyTf8dHArejL1WUaL8x9yi//JgtClgmnRm7t8kSwVB/+NEAGAz4v2b3WjeAD44P+yQ RhsTZBnQMLGzdrhLFQrXWSsfvJKaEfFHsHnMn5e4PD0+rXp7p02hHF4zUqIAJZ0b4Qfx 5Zl6lWx1a5KHLTInYWxO1w3hNG7fk2ZZ8+2ntDVos1EIDEZI2pPeaFNkXPNanunSH2GQ NC2+12wWDyCrdZ82A+poBvroydG0WztCb1naPO+RK26eZCYAGdrjd9VhDEl0upMdqMUk L8dD+fs1jx8lSesWziP1Jl259I4ZxkMdJqoMk3PIefULsDPZQNqQnpUYG3HScJLyOOTj 6N0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=rcK06DL1iaWRL66i5RCoJCFMxbR/EA9YG6MvDrsdvcQ=; b=oCYnPhYXuXefP7mr/I+9aPXWnoGGl86WVNb5PqFON35WC7PJMsUW0xYechBl74qjKo e3Gj2T6a9vI/jkLzGSKP3B/4KFkvMq+DlvchCux4Gl6f1QXKJk3YCNheH4S/wVDbDLG/ wA+pgWxzpGdmzqVybgTyW3ExbX4Tupmt9KiTw9cLOPyeomqapJXOE0IDXdJyubTFt0wG RiV9ZXpTQZzpn/1xufeAidwg+ggnUuSmxKJAK7jsv51tWCJH7wNJmKCJk8CBStsx3XNn 14jmECZyrizBsXCdtEN6bSyiVfrLzZ/6PFj1LMbYtCYGCHt8KV0G/mWsx8/8Gzyj++s8 rKJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2a1Son6W; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r16si3033906edo.473.2020.07.09.17.14.18; Thu, 09 Jul 2020 17:14:42 -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=@kernel.org header.s=default header.b=2a1Son6W; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726496AbgGJAOI (ORCPT + 99 others); Thu, 9 Jul 2020 20:14:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:55818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726272AbgGJAOI (ORCPT ); Thu, 9 Jul 2020 20:14:08 -0400 Received: from localhost (mobile-166-175-191-139.mycingular.net [166.175.191.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A2EE52065F; Fri, 10 Jul 2020 00:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594340048; bh=1Q5ejM91y+rZdlPiC9UJgo7wuGqE1YmvLc2GRbXroko=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=2a1Son6W+Y/jnNfWf/6l+CVIii/kSqwRfl7ye9cOmeJxHyIkrxFAKYiE+Kbt3PD6d E+d1KyZ02ruY1rVQjHcKdPW8+RrhIKlIUcKaH85ObpDYyAI+tK7DIf9zThvjJM8pPn X9oQEEgT+CVubZkBJGaw6L7zIIzaVuByKHmwCqbM= Date: Thu, 9 Jul 2020 19:14:06 -0500 From: Bjorn Helgaas To: Saheed Olayemi Bolarinwa Cc: bjorn@helgaas.com, skhan@linuxfoundation.org, linux-pci@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 5/11 RFC] PCI: pciehp: Make "Power On" the default Message-ID: <20200710001406.GA30420@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200706093121.9731-6-refactormyself@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 06, 2020 at 11:31:15AM +0200, Saheed Olayemi Bolarinwa wrote: > 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 11/11 > changes the behaviour of pcie_capability_read_word() so on falure the > "Off" value will be set. s/falure/failure/ Split this into two patches. The removal of the default case should be in its own patch to make it trivial to review. > 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 >