Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs

From: Joe Perches
Date: Thu Sep 11 2014 - 14:45:31 EST


On Thu, 2014-09-11 at 12:34 -0500, J. German Rivera wrote:
> APIs to access the Management Complex (MC) hardware
> module of Freescale LS2 SoCs. This patch includes
> APIs to check the MC firmware version and to manipulate
> DPRC objects in the MC.

> diff --git a/drivers/bus/fsl-mc/dpmng.c b/drivers/bus/fsl-mc/dpmng.c
[]
> +int mc_get_version(struct fsl_mc_io *mc_io, struct mc_version *mc_ver_info)
> +{
> + struct mc_command cmd = { 0 };
> + int err;
> +
> + cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_VERSION,
> + DPMNG_CMDSZ_GET_VERSION,
> + MC_CMD_PRI_LOW, 0);
> +
> + err = mc_send_command(mc_io, &cmd);
> + if (!err)
> + DPMNG_RSP_GET_VERSION(cmd, mc_ver_info);
> +
> + return err;

I think it better style to read when the
failure case is handled immediately by
a return or a "goto out" and the successful
case code is at the same indent level

err = mc_send_command_(etc...)
if (err)
return err;

DPMNG_RSP_GET_VERSION(cmd, mc_ver_info);

return 0;
}

> diff --git a/drivers/bus/fsl-mc/dprc.c b/drivers/bus/fsl-mc/dprc.c

> +int dprc_get_container_id(struct fsl_mc_io *mc_io, int *container_id)
> +{
> + struct mc_command cmd = { 0 };
> + int err;
> +
> + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_CONT_ID,
> + DPRC_CMDSZ_GET_CONT_ID,
> + MC_CMD_PRI_LOW, 0);
> +
> + err = mc_send_command(mc_io, &cmd);
> + if (!err)
> + DPRC_RSP_GET_CONTAINER_ID(cmd, *container_id);
> +
> + return err;
> +}

Same sort of thing as above.
Actively fail on err and proceed at the same indent
level on success.

> +
> +int dprc_open(struct fsl_mc_io *mc_io, int container_id, uint16_t *dprc_handle)
> +{
> + int err;
> + struct mc_command cmd = { 0 };
> +
> + cmd.header = mc_encode_cmd_header(MC_DPRC_CMDID_OPEN,
> + MC_CMD_OPEN_SIZE, MC_CMD_PRI_LOW, 0);
> +
> + DPRC_CMD_OPEN(cmd, container_id);
> +
> + err = mc_send_command(mc_io, &cmd);
> + if (!err)
> + *dprc_handle = MC_CMD_HDR_READ_AUTHID(cmd.header);
> +
> + return err;
> +}

etc.

I didn't read any more.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/