linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: roderick@gaikai.com
Cc: linux-input@vger.kernel.org
Subject: [bug report] HID: playstation: add DualShock4 accelerometer and gyroscope support.
Date: Tue, 15 Nov 2022 16:48:03 +0300	[thread overview]
Message-ID: <Y3OYkwNSevtPP2B2@kili> (raw)

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

                 reply	other threads:[~2022-11-15 13:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y3OYkwNSevtPP2B2@kili \
    --to=error27@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=roderick@gaikai.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).