Skip to content

Commit 79e4461

Browse files
committed
soc: microchip: sam: optimize clock name for sama75 programmable clock
Change the location of the names for programable clocks from the stack to "static struct clk_programmable" array. Signed-off-by: Tony Han <tony.han@microchip.com>
1 parent 233871d commit 79e4461

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

soc/microchip/sam/common/clk-programmable.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct clk_programmable {
2525
uint8_t num_parents;
2626
uint8_t parent;
2727
const struct clk_programmable_layout *layout;
28+
char name[8];
2829
};
2930

3031
#define to_clk_programmable(ptr) CONTAINER_OF(ptr, struct clk_programmable, clk)
@@ -79,7 +80,7 @@ static DEVICE_API(clock_control, programmable_api) = {
7980
.get_rate = clk_programmable_get_rate,
8081
};
8182

82-
int clk_register_programmable(pmc_registers_t *const pmc, const char *name,
83+
int clk_register_programmable(pmc_registers_t *const pmc,
8384
const struct device **parents,
8485
uint8_t num_parents, uint8_t id,
8586
const struct clk_programmable_layout *layout,
@@ -102,9 +103,10 @@ int clk_register_programmable(pmc_registers_t *const pmc, const char *name,
102103
}
103104

104105
memcpy(prog->parents, parents, sizeof(struct device *) * num_parents);
106+
snprintf(prog->name, sizeof(prog->name), "prog%d", id);
105107

106108
*clk = &prog->clk;
107-
(*clk)->name = name;
109+
(*clk)->name = prog->name;
108110
(*clk)->api = &programmable_api;
109111
prog->num_parents = num_parents;
110112
prog->id = id;

soc/microchip/sam/common/pmc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ int sam9x60_clk_register_frac_pll(pmc_registers_t *const pmc, struct k_spinlock
168168
const struct clk_pll_characteristics *characteristics,
169169
const struct clk_pll_layout *layout, struct device **clk);
170170

171-
int clk_register_programmable(pmc_registers_t *const pmc, const char *name,
171+
int clk_register_programmable(pmc_registers_t *const pmc,
172172
const struct device **parents,
173173
uint8_t num_parents, uint8_t id,
174174
const struct clk_programmable_layout *layout,

soc/microchip/sam/common/sama7g5.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,11 +1154,7 @@ void sam_pmc_setup(const struct device *dev)
11541154
parents[7] = sama7g5_plls[PLL_ID_AUDIO][PLL_COMPID_DIV0].clk;
11551155
parents[8] = sama7g5_plls[PLL_ID_ETH][PLL_COMPID_DIV0].clk;
11561156
for (i = 0; i < 8; i++) {
1157-
char name[6];
1158-
1159-
snprintf(name, sizeof(name), "prog%d", i);
1160-
1161-
ret = clk_register_programmable(regmap, name, parents,
1157+
ret = clk_register_programmable(regmap, parents,
11621158
9, i,
11631159
&programmable_layout,
11641160
sama7g5_prog_mux_table, &clk);

0 commit comments

Comments
 (0)