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

NTB: Rename NTB messaging API methods

There is a common methods signature form used over all the NTB API
like functions naming scheme, arguments names and order, etc.
Recently added NTB messaging API IO callbacks were named a bit
different so should be renamed to be in compliance with the rest
of the API.

Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>

authored by

Serge Semin and committed by
Jon Mason
b87ab219 c6fad21a

+28 -33
+12 -15
drivers/ntb/hw/idt/ntb_hw_idt.c
··· 1744 1744 * idt_ntb_msg_read() - read message register with specified index 1745 1745 * (NTB API callback) 1746 1746 * @ntb: NTB device context. 1747 - * @midx: Message register index 1748 1747 * @pidx: OUT - Port index of peer device a message retrieved from 1749 - * @msg: OUT - Data 1748 + * @midx: Message register index 1750 1749 * 1751 1750 * Read data from the specified message register and source register. 1752 1751 * 1753 - * Return: zero on success, negative error if invalid argument passed. 1752 + * Return: inbound message register value. 1754 1753 */ 1755 - static int idt_ntb_msg_read(struct ntb_dev *ntb, int midx, int *pidx, u32 *msg) 1754 + static u32 idt_ntb_msg_read(struct ntb_dev *ntb, int *pidx, int midx) 1756 1755 { 1757 1756 struct idt_ntb_dev *ndev = to_ndev_ntb(ntb); 1758 1757 1759 1758 if (midx < 0 || IDT_MSG_CNT <= midx) 1760 - return -EINVAL; 1759 + return ~(u32)0; 1761 1760 1762 1761 /* Retrieve source port index of the message */ 1763 1762 if (pidx != NULL) { ··· 1771 1772 } 1772 1773 1773 1774 /* Retrieve data of the corresponding message register */ 1774 - if (msg != NULL) 1775 - *msg = idt_nt_read(ndev, ntdata_tbl.msgs[midx].in); 1776 - 1777 - return 0; 1775 + return idt_nt_read(ndev, ntdata_tbl.msgs[midx].in); 1778 1776 } 1779 1777 1780 1778 /* 1781 - * idt_ntb_msg_write() - write data to the specified message register 1782 - * (NTB API callback) 1779 + * idt_ntb_peer_msg_write() - write data to the specified message register 1780 + * (NTB API callback) 1783 1781 * @ntb: NTB device context. 1784 - * @midx: Message register index 1785 1782 * @pidx: Port index of peer device a message being sent to 1783 + * @midx: Message register index 1786 1784 * @msg: Data to send 1787 1785 * 1788 1786 * Just try to send data to a peer. Message status register should be ··· 1787 1791 * 1788 1792 * Return: zero on success, negative error if invalid argument passed. 1789 1793 */ 1790 - static int idt_ntb_msg_write(struct ntb_dev *ntb, int midx, int pidx, u32 msg) 1794 + static int idt_ntb_peer_msg_write(struct ntb_dev *ntb, int pidx, int midx, 1795 + u32 msg) 1791 1796 { 1792 1797 struct idt_ntb_dev *ndev = to_ndev_ntb(ntb); 1793 1798 unsigned long irqflags; ··· 2055 2058 .msg_set_mask = idt_ntb_msg_set_mask, 2056 2059 .msg_clear_mask = idt_ntb_msg_clear_mask, 2057 2060 .msg_read = idt_ntb_msg_read, 2058 - .msg_write = idt_ntb_msg_write 2061 + .peer_msg_write = idt_ntb_peer_msg_write 2059 2062 }; 2060 2063 2061 2064 /* ··· 2266 2269 "Message data:\n"); 2267 2270 for (idx = 0; idx < IDT_MSG_CNT; idx++) { 2268 2271 int src; 2269 - (void)idt_ntb_msg_read(&ndev->ntb, idx, &src, &data); 2272 + data = idt_ntb_msg_read(&ndev->ntb, &src, idx); 2270 2273 off += scnprintf(strbuf + off, size - off, 2271 2274 "\t%hhu. 0x%08x from peer %hhu (Port %hhu)\n", 2272 2275 idx, data, src, ndev->peers[src].port);
+16 -18
include/linux/ntb.h
··· 253 253 * @msg_set_mask: See ntb_msg_set_mask(). 254 254 * @msg_clear_mask: See ntb_msg_clear_mask(). 255 255 * @msg_read: See ntb_msg_read(). 256 - * @msg_write: See ntb_msg_write(). 256 + * @peer_msg_write: See ntb_peer_msg_write(). 257 257 */ 258 258 struct ntb_dev_ops { 259 259 int (*port_number)(struct ntb_dev *ntb); ··· 324 324 int (*msg_clear_sts)(struct ntb_dev *ntb, u64 sts_bits); 325 325 int (*msg_set_mask)(struct ntb_dev *ntb, u64 mask_bits); 326 326 int (*msg_clear_mask)(struct ntb_dev *ntb, u64 mask_bits); 327 - int (*msg_read)(struct ntb_dev *ntb, int midx, int *pidx, u32 *msg); 328 - int (*msg_write)(struct ntb_dev *ntb, int midx, int pidx, u32 msg); 327 + u32 (*msg_read)(struct ntb_dev *ntb, int *pidx, int midx); 328 + int (*peer_msg_write)(struct ntb_dev *ntb, int pidx, int midx, u32 msg); 329 329 }; 330 330 331 331 static inline int ntb_dev_ops_is_valid(const struct ntb_dev_ops *ops) ··· 387 387 /* !ops->msg_set_mask == !ops->msg_count && */ 388 388 /* !ops->msg_clear_mask == !ops->msg_count && */ 389 389 !ops->msg_read == !ops->msg_count && 390 - !ops->msg_write == !ops->msg_count && 390 + !ops->peer_msg_write == !ops->msg_count && 391 391 1; 392 392 } 393 393 ··· 1462 1462 } 1463 1463 1464 1464 /** 1465 - * ntb_msg_read() - read message register with specified index 1465 + * ntb_msg_read() - read inbound message register with specified index 1466 1466 * @ntb: NTB device context. 1467 - * @midx: Message register index 1468 1467 * @pidx: OUT - Port index of peer device a message retrieved from 1469 - * @msg: OUT - Data 1468 + * @midx: Message register index 1470 1469 * 1471 1470 * Read data from the specified message register. Source port index of a 1472 1471 * message is retrieved as well. 1473 1472 * 1474 - * Return: Zero on success, otherwise a negative error number. 1473 + * Return: The value of the inbound message register. 1475 1474 */ 1476 - static inline int ntb_msg_read(struct ntb_dev *ntb, int midx, int *pidx, 1477 - u32 *msg) 1475 + static inline u32 ntb_msg_read(struct ntb_dev *ntb, int *pidx, int midx) 1478 1476 { 1479 1477 if (!ntb->ops->msg_read) 1480 - return -EINVAL; 1478 + return ~(u32)0; 1481 1479 1482 - return ntb->ops->msg_read(ntb, midx, pidx, msg); 1480 + return ntb->ops->msg_read(ntb, pidx, midx); 1483 1481 } 1484 1482 1485 1483 /** 1486 - * ntb_msg_write() - write data to the specified message register 1484 + * ntb_peer_msg_write() - write data to the specified peer message register 1487 1485 * @ntb: NTB device context. 1488 - * @midx: Message register index 1489 1486 * @pidx: Port index of peer device a message being sent to 1487 + * @midx: Message register index 1490 1488 * @msg: Data to send 1491 1489 * 1492 1490 * Send data to a specified peer device using the defined message register. ··· 1493 1495 * 1494 1496 * Return: Zero on success, otherwise a negative error number. 1495 1497 */ 1496 - static inline int ntb_msg_write(struct ntb_dev *ntb, int midx, int pidx, 1497 - u32 msg) 1498 + static inline int ntb_peer_msg_write(struct ntb_dev *ntb, int pidx, int midx, 1499 + u32 msg) 1498 1500 { 1499 - if (!ntb->ops->msg_write) 1501 + if (!ntb->ops->peer_msg_write) 1500 1502 return -EINVAL; 1501 1503 1502 - return ntb->ops->msg_write(ntb, midx, pidx, msg); 1504 + return ntb->ops->peer_msg_write(ntb, pidx, midx, msg); 1503 1505 } 1504 1506 1505 1507 #endif