From: "Jiawen Wu" <jiawenwu@trustnetic.com>
To: "'Simon Horman'" <simon.horman@corigine.com>
Cc: <netdev@vger.kernel.org>, <jarkko.nikula@linux.intel.com>,
<andriy.shevchenko@linux.intel.com>,
<mika.westerberg@linux.intel.com>, <jsd@semihalf.com>,
<Jose.Abreu@synopsys.com>, <andrew@lunn.ch>,
<hkallweit1@gmail.com>, <linux@armlinux.org.uk>,
<linux-i2c@vger.kernel.org>, <linux-gpio@vger.kernel.org>,
<mengyuanlou@net-swift.com>
Subject: RE: [PATCH net-next v7 3/9] net: txgbe: Register fixed rate clock
Date: Wed, 10 May 2023 14:47:50 +0800 [thread overview]
Message-ID: <009e01d9830b$56f1daf0$04d590d0$@trustnetic.com> (raw)
In-Reply-To: <ZFpnfNy2NSYNwUyI@corigine.com>
On Tuesday, May 9, 2023 11:32 PM, Simon Horman wrote:
> On Tue, May 09, 2023 at 10:27:28AM +0800, Jiawen Wu wrote:
> > In order for I2C to be able to work in standard mode, register a fixed
> > rate clock for each I2C device.
> >
> > Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
>
> ...
>
> > @@ -70,6 +72,32 @@ static int txgbe_swnodes_register(struct txgbe *txgbe)
> > return software_node_register_node_group(nodes->group);
> > }
> >
> > +static int txgbe_clock_register(struct txgbe *txgbe) {
> > + struct pci_dev *pdev = txgbe->wx->pdev;
> > + struct clk_lookup *clock;
> > + char clk_name[32];
> > + struct clk *clk;
> > +
> > + snprintf(clk_name, sizeof(clk_name), "i2c_designware.%d",
> > + (pdev->bus->number << 8) | pdev->devfn);
> > +
> > + clk = clk_register_fixed_rate(NULL, clk_name, NULL, 0, 156250000);
> > + if (IS_ERR(clk))
> > + return PTR_ERR(clk);
> > +
> > + clock = clkdev_create(clk, NULL, clk_name);
> > + if (!clock) {
> > + clk_unregister(clk);
> > + return PTR_ERR(clock);
>
> Hi Jiawen,
>
> Sorry for missing this earlier, but the above error handling doesn't seem right.
>
> * This error condition is met if clock == NULL
> * So the above is returning PTR_ERR(NULL), which is a yellow flag to me.
> In any case, PTR_ERR(NULL) => 0 is returned on error.
> * The caller treats a 0 return value as success.
>
> Perhaps this should be: return -ENOMEM?
No problem, I will fix it in patch v8.
>
> > + }
> > +
> > + txgbe->clk = clk;
> > + txgbe->clock = clock;
> > +
> > + return 0;
> > +}
> > +
> > int txgbe_init_phy(struct txgbe *txgbe) {
> > int ret;
> > @@ -80,10 +108,23 @@ int txgbe_init_phy(struct txgbe *txgbe)
> > return ret;
> > }
> >
> > + ret = txgbe_clock_register(txgbe);
> > + if (ret) {
> > + wx_err(txgbe->wx, "failed to register clock: %d\n", ret);
> > + goto err_unregister_swnode;
> > + }
> > +
> > return 0;
>
> ...
>
next prev parent reply other threads:[~2023-05-10 6:49 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-09 2:27 [PATCH net-next v7 0/9] TXGBE PHYLINK support Jiawen Wu
2023-05-09 2:27 ` [PATCH net-next v7 1/9] net: txgbe: Add software nodes to support phylink Jiawen Wu
2023-05-09 12:38 ` Piotr Raczynski
2023-05-09 2:27 ` [PATCH net-next v7 2/9] i2c: designware: Add driver support for Wangxun 10Gb NIC Jiawen Wu
2023-05-09 13:52 ` Piotr Raczynski
2023-05-10 6:43 ` Jiawen Wu
2023-05-10 7:47 ` andy.shevchenko
2023-05-10 8:00 ` Jiawen Wu
2023-05-09 2:27 ` [PATCH net-next v7 3/9] net: txgbe: Register fixed rate clock Jiawen Wu
2023-05-09 15:32 ` Simon Horman
2023-05-10 6:47 ` Jiawen Wu [this message]
2023-05-09 2:27 ` [PATCH net-next v7 4/9] net: txgbe: Register I2C platform device Jiawen Wu
2023-05-11 12:13 ` Andrew Lunn
2023-05-11 20:16 ` Piotr Raczynski
2023-05-09 2:27 ` [PATCH net-next v7 5/9] net: txgbe: Add SFP module identify Jiawen Wu
2023-05-11 12:13 ` Andrew Lunn
2023-05-11 20:18 ` Piotr Raczynski
2023-05-09 2:27 ` [PATCH net-next v7 6/9] net: txgbe: Support GPIO to SFP socket Jiawen Wu
2023-05-11 12:31 ` Andrew Lunn
2023-05-12 6:38 ` Jiawen Wu
2023-05-12 14:20 ` Andrew Lunn
2023-05-11 12:38 ` Andrew Lunn
2023-05-12 6:35 ` Jiawen Wu
2023-05-11 20:45 ` andy.shevchenko
2023-05-12 8:57 ` Jiawen Wu
2023-05-12 9:43 ` Andy Shevchenko
2023-05-12 9:32 ` Russell King (Oracle)
2023-05-12 10:46 ` Jiawen Wu
2023-05-09 2:27 ` [PATCH net-next v7 7/9] net: pcs: Add 10GBASE-R mode for Synopsys Designware XPCS Jiawen Wu
2023-05-11 12:40 ` Andrew Lunn
2023-05-09 2:27 ` [PATCH net-next v7 8/9] net: txgbe: Implement phylink pcs Jiawen Wu
2023-05-11 19:33 ` Andrew Lunn
2023-05-11 20:32 ` Piotr Raczynski
2023-05-12 9:22 ` Jiawen Wu
2023-05-09 2:27 ` [PATCH net-next v7 9/9] net: txgbe: Support phylink MAC layer Jiawen Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='009e01d9830b$56f1daf0$04d590d0$@trustnetic.com' \
--to=jiawenwu@trustnetic.com \
--cc=Jose.Abreu@synopsys.com \
--cc=andrew@lunn.ch \
--cc=andriy.shevchenko@linux.intel.com \
--cc=hkallweit1@gmail.com \
--cc=jarkko.nikula@linux.intel.com \
--cc=jsd@semihalf.com \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mengyuanlou@net-swift.com \
--cc=mika.westerberg@linux.intel.com \
--cc=netdev@vger.kernel.org \
--cc=simon.horman@corigine.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).