On Fri, Oct 22, 2021 at 09:57:07AM -0500, Shivaprasad G Bhat wrote:
> From: Vaibhav Jain <[email protected]>
>
[snip]
>
> -static int smart_inject(struct ndctl_dimm *dimm)
> +static int smart_inject(struct ndctl_dimm *dimm, unsigned int inject_types)
> {
> const char *name = ndctl_dimm_get_devname(dimm);
> struct ndctl_cmd *si_cmd = NULL;
> int rc = -EOPNOTSUPP;
>
> - send_inject_val(media_temperature)
> - send_inject_val(ctrl_temperature)
> - send_inject_val(spares)
> - send_inject_bool(fatal)
> - send_inject_bool(unsafe_shutdown)
> + if (inject_types & ND_SMART_INJECT_MEDIA_TEMPERATURE)
> + send_inject_val(media_temperature);
>
> + if (inject_types & ND_SMART_INJECT_CTRL_TEMPERATURE)
> + send_inject_val(ctrl_temperature);
> +
> + if (inject_types & ND_SMART_INJECT_SPARES_REMAINING)
> + send_inject_val(spares);
> +
> + if (inject_types & ND_SMART_INJECT_HEALTH_STATE)
> + send_inject_bool(fatal);
> +
> + if (inject_types & ND_SMART_INJECT_UNCLEAN_SHUTDOWN)
> + send_inject_bool(unsafe_shutdown);
> out:
> ndctl_cmd_unref(si_cmd);
> return rc;
> @@ -415,8 +423,10 @@ static int dimm_inject_smart(struct ndctl_dimm *dimm)
> struct json_object *jhealth;
> struct json_object *jdimms;
> struct json_object *jdimm;
> + unsigned int supported_types;
> int rc;
>
> + /* Get supported smart injection types */
NIT: this comment is probably unnecessary.
> rc = ndctl_dimm_smart_inject_supported(dimm);
> switch (rc) {
> case -ENOTTY:
> @@ -431,6 +441,15 @@ static int dimm_inject_smart(struct ndctl_dimm *dimm)
> error("%s: smart injection not supported by either platform
> firmware or the kernel.",
> ndctl_dimm_get_devname(dimm));
> return rc;
> + default:
> + if (rc < 0) {
> + error("%s: Unknown error %d while checking for smart
> injection support",
> + ndctl_dimm_get_devname(dimm), rc);
> + return rc;
> + }
> + /* Assigning to an unsigned type since rc < 0 */
Comment wrong?
> + supported_types = rc;
> + break;
> }
>
> if (sctx.op_mask & (1 << OP_SET)) {
[snip]
Other than the comment it looks fine.
Reviewed-by: Ira Weiny <[email protected]>