From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AD67C433E3 for ; Fri, 10 Jul 2020 22:20:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC27F2068F for ; Fri, 10 Jul 2020 22:20:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="px4x+Ir1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726736AbgGJWUW (ORCPT ); Fri, 10 Jul 2020 18:20:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726631AbgGJWUR (ORCPT ); Fri, 10 Jul 2020 18:20:17 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2B2CC08C5DC; Fri, 10 Jul 2020 15:20:16 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id z13so7340756wrw.5; Fri, 10 Jul 2020 15:20:16 -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=tdpe9RfhxuAkiRZlM5Mq/vRi1xQi0fp5aVSqheR5YGw=; b=px4x+Ir1Hmqt/RIHHKLA49y3QyLmG2TCU6SADKNZHStWzUpoQU6bVSjIaM7sHXrbgl qDzy2e4Z17ZzItXeZdT6HSFTlJXeU1FU2vH0nff6XJf2oFctdr4zH2hKnf/H70zLMUYZ fhe+ON8/guj9R7yGx2KvlNibtktRd8YwMjGUSGQ338kNk/6u74wgHiUKVy8qnjMEfocr 15BUijBnxgqYv3Pch8DeXLnNIjTg8UPTC3SJDcT4FEzNLda4h8vp56xsdcsXwN7HXwgN AQBeFjjDfNXxoGE9/Fvro5okM26H+66moYBDNdTkANlv2C+LDDp1Lys2SmmGP63eYfH6 wJ/A== 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=tdpe9RfhxuAkiRZlM5Mq/vRi1xQi0fp5aVSqheR5YGw=; b=jXxDRThxnQ83IGrQYVVfdjx+4LQppN5czuwSub2IkeD06Eg9IJdT0JnENLvWxcHM/I roAbydizd4AX2lzHQiYFVDh/jfEVYKf+Eh/F1IlR0HGpv6y+pHEb/WjuuajhpZmCRmxQ IaelZN75+JlOiVAvOecQij1xQi6FDPEBaIhSwQUHOIjqBwfG2FQmC3ssABKya3vkQPNJ wnhUDMEcoqf/AsZSelwnpZuBQQck8U+THe+n5JOfRn/Up1RNVEeRyJMZOs6B/h6ppwo3 RJXfdKKgZQFLEKEayHT8hh+hQBGe6caMLAYsrmwkBEDJNK+ieMXNYj9O55LJdDowq4cA L1qg== X-Gm-Message-State: AOAM531PHBfDZvC4DMT3CzTe7ElNN8Bv8KkRdQ/O4AgApN/2FUe1O2LQ 6IqcEH/GmTFqtGSeFENPF0g= X-Google-Smtp-Source: ABdhPJwTRSLucrdEPJQmfs0y7Ck7+PkTy56iEk1AKAT5c0w1w8yRotpSUquRw9umBX/oIIntquItLA== X-Received: by 2002:adf:8b18:: with SMTP id n24mr73874175wra.372.1594419615686; Fri, 10 Jul 2020 15:20:15 -0700 (PDT) Received: from net.saheed (54007186.dsl.pool.telekom.hu. [84.0.113.134]) by smtp.gmail.com with ESMTPSA id l18sm12170281wrm.52.2020.07.10.15.20.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 15:20:15 -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/14 v3] PCI: pciehp: Make "Power On" the default Date: Fri, 10 Jul 2020 23:20:18 +0200 Message-Id: <20200710212026.27136-7-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200710212026.27136-1-refactormyself@gmail.com> References: <20200710212026.27136-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. Make the switch-statement set status to "Power On" by default or when (slot_ctrl & PCI_EXP_SLTCTL_PCC) == PCI_EXP_SLTCTL_PWR_ON. 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31D6AC433E8 for ; Fri, 10 Jul 2020 22:20:21 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0593820725 for ; Fri, 10 Jul 2020 22:20:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="px4x+Ir1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0593820725 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-kernel-mentees-bounces@lists.linuxfoundation.org Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id DCBE488AEC; Fri, 10 Jul 2020 22:20:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gdnACxJ7KGwt; Fri, 10 Jul 2020 22:20:19 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id D768B88AE5; Fri, 10 Jul 2020 22:20:19 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D3CB4C077B; Fri, 10 Jul 2020 22:20:19 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8D9CFC016F for ; Fri, 10 Jul 2020 22:20:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 8A81689FC7 for ; Fri, 10 Jul 2020 22:20:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tUS6tYf6J3Vw for ; Fri, 10 Jul 2020 22:20:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by hemlock.osuosl.org (Postfix) with ESMTPS id 2CB7389FC2 for ; Fri, 10 Jul 2020 22:20:17 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id f2so7311959wrp.7 for ; Fri, 10 Jul 2020 15:20:17 -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=tdpe9RfhxuAkiRZlM5Mq/vRi1xQi0fp5aVSqheR5YGw=; b=px4x+Ir1Hmqt/RIHHKLA49y3QyLmG2TCU6SADKNZHStWzUpoQU6bVSjIaM7sHXrbgl qDzy2e4Z17ZzItXeZdT6HSFTlJXeU1FU2vH0nff6XJf2oFctdr4zH2hKnf/H70zLMUYZ fhe+ON8/guj9R7yGx2KvlNibtktRd8YwMjGUSGQ338kNk/6u74wgHiUKVy8qnjMEfocr 15BUijBnxgqYv3Pch8DeXLnNIjTg8UPTC3SJDcT4FEzNLda4h8vp56xsdcsXwN7HXwgN AQBeFjjDfNXxoGE9/Fvro5okM26H+66moYBDNdTkANlv2C+LDDp1Lys2SmmGP63eYfH6 wJ/A== 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=tdpe9RfhxuAkiRZlM5Mq/vRi1xQi0fp5aVSqheR5YGw=; b=GfJJkHjwavk4RxR3JkWeyTGd7Ey9ZrO5vpkPTbVLxBzUaqd/8dnkf1pQ9AO2auvufu Hblu7511Dm01l8n70Bs7t61PLl8Dr9Zweu2AXq30VteY+gP4xlPgGICgM1y2AQiSAen7 xH7tAWzGYj4r90m2JGgI25LG2LjojG2IH+e+1BG/QzYYYKLnRis7/rSw0MiOKbUnY5B0 lthaaXnl5ilWjmxiQ3eNCklpUdl93PeHDRcarFfYX42sECRUMR6XhSzLTRHuekpfmQEc f5ZUxaSjrLoD9LcKaQpodDyR659pQl4vxGvhGtRid5fhYuPkSGYKnkN6CkGCQnG6B4vi 7gVA== X-Gm-Message-State: AOAM5319/eEeN5gKrwfP7bfdMOexFZcDzOkO2bhut8YBrFKrzk8htHO/ luxe9YfeGSnmX4aPrmspPe4= X-Google-Smtp-Source: ABdhPJwTRSLucrdEPJQmfs0y7Ck7+PkTy56iEk1AKAT5c0w1w8yRotpSUquRw9umBX/oIIntquItLA== X-Received: by 2002:adf:8b18:: with SMTP id n24mr73874175wra.372.1594419615686; Fri, 10 Jul 2020 15:20:15 -0700 (PDT) Received: from net.saheed (54007186.dsl.pool.telekom.hu. [84.0.113.134]) by smtp.gmail.com with ESMTPSA id l18sm12170281wrm.52.2020.07.10.15.20.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 15:20:15 -0700 (PDT) From: Saheed Olayemi Bolarinwa To: helgaas@kernel.org Date: Fri, 10 Jul 2020 23:20:18 +0200 Message-Id: <20200710212026.27136-7-refactormyself@gmail.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200710212026.27136-1-refactormyself@gmail.com> References: <20200710212026.27136-1-refactormyself@gmail.com> Cc: Bolarinwa Olayemi Saheed , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org Subject: [Linux-kernel-mentees] [PATCH 6/14 v3] PCI: pciehp: Make "Power On" the default X-BeenThere: linux-kernel-mentees@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-kernel-mentees-bounces@lists.linuxfoundation.org Sender: "Linux-kernel-mentees" 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. Make the switch-statement set status to "Power On" by default or when (slot_ctrl & PCI_EXP_SLTCTL_PCC) == PCI_EXP_SLTCTL_PWR_ON. 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 _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees