From 872e84fe3085eff3bfe16ce04a9a5bede85a4b36 Mon Sep 17 00:00:00 2001 From: Jan Samek Date: Tue, 30 May 2023 10:56:30 +0200 Subject: 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/75500 Reviewed-by: Himanshu Sahdev Tested-by: build bot (Jenkins) Reviewed-by: Eric Lai Reviewed-by: Mario Scheithauer --- src/drivers/i2c/pi608gp/pi608gp.c | 10 +++++----- src/drivers/i2c/pi608gp/pi608gp.h | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/drivers/i2c/pi608gp') 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 + /* Struct to store fixed-point millivolt values */ struct deemph_lvl { uint32_t lvl, lvl_10; }; -- cgit v1.2.3