-
Notifications
You must be signed in to change notification settings - Fork 664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Add] Transcend plugin command for PLP health #2355
base: master
Are you sure you want to change the base?
Conversation
There are code style issues which need to be addressed. see also the output from checkpatch The rest looks reasonable. Please also use proper commit subject lines, e.g. with the correct prefix. thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update coding style and some errors
Build failed and some other |
- #define PLPRecordPath "PLPRec.txt"
+ #define PLP_RECORD_PATH "PLPRec.txt"
...
- static const int iDis = 20;
+ static const int i_dis = 20;
...
- enum PLPErrorCode {
+ enum plp_error_code { Note: Sorry still not checked detail more so if needed let me comment later. |
Thanks for your reply, I will fix these errors. |
Signed-off-by: WBJisMyName <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better to be mergeged all commits into a commit.
plugins/transcend/transcend-nvme.c
Outdated
} | ||
|
||
int read_useful_plp_value(const char *device) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a static function.
plugins/transcend/transcend-nvme.c
Outdated
} | ||
} | ||
|
||
void record_plp_value(const char *device, int value, bool is_replace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Static function.
plugins/transcend/transcend-nvme.h
Outdated
|
||
#include "define_cmd.h" | ||
#include "define_cmd.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be added a new line code on the end of the line (before the end of file).
plugins/transcend/transcend-nvme.c
Outdated
static const double full_value = 170; | ||
|
||
enum plp_error_code { | ||
PLP_ERROR_NO_MATCH = -1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All indentation should be chagned to 8 character tab instead of the whitespace basically.
plugins/transcend/transcend-nvme.c
Outdated
PLP_ERROR_DATA_EXPIRED = -2 | ||
}; | ||
|
||
const char *string_list[] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those variables seem better to be static variables.
plugins/transcend/transcend-nvme.h
Outdated
@@ -5,17 +5,19 @@ | |||
#if !defined(TRANSCEND_NVME) || defined(CMD_HEADER_MULTI_READ) | |||
#define TRANSCEND_NVME | |||
|
|||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definition is dupulicated with the definition in common.h.
Signed-off-by: WBJisMyName <[email protected]>
plugins/transcend/transcend-nvme.c
Outdated
}; | ||
|
||
static const char *string_list[] = { | ||
"UTE210T", "MTE712P", "MTE560P", "MTE662P", "MTE662P-I", "MTS970P", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still indentation errors. (Should be used 8 characters tab instead of 4 white spaces.)
plugins/transcend/transcend-nvme.c
Outdated
|
||
static int get_health_value(int argc, char **argv, struct command *cmd, struct plugin *plugin) | ||
{ | ||
struct nvme_smart_log smart_log; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are also indentation errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your quick reply, I will correct it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkpatch.pl is helpful to detect these kind of formatting issues. You can run it locally. Fetch the linux kernel source and run linux/scripts/checkpatch.pl -g HEAD
or similar. Keep in mind checkpatch.pl is very opinionated and we should just be ignored some of the advice.
2. Change function to Static function Signed-off-by: WBJisMyName <[email protected]>
} | ||
|
||
static const char *format_char_array(char *str, int str_size, | ||
unsigned char *chr, int chr_size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation error.
tatic const char *format_char_array(char *str, int str_size,
- unsigned char *chr, int chr_size)
+ unsigned char *chr, int chr_size)
} | ||
|
||
static int get_plp_health(int argc, char **argv, struct command *cmd, | ||
struct plugin *plugin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation error.
static int get_plp_health(int argc, char **argv, struct command *cmd,
- struct plugin *plugin)
+ struct plugin *plugin)
} | ||
|
||
/* Calculate PLP health */ | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems better to split this part into a separated function.
return -1; | ||
ret = parse_and_open(&dev, argc, argv, desc, opts); | ||
if (ret) { | ||
pr_err("Device not found\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems better to use fprintf(stderr, ...)
and printf()
instead of the pr_err
and pr_info
since only this file using the pr_***()
funcitons.
} else { | ||
remove(tmp_path); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to insert a line break after }
before EOF
.
fclose(fp_in); | ||
fclose(fp_out); | ||
|
||
if (remove(log_path) == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to use braces {
and }
for the single statement.
static int read_useful_plp_value(const char *device); | ||
static void record_plp_value(const char *device, int value, bool is_replace); | ||
|
||
static int get_health_value(int argc, char **argv, struct command *cmd, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems better to split this function related changes to other patch.
} | ||
|
||
static int getBadblock(int argc, char **argv, struct command *cmd, struct plugin *plugin) | ||
static int get_bad_block(int argc, char **argv, struct command *cmd, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems better to split this function related changes also to other patch since not related to the plphealthvalue command.
There are build errors which need to be address, e.g. there is no The documentation should also be hooked up: --- a/Documentation/meson.build
+++ b/Documentation/meson.build
@@ -148,6 +148,7 @@ adoc_sources = [
'nvme-toshiba-vs-smart-add-log',
'nvme-transcend-badblock',
'nvme-transcend-healthvalue',
+ 'nvme-transcend-plphealthvalue',
'nvme-verify',
'nvme-virtium-save-smart-to-vtview-log',
'nvme-virtium-show-identify', The rest looks almost there (after squashing all changes into a single patch). A few small nitpicks which I'd address myself but as it doesn't build right now, please fix the build and I'd cleanup the rest. |
Are you planing to address the remaining issues? Or is this PR abandoned? |
This function will support the Transcend NVMe Devices.
Please feel free to contact me if you have any question.
Thanks.