aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2015-03-25 14:03:55 -0400
committerLee Jones <lee.jones@linaro.org>2015-03-30 03:19:56 -0400
commitbafc1face21f34005d34b72010ad6d7235bd448e (patch)
treef1cb45ab8d9ddc8009c255aa83789f1f89232ea2
parent0787ded88e620c81ee2e42cee56cbb5cc26077de (diff)
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>
-rw-r--r--drivers/mfd/intel_quark_i2c_gpio.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/drivers/mfd/intel_quark_i2c_gpio.c b/drivers/mfd/intel_quark_i2c_gpio.c
index 006f2a1b1b1e..1ce16037d043 100644
--- a/drivers/mfd/intel_quark_i2c_gpio.c
+++ b/drivers/mfd/intel_quark_i2c_gpio.c
@@ -70,6 +70,7 @@ static const struct i2c_mode_info platform_i2c_mode_info[] = {
70 .name = "GalileoGen2", 70 .name = "GalileoGen2",
71 .i2c_scl_freq = 400000, 71 .i2c_scl_freq = 400000,
72 }, 72 },
73 {}
73}; 74};
74 75
75static struct resource intel_quark_i2c_res[] = { 76static struct resource intel_quark_i2c_res[] = {
@@ -153,10 +154,10 @@ static void intel_quark_unregister_i2c_clk(struct pci_dev *pdev)
153static int intel_quark_i2c_setup(struct pci_dev *pdev, struct mfd_cell *cell) 154static int intel_quark_i2c_setup(struct pci_dev *pdev, struct mfd_cell *cell)
154{ 155{
155 const char *board_name = dmi_get_system_info(DMI_BOARD_NAME); 156 const char *board_name = dmi_get_system_info(DMI_BOARD_NAME);
157 const struct i2c_mode_info *info;
156 struct dw_i2c_platform_data *pdata; 158 struct dw_i2c_platform_data *pdata;
157 struct resource *res = (struct resource *)cell->resources; 159 struct resource *res = (struct resource *)cell->resources;
158 struct device *dev = &pdev->dev; 160 struct device *dev = &pdev->dev;
159 unsigned int i;
160 161
161 res[INTEL_QUARK_IORES_MEM].start = 162 res[INTEL_QUARK_IORES_MEM].start =
162 pci_resource_start(pdev, MFD_I2C_BAR); 163 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)
170 if (!pdata) 171 if (!pdata)
171 return -ENOMEM; 172 return -ENOMEM;
172 173
173 /* Fast mode by default */ 174 /* Normal mode by default */
174 pdata->i2c_scl_freq = 400000; 175 pdata->i2c_scl_freq = 100000;
175 176
176 for (i = 0; i < ARRAY_SIZE(platform_i2c_mode_info); i++) 177 if (board_name) {
177 if (!strcmp(board_name, platform_i2c_mode_info[i].name)) 178 for (info = platform_i2c_mode_info; info->name; info++) {
178 pdata->i2c_scl_freq 179 if (!strcmp(board_name, info->name)) {
179 = platform_i2c_mode_info[i].i2c_scl_freq; 180 pdata->i2c_scl_freq = info->i2c_scl_freq;
181 break;
182 }
183 }
184 }
180 185
181 cell->platform_data = pdata; 186 cell->platform_data = pdata;
182 cell->pdata_size = sizeof(*pdata); 187 cell->pdata_size = sizeof(*pdata);