mirror of
https://github.com/torvalds/linux.git
synced 2026-10-12 21:31:03 +02:00
net: phy: dp83640: embed pin configuration in clock
The DP83640 has a fixed number of PTP pins, and its pin configuration has the same lifetime as the per-bus clock. Allocating the configuration separately adds an allocation failure path and requires a separate free. Embed the pin configuration in struct dp83640_clock and point the PTP clock information at the embedded array. This changes only the storage; the pin functions remain configurable at runtime. It also allows all per-bus clock storage to be managed as one allocation. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn> Link: https://patch.msgid.link/20260811151345.73582-3-xuanqiang.luo@linux.dev Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
ebb16fca01
commit
20663d78f1
|
|
@ -146,6 +146,8 @@ struct dp83640_clock {
|
|||
struct list_head phylist;
|
||||
/* reference to our PTP hardware clock */
|
||||
struct ptp_clock *ptp_clock;
|
||||
/* protected by the PTP core pin configuration lock */
|
||||
struct ptp_pin_desc pin_config[DP83640_N_PINS];
|
||||
};
|
||||
|
||||
/* globals */
|
||||
|
|
@ -960,6 +962,7 @@ static void dp83640_clock_init(struct dp83640_clock *clock, struct mii_bus *bus)
|
|||
mutex_init(&clock->extreg_lock);
|
||||
mutex_init(&clock->clock_lock);
|
||||
INIT_LIST_HEAD(&clock->phylist);
|
||||
clock->caps.pin_config = clock->pin_config;
|
||||
clock->caps.owner = THIS_MODULE;
|
||||
sprintf(clock->caps.name, "dp83640 timer");
|
||||
clock->caps.max_adj = 1953124;
|
||||
|
|
@ -977,9 +980,7 @@ static void dp83640_clock_init(struct dp83640_clock *clock, struct mii_bus *bus)
|
|||
clock->caps.settime64 = ptp_dp83640_settime;
|
||||
clock->caps.enable = ptp_dp83640_enable;
|
||||
clock->caps.verify = ptp_dp83640_verify;
|
||||
/*
|
||||
* Convert the module param defaults into a dynamic pin configuration.
|
||||
*/
|
||||
/* Initialize the runtime pin configuration from gpio_tab. */
|
||||
dp83640_gpio_defaults(clock->caps.pin_config);
|
||||
/*
|
||||
* Get a reference to this bus instance.
|
||||
|
|
@ -1031,13 +1032,6 @@ static struct dp83640_clock *dp83640_clock_get_bus(struct mii_bus *bus)
|
|||
if (!clock)
|
||||
goto out;
|
||||
|
||||
clock->caps.pin_config = kzalloc_objs(struct ptp_pin_desc,
|
||||
DP83640_N_PINS);
|
||||
if (!clock->caps.pin_config) {
|
||||
kfree(clock);
|
||||
clock = NULL;
|
||||
goto out;
|
||||
}
|
||||
dp83640_clock_init(clock, bus);
|
||||
list_add_tail(&clock->list, &phyter_clocks);
|
||||
out:
|
||||
|
|
@ -1509,7 +1503,6 @@ static void dp83640_remove(struct phy_device *phydev)
|
|||
mutex_destroy(&clock->extreg_lock);
|
||||
mutex_destroy(&clock->clock_lock);
|
||||
put_device(&clock->bus->dev);
|
||||
kfree(clock->caps.pin_config);
|
||||
kfree(clock);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user