All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] HID: playstation: add DualShock4 accelerometer and gyroscope support.
@ 2022-11-15 13:48 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2022-11-15 13:48 UTC (permalink / raw)
  To: roderick; +Cc: linux-input

Hello Roderick Colenbrander,

The patch 12882ed83c58: "HID: playstation: add DualShock4
accelerometer and gyroscope support." from Oct 29, 2022, leads to the
following Smatch static checker warning:

	drivers/hid/hid-playstation.c:1766 dualshock4_get_calibration_data()
	warn: ignoring unreachable code.

drivers/hid/hid-playstation.c
    1727 static int dualshock4_get_calibration_data(struct dualshock4 *ds4)
    1728 {
    1729         struct hid_device *hdev = ds4->base.hdev;
    1730         short gyro_pitch_bias, gyro_pitch_plus, gyro_pitch_minus;
    1731         short gyro_yaw_bias, gyro_yaw_plus, gyro_yaw_minus;
    1732         short gyro_roll_bias, gyro_roll_plus, gyro_roll_minus;
    1733         short gyro_speed_plus, gyro_speed_minus;
    1734         short acc_x_plus, acc_x_minus;
    1735         short acc_y_plus, acc_y_minus;
    1736         short acc_z_plus, acc_z_minus;
    1737         int speed_2x;
    1738         int range_2g;
    1739         int ret = 0;
    1740         uint8_t *buf;
    1741 
    1742         if (ds4->base.hdev->bus == BUS_USB) {
    1743                 int retries;
    1744 
    1745                 buf = kzalloc(DS4_FEATURE_REPORT_CALIBRATION_SIZE, GFP_KERNEL);
    1746                 if (!buf)
    1747                         return -ENOMEM;
    1748 
    1749                 /* We should normally receive the feature report data we asked
    1750                  * for, but hidraw applications such as Steam can issue feature
    1751                  * reports as well. In particular for Dongle reconnects, Steam
    1752                  * and this function are competing resulting in often receiving
    1753                  * data for a different HID report, so retry a few times.
    1754                  */
    1755                 for (retries = 0; retries < 3; retries++) {
    1756                         ret = ps_get_report(hdev, DS4_FEATURE_REPORT_CALIBRATION, buf,
    1757                                         DS4_FEATURE_REPORT_CALIBRATION_SIZE, true);
    1758                         if (ret) {
    1759                                 if (retries < 2) {
    1760                                         hid_warn(hdev, "Retrying DualShock 4 get calibration report (0x02) request\n");
    1761                                         continue;
                                                 ^^^^^^^^^
    1762                                 } else {
    1763                                         ret = -EILSEQ;
    1764                                         goto err_free;
                                                 ^^^^^^^^^^^^^^
    1765                                 }
--> 1766                                 hid_err(hdev, "Failed to retrieve DualShock4 calibration info: %d\n", ret);
    1767                                 goto err_free;

Dead code.

    1768                         } else {
    1769                                 break;
    1770                         }
    1771                 }
    1772         } else { /* Bluetooth */
    1773                 buf = kzalloc(DS4_FEATURE_REPORT_CALIBRATION_BT_SIZE, GFP_KERNEL);
    1774                 if (!buf)
    1775                         return -ENOMEM;
    1776 

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-15 13:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-15 13:48 [bug report] HID: playstation: add DualShock4 accelerometer and gyroscope support Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.