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

platform/surface: aggregator: Rename top-level request functions to avoid ambiguities

We currently have a struct ssam_request_sync and a function
ssam_request_sync(). While this is valid C, there are some downsides to
it.

One of these is that current Sphinx versions (>= 3.0) cannot
disambiguate between the two (see disucssion and pull request linked
below). It instead emits a "WARNING: Duplicate C declaration" and links
for the struct and function in the resulting documentation link to the
same entry (i.e. both to either function or struct documentation)
instead of their respective own entries.

While we could just ignore that and wait for a fix, there's also a point
to be made that the current naming can be somewhat confusing when
searching (e.g. via grep) or trying to understand the levels of
abstraction at play:

We currently have struct ssam_request_sync and associated functions
ssam_request_sync_[alloc|free|init|wait|...]() operating on this struct.
However, function ssam_request_sync() is one abstraction level above
this. Similarly, ssam_request_sync_with_buffer() is not a function
operating on struct ssam_request_sync, but rather a sibling to
ssam_request_sync(), both using the struct under the hood.

Therefore, rename the top level request functions:

ssam_request_sync() -> ssam_request_do_sync()
ssam_request_sync_with_buffer() -> ssam_request_do_sync_with_buffer()
ssam_request_sync_onstack() -> ssam_request_do_sync_onstack()

Link: https://lore.kernel.org/all/085e0ada65c11da9303d07e70c510dc45f21315b.1656756450.git.mchehab@kernel.org/
Link: https://github.com/sphinx-doc/sphinx/pull/8313
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Link: https://lore.kernel.org/r/20221220175608.1436273-2-luzmaximilian@gmail.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

authored by

Maximilian Luz and committed by
Hans de Goede
b09ee1cd 13eca7d7

+66 -66
+4 -4
Documentation/driver-api/surface_aggregator/client.rst
··· 19 19 .. |ssam_notifier_unregister| replace:: :c:func:`ssam_notifier_unregister` 20 20 .. |ssam_device_notifier_register| replace:: :c:func:`ssam_device_notifier_register` 21 21 .. |ssam_device_notifier_unregister| replace:: :c:func:`ssam_device_notifier_unregister` 22 - .. |ssam_request_sync| replace:: :c:func:`ssam_request_sync` 22 + .. |ssam_request_do_sync| replace:: :c:func:`ssam_request_do_sync` 23 23 .. |ssam_event_mask| replace:: :c:type:`enum ssam_event_mask <ssam_event_mask>` 24 24 25 25 ··· 209 209 * with the SSAM_REQUEST_HAS_RESPONSE flag set in the specification 210 210 * above. 211 211 */ 212 - status = ssam_request_sync(ctrl, &rqst, &resp); 212 + status = ssam_request_do_sync(ctrl, &rqst, &resp); 213 213 214 214 /* 215 215 * Alternatively use 216 216 * 217 - * ssam_request_sync_onstack(ctrl, &rqst, &resp, sizeof(arg_le)); 217 + * ssam_request_do_sync_onstack(ctrl, &rqst, &resp, sizeof(arg_le)); 218 218 * 219 219 * to perform the request, allocating the message buffer directly 220 220 * on the stack as opposed to allocation via kzalloc(). ··· 230 230 return status; 231 231 } 232 232 233 - Note that |ssam_request_sync| in its essence is a wrapper over lower-level 233 + Note that |ssam_request_do_sync| in its essence is a wrapper over lower-level 234 234 request primitives, which may also be used to perform requests. Refer to its 235 235 implementation and documentation for more details. 236 236
+3 -3
drivers/hid/surface-hid/surface_hid.c
··· 80 80 81 81 rsp.length = 0; 82 82 83 - status = ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp, 83 + status = ssam_retry(ssam_request_do_sync_onstack, shid->ctrl, &rqst, &rsp, 84 84 sizeof(*slice)); 85 85 if (status) 86 86 return status; ··· 131 131 132 132 buf[0] = rprt_id; 133 133 134 - return ssam_retry(ssam_request_sync, shid->ctrl, &rqst, NULL); 134 + return ssam_retry(ssam_request_do_sync, shid->ctrl, &rqst, NULL); 135 135 } 136 136 137 137 static int ssam_hid_get_raw_report(struct surface_hid_device *shid, u8 rprt_id, u8 *buf, size_t len) ··· 151 151 rsp.length = 0; 152 152 rsp.pointer = buf; 153 153 154 - return ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(rprt_id)); 154 + return ssam_retry(ssam_request_do_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(rprt_id)); 155 155 } 156 156 157 157 static u32 ssam_hid_event_fn(struct ssam_event_notifier *nf, const struct ssam_event *event)
+3 -3
drivers/hid/surface-hid/surface_kbd.c
··· 49 49 rsp.length = 0; 50 50 rsp.pointer = buf; 51 51 52 - status = ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(entry)); 52 + status = ssam_retry(ssam_request_do_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(entry)); 53 53 if (status) 54 54 return status; 55 55 ··· 75 75 rqst.length = sizeof(value_u8); 76 76 rqst.payload = &value_u8; 77 77 78 - return ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, NULL, sizeof(value_u8)); 78 + return ssam_retry(ssam_request_do_sync_onstack, shid->ctrl, &rqst, NULL, sizeof(value_u8)); 79 79 } 80 80 81 81 static int ssam_kbd_get_feature_report(struct surface_hid_device *shid, u8 *buf, size_t len) ··· 97 97 rsp.length = 0; 98 98 rsp.pointer = buf; 99 99 100 - status = ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(payload)); 100 + status = ssam_retry(ssam_request_do_sync_onstack, shid->ctrl, &rqst, &rsp, sizeof(payload)); 101 101 if (status) 102 102 return status; 103 103
+3 -3
drivers/platform/surface/aggregator/bus.c
··· 136 136 * is always valid and can be used for requests as long as the client 137 137 * device we add here is registered as child under it. This essentially 138 138 * guarantees that the client driver can always expect the preconditions 139 - * for functions like ssam_request_sync (controller has to be started 140 - * and is not suspended) to hold and thus does not have to check for 141 - * them. 139 + * for functions like ssam_request_do_sync() (controller has to be 140 + * started and is not suspended) to hold and thus does not have to check 141 + * for them. 142 142 * 143 143 * Note that for this to work, the controller has to be a parent device. 144 144 * If it is not a direct parent, care has to be taken that the device is
+16 -16
drivers/platform/surface/aggregator/controller.c
··· 1674 1674 EXPORT_SYMBOL_GPL(ssam_request_sync_submit); 1675 1675 1676 1676 /** 1677 - * ssam_request_sync() - Execute a synchronous request. 1677 + * ssam_request_do_sync() - Execute a synchronous request. 1678 1678 * @ctrl: The controller via which the request will be submitted. 1679 1679 * @spec: The request specification and payload. 1680 1680 * @rsp: The response buffer. ··· 1686 1686 * 1687 1687 * Return: Returns the status of the request or any failure during setup. 1688 1688 */ 1689 - int ssam_request_sync(struct ssam_controller *ctrl, 1690 - const struct ssam_request *spec, 1691 - struct ssam_response *rsp) 1689 + int ssam_request_do_sync(struct ssam_controller *ctrl, 1690 + const struct ssam_request *spec, 1691 + struct ssam_response *rsp) 1692 1692 { 1693 1693 struct ssam_request_sync *rqst; 1694 1694 struct ssam_span buf; ··· 1722 1722 ssam_request_sync_free(rqst); 1723 1723 return status; 1724 1724 } 1725 - EXPORT_SYMBOL_GPL(ssam_request_sync); 1725 + EXPORT_SYMBOL_GPL(ssam_request_do_sync); 1726 1726 1727 1727 /** 1728 - * ssam_request_sync_with_buffer() - Execute a synchronous request with the 1728 + * ssam_request_do_sync_with_buffer() - Execute a synchronous request with the 1729 1729 * provided buffer as back-end for the message buffer. 1730 1730 * @ctrl: The controller via which the request will be submitted. 1731 1731 * @spec: The request specification and payload. ··· 1738 1738 * SSH_COMMAND_MESSAGE_LENGTH() macro can be used to compute the required 1739 1739 * message buffer size. 1740 1740 * 1741 - * This function does essentially the same as ssam_request_sync(), but instead 1742 - * of dynamically allocating the request and message data buffer, it uses the 1743 - * provided message data buffer and stores the (small) request struct on the 1744 - * heap. 1741 + * This function does essentially the same as ssam_request_do_sync(), but 1742 + * instead of dynamically allocating the request and message data buffer, it 1743 + * uses the provided message data buffer and stores the (small) request struct 1744 + * on the heap. 1745 1745 * 1746 1746 * Return: Returns the status of the request or any failure during setup. 1747 1747 */ 1748 - int ssam_request_sync_with_buffer(struct ssam_controller *ctrl, 1749 - const struct ssam_request *spec, 1750 - struct ssam_response *rsp, 1751 - struct ssam_span *buf) 1748 + int ssam_request_do_sync_with_buffer(struct ssam_controller *ctrl, 1749 + const struct ssam_request *spec, 1750 + struct ssam_response *rsp, 1751 + struct ssam_span *buf) 1752 1752 { 1753 1753 struct ssam_request_sync rqst; 1754 1754 ssize_t len; ··· 1772 1772 1773 1773 return status; 1774 1774 } 1775 - EXPORT_SYMBOL_GPL(ssam_request_sync_with_buffer); 1775 + EXPORT_SYMBOL_GPL(ssam_request_do_sync_with_buffer); 1776 1776 1777 1777 1778 1778 /* -- Internal SAM requests. ------------------------------------------------ */ ··· 1864 1864 result.length = 0; 1865 1865 result.pointer = &buf; 1866 1866 1867 - status = ssam_retry(ssam_request_sync_onstack, ctrl, &rqst, &result, 1867 + status = ssam_retry(ssam_request_do_sync_onstack, ctrl, &rqst, &result, 1868 1868 sizeof(params)); 1869 1869 1870 1870 return status < 0 ? status : buf;
+1 -1
drivers/platform/surface/surface_acpi_notify.c
··· 590 590 return san_rqst_fixup_suspended(d, &rqst, buffer); 591 591 } 592 592 593 - status = __ssam_retry(ssam_request_sync_onstack, SAN_REQUEST_NUM_TRIES, 593 + status = __ssam_retry(ssam_request_do_sync_onstack, SAN_REQUEST_NUM_TRIES, 594 594 d->ctrl, &rqst, &rsp, SAN_GSB_MAX_RQSX_PAYLOAD); 595 595 596 596 if (!status) {
+3 -3
drivers/platform/surface/surface_aggregator_cdev.c
··· 302 302 * theoretical maximum (SSH_COMMAND_MAX_PAYLOAD_SIZE) of the 303 303 * underlying protocol (note that nothing remotely this size 304 304 * should ever be allocated in any normal case). This size is 305 - * validated later in ssam_request_sync(), for allocation the 306 - * bound imposed by u16 should be enough. 305 + * validated later in ssam_request_do_sync(), for allocation 306 + * the bound imposed by u16 should be enough. 307 307 */ 308 308 spec.payload = kzalloc(spec.length, GFP_KERNEL); 309 309 if (!spec.payload) { ··· 342 342 } 343 343 344 344 /* Perform request. */ 345 - status = ssam_request_sync(client->cdev->ctrl, &spec, &rsp); 345 + status = ssam_request_do_sync(client->cdev->ctrl, &spec, &rsp); 346 346 if (status) 347 347 goto out; 348 348
+1 -1
drivers/platform/surface/surface_aggregator_tabletsw.c
··· 382 382 rsp.length = 0; 383 383 rsp.pointer = (u8 *)sources; 384 384 385 - status = ssam_retry(ssam_request_sync_onstack, sw->sdev->ctrl, &rqst, &rsp, 0); 385 + status = ssam_retry(ssam_request_do_sync_onstack, sw->sdev->ctrl, &rqst, &rsp, 0); 386 386 if (status) 387 387 return status; 388 388
+28 -28
include/linux/surface_aggregator/controller.h
··· 207 207 return rqst->status; 208 208 } 209 209 210 - int ssam_request_sync(struct ssam_controller *ctrl, 211 - const struct ssam_request *spec, 212 - struct ssam_response *rsp); 210 + int ssam_request_do_sync(struct ssam_controller *ctrl, 211 + const struct ssam_request *spec, 212 + struct ssam_response *rsp); 213 213 214 - int ssam_request_sync_with_buffer(struct ssam_controller *ctrl, 215 - const struct ssam_request *spec, 216 - struct ssam_response *rsp, 217 - struct ssam_span *buf); 214 + int ssam_request_do_sync_with_buffer(struct ssam_controller *ctrl, 215 + const struct ssam_request *spec, 216 + struct ssam_response *rsp, 217 + struct ssam_span *buf); 218 218 219 219 /** 220 - * ssam_request_sync_onstack - Execute a synchronous request on the stack. 220 + * ssam_request_do_sync_onstack - Execute a synchronous request on the stack. 221 221 * @ctrl: The controller via which the request is submitted. 222 222 * @rqst: The request specification. 223 223 * @rsp: The response buffer. ··· 227 227 * fully initializes it via the provided request specification, submits it, 228 228 * and finally waits for its completion before returning its status. This 229 229 * helper macro essentially allocates the request message buffer on the stack 230 - * and then calls ssam_request_sync_with_buffer(). 230 + * and then calls ssam_request_do_sync_with_buffer(). 231 231 * 232 232 * Note: The @payload_len parameter specifies the maximum payload length, used 233 233 * for buffer allocation. The actual payload length may be smaller. ··· 235 235 * Return: Returns the status of the request or any failure during setup, i.e. 236 236 * zero on success and a negative value on failure. 237 237 */ 238 - #define ssam_request_sync_onstack(ctrl, rqst, rsp, payload_len) \ 238 + #define ssam_request_do_sync_onstack(ctrl, rqst, rsp, payload_len) \ 239 239 ({ \ 240 240 u8 __data[SSH_COMMAND_MESSAGE_LENGTH(payload_len)]; \ 241 241 struct ssam_span __buf = { &__data[0], ARRAY_SIZE(__data) }; \ 242 242 \ 243 - ssam_request_sync_with_buffer(ctrl, rqst, rsp, &__buf); \ 243 + ssam_request_do_sync_with_buffer(ctrl, rqst, rsp, &__buf); \ 244 244 }) 245 245 246 246 /** ··· 349 349 * zero on success and negative on failure. The ``ctrl`` parameter is the 350 350 * controller via which the request is being sent. 351 351 * 352 - * Refer to ssam_request_sync_onstack() for more details on the behavior of 352 + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of 353 353 * the generated function. 354 354 */ 355 355 #define SSAM_DEFINE_SYNC_REQUEST_N(name, spec...) \ ··· 366 366 rqst.length = 0; \ 367 367 rqst.payload = NULL; \ 368 368 \ 369 - return ssam_request_sync_onstack(ctrl, &rqst, NULL, 0); \ 369 + return ssam_request_do_sync_onstack(ctrl, &rqst, NULL, 0); \ 370 370 } 371 371 372 372 /** ··· 389 389 * parameter is the controller via which the request is sent. The request 390 390 * argument is specified via the ``arg`` pointer. 391 391 * 392 - * Refer to ssam_request_sync_onstack() for more details on the behavior of 392 + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of 393 393 * the generated function. 394 394 */ 395 395 #define SSAM_DEFINE_SYNC_REQUEST_W(name, atype, spec...) \ ··· 406 406 rqst.length = sizeof(atype); \ 407 407 rqst.payload = (u8 *)arg; \ 408 408 \ 409 - return ssam_request_sync_onstack(ctrl, &rqst, NULL, \ 410 - sizeof(atype)); \ 409 + return ssam_request_do_sync_onstack(ctrl, &rqst, NULL, \ 410 + sizeof(atype)); \ 411 411 } 412 412 413 413 /** ··· 430 430 * the controller via which the request is sent. The request's return value is 431 431 * written to the memory pointed to by the ``ret`` parameter. 432 432 * 433 - * Refer to ssam_request_sync_onstack() for more details on the behavior of 433 + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of 434 434 * the generated function. 435 435 */ 436 436 #define SSAM_DEFINE_SYNC_REQUEST_R(name, rtype, spec...) \ ··· 453 453 rsp.length = 0; \ 454 454 rsp.pointer = (u8 *)ret; \ 455 455 \ 456 - status = ssam_request_sync_onstack(ctrl, &rqst, &rsp, 0); \ 456 + status = ssam_request_do_sync_onstack(ctrl, &rqst, &rsp, 0); \ 457 457 if (status) \ 458 458 return status; \ 459 459 \ ··· 491 491 * request argument is specified via the ``arg`` pointer. The request's return 492 492 * value is written to the memory pointed to by the ``ret`` parameter. 493 493 * 494 - * Refer to ssam_request_sync_onstack() for more details on the behavior of 494 + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of 495 495 * the generated function. 496 496 */ 497 497 #define SSAM_DEFINE_SYNC_REQUEST_WR(name, atype, rtype, spec...) \ ··· 514 514 rsp.length = 0; \ 515 515 rsp.pointer = (u8 *)ret; \ 516 516 \ 517 - status = ssam_request_sync_onstack(ctrl, &rqst, &rsp, sizeof(atype)); \ 517 + status = ssam_request_do_sync_onstack(ctrl, &rqst, &rsp, sizeof(atype)); \ 518 518 if (status) \ 519 519 return status; \ 520 520 \ ··· 550 550 * parameter is the controller via which the request is sent, ``tid`` the 551 551 * target ID for the request, and ``iid`` the instance ID. 552 552 * 553 - * Refer to ssam_request_sync_onstack() for more details on the behavior of 553 + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of 554 554 * the generated function. 555 555 */ 556 556 #define SSAM_DEFINE_SYNC_REQUEST_MD_N(name, spec...) \ ··· 567 567 rqst.length = 0; \ 568 568 rqst.payload = NULL; \ 569 569 \ 570 - return ssam_request_sync_onstack(ctrl, &rqst, NULL, 0); \ 570 + return ssam_request_do_sync_onstack(ctrl, &rqst, NULL, 0); \ 571 571 } 572 572 573 573 /** ··· 592 592 * ``tid`` the target ID for the request, and ``iid`` the instance ID. The 593 593 * request argument is specified via the ``arg`` pointer. 594 594 * 595 - * Refer to ssam_request_sync_onstack() for more details on the behavior of 595 + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of 596 596 * the generated function. 597 597 */ 598 598 #define SSAM_DEFINE_SYNC_REQUEST_MD_W(name, atype, spec...) \ ··· 609 609 rqst.length = sizeof(atype); \ 610 610 rqst.payload = (u8 *)arg; \ 611 611 \ 612 - return ssam_request_sync_onstack(ctrl, &rqst, NULL, \ 612 + return ssam_request_do_sync_onstack(ctrl, &rqst, NULL, \ 613 613 sizeof(atype)); \ 614 614 } 615 615 ··· 635 635 * the target ID for the request, and ``iid`` the instance ID. The request's 636 636 * return value is written to the memory pointed to by the ``ret`` parameter. 637 637 * 638 - * Refer to ssam_request_sync_onstack() for more details on the behavior of 638 + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of 639 639 * the generated function. 640 640 */ 641 641 #define SSAM_DEFINE_SYNC_REQUEST_MD_R(name, rtype, spec...) \ ··· 658 658 rsp.length = 0; \ 659 659 rsp.pointer = (u8 *)ret; \ 660 660 \ 661 - status = ssam_request_sync_onstack(ctrl, &rqst, &rsp, 0); \ 661 + status = ssam_request_do_sync_onstack(ctrl, &rqst, &rsp, 0); \ 662 662 if (status) \ 663 663 return status; \ 664 664 \ ··· 698 698 * The request argument is specified via the ``arg`` pointer. The request's 699 699 * return value is written to the memory pointed to by the ``ret`` parameter. 700 700 * 701 - * Refer to ssam_request_sync_onstack() for more details on the behavior of 701 + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of 702 702 * the generated function. 703 703 */ 704 704 #define SSAM_DEFINE_SYNC_REQUEST_MD_WR(name, atype, rtype, spec...) \ ··· 722 722 rsp.length = 0; \ 723 723 rsp.pointer = (u8 *)ret; \ 724 724 \ 725 - status = ssam_request_sync_onstack(ctrl, &rqst, &rsp, sizeof(atype)); \ 725 + status = ssam_request_do_sync_onstack(ctrl, &rqst, &rsp, sizeof(atype)); \ 726 726 if (status) \ 727 727 return status; \ 728 728 \
+4 -4
include/linux/surface_aggregator/device.h
··· 456 456 * device of the request and by association the controller via which the 457 457 * request is sent. 458 458 * 459 - * Refer to ssam_request_sync_onstack() for more details on the behavior of 459 + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of 460 460 * the generated function. 461 461 */ 462 462 #define SSAM_DEFINE_SYNC_REQUEST_CL_N(name, spec...) \ ··· 490 490 * which the request is sent. The request's argument is specified via the 491 491 * ``arg`` pointer. 492 492 * 493 - * Refer to ssam_request_sync_onstack() for more details on the behavior of 493 + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of 494 494 * the generated function. 495 495 */ 496 496 #define SSAM_DEFINE_SYNC_REQUEST_CL_W(name, atype, spec...) \ ··· 524 524 * the request is sent. The request's return value is written to the memory 525 525 * pointed to by the ``ret`` parameter. 526 526 * 527 - * Refer to ssam_request_sync_onstack() for more details on the behavior of 527 + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of 528 528 * the generated function. 529 529 */ 530 530 #define SSAM_DEFINE_SYNC_REQUEST_CL_R(name, rtype, spec...) \ ··· 560 560 * specified via the ``arg`` pointer. The request's return value is written to 561 561 * the memory pointed to by the ``ret`` parameter. 562 562 * 563 - * Refer to ssam_request_sync_onstack() for more details on the behavior of 563 + * Refer to ssam_request_do_sync_onstack() for more details on the behavior of 564 564 * the generated function. 565 565 */ 566 566 #define SSAM_DEFINE_SYNC_REQUEST_CL_WR(name, atype, rtype, spec...) \