Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: rcar-csi2: Allow writing any code and data value to PHTW

The helper to write an array of code and data values to the PHY Test
Interface Write Register (PHTW) register uses the case where both code
and data are zero as an exit condition. This prevents writing data = 0
and code = 0 to the register.

Up until now this has been OK as no such combination where needed, and
it was a convenient exit condition. In future writing data = 0 and code
= 0 to the PHTW register will be needed.

Avoid using an exit condition when writing an array of PHTW values and
instead pass the length of the array to the helper. This allows any
combination of code and data to be written.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Niklas Söderlund and committed by
Mauro Carvalho Chehab
b230ddd8 ba7eb745

+11 -18
+11 -18
drivers/media/platform/renesas/rcar-csi2.c
··· 1473 1473 } 1474 1474 1475 1475 static int rcsi2_phtw_write_array(struct rcar_csi2 *priv, 1476 - const struct phtw_value *values) 1476 + const struct phtw_value *values, 1477 + unsigned int size) 1477 1478 { 1478 - const struct phtw_value *value; 1479 1479 int ret; 1480 1480 1481 - for (value = values; value->data || value->code; value++) { 1482 - ret = rcsi2_phtw_write(priv, value->data, value->code); 1481 + for (unsigned int i = 0; i < size; i++) { 1482 + ret = rcsi2_phtw_write(priv, values[i].data, values[i].code); 1483 1483 if (ret) 1484 1484 return ret; 1485 1485 } ··· 1520 1520 { .data = 0x11, .code = 0xe4 }, 1521 1521 { .data = 0x01, .code = 0xe5 }, 1522 1522 { .data = 0x10, .code = 0x04 }, 1523 - { /* sentinel */ }, 1524 1523 }; 1525 1524 1526 1525 static const struct phtw_value step2[] = { ··· 1528 1529 { .data = 0x4b, .code = 0xac }, 1529 1530 { .data = 0x03, .code = 0x00 }, 1530 1531 { .data = 0x80, .code = 0x07 }, 1531 - { /* sentinel */ }, 1532 1532 }; 1533 1533 1534 1534 int ret; 1535 1535 1536 - ret = rcsi2_phtw_write_array(priv, step1); 1536 + ret = rcsi2_phtw_write_array(priv, step1, ARRAY_SIZE(step1)); 1537 1537 if (ret) 1538 1538 return ret; 1539 1539 ··· 1547 1549 return ret; 1548 1550 } 1549 1551 1550 - return rcsi2_phtw_write_array(priv, step2); 1552 + return rcsi2_phtw_write_array(priv, step2, ARRAY_SIZE(step2)); 1551 1553 } 1552 1554 1553 1555 static int rcsi2_init_phtw_h3_v3h_m3n(struct rcar_csi2 *priv, unsigned int mbps) ··· 1573 1575 { .data = 0xee, .code = 0x54 }, 1574 1576 { .data = 0xee, .code = 0x84 }, 1575 1577 { .data = 0xee, .code = 0x94 }, 1576 - { /* sentinel */ }, 1577 1578 }; 1578 1579 1579 - return rcsi2_phtw_write_array(priv, step1); 1580 + return rcsi2_phtw_write_array(priv, step1, ARRAY_SIZE(step1)); 1580 1581 } 1581 1582 1582 1583 static int rcsi2_init_phtw_v3u(struct rcar_csi2 *priv, ··· 1584 1587 /* In case of 1500Mbps or less */ 1585 1588 static const struct phtw_value step1[] = { 1586 1589 { .data = 0xcc, .code = 0xe2 }, 1587 - { /* sentinel */ }, 1588 1590 }; 1589 1591 1590 1592 static const struct phtw_value step2[] = { 1591 1593 { .data = 0x01, .code = 0xe3 }, 1592 1594 { .data = 0x11, .code = 0xe4 }, 1593 1595 { .data = 0x01, .code = 0xe5 }, 1594 - { /* sentinel */ }, 1595 1596 }; 1596 1597 1597 1598 /* In case of 1500Mbps or less */ 1598 1599 static const struct phtw_value step3[] = { 1599 1600 { .data = 0x38, .code = 0x08 }, 1600 - { /* sentinel */ }, 1601 1601 }; 1602 1602 1603 1603 static const struct phtw_value step4[] = { ··· 1602 1608 { .data = 0x4b, .code = 0xac }, 1603 1609 { .data = 0x03, .code = 0x00 }, 1604 1610 { .data = 0x80, .code = 0x07 }, 1605 - { /* sentinel */ }, 1606 1611 }; 1607 1612 1608 1613 int ret; 1609 1614 1610 1615 if (mbps != 0 && mbps <= 1500) 1611 - ret = rcsi2_phtw_write_array(priv, step1); 1616 + ret = rcsi2_phtw_write_array(priv, step1, ARRAY_SIZE(step1)); 1612 1617 else 1613 1618 ret = rcsi2_phtw_write_mbps(priv, mbps, phtw_mbps_v3u, 0xe2); 1614 1619 if (ret) 1615 1620 return ret; 1616 1621 1617 - ret = rcsi2_phtw_write_array(priv, step2); 1622 + ret = rcsi2_phtw_write_array(priv, step2, ARRAY_SIZE(step2)); 1618 1623 if (ret) 1619 1624 return ret; 1620 1625 1621 1626 if (mbps != 0 && mbps <= 1500) { 1622 - ret = rcsi2_phtw_write_array(priv, step3); 1627 + ret = rcsi2_phtw_write_array(priv, step3, ARRAY_SIZE(step3)); 1623 1628 if (ret) 1624 1629 return ret; 1625 1630 } 1626 1631 1627 - ret = rcsi2_phtw_write_array(priv, step4); 1632 + ret = rcsi2_phtw_write_array(priv, step4, ARRAY_SIZE(step4)); 1628 1633 if (ret) 1629 1634 return ret; 1630 1635