Re: [PATCH 10/44] staging: spmi: hisi-spmi-controller: do some code cleanups
From: Joe Perches
Date: Wed Aug 12 2020 - 12:17:53 EST
On Wed, 2020-08-12 at 17:56 +0200, Mauro Carvalho Chehab wrote:
> There are several minor things that can be cleanup in
> order to make this driver more prepared for leaving staging.
trivial style notes:
> diff --git a/drivers/staging/hikey9xx/hisi-spmi-controller.c b/drivers/staging/hikey9xx/hisi-spmi-controller.c
[]
> @@ -106,14 +83,13 @@ static int spmi_controller_wait_for_done(struct device *dev,
> struct spmi_controller_dev *ctrl_dev,
> void __iomem *base, u8 sid, u16 addr)
> {
> - u32 status = 0;
> u32 timeout = SPMI_CONTROLLER_TIMEOUT_US;
> - u32 offset;
> + u32 status, offset;
>
> offset = SPMI_APB_SPMI_STATUS_BASE_ADDR;
> offset += SPMI_CHANNEL_OFFSET * ctrl_dev->channel + SPMI_SLAVE_OFFSET * sid;
>
> - while (timeout--) {
> + do {
> status = readl(base + offset);
>
> if (status & SPMI_APB_TRANS_DONE) {
> @@ -126,21 +102,21 @@ static int spmi_controller_wait_for_done(struct device *dev,
> return 0;
> }
> udelay(1);
> - }
> + } while(timeout--);
Odd spacing.
Two spaces after close brace, none before open parenthesis.
> @@ -237,14 +217,13 @@ static int spmi_write_cmd(struct spmi_controller *ctrl,
[]
> - i = 0;
> - do {
> + for (i = 0; bc > i * SPMI_PER_DATAREG_BYTE; i++) {
> data = 0;
> if ((bc - i * SPMI_PER_DATAREG_BYTE) >> 2) {
> memcpy(&data, buf, sizeof(data));
> @@ -256,22 +235,22 @@ static int spmi_write_cmd(struct spmi_controller *ctrl,
>
> writel((u32)cpu_to_be32(data),
> spmi_controller->base + chnl_ofst + SPMI_APB_SPMI_WDATA0_BASE_ADDR + SPMI_PER_DATAREG_BYTE * i);
> - i++;
> - } while (bc > i * SPMI_PER_DATAREG_BYTE);
> + };
Unnecessary semicolon after for loop close brace.