mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 04:06:26 +00:00
mfd: intel_quark_i2c_gpio: Don't crash if !DMI
dmi_get_system_info() may return NULL either when CONFIG_DMI is not set or when board has an old firmware. The patch prevents a crash and changes the default frequency to be in align with older board. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> [Lee: Removed overt "sentinel" comment and extra lines] Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
parent
0787ded88e
commit
bafc1face2
@ -70,6 +70,7 @@ static const struct i2c_mode_info platform_i2c_mode_info[] = {
|
|||||||
.name = "GalileoGen2",
|
.name = "GalileoGen2",
|
||||||
.i2c_scl_freq = 400000,
|
.i2c_scl_freq = 400000,
|
||||||
},
|
},
|
||||||
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct resource intel_quark_i2c_res[] = {
|
static struct resource intel_quark_i2c_res[] = {
|
||||||
@ -153,10 +154,10 @@ static void intel_quark_unregister_i2c_clk(struct pci_dev *pdev)
|
|||||||
static int intel_quark_i2c_setup(struct pci_dev *pdev, struct mfd_cell *cell)
|
static int intel_quark_i2c_setup(struct pci_dev *pdev, struct mfd_cell *cell)
|
||||||
{
|
{
|
||||||
const char *board_name = dmi_get_system_info(DMI_BOARD_NAME);
|
const char *board_name = dmi_get_system_info(DMI_BOARD_NAME);
|
||||||
|
const struct i2c_mode_info *info;
|
||||||
struct dw_i2c_platform_data *pdata;
|
struct dw_i2c_platform_data *pdata;
|
||||||
struct resource *res = (struct resource *)cell->resources;
|
struct resource *res = (struct resource *)cell->resources;
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
res[INTEL_QUARK_IORES_MEM].start =
|
res[INTEL_QUARK_IORES_MEM].start =
|
||||||
pci_resource_start(pdev, MFD_I2C_BAR);
|
pci_resource_start(pdev, MFD_I2C_BAR);
|
||||||
@ -170,13 +171,17 @@ static int intel_quark_i2c_setup(struct pci_dev *pdev, struct mfd_cell *cell)
|
|||||||
if (!pdata)
|
if (!pdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* Fast mode by default */
|
/* Normal mode by default */
|
||||||
pdata->i2c_scl_freq = 400000;
|
pdata->i2c_scl_freq = 100000;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(platform_i2c_mode_info); i++)
|
if (board_name) {
|
||||||
if (!strcmp(board_name, platform_i2c_mode_info[i].name))
|
for (info = platform_i2c_mode_info; info->name; info++) {
|
||||||
pdata->i2c_scl_freq
|
if (!strcmp(board_name, info->name)) {
|
||||||
= platform_i2c_mode_info[i].i2c_scl_freq;
|
pdata->i2c_scl_freq = info->i2c_scl_freq;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cell->platform_data = pdata;
|
cell->platform_data = pdata;
|
||||||
cell->pdata_size = sizeof(*pdata);
|
cell->pdata_size = sizeof(*pdata);
|
||||||
|
Loading…
Reference in New Issue
Block a user