iPXE
mlx_blink_leds.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2015 Mellanox Technologies Ltd.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301, USA.
00018  */
00019 
00020 FILE_LICENCE ( GPL2_OR_LATER );
00021 
00022 #include "../../mlx_lib/mlx_blink_leds/mlx_blink_leds.h"
00023 #include "../../include/public/mlx_memory.h"
00024 #include "../../include/public/mlx_bail.h"
00025 
00026 mlx_status
00027 mlx_blink_leds(
00028                 IN mlx_utils *utils,
00029                 IN mlx_uint16 secs
00030                 )
00031 {
00032         mlx_status status = MLX_SUCCESS;
00033         struct mlx_led_control led_control;
00034         mlx_uint32 reg_status;
00035 
00036         if (utils == NULL ) {
00037                 status = MLX_INVALID_PARAMETER;
00038                 goto bad_param;
00039         }
00040         mlx_memory_set(utils, &led_control, 0, sizeof(led_control));
00041         led_control.beacon_duration = secs;
00042         status = mlx_reg_access(utils, REG_ID_MLCR, REG_ACCESS_WRITE, &led_control, sizeof(led_control),
00043                         &reg_status);
00044         MLX_CHECK_STATUS(utils, status, reg_err, "mlx_reg_access failed ");
00045         if (reg_status != 0) {
00046                 MLX_DEBUG_ERROR(utils,"mlx_reg_access failed with status = %d\n", reg_status);
00047                 status = MLX_FAILED;
00048                 goto reg_err;
00049         }
00050 reg_err:
00051 bad_param:
00052         return status;
00053 }
00054