Commit Graph

6328 Commits

Author SHA1 Message Date
balgxmr
5302959e3b drivers: fts: fts_521: Silence logspam
- This spams way too much

Signed-off-by: balgxmr <jose@pixelos.net>
2023-08-10 12:25:36 -05:00
balgxmr
df3944e170 touchscreen: fts_521: Remove input_report_key on fod status check
* This fixes an issue with stuck scrolling specifically on fod area.

Test: Open chrome, search for a long website, scroll through
      fod area and check that it doesn't get stuck.
2023-08-10 12:25:28 -05:00
EcrosoftXiao
6f3a29314a input: touchscreen: fts_521: Kill fod status check
screenoff udfps won't work when fod_status==0 unless dt2w enabled, hence
kill fod_status check to make screenoff udfps working with dt2w disabled
2023-08-09 17:55:07 -05:00
EcrosoftXiao
fe25fd6cef input: touchscreen: fts_spi: expose fod_state via sysfs 2023-08-09 17:55:03 -05:00
Carlos Ayrton Lopez Arroyo
66e3ef3419 fts_521: silence loggers
Signed-off-by: Carlos Ayrton Lopez Arroyo <15030201@itcelaya.edu.mx>
2023-08-09 17:51:23 -05:00
Elluzion
0dd6345266 [DNM]: fts: Kill logspam
This has been a thing for months and it constantly bothered me, while not really being an issue. The problem is just that this log keeps spamming every time you put the finger down and up. Please don't murder me for this
2023-08-09 17:47:24 -05:00
Luan Cachoroski Halaiko
8700e5c732 Revert "drivers: touchscreen: Import Novatek NT36xxx touchscreen driver"
This reverts commit 0cf326d0b4.
2023-08-09 17:42:31 -05:00
Luan Cachoroski Halaiko
65767e75ee Revert "touchscreen: nt36xxx: Switch to msm drm notifier api"
This reverts commit 1f7ea635ab.
2023-08-09 17:42:28 -05:00
balgxmr
06d0ea64ab Merge tag 'LA.UM.9.1.r1-13700-SMxxx0.QSSI13.0' of https://git.codelinaro.org/clo/la/kernel/msm-4.14 into rebase
"LA.UM.9.1.r1-13700-SMxxx0.QSSI13.0"
2023-08-09 17:00:20 -05:00
balgxmr
434f599332 Merge branch 'upstream-linux-4.14.y' of https://android.googlesource.com/kernel/common into rebase 2023-08-09 16:44:33 -05:00
Dmitry Torokhov
f1da7d7df5 Input: psmouse - fix OOB access in Elantech protocol
commit 7b63a88bb62ba2ddf5fcd956be85fe46624628b9 upstream.

The kernel only allocate 5 MT slots; check that transmitted slot ID
falls within the acceptable range.

Link: https://lore.kernel.org/r/ZFnEL91nrT789dbG@google.com
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-06-14 10:35:26 +02:00
Ismael Ferreras Morezuelas
171f6390c5 Input: xpad - delete a Razer DeathAdder mouse VID/PID entry
commit feee70f4568650cf44c573488798ffc0a2faeea3 upstream.

While doing my research to improve the xpad device names I noticed
that the 1532:0037 VID/PID seems to be used by the DeathAdder 2013,
so that Razer Sabertooth instance looked wrong and very suspect to
me. I didn't see any mention in the official drivers, either.

After doing more research, it turns out that the xpad list
is used by many other projects (like Steam) as-is [1], this
issue was reported [2] and Valve/Sam Lantinga fixed it [3]:

[1]: dcc5eef0e2/src/joystick/controller_type.h (L251)
[2]: https://steamcommunity.com/app/353380/discussions/0/1743392486228754770/
[3]: https://hg.libsdl.org/SDL/rev/29809f6f0271

(With multiple Internet users reporting similar issues, not linked here)

After not being able to find the correct VID/PID combination anywhere
on the Internet and not receiving any reply from Razer support I did
some additional detective work, it seems like it presents itself as
"Razer Sabertooth Gaming Controller (XBOX360)", code 1689:FE00.

Leaving us with this:
 * Razer Sabertooth (1689:fe00)
 * Razer Sabertooth Elite (24c6:5d04)
 * Razer DeathAdder 2013 (1532:0037) [note: not a gamepad]

So, to sum things up; remove this conflicting/duplicate entry:

{ 0x1532, 0x0037, "Razer Sabertooth", 0, XTYPE_XBOX360 },

As the real/correct one is already present there, even if
the Internet as a whole insists on presenting it as the
Razer Sabertooth Elite, which (by all accounts) is not:

{ 0x1689, 0xfe00, "Razer Sabertooth", 0, XTYPE_XBOX360 },

Actual change in SDL2 referencing this kernel issue:
e5e5416975

For more information of the device, take a look here:
https://github.com/xboxdrv/xboxdrv/pull/59

You can see a lsusb dump here: https://github.com/xboxdrv/xboxdrv/files/76581/Qa6dBcrv.txt

Fixes: f554f619b7 ("Input: xpad - sync device IDs with xboxdrv")
Signed-off-by: Ismael Ferreras Morezuelas <swyterzone@gmail.com>
Reviewed-by: Cameron Gutman <aicommander@gmail.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/5c12dbdb-5774-fc68-5c58-ca596383663e@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-06-14 10:35:25 +02:00
Vicki Pfau
ec8f45ed32 Input: xpad - add constants for GIP interface numbers
[ Upstream commit f9b2e603c6216824e34dc9a67205d98ccc9a41ca ]

Wired GIP devices present multiple interfaces with the same USB identification
other than the interface number. This adds constants for differentiating two of
them and uses them where appropriate

Signed-off-by: Vicki Pfau <vi@endrift.com>
Link: https://lore.kernel.org/r/20230411031650.960322-2-vi@endrift.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-05-30 12:38:36 +01:00
Jason A. Donenfeld
6171c70c61 Input: focaltech - use explicitly signed char type
commit 8980f190947ba29f23110408e712444884b74251 upstream.

The recent change of -funsigned-char causes additions of negative
numbers to become additions of large positive numbers, leading to wrong
calculations of mouse movement. Change these casts to be explicitly
signed, to take into account negative offsets.

Fixes: 3bc753c06dd0 ("kbuild: treat char as always unsigned")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Cc: stable@vger.kernel.org
Link: https://bugzilla.kernel.org/show_bug.cgi?id=217211
Link: https://lore.kernel.org/r/20230318133010.1285202-1-Jason@zx2c4.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-04-05 11:14:20 +02:00
Luca Ellero
536fbb4f53 Input: ads7846 - don't check penirq immediately for 7845
[ Upstream commit fa9f4275b20ec7b2a8fb05c66362d10b36f9efec ]

To discard false readings, one should use "ti,penirq-recheck-delay-usecs".
Checking get_pendown_state() at the beginning, most of the time fails
causing malfunctioning.

Fixes: ffa458c1bd ("spi: ads7846 driver")
Signed-off-by: Luca Ellero <l.ellero@asem.it>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230126105227.47648-4-l.ellero@asem.it
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-03-11 16:26:40 +01:00
Luca Ellero
ae1a6691b1 Input: ads7846 - don't report pressure for ads7845
[ Upstream commit d50584d783313c8b05b84d0b07a2142f1bde46dd ]

ADS7845 doesn't support pressure.
Avoid the following error reported by libinput-list-devices:
"ADS7845 Touchscreen: kernel bug: device has min == max on ABS_PRESSURE".

Fixes: ffa458c1bd ("spi: ads7846 driver")
Signed-off-by: Luca Ellero <l.ellero@asem.it>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230126105227.47648-2-l.ellero@asem.it
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-03-11 16:26:40 +01:00
Dmitry Torokhov
e95a822ed1 Revert "Input: synaptics - switch touchpad on HP Laptop 15-da3001TU to RMI mode"
commit 3c44e2b6cde674797b76e76d3a903a63ce8a18bb upstream.

This reverts commit ac5408991ea6b06e29129b4d4861097c4c3e0d59 because
it causes loss of keyboard on HP 15-da1xxx.

Fixes: ac5408991ea6 ("Input: synaptics - switch touchpad on HP Laptop 15-da3001TU to RMI mode")
Reported-by: Jiri Slaby <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/824effa5-8b9a-c28a-82bb-9b0ab24623e1@kernel.org
Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1206358
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-02-06 07:46:32 +01:00
Douglas Anderson
785097c5bf Input: elants_i2c - properly handle the reset GPIO when power is off
[ Upstream commit a85fbd6498441694475716a4d5c65f9d3e073faf ]

As can be seen in elants_i2c_power_off(), we want the reset GPIO
asserted when power is off. The reset GPIO is active low so we need
the reset line logic low when power is off to avoid leakage.

We have a problem, though, at probe time. At probe time we haven't
powered the regulators on yet but we have:

  devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_LOW);

While that _looks_ right, it turns out that it's not. The
GPIOD_OUT_LOW doesn't mean to init the GPIO to low. It means init the
GPIO to "not asserted". Since this is an active low GPIO that inits it
to be high.

Let's fix this to properly init the GPIO. Now after both probe and
power off the state of the GPIO is consistent (it's "asserted" or
level low).

Once we fix this, we can see that at power on time we no longer to
assert the reset GPIO as the first thing. The reset GPIO is _always_
asserted before powering on. Let's fix powering on to account for
this.

Fixes: afe10358e4 ("Input: elants_i2c - wire up regulator support")
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20221117123805.1.I9959ac561dd6e1e8e1ce7085e4de6167b27c574f@changeid
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-01-18 09:26:13 +01:00
Aman Dhoot
b81b2a8222 Input: synaptics - switch touchpad on HP Laptop 15-da3001TU to RMI mode
[ Upstream commit ac5408991ea6b06e29129b4d4861097c4c3e0d59 ]

The device works fine in native RMI mode, there is no reason to use legacy
PS/2 mode with it.

Signed-off-by: Aman Dhoot <amandhoot12@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-12-08 11:16:31 +01:00
baalgx
b23e675de4 Merge remote-tracking branch 'SOVIET-ANDROID' into thirteen 2022-11-11 14:43:05 -05:00
baalgx
e3a7410f0d Revert "Revert "touchscreen: nt36xxx: Switch to msm drm notifier api""
This reverts commit 787878bc1f.
2022-11-10 21:04:58 -05:00
baalgx
706c220b5e Revert "Revert "drivers: touchscreen: Import Novatek NT36xxx touchscreen driver""
This reverts commit 99642c1e8a.
2022-11-10 21:02:30 -05:00
baalgx
e6e81f6843 Revert "Revert "drivers: touchscreen: Import ST FingerTip touchscreen driver""
This reverts commit e2bfca4ad3.
2022-11-10 20:32:29 -05:00
baalgx
079b0f60cf Revert "drivers: input: fix gpio_keys after unused touchscreen removal"
This reverts commit 05cd7decec.
2022-11-10 20:30:41 -05:00
baalgx
a585a8d508 Merge remote-tracking branch 'soviet/13.0' into soviet-13 2022-11-05 17:05:43 -05:00
pwnrazr
78e51d5384 Merge remote-tracking branch 'android-stable/android-4.14-stable' into dev-base 2022-11-01 12:06:43 +02:00
Cameron Gutman
13808875a2 Input: xpad - fix wireless 360 controller breaking after suspend
commit a17b9841152e7f4621619902b347e2cc39c32996 upstream.

Suspending and resuming the system can sometimes cause the out
URB to get hung after a reset_resume. This causes LED setting
and force feedback to break on resume. To avoid this, just drop
the reset_resume callback so the USB core rebinds xpad to the
wireless pads on resume if a reset happened.

A nice side effect of this change is the LED ring on wireless
controllers is now set correctly on system resume.

Cc: stable@vger.kernel.org
Fixes: 4220f7db1e ("Input: xpad - workaround dead irq_out after suspend/ resume")
Signed-off-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
Link: https://lore.kernel.org/r/20220818154411.510308-3-rojtberg@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-10-26 13:16:54 +02:00
Pavel Rojtberg
57d6b62f13 Input: xpad - add supported devices as contributed on github
commit b382c5e37344883dc97525d05f1f6b788f549985 upstream.

This is based on multiple commits at https://github.com/paroj/xpad

Cc: stable@vger.kernel.org
Signed-off-by: Jasper Poppe <jgpoppe@gmail.com>
Signed-off-by: Jeremy Palmer <jpalmer@linz.govt.nz>
Signed-off-by: Ruineka <ruinairas1992@gmail.com>
Signed-off-by: Cleber de Mattos Casali <clebercasali@gmail.com>
Signed-off-by: Kyle Gospodnetich <me@kylegospodneti.ch>
Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
Link: https://lore.kernel.org/r/20220818154411.510308-2-rojtberg@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-10-26 13:16:54 +02:00
Yang Yingliang
c7a356e64e Input: melfas_mip4 - fix return value check in mip4_probe()
[ Upstream commit a54dc27bd25f20ee3ea2009584b3166d25178243 ]

devm_gpiod_get_optional() may return ERR_PTR(-EPROBE_DEFER),
add a minus sign to fix it.

Fixes: 6ccb1d8f78 ("Input: add MELFAS MIP4 Touchscreen driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20220924030715.1653538-1-yangyingliang@huawei.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-10-26 13:16:50 +02:00
kondors1995
a8d8bfc96e drivers: msm: ipa: overhaul
Squashed commit of the following:

commit 3b9d24a9265b0c4211950f39ee5bc21261410db6
Author: Kazuki Hashimoto <kazukih@tuta.io>
Date:   Sun Jun 19 10:44:11 2022 +0900

    ipa: Allocate page with __GFP_RETRY_MAYFAIL and __GFP_NOWARN

    Taken from Google.

    5c90cf2148

    Signed-off-by: Kazuki Hashimoto <kazukih@tuta.io>

commit 07beb1e16313d84eb6239e8d007a9414f1d17ce9
Author: Luan Cachoroski Halaiko <luhalaiko@gmail.com>
Date:   Wed Feb 9 21:14:31 2022 -0300

    [1/5] drivers: platform: msm: ipa: add a switch to disable DEBUG_FS
    --> User builds don't need debugfs, this is the first of 5 patches
        that add a switch disabling DEBUG_FS on user builds, bringing
        kernel size a bit down and providing less spamming on kernel log

    Signed-off-by: Luan Cachoroski Halaiko <luhalaiko@gmail.com>

commit 74c16e08c078ca3ac5f0d2d7af691ed10f0e5a53
Author: Pooja Kumari <kumarip@codeaurora.org>
Date:   Wed Mar 11 19:15:04 2020 +0530

    msm: ipa3: increase rmnet_ipa timeout value

    With current timeout value rmnet_ipa driver is
    getting watchdog timeout. Increase timeout value
    to avoid timeout error.

    Bug: 134918361
    Test: Browsing/Speedtest/SST
    Change-Id: I76b35948968114c6540294fe1b560003bed5e1fb
    Signed-off-by: Pooja Kumari <kumarip@codeaurora.org>

commit e5d5511b3c2b3a5e1cddd39d058488e5c9d4f0cd
Author: Andrzej Perczak <linux@andrzejperczak.com>
Date:   Thu Jul 7 21:29:27 2022 +0200

    msm: ipa: Cast enums to fix compiler warnings

    Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com>

commit 24e6f2b99953b50b60ef998fec8010eececa439e
Author: Ashok Vuyyuru <avuyyuru@codeaurora.org>
Date:   Mon Jul 4 15:56:28 2022 +0200

    msm: ipa3: Fix to avoid gsi/sys len stats mismatch

    In suspend just before stopping the channel possible to receive
    the IEOB interrupt and xfer pointer will not be processed in this
    mode but gsi stats are updated.  In resume after starting the channel
    will receive the IEOB interrupt and xfer pointer will be overwritten
    because of this observing the gsi/sys len stats are not matching and
    buffers won't be replinished properly leading to HW stall.
    To avoid this process all data in polling context, gsi/sys len
    stats are updated properly.

    Change-Id: Id665448165b6aa51b251cddd72573c6df64ee541
    Signed-off-by: Ashok Vuyyuru <avuyyuru@codeaurora.org>
    Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com>

commit e9bf5fcaa70735ad327431a8a8131a505807a2b7
Author: Signed-off-by: Michael Adisumarta <madisuma@codeaurora.org>
Date:   Sun Dec 19 13:43:23 2021 +0100

    msm: ipa: use detach/attach netif instead of stop/wakeup

    To make sure detach and attach netif instead of stop
    and wakeup and also to update transfer timer update.

    Change-Id: I9d589b7f9f6fe98f778df509d3c16f339dfdeea1
    Signed-off-by: Michael Adisumarta <madisuma@codeaurora.org>
    Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com>

commit 96053803d70c48e3dbc2e986dc0ec78bc9129aa4
Author: Andrzej Perczak <linux@andrzejperczak.com>
Date:   Sun Dec 19 13:41:39 2021 +0100

    Revert "msm: ipa: Fix to avoid  NETDEV WATCHDOG warning logs"

    This reverts commit 7f6c43f620.

commit a9becf6c3ae3e78ac51872b4c1f61c7fed6f0e11
Author: Amir Levy <alevy@codeaurora.org>
Date:   Sun Dec 12 22:58:00 2021 +0100

    msm: ipa: added likely/unlikely branch prediction to the lan dp

    Added branch prediction in an effort to make
    the data path more efficent.

    Acked-by: Tal Gelbard <tgelbard@qti.qualcomm.com>
    Change-Id: I3bd2157ee6c263d89de9425c7a0249370ab918fc
    Signed-off-by: Amir Levy <alevy@codeaurora.org>
    Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com>

commit 1f411db6f9962c991120c26b6f7aba0afc316122
Author: Ashok Vuyyuru <avuyyuru@codeaurora.org>
Date:   Thu Apr 2 22:26:35 2020 +0530

    msm: ipa3: Fix to use paired PM operation for IPA

    Becauase of using wrong pair of PM operation device
    was not resuming if suspend fails. Adding changes to
    use correct set of PM operations.

    Change-Id: Ib9fdea8f93f0a6dafbd5908dc8fc2bbf4f1e0904
    Signed-off-by: Ashok Vuyyuru <avuyyuru@codeaurora.org>
    Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com>

commit 5719e064761ead0ed048127bc3144ff10ad592f1
Author: Kailash <kailash.sudhakar@gmail.com>
Date:   Thu Apr 16 01:38:29 2020 +0530

    drivers: msm: ipa_v3: Return operation unsupported when CONFIG_PCI is unset

    From 100.10.107.46 source drop

commit 2a9bf475119b27b56fda73f9e8c432f6e894c19a
Author: Bojun Pan <bojunp@codeaurora.org>
Date:   Fri Jan 31 22:24:47 2020 +0530

    msm: ipa: Fix the force_coals command stuck issue on AP suspend

    IPA force_coals command stuck due to not getting the gsi interrupt.
    The suspend on IPA AP/RMNET_IPA driver was registered as noirq type,
    gsi interrupt handler won't be called because of this.
    The fix is to change the suspend cb from suspend_noirq to suspend.

    Change-Id: I148c981b0edb28c414a30b991294b2683b198399
    Signed-off-by: Bojun Pan <bojunp@codeaurora.org>
    Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com>

commit cb9c06b83fd9957ac8d63a990847076dd34aa559
Author: Alex Naidis <alex.naidis@paranoidandroid.co>
Date:   Tue Jul 31 16:37:16 2018 -0400

    msm: ipa_v3: Mitigate usleep_range calls

    Calling usleep_range with identical min and max values,
    results in a delta of 0us.

    This causes the issue that the scheduler gets no chance to re-use an already
    scheduled interrupt for this wait which results in a negative performance
    impact by adding uninterruptible sleep.

    Fix the issue by allowing the delay to take 20% longer than requested.
    This should be good enough for these cases.

    Signed-off-by: Alex Naidis <alex.naidis@paranoidandroid.co>
    Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>

commit 0ec1247d32dd39a8b4a0b2da78c58c2537c4ead3
Author: Sultan Alsawaf <sultan@kerneltoast.com>
Date:   Tue Jan 12 00:08:29 2021 -0800

    msm: ipa3: Fix non-atomic read on atomic_t variable

    Accessing an atomic variable without the atomic_*() helpers is illegal.

    Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>

commit 891f71a631b08746b7070c0f35a06be03e1784fe
Author: Sultan Alsawaf <sultan@kerneltoast.com>
Date:   Tue Jan 12 00:07:19 2021 -0800

    msm: ipa3: Fix format specifier warnings

    Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>

commit 68fba094615efc7c1131d8e6df0be7863a0938ad
Author: Sultan Alsawaf <sultan@kerneltoast.com>
Date:   Thu Dec 24 22:53:54 2020 -0800

    msm: ipa: Refactor buffer size check in ipa3_write()

    This confuses GCC's FORTIFY_SOURCE check for the copy_from_user() in
    this function. Simplify it to resolve the GCC warning.

    Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>

commit 883cd9e245955fcdd8ed1c4166b8f4324d3ac090
Author: Sami Tolvanen <samitolvanen@google.com>
Date:   Fri Jan 19 11:19:11 2018 -0800

    msm: ipa3: fix callback function type for ndo_start_xmit

    Bug: 117299373
    Change-Id: Iad7ed493bd29e2da85e2d6bc0f1dc0fbdac8a41d
    Signed-off-by: Sami Tolvanen <samitolvanen@google.com>

commit 98d90c2ac07a802751b31b0afff300dce17ad511
Author: kondors1995 <normandija1945@gmail.com>
Date:   Mon Oct 17 13:50:52 2022 +0300

    \Revert "drivers: ipa_v3: Conditionally compile out ipa wakelock code"

    This reverts commit e46958360f.

commit 314eab9899967ab6487bd8163ef6404106cbd602
Author: kondors1995 <normandija1945@gmail.com>
Date:   Mon Oct 17 13:50:49 2022 +0300

    Revert "[1/5] drivers: platform: msm: ipa: add a switch to disable DEBUG_FS"

    This reverts commit 9f9dc2f45c.

commit 090ab7d9400bba97b2fc0d68cb5b5cc3a986376a
Author: kondors1995 <normandija1945@gmail.com>
Date:   Mon Oct 17 13:50:06 2022 +0300

    Revert "msm: ipa_v3: Mitigate usleep_range calls"

    This reverts commit df2ea99946.

commit 23234070df088d9b08ae61bb1b99f1749e2b76cb
Author: kondors1995 <normandija1945@gmail.com>
Date:   Mon Oct 17 13:49:59 2022 +0300

    Revert "drivers: msm-ipa: Only include emulation init with CONFIG_IPA_EMULATION"

    This reverts commit c827afff53.

commit 550cb7c2a4eccb3aa8452399d3311aa2a4825dfd
Author: kondors1995 <normandija1945@gmail.com>
Date:   Mon Oct 17 13:49:47 2022 +0300

    Revert "msm: ipa: Fix the force_coals command stuck issue on AP suspend"

    This reverts commit a7d75b5f3e.

commit 510b440d3df7ea9c3f6b5537b60cac0c39269912
Author: kondors1995 <normandija1945@gmail.com>
Date:   Mon Oct 17 13:49:38 2022 +0300

    Revert "msm: ipa3: Fix to use paired PM operation for IPA"

    This reverts commit 00cbc4db2c.

commit 245f9a9d555c6b0488c6031fd2d3cbfda38651c2
Author: kondors1995 <normandija1945@gmail.com>
Date:   Mon Oct 17 13:49:23 2022 +0300

    Revert "rmnet_ipa: Fix netdev watchdog triggering on suspend"

    This reverts commit d42f2391da.

commit d385eb5a1e8c65231edf8b3b73953e952b560038
Author: kondors1995 <normandija1945@gmail.com>
Date:   Mon Oct 17 13:48:57 2022 +0300

    Revert "ipa: Allocate page with __GFP_RETRY_MAYFAIL and __GFP_NOWARN"

    This reverts commit 75f9a8c6b4.

commit 119731ad74ac2cb0228d5571020e37a0cf67784b
Author: kondors1995 <normandija1945@gmail.com>
Date:   Mon Oct 17 13:48:47 2022 +0300

    Revert "msm: ipa: Cast enums to fix compiler warnings"

    This reverts commit 9eaf6d119f.

commit 91aaadc7d9d66819f26490899abfa0ace5c014c8
Author: kondors1995 <normandija1945@gmail.com>
Date:   Mon Oct 17 13:48:06 2022 +0300

    Revert "msm: ipa3: increase rmnet_ipa timeout value"

    This reverts commit 4503a36ec7.

commit 1a88043379494ba9c343a8736e4921c44d40252c
Author: kondors1995 <normandija1945@gmail.com>
Date:   Mon Oct 17 13:48:00 2022 +0300

    Revert "msm: ipa3: fix callback function type for ndo_start_xmit"

    This reverts commit a25522ebfe.

commit 0a2748e422c0aa56be9d07bd5effc50ff05d7874
Author: kondors1995 <normandija1945@gmail.com>
Date:   Mon Oct 17 13:47:50 2022 +0300

    Revert "platform: msm: ipa: Correctly allocate memory for copy_from_user"

    This reverts commit c18f8ff38c.

commit c032130a46746b3e4b6e0ae41cb96c58f11521da
Author: kondors1995 <normandija1945@gmail.com>
Date:   Mon Oct 17 13:47:42 2022 +0300

    Revert "platform: msm: ipav3: Correct smallest ipa3_write string to 1."

    This reverts commit 2fff1651ec.
2022-10-24 11:55:48 +03:00
Kees Cook
ec2dbb049c treewide: devm_kzalloc() -> devm_kcalloc()
The devm_kzalloc() function has a 2-factor argument form, devm_kcalloc().
This patch replaces cases of:

        devm_kzalloc(handle, a * b, gfp)

with:
        devm_kcalloc(handle, a * b, gfp)

as well as handling cases of:

        devm_kzalloc(handle, a * b * c, gfp)

with:

        devm_kzalloc(handle, array3_size(a, b, c), gfp)

as it's slightly less ugly than:

        devm_kcalloc(handle, array_size(a, b), c, gfp)

This does, however, attempt to ignore constant size factors like:

        devm_kzalloc(handle, 4 * 1024, gfp)

though any constants defined via macros get caught up in the conversion.

Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.

Some manual whitespace fixes were needed in this patch, as Coccinelle
really liked to write "=devm_kcalloc..." instead of "= devm_kcalloc...".

The Coccinelle script used for this was:

// Fix redundant parens around sizeof().
@@
expression HANDLE;
type TYPE;
expression THING, E;
@@

(
  devm_kzalloc(HANDLE,
-	(sizeof(TYPE)) * E
+	sizeof(TYPE) * E
  , ...)
|
  devm_kzalloc(HANDLE,
-	(sizeof(THING)) * E
+	sizeof(THING) * E
  , ...)
)

// Drop single-byte sizes and redundant parens.
@@
expression HANDLE;
expression COUNT;
typedef u8;
typedef __u8;
@@

(
  devm_kzalloc(HANDLE,
-	sizeof(u8) * (COUNT)
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(__u8) * (COUNT)
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(char) * (COUNT)
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(unsigned char) * (COUNT)
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(u8) * COUNT
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(__u8) * COUNT
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(char) * COUNT
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(unsigned char) * COUNT
+	COUNT
  , ...)
)

// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
expression HANDLE;
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@

(
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * (COUNT_ID)
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * COUNT_ID
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * (COUNT_CONST)
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * COUNT_CONST
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * (COUNT_ID)
+	COUNT_ID, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * COUNT_ID
+	COUNT_ID, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * (COUNT_CONST)
+	COUNT_CONST, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * COUNT_CONST
+	COUNT_CONST, sizeof(THING)
  , ...)
)

// 2-factor product, only identifiers.
@@
expression HANDLE;
identifier SIZE, COUNT;
@@

- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	SIZE * COUNT
+	COUNT, SIZE
  , ...)

// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression HANDLE;
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@

(
  devm_kzalloc(HANDLE,
-	sizeof(TYPE) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
)

// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression HANDLE;
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@

(
  devm_kzalloc(HANDLE,
-	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
)

// 3-factor product, only identifiers, with redundant parens removed.
@@
expression HANDLE;
identifier STRIDE, SIZE, COUNT;
@@

(
  devm_kzalloc(HANDLE,
-	(COUNT) * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	COUNT * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	COUNT * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(COUNT) * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	COUNT * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(COUNT) * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(COUNT) * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	COUNT * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
)

// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression HANDLE;
expression E1, E2, E3;
constant C1, C2, C3;
@@

(
  devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
|
  devm_kzalloc(HANDLE,
-	(E1) * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(E1) * (E2) * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(E1) * (E2) * (E3)
+	array3_size(E1, E2, E3)
  , ...)
|
  devm_kzalloc(HANDLE,
-	E1 * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
)

// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression HANDLE;
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@

(
  devm_kzalloc(HANDLE, sizeof(THING) * C2, ...)
|
  devm_kzalloc(HANDLE, sizeof(TYPE) * C2, ...)
|
  devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
|
  devm_kzalloc(HANDLE, C1 * C2, ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * (E2)
+	E2, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * E2
+	E2, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * (E2)
+	E2, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * E2
+	E2, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	(E1) * E2
+	E1, E2
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	(E1) * (E2)
+	E1, E2
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	E1 * E2
+	E1, E2
  , ...)
)

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
Signed-off-by: Fiqri Ardyansyah <fiqri15072019@gmail.com>

 Conflicts:
	drivers/platform/msm/gsi/gsi.c
pwnrazr:original commit had changes in gsi.c but conflicted with our tree here
	original commit:f7985e33e6
2022-10-07 11:27:03 +03:00
Kees Cook
84e16102a1 treewide: kzalloc() -> kcalloc()
The kzalloc() function has a 2-factor argument form, kcalloc(). This
patch replaces cases of:

        kzalloc(a * b, gfp)

with:
        kcalloc(a * b, gfp)

as well as handling cases of:

        kzalloc(a * b * c, gfp)

with:

        kzalloc(array3_size(a, b, c), gfp)

as it's slightly less ugly than:

        kzalloc_array(array_size(a, b), c, gfp)

This does, however, attempt to ignore constant size factors like:

        kzalloc(4 * 1024, gfp)

though any constants defined via macros get caught up in the conversion.

Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.

The Coccinelle script used for this was:

// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@

(
  kzalloc(
-	(sizeof(TYPE)) * E
+	sizeof(TYPE) * E
  , ...)
|
  kzalloc(
-	(sizeof(THING)) * E
+	sizeof(THING) * E
  , ...)
)

// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@

(
  kzalloc(
-	sizeof(u8) * (COUNT)
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(__u8) * (COUNT)
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(char) * (COUNT)
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(unsigned char) * (COUNT)
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(u8) * COUNT
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(__u8) * COUNT
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(char) * COUNT
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(unsigned char) * COUNT
+	COUNT
  , ...)
)

// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@

(
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * (COUNT_ID)
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * COUNT_ID
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * (COUNT_CONST)
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * COUNT_CONST
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * (COUNT_ID)
+	COUNT_ID, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * COUNT_ID
+	COUNT_ID, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * (COUNT_CONST)
+	COUNT_CONST, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * COUNT_CONST
+	COUNT_CONST, sizeof(THING)
  , ...)
)

// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@

- kzalloc
+ kcalloc
  (
-	SIZE * COUNT
+	COUNT, SIZE
  , ...)

// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@

(
  kzalloc(
-	sizeof(TYPE) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kzalloc(
-	sizeof(TYPE) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kzalloc(
-	sizeof(TYPE) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kzalloc(
-	sizeof(TYPE) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kzalloc(
-	sizeof(THING) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kzalloc(
-	sizeof(THING) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kzalloc(
-	sizeof(THING) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kzalloc(
-	sizeof(THING) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
)

// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@

(
  kzalloc(
-	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  kzalloc(
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  kzalloc(
-	sizeof(THING1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  kzalloc(
-	sizeof(THING1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  kzalloc(
-	sizeof(TYPE1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
|
  kzalloc(
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
)

// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@

(
  kzalloc(
-	(COUNT) * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	COUNT * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	COUNT * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	(COUNT) * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	COUNT * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	(COUNT) * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	(COUNT) * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	COUNT * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
)

// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@

(
  kzalloc(C1 * C2 * C3, ...)
|
  kzalloc(
-	(E1) * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  kzalloc(
-	(E1) * (E2) * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  kzalloc(
-	(E1) * (E2) * (E3)
+	array3_size(E1, E2, E3)
  , ...)
|
  kzalloc(
-	E1 * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
)

// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@

(
  kzalloc(sizeof(THING) * C2, ...)
|
  kzalloc(sizeof(TYPE) * C2, ...)
|
  kzalloc(C1 * C2 * C3, ...)
|
  kzalloc(C1 * C2, ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * (E2)
+	E2, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * E2
+	E2, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * (E2)
+	E2, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * E2
+	E2, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	(E1) * E2
+	E1, E2
  , ...)
|
- kzalloc
+ kcalloc
  (
-	(E1) * (E2)
+	E1, E2
  , ...)
|
- kzalloc
+ kcalloc
  (
-	E1 * E2
+	E1, E2
  , ...)
)

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
[fiqri19102002: Adapt to new extcon.c changes]
Signed-off-by: Fiqri Ardyansyah <fiqri15072019@gmail.com>

 Conflicts:
	arch/arm64/mm/context.c
pwnrazr: an upstream commit conflicted, but I think upstream one is better?
	Original commit: 299d38205a
	`bitmap_zalloc`
2022-10-07 11:26:56 +03:00
Kees Cook
b6399c388a treewide: kmalloc() -> kmalloc_array()
The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
patch replaces cases of:

        kmalloc(a * b, gfp)

with:
        kmalloc_array(a * b, gfp)

as well as handling cases of:

        kmalloc(a * b * c, gfp)

with:

        kmalloc(array3_size(a, b, c), gfp)

as it's slightly less ugly than:

        kmalloc_array(array_size(a, b), c, gfp)

This does, however, attempt to ignore constant size factors like:

        kmalloc(4 * 1024, gfp)

though any constants defined via macros get caught up in the conversion.

Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.

The tools/ directory was manually excluded, since it has its own
implementation of kmalloc().

The Coccinelle script used for this was:

// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@

(
  kmalloc(
-	(sizeof(TYPE)) * E
+	sizeof(TYPE) * E
  , ...)
|
  kmalloc(
-	(sizeof(THING)) * E
+	sizeof(THING) * E
  , ...)
)

// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@

(
  kmalloc(
-	sizeof(u8) * (COUNT)
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(__u8) * (COUNT)
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(char) * (COUNT)
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(unsigned char) * (COUNT)
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(u8) * COUNT
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(__u8) * COUNT
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(char) * COUNT
+	COUNT
  , ...)
|
  kmalloc(
-	sizeof(unsigned char) * COUNT
+	COUNT
  , ...)
)

// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@

(
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * (COUNT_ID)
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * COUNT_ID
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * (COUNT_CONST)
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * COUNT_CONST
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * (COUNT_ID)
+	COUNT_ID, sizeof(THING)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * COUNT_ID
+	COUNT_ID, sizeof(THING)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * (COUNT_CONST)
+	COUNT_CONST, sizeof(THING)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * COUNT_CONST
+	COUNT_CONST, sizeof(THING)
  , ...)
)

// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@

- kmalloc
+ kmalloc_array
  (
-	SIZE * COUNT
+	COUNT, SIZE
  , ...)

// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@

(
  kmalloc(
-	sizeof(TYPE) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kmalloc(
-	sizeof(TYPE) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kmalloc(
-	sizeof(TYPE) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kmalloc(
-	sizeof(TYPE) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kmalloc(
-	sizeof(THING) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kmalloc(
-	sizeof(THING) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kmalloc(
-	sizeof(THING) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kmalloc(
-	sizeof(THING) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
)

// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@

(
  kmalloc(
-	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  kmalloc(
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  kmalloc(
-	sizeof(THING1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  kmalloc(
-	sizeof(THING1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  kmalloc(
-	sizeof(TYPE1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
|
  kmalloc(
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
)

// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@

(
  kmalloc(
-	(COUNT) * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	COUNT * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	COUNT * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	(COUNT) * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	COUNT * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	(COUNT) * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	(COUNT) * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kmalloc(
-	COUNT * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
)

// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@

(
  kmalloc(C1 * C2 * C3, ...)
|
  kmalloc(
-	(E1) * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  kmalloc(
-	(E1) * (E2) * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  kmalloc(
-	(E1) * (E2) * (E3)
+	array3_size(E1, E2, E3)
  , ...)
|
  kmalloc(
-	E1 * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
)

// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@

(
  kmalloc(sizeof(THING) * C2, ...)
|
  kmalloc(sizeof(TYPE) * C2, ...)
|
  kmalloc(C1 * C2 * C3, ...)
|
  kmalloc(C1 * C2, ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * (E2)
+	E2, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(TYPE) * E2
+	E2, sizeof(TYPE)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * (E2)
+	E2, sizeof(THING)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	sizeof(THING) * E2
+	E2, sizeof(THING)
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	(E1) * E2
+	E1, E2
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	(E1) * (E2)
+	E1, E2
  , ...)
|
- kmalloc
+ kmalloc_array
  (
-	E1 * E2
+	E1, E2
  , ...)
)

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
Signed-off-by: Fiqri Ardyansyah <fiqri15072019@gmail.com>
2022-10-07 11:19:36 +03:00
Kees Cook
eed6c58b09 treewide: Use struct_size() for devm_kmalloc() and friends
Replaces open-coded struct size calculations with struct_size() for
devm_*, f2fs_*, and sock_* allocations. Automatically generated (and
manually adjusted) from the following Coccinelle script:

// Direct reference to struct field.
@@
identifier alloc =~ "devm_kmalloc|devm_kzalloc|sock_kmalloc|f2fs_kmalloc|f2fs_kzalloc";
expression HANDLE;
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@

- alloc(HANDLE, sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
+ alloc(HANDLE, struct_size(VAR, ELEMENT, COUNT), GFP)

// mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
@@
identifier alloc =~ "devm_kmalloc|devm_kzalloc|sock_kmalloc|f2fs_kmalloc|f2fs_kzalloc";
expression HANDLE;
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@

- alloc(HANDLE, sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
+ alloc(HANDLE, struct_size(VAR, ELEMENT, COUNT), GFP)

// Same pattern, but can't trivially locate the trailing element name,
// or variable name.
@@
identifier alloc =~ "devm_kmalloc|devm_kzalloc|sock_kmalloc|f2fs_kmalloc|f2fs_kzalloc";
expression HANDLE;
expression GFP;
expression SOMETHING, COUNT, ELEMENT;
@@

- alloc(HANDLE, sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
+ alloc(HANDLE, CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
Signed-off-by: Fiqri Ardyansyah <fiqri15072019@gmail.com>
2022-10-07 11:19:35 +03:00
Kees Cook
a143b6702e treewide: Use struct_size() for kmalloc()-family
One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:

struct foo {
    int stuff;
    void *entry[];
};

instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);

Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:

instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL);

This patch makes the changes for kmalloc()-family (and kvmalloc()-family)
uses. It was done via automatic conversion with manual review for the
"CHECKME" non-standard cases noted below, using the following Coccinelle
script:

// pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len *
//                      sizeof *pkey_cache->table, GFP_KERNEL);
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@

- alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
+ alloc(struct_size(VAR, ELEMENT, COUNT), GFP)

// mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@

- alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
+ alloc(struct_size(VAR, ELEMENT, COUNT), GFP)

// Same pattern, but can't trivially locate the trailing element name,
// or variable name.
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
expression SOMETHING, COUNT, ELEMENT;
@@

- alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
+ alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
Signed-off-by: Fiqri Ardyansyah <fiqri15072019@gmail.com>
2022-10-07 11:19:35 +03:00
pwnrazr
169dc8150b Merge remote-tracking branch 'android-stable/android-4.14-stable' into dev-base 2022-09-27 11:18:23 +03:00
Logan-Developer
f36c63a2ee Fix struct for clang 15 compatibility 2022-09-22 15:51:06 -05:00
Luan Cachoroski Halaiko
05cd7decec drivers: input: fix gpio_keys after unused touchscreen removal
Signed-off-by: Luan Cachoroski Halaiko <luhalaiko@gmail.com>
2022-09-22 17:37:47 +03:00
Luan Cachoroski Halaiko
e2bfca4ad3 Revert "drivers: touchscreen: Import ST FingerTip touchscreen driver"
This reverts commit d31c6fc931.
2022-09-22 17:36:23 +03:00
Luan Cachoroski Halaiko
2b8a8a2264 Revert "fts_521: fix old style function defination"
This reverts commit 60d7d5614d.
2022-09-22 17:36:23 +03:00
Luan Cachoroski Halaiko
99642c1e8a Revert "drivers: touchscreen: Import Novatek NT36xxx touchscreen driver"
This reverts commit 0cf326d0b4.
2022-09-22 17:36:22 +03:00
Luan Cachoroski Halaiko
787878bc1f Revert "touchscreen: nt36xxx: Switch to msm drm notifier api"
This reverts commit 1f7ea635ab.
2022-09-22 17:36:16 +03:00
baalgx
2518462029 Merge remote-tracking branch 'soviet-raphael/dev/xnombre-uclamp-v3' into 12.1 2022-09-21 20:37:44 -05:00
Peter Robinson
40d8aaa4b9 Input: rk805-pwrkey - fix module autoloading
[ Upstream commit 99077ad668ddd9b4823cc8ce3f3c7a3fc56f6fd9 ]

Add the module alias so the rk805-pwrkey driver will
autoload when built as a module.

Fixes: 5a35b85c2d ("Input: add power key driver for Rockchip RK805 PMIC")
Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://lore.kernel.org/r/20220612225437.3628788-1-pbrobinson@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-09-15 12:23:50 +02:00
Surya Teja Kudiri
3638686626 Revert "input: touchscreen: focaltech: support FT5446DQS"
This reverts commit 56b48a4c08.

Change-Id: I6e9c377ec2a8dda0018cb73fcd37bfb9d25ee231
Signed-off-by: Ke Du <quic_kedu@quicinc.com>
Signed-off-by: Surya Teja Kudiri <quic_skudiri@quicinc.com>
2022-08-21 15:52:17 +05:30
Surya Teja Kudiri
4729283adc Revert "input: touchscreen: focaltech: add a new property"
This reverts commit 32aeb3bff2.

Change-Id: I51d7b75897b124e77f593fb03026127a21c66648
Signed-off-by: Fei Mao <feim1@codeaurora.org>
Signed-off-by: Surya Teja Kudiri <quic_skudiri@quicinc.com>
2022-08-21 11:29:39 +05:30
Surya Teja Kudiri
74cc467cf2 Revert "input: touchscreen: focaltech: Use disable/enable irq wake in LA to LE"
This reverts commit 88fed2127a.

Change-Id: I13161d319a96c338c759b2196857b2350a7b7de0
Signed-off-by: Ritesh Kumar <riteshk@codeaurora.org>
Signed-off-by: Surya Teja Kudiri <quic_skudiri@quicinc.com>
2022-08-19 11:09:56 +05:30
qctecmdr
dd882b632d Merge "input: touchscreen: focaltech: Use disable/enable irq wake in LA to LE" 2022-08-08 03:37:12 -07:00
Ritesh Kumar
8c9a7926e9 input: touchscreen: focaltech: release i2c session early
Release I2C session lock before releasing IO regions in TVM
during trusted touch scenario.

Change-Id: If943165b687318eac6c5f7b734bc6dea4c0efa46
Signed-off-by: ppadasal <quic_ppadasal@quicinc.com>
2022-07-26 21:28:35 -07:00
Ritesh Kumar
49d92b68d6 input: touchscreen: focaltech: toggle reset gpio during error
Toggle reset gpio of touch controller during an error scenario
on Secondary Virtual Machine(SVM).

Change-Id: Id5fdbb8e0106e636676060edfb05b6219f7400c8
Signed-off-by: ppadasal <quic_ppadasal@quicinc.com>
2022-07-26 21:27:37 -07:00