From patchwork Thu Feb 29 18:12:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 208474 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp588183dyb; Thu, 29 Feb 2024 10:14:57 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWr+ayV1aLe7Y7oH2uYyQVqmg1fHfYVa7Fch+4vr4ISY3UKqsbX/daVsvc6YaskfUctAXtIm4N2NCc2+4ydWtUDwC4aWg== X-Google-Smtp-Source: AGHT+IF4jNJI0Ua0SbTvbGfFJbGk9DF+EL6BpDe9aa9wfXUicqd7GXgIDExjcytIA5ApqFh0HZ0v X-Received: by 2002:a05:6a21:164e:b0:1a1:2f18:22bc with SMTP id no14-20020a056a21164e00b001a12f1822bcmr1827006pzb.12.1709230497585; Thu, 29 Feb 2024 10:14:57 -0800 (PST) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m14-20020a63ed4e000000b005dc9404f489si1839243pgk.338.2024.02.29.10.14.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 10:14:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87255-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=fBwWb12H; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-87255-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87255-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6608F286AD7 for ; Thu, 29 Feb 2024 18:14:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1D9E134412; Thu, 29 Feb 2024 18:13:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fBwWb12H" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E74497BAEB for ; Thu, 29 Feb 2024 18:13:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709230390; cv=none; b=bFy9w/x6qaKAr2IWyP65EBVJ5xVS8fm/DuCxqXuNWcJxg31z/h96M0Xpp+Z4fk4HiZr549t0olNiF8jYBqVe7VfCP87HmV8zxT+c+VZZDBojscj+TDDL7nHQKAXFnB5B8vU/y06pEBc9EDISiGfkim/A5mDBXItjUeReXKdUf9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709230390; c=relaxed/simple; bh=4UHafzd9xCDmrdK5pv4Mx3tzDTPiSQz7ubBe9sEoTrs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=okDQ6HNJm31d9LRXs4RvR5hhxQUH2MVSUYZ9W1jIizSBXqELVzJAoJNJTcD6qzA2zbZjxxPN5ckwzQFGDH+bf7intwrcgUKbg7rJa/HSHy9zxEiB/92LCwU22BklNEjeA4B3Za6lUKICQDsDYnMJ2WWbhMIUUrSvNmnv8iUFBW8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fBwWb12H; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4808DC43394; Thu, 29 Feb 2024 18:13:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709230389; bh=4UHafzd9xCDmrdK5pv4Mx3tzDTPiSQz7ubBe9sEoTrs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fBwWb12HgkQEskAVKOOBPEXt6nrLTrqw8Vd9Z2e4IAmTl+AOC334G04LrqPPrNzUc c1605660oH8KtAZrOUCpdQge9+aGYC2RshjZK7x4mY+GrGBgI6mkUT+VB7OGw6VwnA hvTopz55/OBEtnP7l4LqGR4iWi9pJKkk6XI9JcF6HOyONJ0F4v5viUDvSrYh9cyuvH aZhQH61Wb/mLIBC9wvhymlsX+A/bc+QPCK2ekASfSeP1voKiD0x+vlypvjRUVKadL9 xHSS66qT/CsHQkK3xxY2DryONRBfwI8+kZYvNWa+3LaNqVm/mMviBtUwy7cVMZ+Nld YR0xHviTS9Q8g== From: Bjorn Helgaas To: Tomas Winkler , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Bjorn Helgaas Subject: [PATCH 1/3] mei: gsc: remove unnecessary NULL pointer checks Date: Thu, 29 Feb 2024 12:12:58 -0600 Message-Id: <20240229181300.352077-2-helgaas@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229181300.352077-1-helgaas@kernel.org> References: <20240229181300.352077-1-helgaas@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792258078083550486 X-GMAIL-MSGID: 1792258078083550486 From: Bjorn Helgaas The .remove() and power management callbacks are never called unless probe() has already returned success, which means it has set drvdata to a non-NULL pointer, so "dev" can never be NULL in the other callbacks. Remove the unnecessary checks. Signed-off-by: Bjorn Helgaas --- drivers/misc/mei/gsc-me.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/misc/mei/gsc-me.c b/drivers/misc/mei/gsc-me.c index 6be8f1cc052c..45c10974b12b 100644 --- a/drivers/misc/mei/gsc-me.c +++ b/drivers/misc/mei/gsc-me.c @@ -144,9 +144,6 @@ static void mei_gsc_remove(struct auxiliary_device *aux_dev) struct mei_me_hw *hw; dev = dev_get_drvdata(&aux_dev->dev); - if (!dev) - return; - hw = to_me_hw(dev); mei_stop(dev); @@ -168,9 +165,6 @@ static int __maybe_unused mei_gsc_pm_suspend(struct device *device) { struct mei_device *dev = dev_get_drvdata(device); - if (!dev) - return -ENODEV; - mei_stop(dev); mei_disable_interrupts(dev); @@ -186,9 +180,6 @@ static int __maybe_unused mei_gsc_pm_resume(struct device *device) int err; struct mei_me_hw *hw; - if (!dev) - return -ENODEV; - hw = to_me_hw(dev); aux_dev = to_auxiliary_dev(device); adev = auxiliary_dev_to_mei_aux_dev(aux_dev); @@ -211,8 +202,6 @@ static int __maybe_unused mei_gsc_pm_runtime_idle(struct device *device) { struct mei_device *dev = dev_get_drvdata(device); - if (!dev) - return -ENODEV; if (mei_write_is_idle(dev)) pm_runtime_autosuspend(device); @@ -225,9 +214,6 @@ static int __maybe_unused mei_gsc_pm_runtime_suspend(struct device *device) struct mei_me_hw *hw; int ret; - if (!dev) - return -ENODEV; - mutex_lock(&dev->device_lock); if (mei_write_is_idle(dev)) { @@ -252,9 +238,6 @@ static int __maybe_unused mei_gsc_pm_runtime_resume(struct device *device) struct mei_me_hw *hw; irqreturn_t irq_ret; - if (!dev) - return -ENODEV; - mutex_lock(&dev->device_lock); hw = to_me_hw(dev); From patchwork Thu Feb 29 18:12:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 208475 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp588343dyb; Thu, 29 Feb 2024 10:15:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUpQP/brTUl3hv6Wl816I4V+hfErlnilTluy+ef3iiMptuwhIJM7OOoKBpTYenE7AjCGbmb8WZvZLbbEJdvvLn9+T8q9Q== X-Google-Smtp-Source: AGHT+IGqHOo6Gt7GN+Rv5wF5b2BarW82J3lm2EOooHMf6/5QSOiXXskT2iSW7j/+m7pTLPxu5JGh X-Received: by 2002:a17:906:a391:b0:a44:2563:d30b with SMTP id k17-20020a170906a39100b00a442563d30bmr2123756ejz.68.1709230510828; Thu, 29 Feb 2024 10:15:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709230510; cv=pass; d=google.com; s=arc-20160816; b=N6SpRURDjZz1R3ONy8O4H9N0G4er2Y8ZS/S+cA0j19p9X9PvOZKRV3ojL4/xVCOHI9 EWGLm7WWrIG+zYTnbt5yty7NbGMRWzz0lrUeeVSp2vEa9W0RY4fE0Zj/nAwxEZ8Cyqjd ChuBFaO9BSyg5KYAvdv0az+kGRuJ7iyAbmnl9PMBnjjucLqwk/81jm+e1wDc+WBDQmzj NOSDyJ9jQ7r7TjJeY231UVJc63v5SbxlpKci0WH66zFAGpXWRUm6KdkGl9b67KSn3vM5 twMOKGc6VHgAqWVcSimQVzv6LQqTt6ppueXq0np6ahM7UjlVA3yACVxiCp3eQJgigOKS uipg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=jqgLg9VSIRJm7n4Vx4V5Pz+RavLUgmm3Uh3VVu8xUfc=; fh=jGe2mpm4FTr+E4VJvTfPCKax/XlUY+S86fjBeuo/gQg=; b=yASpW+1yE7T3P9iETpZSBSD886CjKKfbH46tJrHY73Tg2cAkgq7x8MbxvyAeIjKUSR gq2arMpgR76pUvRu6tMP4Z8Ls8QYRLk01xIt9KpKVKZPfwkz5Mg/xy6GU6qc5DQbgIS9 5QorsIil7xEyYubLFtH99sgp7lTC5NIvCsDmciF5u7sdvemSOqFuHTtvrsWM8dO0uYFc dbH4cJF6hm3U44fPTh4wG3MSUqYUTQj8I7QaF0jSPHVaGmDCKlKV9BdoJNz2vVHWZEPk a2X+YBjLLAae/znB+D7b3nIG4zbsoDREcf+nJ57WZcRKgRdqrWjkYCjB3svrPqJ37uh7 A5zg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q4C7myv3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-87256-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87256-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qw5-20020a170906fca500b00a43d3f2575fsi760876ejb.398.2024.02.29.10.15.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 10:15:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87256-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q4C7myv3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-87256-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87256-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5D4BF1F265EE for ; Thu, 29 Feb 2024 18:15:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 993B9134430; Thu, 29 Feb 2024 18:13:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q4C7myv3" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F30A8134404 for ; Thu, 29 Feb 2024 18:13:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709230392; cv=none; b=ccMNGs7AeVHEIAjjSilWrrKOZ45I+RIoIATSOP/P4wRrqr7YO7P82L3hIx3Ge4fOIPPEBXo3Ol1QsPrSOXD2jI7syTNUvmrTkpxF7gGP7FwEfmVxP2xFpODghogizyTwC8vXY4/TBTcTB8M1YvMdLQOkVcwBb2Y44F967YjxNj0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709230392; c=relaxed/simple; bh=AE4Wax6AwWzhWNRdm2NepGfbrJaZkUojuHf7ZO1wUMM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ja+u4ckN71BSvyFpylKB0bTP35b6HtUnPU49xc5D/rtV9iH8vUPQZGsk/drIxUhwuMeV6QieFGqwVT4reDy7xnQDoJ+1X+uid9/n84LQCtZOQeP6ilIjJdJR13GuQBa46vi+4FM2ib2pFC1+l4X010SUMjcWEK076zeu8YPrxl8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q4C7myv3; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E3F3C433F1; Thu, 29 Feb 2024 18:13:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709230391; bh=AE4Wax6AwWzhWNRdm2NepGfbrJaZkUojuHf7ZO1wUMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q4C7myv3oAagE1rI8WVPi5L1zholvwFbhRoaGGTQf6moCO+soeLoTeMCxMxiXr5L3 pkH0Qt92RgAAWtbD5svK8/SWbnV2NPi7cG/Y+6l2cXL/fEoWrenkoYSL9yIgY7+IX7 83wzlTnwTdBQoQYxPa/vATWIKBupgTmCdCfa2gE6eVjoiQufJN4ggKmwWKo3Yhk9bv qo3WMUKq3lTT7H+mMiRhzGOm8cma2iVSblxT5/AqO1y3FNhyTAJRIvaGeZw59P1bt6 ea4xmkAoFsxiFPra7c8R70JJ7sD/P0xaoNOkkugooNlUryrub9tzVw6cwVWfe5u+E1 DaqxeLl8i5brQ== From: Bjorn Helgaas To: Tomas Winkler , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Bjorn Helgaas Subject: [PATCH 2/3] mei: txe: remove unnecessary NULL pointer checks Date: Thu, 29 Feb 2024 12:12:59 -0600 Message-Id: <20240229181300.352077-3-helgaas@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229181300.352077-1-helgaas@kernel.org> References: <20240229181300.352077-1-helgaas@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792258092117632740 X-GMAIL-MSGID: 1792258092117632740 From: Bjorn Helgaas The .shutdown(), .remove(), and power management callbacks are never called unless .probe() has already returned success, which means it has set drvdata to a non-NULL pointer, so "dev" can never be NULL in the other callbacks. Remove the unnecessary checks. Signed-off-by: Bjorn Helgaas --- drivers/misc/mei/pci-txe.c | 40 ++++++-------------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/drivers/misc/mei/pci-txe.c b/drivers/misc/mei/pci-txe.c index fa20d9a27813..2a584104ba38 100644 --- a/drivers/misc/mei/pci-txe.c +++ b/drivers/misc/mei/pci-txe.c @@ -166,11 +166,7 @@ static int mei_txe_probe(struct pci_dev *pdev, const struct pci_device_id *ent) */ static void mei_txe_shutdown(struct pci_dev *pdev) { - struct mei_device *dev; - - dev = pci_get_drvdata(pdev); - if (!dev) - return; + struct mei_device *dev = pci_get_drvdata(pdev); dev_dbg(&pdev->dev, "shutdown\n"); mei_stop(dev); @@ -191,13 +187,7 @@ static void mei_txe_shutdown(struct pci_dev *pdev) */ static void mei_txe_remove(struct pci_dev *pdev) { - struct mei_device *dev; - - dev = pci_get_drvdata(pdev); - if (!dev) { - dev_err(&pdev->dev, "mei: dev == NULL\n"); - return; - } + struct mei_device *dev = pci_get_drvdata(pdev); pm_runtime_get_noresume(&pdev->dev); @@ -218,9 +208,6 @@ static int mei_txe_pci_suspend(struct device *device) struct pci_dev *pdev = to_pci_dev(device); struct mei_device *dev = pci_get_drvdata(pdev); - if (!dev) - return -ENODEV; - dev_dbg(&pdev->dev, "suspend\n"); mei_stop(dev); @@ -236,13 +223,9 @@ static int mei_txe_pci_suspend(struct device *device) static int mei_txe_pci_resume(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); - struct mei_device *dev; + struct mei_device *dev = pci_get_drvdata(pdev); int err; - dev = pci_get_drvdata(pdev); - if (!dev) - return -ENODEV; - pci_enable_msi(pdev); mei_clear_interrupts(dev); @@ -273,13 +256,10 @@ static int mei_txe_pci_resume(struct device *device) #ifdef CONFIG_PM static int mei_txe_pm_runtime_idle(struct device *device) { - struct mei_device *dev; + struct mei_device *dev = dev_get_drvdata(device); dev_dbg(device, "rpm: txe: runtime_idle\n"); - dev = dev_get_drvdata(device); - if (!dev) - return -ENODEV; if (mei_write_is_idle(dev)) pm_runtime_autosuspend(device); @@ -287,15 +267,11 @@ static int mei_txe_pm_runtime_idle(struct device *device) } static int mei_txe_pm_runtime_suspend(struct device *device) { - struct mei_device *dev; + struct mei_device *dev = dev_get_drvdata(device); int ret; dev_dbg(device, "rpm: txe: runtime suspend\n"); - dev = dev_get_drvdata(device); - if (!dev) - return -ENODEV; - mutex_lock(&dev->device_lock); if (mei_write_is_idle(dev)) @@ -317,15 +293,11 @@ static int mei_txe_pm_runtime_suspend(struct device *device) static int mei_txe_pm_runtime_resume(struct device *device) { - struct mei_device *dev; + struct mei_device *dev = dev_get_drvdata(device); int ret; dev_dbg(device, "rpm: txe: runtime resume\n"); - dev = dev_get_drvdata(device); - if (!dev) - return -ENODEV; - mutex_lock(&dev->device_lock); mei_enable_interrupts(dev); From patchwork Thu Feb 29 18:13:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 208476 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp588402dyb; Thu, 29 Feb 2024 10:15:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+l1aKzLVW4LOruP+AemZknEWrWT6QEGq8gf3FzQe9iThAUg92Q1jXPB1fWsYGR4pvUbi65Xa/NXgiO1QhbXs0d1AGwA== X-Google-Smtp-Source: AGHT+IFP1hX459NlaK1O4t7OkfNBBtoNk8qnNBpqqaOQ36TNiUg2CfORoXYY/8PCgpOIGwhHXu/q X-Received: by 2002:a17:902:e5c5:b0:1db:c6a0:d023 with SMTP id u5-20020a170902e5c500b001dbc6a0d023mr3942731plf.8.1709230517629; Thu, 29 Feb 2024 10:15:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709230517; cv=pass; d=google.com; s=arc-20160816; b=Z+IPiChpcBT1vfTiR79YXI8M3k9TPalfeTjOzBPv90T6hXMZw3RmcZB51A2fykEZ/K oAY/GtlHlawYTnf5HbkR0JP/TMd7Gvf5qRptPeAUb4GayLfJRHEJG4eAoo/4tEmstBIc ZGMjj7/+A/xRx7AhIvvOQgz0w87FxMTLK8znJGMgF2MzdwIh5rn6KVpSNooQ2qeybA+w 5yP3GbtQqS5JdhyF0L+o2ZGQwKeXwlHLcR3DvGqJ6SDn1LSRA+VEwa8wnUi8+SgZjVSp qLTIMgV23nOI48s5DvvJxByn7UHH3tZXCfqXwDLe3taGxwkSe3rgkuxiu6JbcNR8adGx CMfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=0x/buHnR/ccxRCo8RHWHy3ZLHs8lH4m2tX3gl4iHgUo=; fh=jGe2mpm4FTr+E4VJvTfPCKax/XlUY+S86fjBeuo/gQg=; b=wsiBEh9yEPJPPUuCrldGH8hK/QIaTMjdC3HCM0eMJVWrUI56bXpoU0UysEGAd9E9Oc LZqUXOSv0UN+bmuOkyVV8Lc5U54FpYtrqaQ4nNg5niXLYe220wwTmOtzQd+a+0zqhBOX Xy12RhA0FV/awSS2J0EYBiFGosulX+SI/5VEtV1HRsJ5I+6SxDXZb7DbEtNdIiOFH7Tz e2yqL1pSKDp5jiDf/3jHQ97wxRBi8ef7d988t0n1tNDpWrGjPWpqJyUAP4SYjqKnc5MP CkAwcT3T2EBqA0/qdXJI8EniIU6ET8HVTjHGRdrlIrnHAfF58QPct24O+xk1ov0IybjS tbfg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kLx6jYEv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-87257-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87257-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e6-20020a170902ef4600b001dbfefe6708si1814750plx.325.2024.02.29.10.15.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 10:15:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87257-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kLx6jYEv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-87257-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87257-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 67C71286D78 for ; Thu, 29 Feb 2024 18:15:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 467C51361BF; Thu, 29 Feb 2024 18:13:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kLx6jYEv" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DEA012FB0B for ; Thu, 29 Feb 2024 18:13:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709230393; cv=none; b=KfFmdRC3j0PTbus6eUMtRCe25k0pjrigG/lWBaTqLRI/P/qm+2U36ZJbUcM6ZpcygDeNWrwiPbivjiSYt4FbuemVrFVPuLsc93xalK4AFTijuln0Ft9XYl3CqI8RbQ0I4iKp+eAXTZ3XbHwBRUO01YWqaSexgPtPTwhN7hLtZF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709230393; c=relaxed/simple; bh=Dkk4i1JgX0DpGT8BHQSypGGCaf+0/nlf7ejjaAd9LM4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QD7yXmPoPhCKB95ZXsgs90l2ipmUwBO5+snBQJwdAXSuD0+L+ETpkHvTx4mviCa7xoKFCW9+e+7ODsGgO10TYNwoYXPASQjUHoOuDXe/D03j7qVNzdRNWpT3X4aljSKhNn0N08TBmRyU567MrwMfUC2xZcIskBo2FJ3mEDoh6UY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kLx6jYEv; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 029D1C43394; Thu, 29 Feb 2024 18:13:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709230393; bh=Dkk4i1JgX0DpGT8BHQSypGGCaf+0/nlf7ejjaAd9LM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kLx6jYEvLDIJSohi1mL2aFZMKS5uU2mNnrYEkCq/W8DJMzoI873tRTsRnzQXMG/YZ ugENU1BojjNHkG/un/SXNZeBmRkekNS07BaH9oiDHC8I2qt0lwI8KBTU6GsV836uaa O2J4PuhTqxUhaXsAVet9f2U9C5Qx+g7bgUf8N1+T6SH6+uRKzrseoSzqHlH8iCIyp6 he4iqhdzEgw8bBMYYIFF2GwS96VMrGG84NZkGB0H9h31H1yf2k/8cixzNYuW5B1q9l wEDDIYOLYhQro3EATwlFPEqfL++F2HmHWS/n1SGvTHO45Z9PXevSNPQYIkzzW/zaAy fBCzDkJtrlcJQ== From: Bjorn Helgaas To: Tomas Winkler , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Bjorn Helgaas Subject: [PATCH 3/3] mei: me: remove unnecessary NULL pointer checks Date: Thu, 29 Feb 2024 12:13:00 -0600 Message-Id: <20240229181300.352077-4-helgaas@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240229181300.352077-1-helgaas@kernel.org> References: <20240229181300.352077-1-helgaas@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792258099115237548 X-GMAIL-MSGID: 1792258099115237548 From: Bjorn Helgaas The .shutdown(), .remove(), and power management callbacks are never called unless .probe() has already returned success, which means it has set drvdata to a non-NULL pointer, so "dev" can never be NULL in the other callbacks. Remove the unnecessary checks. Signed-off-by: Bjorn Helgaas --- drivers/misc/mei/pci-me.c | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c index 676d566f38dd..1f0d983d3f06 100644 --- a/drivers/misc/mei/pci-me.c +++ b/drivers/misc/mei/pci-me.c @@ -295,11 +295,7 @@ static int mei_me_probe(struct pci_dev *pdev, const struct pci_device_id *ent) */ static void mei_me_shutdown(struct pci_dev *pdev) { - struct mei_device *dev; - - dev = pci_get_drvdata(pdev); - if (!dev) - return; + struct mei_device *dev = pci_get_drvdata(pdev); dev_dbg(&pdev->dev, "shutdown\n"); mei_stop(dev); @@ -320,11 +316,7 @@ static void mei_me_shutdown(struct pci_dev *pdev) */ static void mei_me_remove(struct pci_dev *pdev) { - struct mei_device *dev; - - dev = pci_get_drvdata(pdev); - if (!dev) - return; + struct mei_device *dev = pci_get_drvdata(pdev); if (mei_pg_is_enabled(dev)) pm_runtime_get_noresume(&pdev->dev); @@ -353,9 +345,6 @@ static int mei_me_pci_suspend(struct device *device) struct pci_dev *pdev = to_pci_dev(device); struct mei_device *dev = pci_get_drvdata(pdev); - if (!dev) - return -ENODEV; - dev_dbg(&pdev->dev, "suspend\n"); mei_stop(dev); @@ -371,14 +360,10 @@ static int mei_me_pci_suspend(struct device *device) static int mei_me_pci_resume(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); - struct mei_device *dev; + struct mei_device *dev = pci_get_drvdata(pdev); unsigned int irqflags; int err; - dev = pci_get_drvdata(pdev); - if (!dev) - return -ENODEV; - pci_enable_msi(pdev); irqflags = pci_dev_msi_enabled(pdev) ? IRQF_ONESHOT : IRQF_SHARED; @@ -419,13 +404,10 @@ static void mei_me_pci_complete(struct device *device) #ifdef CONFIG_PM static int mei_me_pm_runtime_idle(struct device *device) { - struct mei_device *dev; + struct mei_device *dev = dev_get_drvdata(device); dev_dbg(device, "rpm: me: runtime_idle\n"); - dev = dev_get_drvdata(device); - if (!dev) - return -ENODEV; if (mei_write_is_idle(dev)) pm_runtime_autosuspend(device); @@ -434,15 +416,11 @@ static int mei_me_pm_runtime_idle(struct device *device) static int mei_me_pm_runtime_suspend(struct device *device) { - struct mei_device *dev; + struct mei_device *dev = dev_get_drvdata(device); int ret; dev_dbg(device, "rpm: me: runtime suspend\n"); - dev = dev_get_drvdata(device); - if (!dev) - return -ENODEV; - mutex_lock(&dev->device_lock); if (mei_write_is_idle(dev)) @@ -462,15 +440,11 @@ static int mei_me_pm_runtime_suspend(struct device *device) static int mei_me_pm_runtime_resume(struct device *device) { - struct mei_device *dev; + struct mei_device *dev = dev_get_drvdata(device); int ret; dev_dbg(device, "rpm: me: runtime resume\n"); - dev = dev_get_drvdata(device); - if (!dev) - return -ENODEV; - mutex_lock(&dev->device_lock); ret = mei_me_pg_exit_sync(dev);