summaryrefslogtreecommitdiff
path: root/src/drivers/i2c/pi608gp
diff options
context:
space:
mode:
authorJan Samek <jan.samek@siemens.com>2023-05-30 10:56:30 +0200
committerFelix Held <felix-coreboot@felixheld.de>2023-06-15 14:59:53 +0000
commit872e84fe3085eff3bfe16ce04a9a5bede85a4b36 (patch)
tree3b6a2ffa0110a00dc41b4d1a9e6cf076e36b39cf /src/drivers/i2c/pi608gp
parent3d51e833478005196b5e0e01bb60878a76274a3d (diff)
drv/i2c/pi608gp: Fix types
In commit e59f18bf29a8 ("drivers/i2c: Add PI7C9X2G608GP PCIe switch driver (pi608gp)"), there were some suggestions after it's been already merged. This patch addresses the points regarding the number types - fix of the printk format strings, inclusion of 'stdint.h' and marking the set of allowed values as constant. BUG=none TEST=Build OK, no behavioral changes in the pi608gp driver, console logs without changes. Change-Id: I34c664f6a8a257b260facdbf9043825ff4a4c932 Signed-off-by: Jan Samek <jan.samek@siemens.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/75500 Reviewed-by: Himanshu Sahdev <himanshu.sahdev@intel.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com> Reviewed-by: Mario Scheithauer <mario.scheithauer@siemens.com>
Diffstat (limited to 'src/drivers/i2c/pi608gp')
-rw-r--r--src/drivers/i2c/pi608gp/pi608gp.c10
-rw-r--r--src/drivers/i2c/pi608gp/pi608gp.h2
2 files changed, 7 insertions, 5 deletions
diff --git a/src/drivers/i2c/pi608gp/pi608gp.c b/src/drivers/i2c/pi608gp/pi608gp.c
index e50e7267b2..9d63f85fe8 100644
--- a/src/drivers/i2c/pi608gp/pi608gp.c
+++ b/src/drivers/i2c/pi608gp/pi608gp.c
@@ -30,12 +30,12 @@ static uint8_t pi608gp_encode_amp_lvl(uint32_t level_mv)
/* Allowed drive amplitude levels are in units of mV in range 0 to 475 mV with 25 mV
steps, based on Table 6-6 from the PI7C9X2G608GP datasheet. */
if (level_mv > 475) {
- printk(BIOS_ERR, "PI608GP: Drive level %d mV out of range 0 to 475 mV!",
+ printk(BIOS_ERR, "PI608GP: Drive level %u mV out of range 0 to 475 mV!",
level_mv);
return PI608GP_ENCODE_ERR;
}
if (level_mv % 25 != 0) {
- printk(BIOS_ERR, "PI608GP: Drive level %d mV not a multiple of 25!\n",
+ printk(BIOS_ERR, "PI608GP: Drive level %u mV not a multiple of 25!\n",
level_mv);
return PI608GP_ENCODE_ERR;
}
@@ -48,7 +48,7 @@ static uint8_t pi608gp_encode_deemph_lvl(struct deemph_lvl level_mv)
{
/* Table of allowed fixed-point millivolt values, based on Table 6-8 from the
PI7C9X2G608GP datasheet. */
- struct deemph_lvl allowed[] = {
+ const struct deemph_lvl allowed[] = {
{ 0, 0}, { 6, 0}, { 12, 5}, { 19, 0}, { 25, 0}, { 31, 0}, { 37, 5}, { 44, 0},
{ 50, 0}, { 56, 0}, { 62, 5}, { 69, 0}, { 75, 0}, { 81, 0}, { 87, 0}, { 94, 0},
{100, 0}, {106, 0}, {112, 5}, {119, 0}, {125, 0}, {131, 0}, {137, 5}, {144, 0},
@@ -59,10 +59,10 @@ static uint8_t pi608gp_encode_deemph_lvl(struct deemph_lvl level_mv)
if (allowed[i].lvl == level_mv.lvl && allowed[i].lvl_10 == level_mv.lvl_10)
/* When found, the encoded value is a 5-bit number that corresponds to
the index in the table of allowed values above. */
- return (uint8_t) (i & 0x1f);
+ return i & 0x1f;
}
- printk(BIOS_ERR, "PI608GP: Requested unsupported de-emphasis level value: %d.%d mV!\n",
+ printk(BIOS_ERR, "PI608GP: Requested unsupported de-emphasis level value: %u.%u mV!\n",
level_mv.lvl, level_mv.lvl_10);
return PI608GP_ENCODE_ERR;
}
diff --git a/src/drivers/i2c/pi608gp/pi608gp.h b/src/drivers/i2c/pi608gp/pi608gp.h
index fe2776be01..9a5f5df7e8 100644
--- a/src/drivers/i2c/pi608gp/pi608gp.h
+++ b/src/drivers/i2c/pi608gp/pi608gp.h
@@ -3,6 +3,8 @@
#ifndef _I2C_PI608GP_H_
#define _I2C_PI608GP_H_
+#include <stdint.h>
+
/* Struct to store fixed-point millivolt values */
struct deemph_lvl { uint32_t lvl, lvl_10; };