[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFXsbZrNgqqOCke=iZrX_fD8N2H6YecA-8JbJkxVh-KJLjENcw@mail.gmail.com>
Date: Mon, 6 Jul 2020 16:03:05 -0700
From: Chris Healy <cphealy@...il.com>
To: Andrew Lunn <andrew@...n.ch>
Cc: Russell King - ARM Linux <linux@...linux.org.uk>,
Florian Fainelli <f.fainelli@...il.com>,
Heiner Kallweit <hkallweit1@...il.com>,
"David S. Miller" <davem@...emloft.net>, kuba@...nel.org,
netdev <netdev@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] net: sfp: Unique GPIO interrupt names
On Mon, Jul 6, 2020 at 1:07 PM Andrew Lunn <andrew@...n.ch> wrote:
>
> On Mon, Jul 06, 2020 at 12:38:37PM -0700, Chris Healy wrote:
> > Dynamically generate a unique GPIO interrupt name, based on the
> > device name and the GPIO name. For example:
> >
> > 103: 0 sx1503q 12 Edge sff2-los
> > 104: 0 sx1503q 13 Edge sff3-los
> >
> > The sffX indicates the SFP the loss of signal GPIO is associated with.
>
> Hi Chris
>
> For netdev, please put inside the [PATCH] part of the subject, which
> tree this is for, i.e. net-next.
Will do.
>
> > Signed-off-by: Chris Healy <cphealy@...il.com>
> > ---
> > drivers/net/phy/sfp.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> > index 73c2969f11a4..9b03c7229320 100644
> > --- a/drivers/net/phy/sfp.c
> > +++ b/drivers/net/phy/sfp.c
> > @@ -220,6 +220,7 @@ struct sfp {
> > struct phy_device *mod_phy;
> > const struct sff_data *type;
> > u32 max_power_mW;
> > + char sfp_irq_name[32];
> >
> > unsigned int (*get_state)(struct sfp *);
> > void (*set_state)(struct sfp *, unsigned int);
> > @@ -2349,12 +2350,15 @@ static int sfp_probe(struct platform_device *pdev)
> > continue;
> > }
> >
> > + snprintf(sfp->sfp_irq_name, sizeof(sfp->sfp_irq_name),
> > + "%s-%s", dev_name(sfp->dev), gpio_of_names[i]);
> > +
>
> This is perfectly O.K, but you could consider using
> devm_kasprintf(). That will allocate as much memory as needed for the
> string, and hence avoid truncation issues, which we have seen before
> with other interrupt names.
I'll give this a try for the next version of this patch.
>
> Andrew
Powered by blists - more mailing lists