Skip to content

Commit df2a63d

Browse files
License header standardization, copyright update and code beautification
License Changes: - Add SPDX-FileCopyrightText identifiers for license compliance - Update copyright years from 2024 to 2025 - Standardize copyright format with 'All rights reserved' - Add complete GPL-2.0-only license headers to files missing them - Ensure consistent license attribution across all source files Code Beautification: - Standardize indentation (convert tabs to spaces) - Improve code formatting consistency - Apply consistent style across C source files and Python scripts Affects 53 files total: shell scripts, Python scripts, and C source files
1 parent aba3729 commit df2a63d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+905
-593
lines changed

examples/src/ev_hndl/ev_hndl.c

Lines changed: 332 additions & 324 deletions
Large diffs are not rendered by default.

examples/src/ev_hndl/ev_hndl.h

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* Copyright (c) 2019 Mellanox Technologies. All rights reserved.
2+
* SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
3+
* Copyright (c) 2019-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
34
*
45
* Redistribution and use in source and binary forms, with or without
56
* modification, are permitted provided that the following conditions are met:
@@ -33,33 +34,33 @@
3334
#ifndef __EV_HNDL_H__
3435
#define __EV_HNDL_H__
3536

36-
#define HW_MGMT_PATH "/var/run/hw-management/"
37-
#define CONFIG_PATH HW_MGMT_PATH "config/"
38-
#define EVENTS_PATH HW_MGMT_PATH "events/"
39-
#define PSU_NUM_FILE "hotplug_psus"
40-
#define PWR_NUM_FILE "hotplug_pwrs"
41-
#define FAN_NUM_FILE "hotplug_fans"
37+
#define HW_MGMT_PATH "/var/run/hw-management/"
38+
#define CONFIG_PATH HW_MGMT_PATH "config/"
39+
#define EVENTS_PATH HW_MGMT_PATH "events/"
40+
#define PSU_NUM_FILE "hotplug_psus"
41+
#define PWR_NUM_FILE "hotplug_pwrs"
42+
#define FAN_NUM_FILE "hotplug_fans"
4243

43-
#define EVENT_IN 1
44-
#define EVENT_OUT 0
44+
#define EVENT_IN 1
45+
#define EVENT_OUT 0
4546

46-
#define EV_NAME_MAX_LEN 16
47-
#define FPATH_MAX_LEN 256
47+
#define EV_NAME_MAX_LEN 16
48+
#define FPATH_MAX_LEN 256
4849

4950
struct ev_hndl_ev_info {
50-
int wd;
51-
char fname[FPATH_MAX_LEN];
52-
char name[EV_NAME_MAX_LEN];
51+
int wd;
52+
char fname[FPATH_MAX_LEN];
53+
char name[EV_NAME_MAX_LEN];
5354
};
5455

5556
struct ev_hndl_priv_data {
56-
int ifd;
57-
struct ev_hndl_ev_info *ev_info;
58-
int psu_num;
59-
int pwr_num;
60-
int fan_num;
61-
int ev_num;
62-
long to;
57+
int ifd;
58+
struct ev_hndl_ev_info *ev_info;
59+
int psu_num;
60+
int pwr_num;
61+
int fan_num;
62+
int ev_num;
63+
long to;
6364
};
6465

6566
#endif
Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* Copyright (C) Mellanox Technologies, Ltd. 2001-2020 ALL RIGHTS RESERVED.
2+
* SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
3+
* Copyright (c) 2001-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
34
*
45
* This software product is a proprietary product of Mellanox Technologies, Ltd.
56
* (the "Company") and all right, title, and interest in and to the software product,
@@ -25,49 +26,51 @@
2526

2627

2728
#define EVENT_SIZE (sizeof(struct inotify_event))
28-
#define EVENT_NUM 128
29-
#define BUF_LEN (EVENT_SIZE*EVENT_NUM)
30-
#define POWER_ON 1
31-
//#define LC1_VERIFIED_PATH "/var/run/hw-management/events/lc1_verified"
29+
#define EVENT_NUM 128
30+
#define BUF_LEN (EVENT_SIZE * EVENT_NUM)
31+
#define POWER_ON 1
32+
/*#define LC1_VERIFIED_PATH "/var/run/hw-management/events/lc1_verified" */
3233

33-
int main(int argc, char *argv[]) {
34-
char events_buffer[BUF_LEN];
34+
int main(int argc, char *argv[])
35+
{
36+
char events_buffer[BUF_LEN];
3537
char * event_filepath;
36-
int wd, ifd, len, i=0;
37-
char event_val;
38-
FILE* fd;
39-
if(argc != 2) {
38+
int wd, ifd, len, i = 0;
39+
char event_val;
40+
FILE * fd;
41+
42+
if (argc != 2) {
4043
printf("Invalid argument number %d. Pass event filepath as argument.\n", argc);
4144
}
42-
event_filepath=argv[1];
45+
event_filepath = argv[1];
4346
ifd = inotify_init();
4447
wd = inotify_add_watch(ifd, event_filepath, IN_CLOSE_WRITE);
4548
if (wd < 0) {
4649
printf("Failed to add file %s to watch, %s \n",
4750
event_filepath, strerror(errno));
4851
return -1;
4952
} else {
50-
while(1) {
53+
while (1) {
5154
len = read(ifd, &events_buffer, BUF_LEN);
52-
i=0;
55+
i = 0;
5356
while (i < len) {
54-
struct inotify_event *event = (struct inotify_event *) &events_buffer[i];
57+
struct inotify_event *event = (struct inotify_event *)&events_buffer[i];
5558
if (wd == event->wd) {
5659
if (event->mask & IN_CLOSE_WRITE) {
5760
fd = fopen(event_filepath, "r");
58-
event_val=(char)fgetc(fd);
61+
event_val = (char)fgetc(fd);
5962
printf("event: %s %c.\n", event_filepath, event_val);
60-
// Do some event based action. For lc{n}_verifiled:
61-
// Validation line card type, max power consumption, CPLD version, VPD, INI blob.
62-
// Validate VPD /var/run/hw-management/lc1/eeprom/vpd.
63-
// Validate INI /var/run/hw-management/lc1/eeprom/ini.
64-
// Check /var/run/hw-management/lc1/system/max_power is enough power.
65-
// Continue init flow - power on line card.
63+
/* Do some event based action. For lc{n}_verifiled: */
64+
/* Validation line card type, max power consumption, CPLD version, VPD, INI blob. */
65+
/* Validate VPD /var/run/hw-management/lc1/eeprom/vpd. */
66+
/* Validate INI /var/run/hw-management/lc1/eeprom/ini. */
67+
/* Check /var/run/hw-management/lc1/system/max_power is enough power. */
68+
/* Continue init flow - power on line card. */
6669
}
6770
}
6871
i += EVENT_SIZE + event->len;
6972
}
7073
}
7174
}
72-
return(0);
75+
return (0);
7376
}

examples/src/ev_hndl/lc_event_handler.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
#!/usr/bin/python
2+
#
3+
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
4+
# Copyright (c) 2020-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
5+
# SPDX-License-Identifier: GPL-2.0-only
6+
#
7+
# This program is free software; you can redistribute it and/or modify it
8+
# under the terms and conditions of the GNU General Public License,
9+
# version 2, as published by the Free Software Foundation.
10+
#
11+
# This program is distributed in the hope it will be useful, but WITHOUT
12+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14+
# more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
#
19+
220
"""
321
422
@copyright:

0 commit comments

Comments
 (0)