From patchwork Fri Oct 28 21:14:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 12562 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1050462wru; Fri, 28 Oct 2022 14:24:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7yU9hF3iov08dCom03Cgi1d+EBf9V3VFUR9aXyEPjGAdD5zAmcVJGQI4Jo2DvyRFXYDNno X-Received: by 2002:a17:902:8a93:b0:17f:66ae:b6c with SMTP id p19-20020a1709028a9300b0017f66ae0b6cmr1024719plo.94.1666992278373; Fri, 28 Oct 2022 14:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666992278; cv=none; d=google.com; s=arc-20160816; b=WolzGERJzxWIEBarHM9S5bdgbWZeEv+btNx6jHwS11AHLM+VZi5GO0ZHvAAr8OZnEc UcMW4uH2wCFFgFMdSy5dGVP8+AVybzj9dK5QOGklcN3mssdeee8alqT60gG3Raku3y7o W+9BC4XuTNPfYKuJwMSvDnTB9Aig2c/anp1TTEQiORgCs7Ir9UlHEaJVKru/lAPr4bjl yyCXONtlZ+zanl0K0VpgNyw/hTG9iqIrwqHm+7ZEeGjhdgQBK5OJ0UUNlnPJkX0lTegb tTxjAC9Ay4IbDBQHMb35z4o9nz/NrTWGq9R+paSfltq+FzwmvmMMSQrC8IPOxegUGUtC eJeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=M+RiQTpwuN97JRf0F9V4tVIm2v8ZxHlLZa7P/ilnDGY=; b=cM9WxXBgznI6i+sOfg6ZKI8GZKsvzrjIlHxqOF+73Aa/Y5RU2v39JDepnal9GLw2/J XVJgmGSXI4EHELP3FP+nzUiuCPlak+8ciTJG98tPaqhB4MwBCdYHcsYJIJjH2zb7P0eV IECcjLBm4+4ccLn84J1uvfCQqGtTxXVDYi0oBjTwtb7H/Uz+ExO3szdKx7RSr3BnIZaw QcLj+qHJhPfAgj489aaep4/W3ecb6ooU/pBc1HqswtO0iAi8zdUhJxrj7oCokXq8R6Fp 3lFCMTeUOFe8MeJ1s5/69JTo5NCsynm689ZBAStGr64w4o5m22PJtRitKrFHDNTBT1oZ lgFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Yj9XXzuU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i5-20020a170902cf0500b00186905ef969si6510406plg.90.2022.10.28.14.24.25; Fri, 28 Oct 2022 14:24:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Yj9XXzuU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229752AbiJ1VPE (ORCPT + 99 others); Fri, 28 Oct 2022 17:15:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbiJ1VO6 (ORCPT ); Fri, 28 Oct 2022 17:14:58 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A27292317C for ; Fri, 28 Oct 2022 14:14:54 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id v28so5621616pfi.12 for ; Fri, 28 Oct 2022 14:14:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=M+RiQTpwuN97JRf0F9V4tVIm2v8ZxHlLZa7P/ilnDGY=; b=Yj9XXzuUNOrCtA5zzryZJ10G9E2xQzsOg4wGDQ7XvEREUd7J5u5VTSx/QNQIdwbo24 Q594O7/zX76xEh9Gc0iNGrU4TqZtcazJZ2+Pt0GrlTPqOU1rG0zSAjw8Ls7Qt1TBcVFR Wjei+HXIwy07bZT+qPsUiKi1PlGLFN8O2EUOQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=M+RiQTpwuN97JRf0F9V4tVIm2v8ZxHlLZa7P/ilnDGY=; b=0wYZMVY51Aa/raO0IMkr5ihkjl0cZAe7rksty0AmIcR9Y7wPAwdhtAmqsOJAxOeSdH hjB5b3GHwLSpsjHXmcJfpwS5Jm4NCNqlOTHTmFwOan2WhodfMseWMqRfhCemZggbYzqz 7VrQHz0nwj8akg4dWIyw1l+bYa6U6AJgGVwylG6q5Pk01mn7Wer6h7iZb4jKk+qQVFNz 5QkKR2xxS/+Li+0nVRU5dx+vAd5/7geAmczSAGZxg54RSMcPDep3NFhZ+qM/pftS9vgI Y1bFE+UsqW6o/RRfNZOo635gygZvLjgtNupsUvHQuEcxtF6JEH+WD5TySIHcIqy8popo Va4A== X-Gm-Message-State: ACrzQf1h+RnkWUK8otbkFux8A/ras9NfOZrxC206EnnghgFVtNgjMQfV H0ynS/YvGN0DhRy2z3l/35d5rjID3Kf9wQ== X-Received: by 2002:a63:6f8a:0:b0:439:36bc:89f9 with SMTP id k132-20020a636f8a000000b0043936bc89f9mr1288835pgc.100.1666991694115; Fri, 28 Oct 2022 14:14:54 -0700 (PDT) Received: from localhost ([2620:15c:9d:2:65f9:c180:249c:190f]) by smtp.gmail.com with UTF8SMTPSA id e11-20020a170902784b00b001730a1af0fbsm3488563pln.23.2022.10.28.14.14.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Oct 2022 14:14:53 -0700 (PDT) From: Brian Norris To: Benson Leung , Guenter Roeck Cc: chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, Brian Norris Subject: [PATCH 1/5] platform/chrome: cros_ec_lpc: Move mec_init/destroy to device probe/remove Date: Fri, 28 Oct 2022 14:14:45 -0700 Message-Id: <20221028141411.1.I0728421299079b104710c202d5d7095b2674fd8c@changeid> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747968095115515140?= X-GMAIL-MSGID: =?utf-8?q?1747968095115515140?= Disregarding the weird global state hiding in this cros_ec_lpc_mec_*() stuff, it belongs in device probe/remove. We shouldn't assume we can access hardware resources when the device isn't attached to the driver. Signed-off-by: Brian Norris --- drivers/platform/chrome/cros_ec_lpc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c index 7677ab3c0ead..0b6c7c912ec7 100644 --- a/drivers/platform/chrome/cros_ec_lpc.c +++ b/drivers/platform/chrome/cros_ec_lpc.c @@ -354,6 +354,9 @@ static int cros_ec_lpc_probe(struct platform_device *pdev) return -EBUSY; } + cros_ec_lpc_mec_init(EC_HOST_CMD_REGION0, + EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SIZE); + /* * Read the mapped ID twice, the first one is assuming the * EC is a Microchip Embedded Controller (MEC) variant, if the @@ -456,6 +459,8 @@ static int cros_ec_lpc_remove(struct platform_device *pdev) cros_ec_unregister(ec_dev); + cros_ec_lpc_mec_destroy(); + return 0; } @@ -586,9 +591,6 @@ static int __init cros_ec_lpc_init(void) return -ENODEV; } - cros_ec_lpc_mec_init(EC_HOST_CMD_REGION0, - EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SIZE); - /* Register the driver */ ret = platform_driver_register(&cros_ec_lpc_driver); if (ret) { @@ -615,7 +617,6 @@ static void __exit cros_ec_lpc_exit(void) if (!cros_ec_lpc_acpi_device_found) platform_device_unregister(&cros_ec_lpc_device); platform_driver_unregister(&cros_ec_lpc_driver); - cros_ec_lpc_mec_destroy(); } module_init(cros_ec_lpc_init);