Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1615020 > unrolled thread
| Started by | Corentin Labbe <clabbe.montjoie@gmail.com> |
|---|---|
| First post | 2017-04-03 11:30 +0200 |
| Last post | 2017-04-07 15:00 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v3 02/20] net: stmmac: add optional setup function Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-04-03 11:30 +0200
Re: [PATCH v3 02/20] net: stmmac: add optional setup function Giuseppe CAVALLARO <peppe.cavallaro@st.com> - 2017-04-03 14:40 +0200
Re: [PATCH v3 02/20] net: stmmac: add optional setup function Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-04-07 15:00 +0200
| From | Corentin Labbe <clabbe.montjoie@gmail.com> |
|---|---|
| Date | 2017-04-03 11:30 +0200 |
| Subject | [PATCH v3 02/20] net: stmmac: add optional setup function |
| Message-ID | <ts6tc-4ZD-27@gated-at.bofh.it> |
Instead of adding more ifthen logic for adding a new mac_device_info
setup function, it is easier to add a function pointer to the function
needed.
Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +++-
include/linux/stmmac.h | 3 +++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 43361f3..3beca41 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3508,7 +3508,9 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
struct mac_device_info *mac;
/* Identify the MAC HW device */
- if (priv->plat->has_gmac) {
+ if (priv->plat->setup) {
+ mac = priv->plat->setup(priv);
+ } else if (priv->plat->has_gmac) {
priv->dev->priv_flags |= IFF_UNICAST_FLT;
mac = dwmac1000_setup(priv->ioaddr,
priv->plat->multicast_filter_bins,
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 3921cb9..dadd74b 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -144,6 +144,8 @@ struct stmmac_txq_cfg {
u32 prio;
};
+struct stmmac_priv;
+
struct plat_stmmacenet_data {
int bus_id;
int phy_addr;
@@ -177,6 +179,7 @@ struct plat_stmmacenet_data {
void (*fix_mac_speed)(void *priv, unsigned int speed);
int (*init)(struct platform_device *pdev, void *priv);
void (*exit)(struct platform_device *pdev, void *priv);
+ struct mac_device_info *(*setup)(struct stmmac_priv *priv);
void *bsp_priv;
struct clk *stmmac_clk;
struct clk *pclk;
--
2.10.2
[toc] | [next] | [standalone]
| From | Giuseppe CAVALLARO <peppe.cavallaro@st.com> |
|---|---|
| Date | 2017-04-03 14:40 +0200 |
| Message-ID | <ts9r4-6Ro-15@gated-at.bofh.it> |
| In reply to | #1615020 |
Hello Corentin
On 4/3/2017 11:14 AM, Corentin Labbe wrote:
> Instead of adding more ifthen logic for adding a new mac_device_info
> setup function, it is easier to add a function pointer to the function
> needed.
>
> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +++-
> include/linux/stmmac.h | 3 +++
> 2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 43361f3..3beca41 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -3508,7 +3508,9 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
> struct mac_device_info *mac;
>
> /* Identify the MAC HW device */
> - if (priv->plat->has_gmac) {
> + if (priv->plat->setup) {
> + mac = priv->plat->setup(priv);
> + } else if (priv->plat->has_gmac) {
> priv->dev->priv_flags |= IFF_UNICAST_FLT;
> mac = dwmac1000_setup(priv->ioaddr,
> priv->plat->multicast_filter_bins,
> diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
> index 3921cb9..dadd74b 100644
> --- a/include/linux/stmmac.h
> +++ b/include/linux/stmmac.h
> @@ -144,6 +144,8 @@ struct stmmac_txq_cfg {
> u32 prio;
> };
>
> +struct stmmac_priv;
> +
> struct plat_stmmacenet_data {
> int bus_id;
> int phy_addr;
> @@ -177,6 +179,7 @@ struct plat_stmmacenet_data {
> void (*fix_mac_speed)(void *priv, unsigned int speed);
> int (*init)(struct platform_device *pdev, void *priv);
> void (*exit)(struct platform_device *pdev, void *priv);
> + struct mac_device_info *(*setup)(struct stmmac_priv *priv);
In that case I prefer to have void *priv as done for the other callbacks.
I mean, keep the priv struct inside the driver part.
peppe
> void *bsp_priv;
> struct clk *stmmac_clk;
> struct clk *pclk;
[toc] | [prev] | [next] | [standalone]
| From | Corentin Labbe <clabbe.montjoie@gmail.com> |
|---|---|
| Date | 2017-04-07 15:00 +0200 |
| Message-ID | <ttBEC-7cJ-23@gated-at.bofh.it> |
| In reply to | #1615170 |
On Mon, Apr 03, 2017 at 02:32:33PM +0200, Giuseppe CAVALLARO wrote:
> Hello Corentin
>
> On 4/3/2017 11:14 AM, Corentin Labbe wrote:
> > Instead of adding more ifthen logic for adding a new mac_device_info
> > setup function, it is easier to add a function pointer to the function
> > needed.
> >
> > Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
> > ---
> > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +++-
> > include/linux/stmmac.h | 3 +++
> > 2 files changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > index 43361f3..3beca41 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > @@ -3508,7 +3508,9 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
> > struct mac_device_info *mac;
> >
> > /* Identify the MAC HW device */
> > - if (priv->plat->has_gmac) {
> > + if (priv->plat->setup) {
> > + mac = priv->plat->setup(priv);
> > + } else if (priv->plat->has_gmac) {
> > priv->dev->priv_flags |= IFF_UNICAST_FLT;
> > mac = dwmac1000_setup(priv->ioaddr,
> > priv->plat->multicast_filter_bins,
> > diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
> > index 3921cb9..dadd74b 100644
> > --- a/include/linux/stmmac.h
> > +++ b/include/linux/stmmac.h
> > @@ -144,6 +144,8 @@ struct stmmac_txq_cfg {
> > u32 prio;
> > };
> >
> > +struct stmmac_priv;
> > +
> > struct plat_stmmacenet_data {
> > int bus_id;
> > int phy_addr;
> > @@ -177,6 +179,7 @@ struct plat_stmmacenet_data {
> > void (*fix_mac_speed)(void *priv, unsigned int speed);
> > int (*init)(struct platform_device *pdev, void *priv);
> > void (*exit)(struct platform_device *pdev, void *priv);
> > + struct mac_device_info *(*setup)(struct stmmac_priv *priv);
>
> In that case I prefer to have void *priv as done for the other callbacks.
> I mean, keep the priv struct inside the driver part.
>
Agree, I will change it
Thanks
Regards
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web