Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: si5351: remove variant from platform_data

Commit 9807362bfe1748d9bb48eecb9261f1b1aaafea1c
"clk: si5351: declare all device IDs for module loading"
removed the common i2c_device_id and introduced new ones for each variant
of the clock generator. Instead of exploiting that information in the driver,
it still depends on platform_data passing the chips .variant.

This removes the now redundant .variant from the platform_data and puts it in
i2c_device_id's .driver_data instead.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>

authored by

Sebastian Hesselbarth and committed by
Mike Turquette
9d43dc7f 8e31d19b

+26 -32
+12 -16
drivers/clk/clk-si5351.c
··· 1111 1111 }; 1112 1112 MODULE_DEVICE_TABLE(of, si5351_dt_ids); 1113 1113 1114 - static int si5351_dt_parse(struct i2c_client *client) 1114 + static int si5351_dt_parse(struct i2c_client *client, 1115 + enum si5351_variant variant) 1115 1116 { 1116 1117 struct device_node *child, *np = client->dev.of_node; 1117 1118 struct si5351_platform_data *pdata; 1118 - const struct of_device_id *match; 1119 1119 struct property *prop; 1120 1120 const __be32 *p; 1121 1121 int num = 0; ··· 1124 1124 if (np == NULL) 1125 1125 return 0; 1126 1126 1127 - match = of_match_node(si5351_dt_ids, np); 1128 - if (match == NULL) 1129 - return -EINVAL; 1130 - 1131 1127 pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); 1132 1128 if (!pdata) 1133 1129 return -ENOMEM; 1134 1130 1135 - pdata->variant = (enum si5351_variant)match->data; 1136 1131 pdata->clk_xtal = of_clk_get(np, 0); 1137 1132 if (!IS_ERR(pdata->clk_xtal)) 1138 1133 clk_put(pdata->clk_xtal); ··· 1158 1163 pdata->pll_src[num] = SI5351_PLL_SRC_XTAL; 1159 1164 break; 1160 1165 case 1: 1161 - if (pdata->variant != SI5351_VARIANT_C) { 1166 + if (variant != SI5351_VARIANT_C) { 1162 1167 dev_err(&client->dev, 1163 1168 "invalid parent %d for pll %d\n", 1164 1169 val, num); ··· 1182 1187 } 1183 1188 1184 1189 if (num >= 8 || 1185 - (pdata->variant == SI5351_VARIANT_A3 && num >= 3)) { 1190 + (variant == SI5351_VARIANT_A3 && num >= 3)) { 1186 1191 dev_err(&client->dev, "invalid clkout %d\n", num); 1187 1192 return -EINVAL; 1188 1193 } ··· 1221 1226 SI5351_CLKOUT_SRC_XTAL; 1222 1227 break; 1223 1228 case 3: 1224 - if (pdata->variant != SI5351_VARIANT_C) { 1229 + if (variant != SI5351_VARIANT_C) { 1225 1230 dev_err(&client->dev, 1226 1231 "invalid parent %d for clkout %d\n", 1227 1232 val, num); ··· 1302 1307 static int si5351_i2c_probe(struct i2c_client *client, 1303 1308 const struct i2c_device_id *id) 1304 1309 { 1310 + enum si5351_variant variant = (enum si5351_variant)id->driver_data; 1305 1311 struct si5351_platform_data *pdata; 1306 1312 struct si5351_driver_data *drvdata; 1307 1313 struct clk_init_data init; ··· 1311 1315 u8 num_parents, num_clocks; 1312 1316 int ret, n; 1313 1317 1314 - ret = si5351_dt_parse(client); 1318 + ret = si5351_dt_parse(client, variant); 1315 1319 if (ret) 1316 1320 return ret; 1317 1321 ··· 1327 1331 1328 1332 i2c_set_clientdata(client, drvdata); 1329 1333 drvdata->client = client; 1330 - drvdata->variant = pdata->variant; 1334 + drvdata->variant = variant; 1331 1335 drvdata->pxtal = pdata->clk_xtal; 1332 1336 drvdata->pclkin = pdata->clk_clkin; 1333 1337 ··· 1564 1568 } 1565 1569 1566 1570 static const struct i2c_device_id si5351_i2c_ids[] = { 1567 - { "si5351a", 0 }, 1568 - { "si5351a-msop", 0 }, 1569 - { "si5351b", 0 }, 1570 - { "si5351c", 0 }, 1571 + { "si5351a", SI5351_VARIANT_A }, 1572 + { "si5351a-msop", SI5351_VARIANT_A3 }, 1573 + { "si5351b", SI5351_VARIANT_B }, 1574 + { "si5351c", SI5351_VARIANT_C }, 1571 1575 { } 1572 1576 }; 1573 1577 MODULE_DEVICE_TABLE(i2c, si5351_i2c_ids);
+14
drivers/clk/clk-si5351.h
··· 153 153 #define SI5351_XTAL_ENABLE (1<<6) 154 154 #define SI5351_MULTISYNTH_ENABLE (1<<4) 155 155 156 + /** 157 + * enum si5351_variant - SiLabs Si5351 chip variant 158 + * @SI5351_VARIANT_A: Si5351A (8 output clocks, XTAL input) 159 + * @SI5351_VARIANT_A3: Si5351A MSOP10 (3 output clocks, XTAL input) 160 + * @SI5351_VARIANT_B: Si5351B (8 output clocks, XTAL/VXCO input) 161 + * @SI5351_VARIANT_C: Si5351C (8 output clocks, XTAL/CLKIN input) 162 + */ 163 + enum si5351_variant { 164 + SI5351_VARIANT_A = 1, 165 + SI5351_VARIANT_A3 = 2, 166 + SI5351_VARIANT_B = 3, 167 + SI5351_VARIANT_C = 4, 168 + }; 169 + 156 170 #endif
-16
include/linux/platform_data/si5351.h
··· 8 8 struct clk; 9 9 10 10 /** 11 - * enum si5351_variant - SiLabs Si5351 chip variant 12 - * @SI5351_VARIANT_A: Si5351A (8 output clocks, XTAL input) 13 - * @SI5351_VARIANT_A3: Si5351A MSOP10 (3 output clocks, XTAL input) 14 - * @SI5351_VARIANT_B: Si5351B (8 output clocks, XTAL/VXCO input) 15 - * @SI5351_VARIANT_C: Si5351C (8 output clocks, XTAL/CLKIN input) 16 - */ 17 - enum si5351_variant { 18 - SI5351_VARIANT_A = 1, 19 - SI5351_VARIANT_A3 = 2, 20 - SI5351_VARIANT_B = 3, 21 - SI5351_VARIANT_C = 4, 22 - }; 23 - 24 - /** 25 11 * enum si5351_pll_src - Si5351 pll clock source 26 12 * @SI5351_PLL_SRC_DEFAULT: default, do not change eeprom config 27 13 * @SI5351_PLL_SRC_XTAL: pll source clock is XTAL input ··· 101 115 102 116 /** 103 117 * struct si5351_platform_data - Platform data for the Si5351 clock driver 104 - * @variant: Si5351 chip variant 105 118 * @clk_xtal: xtal input clock 106 119 * @clk_clkin: clkin input clock 107 120 * @pll_src: array of pll source clock setting 108 121 * @clkout: array of clkout configuration 109 122 */ 110 123 struct si5351_platform_data { 111 - enum si5351_variant variant; 112 124 struct clk *clk_xtal; 113 125 struct clk *clk_clkin; 114 126 enum si5351_pll_src pll_src[2];