hc
2024-09-20 a36159eec6ca17402b0e146b86efaf76568dc353
kernel/drivers/net/ethernet/ti/davinci_mdio.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0+
12 /*
23 * DaVinci MDIO Module driver
34 *
....@@ -7,22 +8,6 @@
78 *
89 * Copyright (C) 2009 Texas Instruments.
910 *
10
- * ---------------------------------------------------------------------------
11
- *
12
- * This program is free software; you can redistribute it and/or modify
13
- * it under the terms of the GNU General Public License as published by
14
- * the Free Software Foundation; either version 2 of the License, or
15
- * (at your option) any later version.
16
- *
17
- * This program is distributed in the hope that it will be useful,
18
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- * GNU General Public License for more details.
21
- *
22
- * You should have received a copy of the GNU General Public License
23
- * along with this program; if not, write to the Free Software
24
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
- * ---------------------------------------------------------------------------
2611 */
2712 #include <linux/module.h>
2813 #include <linux/kernel.h>
....@@ -140,7 +125,7 @@
140125 static void davinci_mdio_enable(struct davinci_mdio_data *data)
141126 {
142127 /* set enable and clock divider */
143
- __raw_writel(data->clk_div | CONTROL_ENABLE, &data->regs->control);
128
+ writel(data->clk_div | CONTROL_ENABLE, &data->regs->control);
144129 }
145130
146131 static int davinci_mdio_reset(struct mii_bus *bus)
....@@ -159,7 +144,7 @@
159144 msleep(PHY_MAX_ADDR * data->access_time);
160145
161146 /* dump hardware version info */
162
- ver = __raw_readl(&data->regs->version);
147
+ ver = readl(&data->regs->version);
163148 dev_info(data->dev,
164149 "davinci mdio revision %d.%d, bus freq %ld\n",
165150 (ver >> 8) & 0xff, ver & 0xff,
....@@ -169,7 +154,7 @@
169154 goto done;
170155
171156 /* get phy mask from the alive register */
172
- phy_mask = __raw_readl(&data->regs->alive);
157
+ phy_mask = readl(&data->regs->alive);
173158 if (phy_mask) {
174159 /* restrict mdio bus to live phys only */
175160 dev_info(data->dev, "detected phy mask %x\n", ~phy_mask);
....@@ -196,11 +181,11 @@
196181 u32 reg;
197182
198183 while (time_after(timeout, jiffies)) {
199
- reg = __raw_readl(&regs->user[0].access);
184
+ reg = readl(&regs->user[0].access);
200185 if ((reg & USERACCESS_GO) == 0)
201186 return 0;
202187
203
- reg = __raw_readl(&regs->control);
188
+ reg = readl(&regs->control);
204189 if ((reg & CONTROL_IDLE) == 0) {
205190 usleep_range(100, 200);
206191 continue;
....@@ -216,7 +201,7 @@
216201 return -EAGAIN;
217202 }
218203
219
- reg = __raw_readl(&regs->user[0].access);
204
+ reg = readl(&regs->user[0].access);
220205 if ((reg & USERACCESS_GO) == 0)
221206 return 0;
222207
....@@ -263,7 +248,7 @@
263248 if (ret < 0)
264249 break;
265250
266
- __raw_writel(reg, &data->regs->user[0].access);
251
+ writel(reg, &data->regs->user[0].access);
267252
268253 ret = wait_for_user_access(data);
269254 if (ret == -EAGAIN)
....@@ -271,7 +256,7 @@
271256 if (ret < 0)
272257 break;
273258
274
- reg = __raw_readl(&data->regs->user[0].access);
259
+ reg = readl(&data->regs->user[0].access);
275260 ret = (reg & USERACCESS_ACK) ? (reg & USERACCESS_DATA) : -EIO;
276261 break;
277262 }
....@@ -307,7 +292,7 @@
307292 if (ret < 0)
308293 break;
309294
310
- __raw_writel(reg, &data->regs->user[0].access);
295
+ writel(reg, &data->regs->user[0].access);
311296
312297 ret = wait_for_user_access(data);
313298 if (ret == -EAGAIN)
....@@ -412,9 +397,11 @@
412397 data->dev = dev;
413398
414399 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
415
- data->regs = devm_ioremap_resource(dev, res);
416
- if (IS_ERR(data->regs))
417
- return PTR_ERR(data->regs);
400
+ if (!res)
401
+ return -EINVAL;
402
+ data->regs = devm_ioremap(dev, res->start, resource_size(res));
403
+ if (!data->regs)
404
+ return -ENOMEM;
418405
419406 davinci_mdio_init_clk(data);
420407
....@@ -472,9 +459,9 @@
472459 u32 ctrl;
473460
474461 /* shutdown the scan state machine */
475
- ctrl = __raw_readl(&data->regs->control);
462
+ ctrl = readl(&data->regs->control);
476463 ctrl &= ~CONTROL_ENABLE;
477
- __raw_writel(ctrl, &data->regs->control);
464
+ writel(ctrl, &data->regs->control);
478465 wait_for_idle(data);
479466
480467 return 0;