hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/clk/socfpga/clk-gate.c
....@@ -174,21 +174,24 @@
174174 u32 div_reg[3];
175175 u32 clk_phase[2];
176176 u32 fixed_div;
177
- struct clk *clk;
177
+ struct clk_hw *hw_clk;
178178 struct socfpga_gate_clk *socfpga_clk;
179179 const char *clk_name = node->name;
180180 const char *parent_name[SOCFPGA_MAX_PARENTS];
181181 struct clk_init_data init;
182182 struct clk_ops *ops;
183183 int rc;
184
+ int err;
184185
185186 socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL);
186187 if (WARN_ON(!socfpga_clk))
187188 return;
188189
189190 ops = kmemdup(&gateclk_ops, sizeof(gateclk_ops), GFP_KERNEL);
190
- if (WARN_ON(!ops))
191
+ if (WARN_ON(!ops)) {
192
+ kfree(socfpga_clk);
191193 return;
194
+ }
192195
193196 rc = of_property_read_u32_array(node, "clk-gate", clk_gate, 2);
194197 if (rc)
....@@ -238,12 +241,15 @@
238241 init.parent_names = parent_name;
239242 socfpga_clk->hw.hw.init = &init;
240243
241
- clk = clk_register(NULL, &socfpga_clk->hw.hw);
242
- if (WARN_ON(IS_ERR(clk))) {
244
+ hw_clk = &socfpga_clk->hw.hw;
245
+
246
+ err = clk_hw_register(NULL, hw_clk);
247
+ if (err) {
248
+ kfree(ops);
243249 kfree(socfpga_clk);
244250 return;
245251 }
246
- rc = of_clk_add_provider(node, of_clk_src_simple_get, clk);
252
+ rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk);
247253 if (WARN_ON(rc))
248254 return;
249255 }