Skip to contentSkip to conversation

i2c: stm32f7: cosmetic: clean the driver

PATCH New Patrick Delaunay 2 participants 4 messages Oct 29, 2018 – Nov 17, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 i2c: stm32f7: cosmetic: clean the driver

Solve alignments issues in the driver to avoid
checkpatch error.

---

 drivers/i2c/stm32f7_i2c.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)
drivers/i2c/stm32f7_i2c.c +16 -15
index 36ec610..7ed04d9 100644
@@ -58,7 +58,7 @@ struct stm32_i2c_regs {
 #define STM32_I2C_CR2_ADD10			BIT(11)
 #define STM32_I2C_CR2_RD_WRN			BIT(10)
 #define STM32_I2C_CR2_SADD10_MASK		GENMASK(9, 0)
-#define STM32_I2C_CR2_SADD10(n)			((n & STM32_I2C_CR2_SADD10_MASK))
+#define STM32_I2C_CR2_SADD10(n)			(n & STM32_I2C_CR2_SADD10_MASK)
 #define STM32_I2C_CR2_SADD7_MASK		GENMASK(7, 1)
 #define STM32_I2C_CR2_SADD7(n)			((n & 0x7f) << 1)
 #define STM32_I2C_CR2_RESET_MASK		(STM32_I2C_CR2_HEAD10R \
@@ -255,7 +255,7 @@ static int stm32_i2c_check_device_busy(struct stm32_i2c_priv *i2c_priv)
 }
 
 static void stm32_i2c_message_start(struct stm32_i2c_priv *i2c_priv,
-				      struct i2c_msg *msg, bool stop)
+				    struct i2c_msg *msg, bool stop)
 {
 	struct stm32_i2c_regs *regs = i2c_priv->regs;
 	u32 cr2 = readl(&regs->cr2);
@@ -299,7 +299,7 @@ static void stm32_i2c_message_start(struct stm32_i2c_priv *i2c_priv,
  */
 
 static void stm32_i2c_handle_reload(struct stm32_i2c_priv *i2c_priv,
-				      struct i2c_msg *msg, bool stop)
+				    struct i2c_msg *msg, bool stop)
 {
 	struct stm32_i2c_regs *regs = i2c_priv->regs;
 	u32 cr2 = readl(&regs->cr2);
@@ -317,7 +317,7 @@ static void stm32_i2c_handle_reload(struct stm32_i2c_priv *i2c_priv,
 }
 
 static int stm32_i2c_wait_flags(struct stm32_i2c_priv *i2c_priv,
-				  u32 flags, u32 *status)
+				u32 flags, u32 *status)
 {
 	struct stm32_i2c_regs *regs = i2c_priv->regs;
 	u32 time_start = get_timer(0);
@@ -392,7 +392,7 @@ static int stm32_i2c_check_end_of_message(struct stm32_i2c_priv *i2c_priv)
 }
 
 static int stm32_i2c_message_xfer(struct stm32_i2c_priv *i2c_priv,
-				    struct i2c_msg *msg, bool stop)
+				  struct i2c_msg *msg, bool stop)
 {
 	struct stm32_i2c_regs *regs = i2c_priv->regs;
 	u32 status;
@@ -465,7 +465,7 @@ static int stm32_i2c_message_xfer(struct stm32_i2c_priv *i2c_priv,
 }
 
 static int stm32_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
-			    int nmsgs)
+			  int nmsgs)
 {
 	struct stm32_i2c_priv *i2c_priv = dev_get_priv(bus);
 	int ret;
@@ -594,6 +594,7 @@ static int stm32_i2c_choose_solution(struct stm32_i2c_setup *setup,
 
 		for (l = 0; l < STM32_SCLL_MAX; l++) {
 			u32 tscl_l = (l + 1) * prescaler + tsync;
+
 			if ((tscl_l < i2c_specs[setup->speed].l_min) ||
 			    (i2cclk >=
 			     ((tscl_l - af_delay_min - dnf_delay) / 4))) {
@@ -634,8 +635,8 @@ static int stm32_i2c_choose_solution(struct stm32_i2c_setup *setup,
 }
 
 static int stm32_i2c_compute_timing(struct stm32_i2c_priv *i2c_priv,
-				      struct stm32_i2c_setup *setup,
-				      struct stm32_i2c_timings *output)
+				    struct stm32_i2c_setup *setup,
+				    struct stm32_i2c_timings *output)
 {
 	struct stm32_i2c_timings *v, *_v;
 	struct list_head solutions;
@@ -643,28 +644,28 @@ static int stm32_i2c_compute_timing(struct stm32_i2c_priv *i2c_priv,
 
 	if (setup->speed >= STM32_I2C_SPEED_END) {
 		pr_err("%s: speed out of bound {%d/%d}\n", __func__,
-		      setup->speed, STM32_I2C_SPEED_END - 1);
+		       setup->speed, STM32_I2C_SPEED_END - 1);
 		return -EINVAL;
 	}
 
 	if ((setup->rise_time > i2c_specs[setup->speed].rise_max) ||
 	    (setup->fall_time > i2c_specs[setup->speed].fall_max)) {
 		pr_err("%s :timings out of bound Rise{%d>%d}/Fall{%d>%d}\n",
-		      __func__,
-		      setup->rise_time, i2c_specs[setup->speed].rise_max,
-		      setup->fall_time, i2c_specs[setup->speed].fall_max);
+		       __func__,
+		       setup->rise_time, i2c_specs[setup->speed].rise_max,
+		       setup->fall_time, i2c_specs[setup->speed].fall_max);
 		return -EINVAL;
 	}
 
 	if (setup->dnf > STM32_I2C_DNF_MAX) {
 		pr_err("%s: DNF out of bound %d/%d\n", __func__,
-		      setup->dnf, STM32_I2C_DNF_MAX);
+		       setup->dnf, STM32_I2C_DNF_MAX);
 		return -EINVAL;
 	}
 
 	if (setup->speed_freq > i2c_specs[setup->speed].rate) {
 		pr_err("%s: Freq {%d/%d}\n", __func__,
-		      setup->speed_freq, i2c_specs[setup->speed].rate);
+		       setup->speed_freq, i2c_specs[setup->speed].rate);
 		return -EINVAL;
 	}
 
@@ -693,7 +694,7 @@ exit:
 }
 
 static int stm32_i2c_setup_timing(struct stm32_i2c_priv *i2c_priv,
-				    struct stm32_i2c_timings *timing)
+				  struct stm32_i2c_timings *timing)
 {
 	struct stm32_i2c_setup *setup = i2c_priv->setup;
 	int ret = 0;
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 i2c: stm32f7: change setup struct to const

Change static array to const when it is useful to save memory (move stm32f7_setup=0x18 from .data to .rodata section)

---

 drivers/i2c/stm32f7_i2c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/stm32f7_i2c.c +2 -2
index 7ed04d9..3872364 100644
@@ -197,7 +197,7 @@ struct stm32_i2c_priv {
 	int speed;
 };
 
-static struct stm32_i2c_spec i2c_specs[] = {
+static const struct stm32_i2c_spec i2c_specs[] = {
 	[STM32_I2C_SPEED_STANDARD] = {
 		.rate = STANDARD_RATE,
 		.rate_min = 8000,
@@ -236,7 +236,7 @@ static struct stm32_i2c_spec i2c_specs[] = {
 	},
 };
 
-static struct stm32_i2c_setup stm32f7_setup = {
+static const struct stm32_i2c_setup stm32f7_setup = {
 	.rise_time = STM32_I2C_RISE_TIME_DEFAULT,
 	.fall_time = STM32_I2C_FALL_TIME_DEFAULT,
 	.dnf = STM32_I2C_DNF_DEFAULT,
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/2 i2c: stm32f7: change setup struct to const

Quoted 4 lines · Patrick Delaunay

Change static array to const when it is useful to save memory (move stm32f7_setup=0x18 from .data to .rodata section)

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181117/869bcd57/attachment.sig>
#3 lore raw

PATCH 1/2 i2c: stm32f7: cosmetic: clean the driver

In reply to Patrick Delaunay
Quoted 4 lines · Patrick Delaunay

Solve alignments issues in the driver to avoid
checkpatch error.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181117/a9270b22/attachment.sig>