提交 727b4ddb 编写于 作者: F Felipe Balbi 提交者: Greg Kroah-Hartman

usb: chipidea: don't redefine __ffs()

chipidea's ffs_nr() is pretty much what __ffs() does.

Use that one instead.
Signed-off-by: NFelipe Balbi <balbi@ti.com>
[rebased on top of debug infrastructure rework]
Signed-off-by: NAlexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 ba8618e0
...@@ -234,19 +234,6 @@ enum ci13xxx_regs { ...@@ -234,19 +234,6 @@ enum ci13xxx_regs {
OP_LAST = OP_ENDPTCTRL + ENDPT_MAX / 2, OP_LAST = OP_ENDPTCTRL + ENDPT_MAX / 2,
}; };
/**
* ffs_nr: find first (least significant) bit set
* @x: the word to search
*
* This function returns bit number (instead of position)
*/
static inline int ffs_nr(u32 x)
{
int n = ffs(x);
return n ? n-1 : 32;
}
/** /**
* hw_read: reads from a hw register * hw_read: reads from a hw register
* @reg: register index * @reg: register index
...@@ -305,7 +292,7 @@ static inline u32 hw_test_and_write(struct ci13xxx *ci, enum ci13xxx_regs reg, ...@@ -305,7 +292,7 @@ static inline u32 hw_test_and_write(struct ci13xxx *ci, enum ci13xxx_regs reg,
u32 val = hw_read(ci, reg, ~0); u32 val = hw_read(ci, reg, ~0);
hw_write(ci, reg, mask, data); hw_write(ci, reg, mask, data);
return (val & mask) >> ffs_nr(mask); return (val & mask) >> __ffs(mask);
} }
int hw_device_reset(struct ci13xxx *ci, u32 mode); int hw_device_reset(struct ci13xxx *ci, u32 mode);
......
...@@ -155,7 +155,7 @@ int hw_port_test_set(struct ci13xxx *ci, u8 mode) ...@@ -155,7 +155,7 @@ int hw_port_test_set(struct ci13xxx *ci, u8 mode)
if (mode > TEST_MODE_MAX) if (mode > TEST_MODE_MAX)
return -EINVAL; return -EINVAL;
hw_write(ci, OP_PORTSC, PORTSC_PTC, mode << ffs_nr(PORTSC_PTC)); hw_write(ci, OP_PORTSC, PORTSC_PTC, mode << __ffs(PORTSC_PTC));
return 0; return 0;
} }
...@@ -166,7 +166,7 @@ int hw_port_test_set(struct ci13xxx *ci, u8 mode) ...@@ -166,7 +166,7 @@ int hw_port_test_set(struct ci13xxx *ci, u8 mode)
*/ */
u8 hw_port_test_get(struct ci13xxx *ci) u8 hw_port_test_get(struct ci13xxx *ci)
{ {
return hw_read(ci, OP_PORTSC, PORTSC_PTC) >> ffs_nr(PORTSC_PTC); return hw_read(ci, OP_PORTSC, PORTSC_PTC) >> __ffs(PORTSC_PTC);
} }
static int hw_device_init(struct ci13xxx *ci, void __iomem *base) static int hw_device_init(struct ci13xxx *ci, void __iomem *base)
...@@ -182,7 +182,7 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem *base) ...@@ -182,7 +182,7 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem *base)
hw_alloc_regmap(ci, false); hw_alloc_regmap(ci, false);
reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) >> reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) >>
ffs_nr(HCCPARAMS_LEN); __ffs(HCCPARAMS_LEN);
ci->hw_bank.lpm = reg; ci->hw_bank.lpm = reg;
hw_alloc_regmap(ci, !!reg); hw_alloc_regmap(ci, !!reg);
ci->hw_bank.size = ci->hw_bank.op - ci->hw_bank.abs; ci->hw_bank.size = ci->hw_bank.op - ci->hw_bank.abs;
...@@ -190,7 +190,7 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem *base) ...@@ -190,7 +190,7 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem *base)
ci->hw_bank.size /= sizeof(u32); ci->hw_bank.size /= sizeof(u32);
reg = hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_DEN) >> reg = hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_DEN) >>
ffs_nr(DCCPARAMS_DEN); __ffs(DCCPARAMS_DEN);
ci->hw_ep_max = reg * 2; /* cache hw ENDPT_MAX */ ci->hw_ep_max = reg * 2; /* cache hw ENDPT_MAX */
if (ci->hw_ep_max > ENDPT_MAX) if (ci->hw_ep_max > ENDPT_MAX)
......
...@@ -140,7 +140,7 @@ static int hw_ep_enable(struct ci13xxx *ci, int num, int dir, int type) ...@@ -140,7 +140,7 @@ static int hw_ep_enable(struct ci13xxx *ci, int num, int dir, int type)
if (dir) { if (dir) {
mask = ENDPTCTRL_TXT; /* type */ mask = ENDPTCTRL_TXT; /* type */
data = type << ffs_nr(mask); data = type << __ffs(mask);
mask |= ENDPTCTRL_TXS; /* unstall */ mask |= ENDPTCTRL_TXS; /* unstall */
mask |= ENDPTCTRL_TXR; /* reset data toggle */ mask |= ENDPTCTRL_TXR; /* reset data toggle */
...@@ -149,7 +149,7 @@ static int hw_ep_enable(struct ci13xxx *ci, int num, int dir, int type) ...@@ -149,7 +149,7 @@ static int hw_ep_enable(struct ci13xxx *ci, int num, int dir, int type)
data |= ENDPTCTRL_TXE; data |= ENDPTCTRL_TXE;
} else { } else {
mask = ENDPTCTRL_RXT; /* type */ mask = ENDPTCTRL_RXT; /* type */
data = type << ffs_nr(mask); data = type << __ffs(mask);
mask |= ENDPTCTRL_RXS; /* unstall */ mask |= ENDPTCTRL_RXS; /* unstall */
mask |= ENDPTCTRL_RXR; /* reset data toggle */ mask |= ENDPTCTRL_RXR; /* reset data toggle */
...@@ -331,7 +331,7 @@ static int hw_test_and_set_setup_guard(struct ci13xxx *ci) ...@@ -331,7 +331,7 @@ static int hw_test_and_set_setup_guard(struct ci13xxx *ci)
static void hw_usb_set_address(struct ci13xxx *ci, u8 value) static void hw_usb_set_address(struct ci13xxx *ci, u8 value)
{ {
hw_write(ci, OP_DEVICEADDR, DEVICEADDR_USBADR, hw_write(ci, OP_DEVICEADDR, DEVICEADDR_USBADR,
value << ffs_nr(DEVICEADDR_USBADR)); value << __ffs(DEVICEADDR_USBADR));
} }
/** /**
...@@ -418,7 +418,7 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq) ...@@ -418,7 +418,7 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
* TODO - handle requests which spawns into several TDs * TODO - handle requests which spawns into several TDs
*/ */
memset(mReq->ptr, 0, sizeof(*mReq->ptr)); memset(mReq->ptr, 0, sizeof(*mReq->ptr));
mReq->ptr->token = length << ffs_nr(TD_TOTAL_BYTES); mReq->ptr->token = length << __ffs(TD_TOTAL_BYTES);
mReq->ptr->token &= TD_TOTAL_BYTES; mReq->ptr->token &= TD_TOTAL_BYTES;
mReq->ptr->token |= TD_STATUS_ACTIVE; mReq->ptr->token |= TD_STATUS_ACTIVE;
if (mReq->zptr) { if (mReq->zptr) {
...@@ -504,7 +504,7 @@ static int _hardware_dequeue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq) ...@@ -504,7 +504,7 @@ static int _hardware_dequeue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
mReq->req.status = -1; mReq->req.status = -1;
mReq->req.actual = mReq->ptr->token & TD_TOTAL_BYTES; mReq->req.actual = mReq->ptr->token & TD_TOTAL_BYTES;
mReq->req.actual >>= ffs_nr(TD_TOTAL_BYTES); mReq->req.actual >>= __ffs(TD_TOTAL_BYTES);
mReq->req.actual = mReq->req.length - mReq->req.actual; mReq->req.actual = mReq->req.length - mReq->req.actual;
mReq->req.actual = mReq->req.status ? 0 : mReq->req.actual; mReq->req.actual = mReq->req.status ? 0 : mReq->req.actual;
...@@ -1011,7 +1011,7 @@ static int ep_enable(struct usb_ep *ep, ...@@ -1011,7 +1011,7 @@ static int ep_enable(struct usb_ep *ep,
mEp->qh.ptr->cap &= ~QH_ZLT; mEp->qh.ptr->cap &= ~QH_ZLT;
mEp->qh.ptr->cap |= mEp->qh.ptr->cap |=
(mEp->ep.maxpacket << ffs_nr(QH_MAX_PKT)) & QH_MAX_PKT; (mEp->ep.maxpacket << __ffs(QH_MAX_PKT)) & QH_MAX_PKT;
mEp->qh.ptr->td.next |= TD_TERMINATE; /* needed? */ mEp->qh.ptr->td.next |= TD_TERMINATE; /* needed? */
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册