From nobody Tue Dec 24 02:18:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1514389820135428.0407715238166; Wed, 27 Dec 2017 07:50:20 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D521522280C3F; Wed, 27 Dec 2017 07:45:21 -0800 (PST) Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B618E22280C27 for ; Wed, 27 Dec 2017 07:45:19 -0800 (PST) Received: by mail-wr0-x241.google.com with SMTP id o2so37037782wro.5 for ; Wed, 27 Dec 2017 07:50:15 -0800 (PST) Received: from localhost.localdomain ([105.137.110.132]) by smtp.gmail.com with ESMTPSA id i17sm20840876wrf.71.2017.12.27.07.50.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Dec 2017 07:50:13 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::241; helo=mail-wr0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mYfkUwmOQm2oWGvmPBoBYxum1hPxS1NW1MLnfykGhRY=; b=J7gnxf4zMudJWe33wojE8hWAvD3Cuaq7uUgiVM5Ay8JL3ICGch7NqR9I7ByS56vdsK dEXWDeqK7SpJO/qEBjMURtPQdc8qAF750ckV1ZmKBqWTJ2pqloPsa2AUMw3Gw9UPZEjM nGGIDlBTzYhEehDpTZQJFYSFP0fGDIgKszFMw= 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=mYfkUwmOQm2oWGvmPBoBYxum1hPxS1NW1MLnfykGhRY=; b=ZKDvymnDHN+JUnAwdDGlnWtfD9JvEq70BHkTjJHV+7H3KttThCXaoGcFBFpDsem4xF 0FqN4xzHzbNeRr0TnT+r9SlHk8rz0JwrSVtUVmBI+RIYLpNyApRAerMWMwtAnjTmb+GJ BtsCGMdM3EKmhFn11Xi3d2Fo+uAxnu5JxfWxPPEysIYbXDwCHTUwH6E9jX0My4KPiYCI A/JOIikjQkB6JwZG7xr9r9WJGvIsXxEp2n6RLOYNgCeoQ156Q8kNq1f6Q63dh6sgu3FK gy3iD3aLSqiZiLqDDqP6b+IFeuyuTXmS2qYmbj8wDc7RP3DmU5L0HvhxoUHehAxz/Lxm 8h2Q== X-Gm-Message-State: AKGB3mKq5ydfnzx/b2aTd9xBvnQ8iPFfuhegqsUpcVoySvQgy9OzP5Hq r0kc6x2TCknhpVQerFinSVJD6EzXLfQ= X-Google-Smtp-Source: ACJfBotS+2CwZOf0c7Lu2h+3N2JL6zrPAPu3ebOm91CEtN1h/X40hxNKDvNcXpms9MrnoWRZZQiMOw== X-Received: by 10.223.188.66 with SMTP id a2mr30212691wrh.249.1514389813896; Wed, 27 Dec 2017 07:50:13 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 27 Dec 2017 15:49:57 +0000 Message-Id: <20171227155001.25886-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171227155001.25886-1-ard.biesheuvel@linaro.org> References: <20171227155001.25886-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms 2/6] Silicon/NXP/Pcf8563RealTimeClockLib: avoid driver binding protocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Instead of registering a notification callback on the driver binding protocol, and attempting to connect our I2C master handle each time a new driver is registered, switch to the more obvious approach of registering a notification callback on the I2C master protocol directly. The original code was written under the assumption that it would make the RTC available at an earlier time, but given that all handles that are created during the execution of a driver entry point are connected by DXE core right away (i.e., before StartImage() returns), this is not really necessary, and in fact, may result in the driver already having been connected by the time we attempt to connect it. Note that it is now up to the platform to ensure that ConnectController() is called for the handle if DXE core does not call it by itself, or does call it but at a time when no I2C master protocol driver is available yet. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c | = 31 ++++++++------------ Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf | = 1 - 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClo= ckLib.c b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockL= ib.c index 6bc4aef28849..fb58e1feb424 100644 --- a/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c +++ b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c @@ -41,7 +41,7 @@ #define EPOCH_BASE 2000 =20 STATIC EFI_HANDLE mI2cMasterHandle; -STATIC VOID *mDriverEventRegistration; +STATIC VOID *mI2cMasterEventRegistration; STATIC EFI_I2C_MASTER_PROTOCOL *mI2cMaster; STATIC EFI_EVENT mRtcVirtualAddrChangeEvent; =20 @@ -263,12 +263,12 @@ LibSetWakeupTime ( =20 STATIC VOID -DriverRegistrationEvent ( +I2cMasterRegistrationEvent ( IN EFI_EVENT Event, IN VOID *Context ) { - EFI_HANDLE Handle[2]; + EFI_HANDLE Handle; UINTN BufferSize; EFI_STATUS Status; EFI_I2C_MASTER_PROTOCOL *I2cMaster; @@ -280,10 +280,10 @@ DriverRegistrationEvent ( do { BufferSize =3D sizeof (EFI_HANDLE); Status =3D gBS->LocateHandle (ByRegisterNotify, - &gEfiDriverBindingProtocolGuid, - mDriverEventRegistration, + &gEfiI2cMasterProtocolGuid, + mI2cMasterEventRegistration, &BufferSize, - Handle); + &Handle); if (EFI_ERROR (Status)) { if (Status !=3D EFI_NOT_FOUND) { DEBUG ((DEBUG_WARN, "%a: gBS->LocateHandle () returned %r\n", @@ -292,12 +292,7 @@ DriverRegistrationEvent ( break; } =20 - // - // Check if we can connect our handle to this driver. - // - Handle[1] =3D NULL; - Status =3D gBS->ConnectController (mI2cMasterHandle, Handle, NULL, FAL= SE); - if (EFI_ERROR (Status)) { + if (Handle !=3D mI2cMasterHandle) { continue; } =20 @@ -378,16 +373,16 @@ LibRtcInitialize ( ASSERT_EFI_ERROR (Status); =20 // - // Register a protocol registration notification callback on the driver - // binding protocol so we can attempt to connect our I2C master to it - // as soon as it appears. + // Register a protocol registration notification callback on the I2C mas= ter + // protocol. This will notify us even if the protocol instance we are lo= oking + // for has already been installed. // EfiCreateProtocolNotifyEvent ( - &gEfiDriverBindingProtocolGuid, + &gEfiI2cMasterProtocolGuid, TPL_CALLBACK, - DriverRegistrationEvent, + I2cMasterRegistrationEvent, NULL, - &mDriverEventRegistration); + &mI2cMasterEventRegistration); =20 // // Register for the virtual address change event diff --git a/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClo= ckLib.inf b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeCloc= kLib.inf index 1a9a6f6c9cf3..e232902c6b5d 100644 --- a/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.i= nf +++ b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.i= nf @@ -40,7 +40,6 @@ [Guids] gEfiEventVirtualAddressChangeGuid =20 [Protocols] - gEfiDriverBindingProtocolGuid ## CONSUMES gEfiI2cMasterProtocolGuid ## CONSUMES gPcf8563RealTimeClockLibI2cMasterProtocolGuid ## CONSUMES =20 --=20 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel