Skip to content

Commit 0a6d7f8

Browse files
committed
Merge branch 'clk-cleanup' into clk-next
* clk-cleanup: clk: si521xx: Increase stack based print buffer size in probe clk: Use device_get_match_data() clk: cdce925: Extend match support for OF tables clk: si570: Simplify probe clk: si5351: Simplify probe clk: rs9: Use i2c_get_match_data() instead of device_get_match_data() clk: clk-si544: Simplify probe() and is_valid_frequency() clk: si521xx: Use i2c_get_match_data() instead of device_get_match_data() clk: npcm7xx: Fix incorrect kfree clk: at91: remove unnecessary conditions clk: ti: fix double free in of_ti_divider_clk_setup() clk: keystone: pll: fix a couple NULL vs IS_ERR() checks clk: ralink: mtmips: quiet unused variable warning clk: gate: fix comment typo and grammar clk: asm9620: Remove 'hw' local variable that isn't checked
2 parents 720e4a4 + 7e52b11 commit 0a6d7f8

26 files changed

+161
-237
lines changed

drivers/clk/at91/clk-utmi.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,11 @@ at91_clk_register_utmi_internal(struct regmap *regmap_pmc,
161161

162162
init.name = name;
163163
init.ops = ops;
164-
if (parent_hw) {
165-
init.parent_hws = parent_hw ? (const struct clk_hw **)&parent_hw : NULL;
166-
init.num_parents = parent_hw ? 1 : 0;
167-
} else {
168-
init.parent_names = parent_name ? &parent_name : NULL;
169-
init.num_parents = parent_name ? 1 : 0;
170-
}
164+
if (parent_hw)
165+
init.parent_hws = (const struct clk_hw **)&parent_hw;
166+
else
167+
init.parent_names = &parent_name;
168+
init.num_parents = 1;
171169
init.flags = flags;
172170

173171
utmi->hw.init = &init;

drivers/clk/clk-asm9260.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ static struct asm9260_mux_clock asm9260_mux_clks[] __initdata = {
255255

256256
static void __init asm9260_acc_init(struct device_node *np)
257257
{
258-
struct clk_hw *hw, *pll_hw;
258+
struct clk_hw *pll_hw;
259259
struct clk_hw **hws;
260260
const char *pll_clk = "pll";
261261
struct clk_parent_data pll_parent_data = { .index = 0 };
@@ -283,7 +283,7 @@ static void __init asm9260_acc_init(struct device_node *np)
283283
for (n = 0; n < ARRAY_SIZE(asm9260_mux_clks); n++) {
284284
const struct asm9260_mux_clock *mc = &asm9260_mux_clks[n];
285285

286-
hw = clk_hw_register_mux_table_parent_data(NULL, mc->name, mc->parent_data,
286+
clk_hw_register_mux_table_parent_data(NULL, mc->name, mc->parent_data,
287287
mc->num_parents, mc->flags, base + mc->offset,
288288
0, mc->mask, 0, mc->table, &asm9260_clk_lock);
289289
}
@@ -292,7 +292,7 @@ static void __init asm9260_acc_init(struct device_node *np)
292292
for (n = 0; n < ARRAY_SIZE(asm9260_mux_gates); n++) {
293293
const struct asm9260_gate_data *gd = &asm9260_mux_gates[n];
294294

295-
hw = clk_hw_register_gate(NULL, gd->name,
295+
clk_hw_register_gate(NULL, gd->name,
296296
gd->parent_name, gd->flags | CLK_SET_RATE_PARENT,
297297
base + gd->reg, gd->bit_idx, 0, &asm9260_clk_lock);
298298
}

drivers/clk/clk-cdce925.c

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,11 @@
2525
* Model this as 2 PLL clocks which are parents to the outputs.
2626
*/
2727

28-
enum {
29-
CDCE913,
30-
CDCE925,
31-
CDCE937,
32-
CDCE949,
33-
};
34-
3528
struct clk_cdce925_chip_info {
3629
int num_plls;
3730
int num_outputs;
3831
};
3932

40-
static const struct clk_cdce925_chip_info clk_cdce925_chip_info_tbl[] = {
41-
[CDCE913] = { .num_plls = 1, .num_outputs = 3 },
42-
[CDCE925] = { .num_plls = 2, .num_outputs = 5 },
43-
[CDCE937] = { .num_plls = 3, .num_outputs = 7 },
44-
[CDCE949] = { .num_plls = 4, .num_outputs = 9 },
45-
};
46-
4733
#define MAX_NUMBER_OF_PLLS 4
4834
#define MAX_NUMBER_OF_OUTPUTS 9
4935

@@ -621,20 +607,10 @@ static struct regmap_bus regmap_cdce925_bus = {
621607
.read = cdce925_regmap_i2c_read,
622608
};
623609

624-
static const struct i2c_device_id cdce925_id[] = {
625-
{ "cdce913", CDCE913 },
626-
{ "cdce925", CDCE925 },
627-
{ "cdce937", CDCE937 },
628-
{ "cdce949", CDCE949 },
629-
{ }
630-
};
631-
MODULE_DEVICE_TABLE(i2c, cdce925_id);
632-
633610
static int cdce925_probe(struct i2c_client *client)
634611
{
635612
struct clk_cdce925_chip *data;
636613
struct device_node *node = client->dev.of_node;
637-
const struct i2c_device_id *id = i2c_match_id(cdce925_id, client);
638614
const char *parent_name;
639615
const char *pll_clk_name[MAX_NUMBER_OF_PLLS] = {NULL,};
640616
struct clk_init_data init;
@@ -665,7 +641,7 @@ static int cdce925_probe(struct i2c_client *client)
665641
return -ENOMEM;
666642

667643
data->i2c_client = client;
668-
data->chip_info = &clk_cdce925_chip_info_tbl[id->driver_data];
644+
data->chip_info = i2c_get_match_data(client);
669645
config.max_register = CDCE925_OFFSET_PLL +
670646
data->chip_info->num_plls * 0x10 - 1;
671647
data->regmap = devm_regmap_init(&client->dev, &regmap_cdce925_bus,
@@ -822,12 +798,41 @@ static int cdce925_probe(struct i2c_client *client)
822798
return err;
823799
}
824800

801+
static const struct clk_cdce925_chip_info clk_cdce913_info = {
802+
.num_plls = 1,
803+
.num_outputs = 3,
804+
};
805+
806+
static const struct clk_cdce925_chip_info clk_cdce925_info = {
807+
.num_plls = 2,
808+
.num_outputs = 5,
809+
};
810+
811+
static const struct clk_cdce925_chip_info clk_cdce937_info = {
812+
.num_plls = 3,
813+
.num_outputs = 7,
814+
};
815+
816+
static const struct clk_cdce925_chip_info clk_cdce949_info = {
817+
.num_plls = 4,
818+
.num_outputs = 9,
819+
};
820+
821+
static const struct i2c_device_id cdce925_id[] = {
822+
{ "cdce913", (kernel_ulong_t)&clk_cdce913_info },
823+
{ "cdce925", (kernel_ulong_t)&clk_cdce925_info },
824+
{ "cdce937", (kernel_ulong_t)&clk_cdce937_info },
825+
{ "cdce949", (kernel_ulong_t)&clk_cdce949_info },
826+
{ }
827+
};
828+
MODULE_DEVICE_TABLE(i2c, cdce925_id);
829+
825830
static const struct of_device_id clk_cdce925_of_match[] = {
826-
{ .compatible = "ti,cdce913" },
827-
{ .compatible = "ti,cdce925" },
828-
{ .compatible = "ti,cdce937" },
829-
{ .compatible = "ti,cdce949" },
830-
{ },
831+
{ .compatible = "ti,cdce913", .data = &clk_cdce913_info },
832+
{ .compatible = "ti,cdce925", .data = &clk_cdce925_info },
833+
{ .compatible = "ti,cdce937", .data = &clk_cdce937_info },
834+
{ .compatible = "ti,cdce949", .data = &clk_cdce949_info },
835+
{ }
831836
};
832837
MODULE_DEVICE_TABLE(of, clk_cdce925_of_match);
833838

drivers/clk/clk-gate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <linux/string.h>
1616

1717
/**
18-
* DOC: basic gatable clock which can gate and ungate it's ouput
18+
* DOC: basic gatable clock which can gate and ungate its output
1919
*
2020
* Traits of this clock:
2121
* prepare - clk_(un)prepare only ensures parent is (un)prepared

drivers/clk/clk-lochnagar.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#include <linux/device.h>
1313
#include <linux/module.h>
1414
#include <linux/of.h>
15-
#include <linux/of_device.h>
1615
#include <linux/platform_device.h>
16+
#include <linux/property.h>
1717
#include <linux/regmap.h>
1818

1919
#include <linux/mfd/lochnagar1_regs.h>
@@ -242,22 +242,17 @@ static int lochnagar_clk_probe(struct platform_device *pdev)
242242
};
243243
struct device *dev = &pdev->dev;
244244
struct lochnagar_clk_priv *priv;
245-
const struct of_device_id *of_id;
246245
struct lochnagar_clk *lclk;
247246
struct lochnagar_config *conf;
248247
int ret, i;
249248

250-
of_id = of_match_device(lochnagar_of_match, dev);
251-
if (!of_id)
252-
return -EINVAL;
253-
254249
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
255250
if (!priv)
256251
return -ENOMEM;
257252

258253
priv->dev = dev;
259254
priv->regmap = dev_get_regmap(dev->parent, NULL);
260-
conf = (struct lochnagar_config *)of_id->data;
255+
conf = (struct lochnagar_config *)device_get_match_data(dev);
261256

262257
memcpy(priv->lclks, conf->clks, sizeof(priv->lclks));
263258

drivers/clk/clk-npcm7xx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ static void __init npcm7xx_clk_init(struct device_node *clk_np)
510510
return;
511511

512512
npcm7xx_init_fail:
513-
kfree(npcm7xx_clk_data->hws);
513+
kfree(npcm7xx_clk_data);
514514
npcm7xx_init_np_err:
515515
iounmap(clk_base);
516516
npcm7xx_init_error:

drivers/clk/clk-renesas-pcie.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static int rs9_probe(struct i2c_client *client)
298298

299299
i2c_set_clientdata(client, rs9);
300300
rs9->client = client;
301-
rs9->chip_info = device_get_match_data(&client->dev);
301+
rs9->chip_info = i2c_get_match_data(client);
302302
if (!rs9->chip_info)
303303
return -EINVAL;
304304

drivers/clk/clk-si521xx.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,10 @@ si521xx_of_clk_get(struct of_phandle_args *clkspec, void *data)
279279

280280
static int si521xx_probe(struct i2c_client *client)
281281
{
282-
const u16 chip_info = (u16)(uintptr_t)device_get_match_data(&client->dev);
282+
const u16 chip_info = (u16)(uintptr_t)i2c_get_match_data(client);
283283
const struct clk_parent_data clk_parent_data = { .index = 0 };
284284
const u8 data[3] = { SI521XX_REG_BC, 1, 1 };
285-
unsigned char name[6] = "DIFF0";
285+
unsigned char name[16] = "DIFF0";
286286
struct clk_init_data init = {};
287287
struct si521xx *si;
288288
int i, ret;
@@ -316,7 +316,7 @@ static int si521xx_probe(struct i2c_client *client)
316316
/* Register clock */
317317
for (i = 0; i < hweight16(chip_info); i++) {
318318
memset(&init, 0, sizeof(init));
319-
snprintf(name, 6, "DIFF%d", i);
319+
snprintf(name, sizeof(name), "DIFF%d", i);
320320
init.name = name;
321321
init.ops = &si521xx_diff_clk_ops;
322322
init.parent_data = &clk_parent_data;

drivers/clk/clk-si5351.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,15 +1385,15 @@ MODULE_DEVICE_TABLE(i2c, si5351_i2c_ids);
13851385

13861386
static int si5351_i2c_probe(struct i2c_client *client)
13871387
{
1388-
const struct i2c_device_id *id = i2c_match_id(si5351_i2c_ids, client);
1389-
enum si5351_variant variant = (enum si5351_variant)id->driver_data;
1388+
enum si5351_variant variant;
13901389
struct si5351_platform_data *pdata;
13911390
struct si5351_driver_data *drvdata;
13921391
struct clk_init_data init;
13931392
const char *parent_names[4];
13941393
u8 num_parents, num_clocks;
13951394
int ret, n;
13961395

1396+
variant = (enum si5351_variant)(uintptr_t)i2c_get_match_data(client);
13971397
ret = si5351_dt_parse(client, variant);
13981398
if (ret)
13991399
return ret;

drivers/clk/clk-si544.c

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,11 @@
5656
#define DELTA_M_FRAC_NUM 19
5757
#define DELTA_M_FRAC_DEN 20000
5858

59-
enum si544_speed_grade {
60-
si544a,
61-
si544b,
62-
si544c,
63-
};
64-
6559
struct clk_si544 {
6660
struct clk_hw hw;
6761
struct regmap *regmap;
6862
struct i2c_client *i2c_client;
69-
enum si544_speed_grade speed_grade;
63+
unsigned long max_freq;
7064
};
7165
#define to_clk_si544(_hw) container_of(_hw, struct clk_si544, hw)
7266

@@ -196,24 +190,10 @@ static int si544_set_muldiv(struct clk_si544 *data,
196190
static bool is_valid_frequency(const struct clk_si544 *data,
197191
unsigned long frequency)
198192
{
199-
unsigned long max_freq = 0;
200-
201193
if (frequency < SI544_MIN_FREQ)
202194
return false;
203195

204-
switch (data->speed_grade) {
205-
case si544a:
206-
max_freq = 1500000000;
207-
break;
208-
case si544b:
209-
max_freq = 800000000;
210-
break;
211-
case si544c:
212-
max_freq = 350000000;
213-
break;
214-
}
215-
216-
return frequency <= max_freq;
196+
return frequency <= data->max_freq;
217197
}
218198

219199
/* Calculate divider settings for a given frequency */
@@ -451,19 +431,10 @@ static const struct regmap_config si544_regmap_config = {
451431
.volatile_reg = si544_regmap_is_volatile,
452432
};
453433

454-
static const struct i2c_device_id si544_id[] = {
455-
{ "si544a", si544a },
456-
{ "si544b", si544b },
457-
{ "si544c", si544c },
458-
{ }
459-
};
460-
MODULE_DEVICE_TABLE(i2c, si544_id);
461-
462434
static int si544_probe(struct i2c_client *client)
463435
{
464436
struct clk_si544 *data;
465437
struct clk_init_data init;
466-
const struct i2c_device_id *id = i2c_match_id(si544_id, client);
467438
int err;
468439

469440
data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
@@ -475,7 +446,7 @@ static int si544_probe(struct i2c_client *client)
475446
init.num_parents = 0;
476447
data->hw.init = &init;
477448
data->i2c_client = client;
478-
data->speed_grade = id->driver_data;
449+
data->max_freq = (uintptr_t)i2c_get_match_data(client);
479450

480451
if (of_property_read_string(client->dev.of_node, "clock-output-names",
481452
&init.name))
@@ -507,11 +478,19 @@ static int si544_probe(struct i2c_client *client)
507478
return 0;
508479
}
509480

481+
static const struct i2c_device_id si544_id[] = {
482+
{ "si544a", 1500000000 },
483+
{ "si544b", 800000000 },
484+
{ "si544c", 350000000 },
485+
{ }
486+
};
487+
MODULE_DEVICE_TABLE(i2c, si544_id);
488+
510489
static const struct of_device_id clk_si544_of_match[] = {
511-
{ .compatible = "silabs,si544a" },
512-
{ .compatible = "silabs,si544b" },
513-
{ .compatible = "silabs,si544c" },
514-
{ },
490+
{ .compatible = "silabs,si544a", .data = (void *)1500000000 },
491+
{ .compatible = "silabs,si544b", .data = (void *)800000000 },
492+
{ .compatible = "silabs,si544c", .data = (void *)350000000 },
493+
{ }
515494
};
516495
MODULE_DEVICE_TABLE(of, clk_si544_of_match);
517496

0 commit comments

Comments
 (0)