Commit 76457783 authored by Alessandro Rubini's avatar Alessandro Rubini

kernel modules: added an ioctl to read EP registers

parent 61494330
......@@ -221,6 +221,7 @@ static int wrn_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
struct wrn_ep *ep = netdev_priv(dev);
int res;
u32 reg;
switch (cmd) {
case SIOCSHWTSTAMP:
......@@ -229,6 +230,16 @@ static int wrn_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
return wrn_calib_ioctl(dev, rq, cmd);
case PRIV_IOCGGETPHASE:
return wrn_phase_ioctl(dev, rq, cmd);
case PRIV_IOCREADREG:
if (get_user(reg, (u32 *)rq->ifr_data) < 0)
return -EFAULT;
if (reg > sizeof(struct EP_WB) || reg & 3)
return -EINVAL;
reg = readl((void *)ep->ep_regs + reg);
if (put_user(reg, (u32 *)rq->ifr_data) < 0)
return -EFAULT;
return 0;
default:
spin_lock_irq(&ep->lock);
res = generic_mii_ioctl(&ep->mii, if_mii(rq), cmd, NULL);
......
......@@ -158,9 +158,10 @@ enum wrn_resnames {
#define wrn_ep_read(ep, reg) __raw_readl(&(ep)->ep_regs->reg)
#define wrn_ep_write(ep, reg, val) __raw_writel((val), &(ep)->ep_regs->reg)
/* Private ioctls, like in wr_minic.c */
#define PRIV_IOCGCALIBRATE (SIOCDEVPRIVATE+1)
#define PRIV_IOCGGETPHASE (SIOCDEVPRIVATE+2)
/* Private ioctls, (the first 2 are the same as they were in wr_minic.c */
#define PRIV_IOCGCALIBRATE (SIOCDEVPRIVATE + 1)
#define PRIV_IOCGGETPHASE (SIOCDEVPRIVATE + 2)
#define PRIV_IOCREADREG (SIOCDEVPRIVATE + 3)
/* Structures straight from wr_minic.c -- should user-space include this? */
struct wrn_calibration_req {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment