Skip to content

Commit b26d1ad

Browse files
diandersgregkh
authored andcommitted
serial: qcom-geni: introduce qcom_geni_serial_poll_bitfield()
With a small modification the qcom_geni_serial_poll_bit() function could be used to poll more than just a single bit. Let's generalize it. We'll make the qcom_geni_serial_poll_bit() into just a wrapper of the general function. Signed-off-by: Douglas Anderson <[email protected]> Reviewed-by: Konrad Dybcio <[email protected]> Link: https://lore.kernel.org/r/20240610152420.v4.5.Ic6411eab8d9d37acc451705f583fb535cd6dadb2@changeid Tested-by: Nícolas F. R. A. Prado <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c2eaf5e commit b26d1ad

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/tty/serial/qcom_geni_serial.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ static bool qcom_geni_serial_secondary_active(struct uart_port *uport)
265265
return readl(uport->membase + SE_GENI_STATUS) & S_GENI_CMD_ACTIVE;
266266
}
267267

268-
static bool qcom_geni_serial_poll_bit(struct uart_port *uport,
269-
unsigned int offset, u32 field, bool set)
268+
static bool qcom_geni_serial_poll_bitfield(struct uart_port *uport,
269+
unsigned int offset, u32 field, u32 val)
270270
{
271271
u32 reg;
272272
struct qcom_geni_serial_port *port;
@@ -286,14 +286,20 @@ static bool qcom_geni_serial_poll_bit(struct uart_port *uport,
286286
timeout_us = DIV_ROUND_UP(timeout_us, 10) * 10;
287287
while (timeout_us) {
288288
reg = readl(uport->membase + offset);
289-
if ((bool)(reg & field) == set)
289+
if ((reg & field) == val)
290290
return true;
291291
udelay(10);
292292
timeout_us -= 10;
293293
}
294294
return false;
295295
}
296296

297+
static bool qcom_geni_serial_poll_bit(struct uart_port *uport,
298+
unsigned int offset, u32 field, bool set)
299+
{
300+
return qcom_geni_serial_poll_bitfield(uport, offset, field, set ? field : 0);
301+
}
302+
297303
static void qcom_geni_serial_setup_tx(struct uart_port *uport, u32 xmit_size)
298304
{
299305
u32 m_cmd;

0 commit comments

Comments
 (0)