summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.c
blob: bb5d83927cb16753295793f6d796978186bddb22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/** @file
  This file implements the entrypoint and unload function for I2C DXE module.

  Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
  SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include "I2cDxe.h"

/**
  The user Entry Point for I2C module. The user code starts with this function.

  @param[in] ImageHandle    The firmware allocated handle for the EFI image.
  @param[in] SystemTable    A pointer to the EFI System Table.

  @retval EFI_SUCCESS       The entry point is executed successfully.
  @retval other             Some error occurs when executing this entry point.

**/
EFI_STATUS
EFIAPI
InitializeI2c(
  IN EFI_HANDLE           ImageHandle,
  IN EFI_SYSTEM_TABLE     *SystemTable
  )
{
  EFI_STATUS              Status;

  //
  // Install driver model protocol(s).
  //
  Status = InitializeI2cHost ( ImageHandle, SystemTable );
  if ( !EFI_ERROR ( Status ))
  {
    Status = InitializeI2cBus ( ImageHandle, SystemTable );
  }
  return Status;
}

/**
  This is the unload handle for I2C module.

  Disconnect the driver specified by ImageHandle from all the devices in the handle database.
  Uninstall all the protocols installed in the driver entry point.

  @param[in] ImageHandle           The drivers' driver image.

  @retval    EFI_SUCCESS           The image is unloaded.
  @retval    Others                Failed to unload the image.

**/
EFI_STATUS
EFIAPI
I2cUnload (
  IN EFI_HANDLE             ImageHandle
  )
{
  EFI_STATUS                        Status;

  //
  //  Disconnect the drivers
  //
  Status = I2cBusUnload ( ImageHandle );
  if ( !EFI_ERROR ( Status )) {
    Status = I2cHostUnload ( ImageHandle );
  }
  return Status;
}