drv/i2c/pi608gp: Fix types

In commit e59f18bf29 ("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>
This commit is contained in:
Jan Samek 2023-05-30 10:56:30 +02:00 committed by Felix Held
parent 3d51e83347
commit 872e84fe30
2 changed files with 7 additions and 5 deletions

View File

@ -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;
}

View File

@ -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; };