--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:01 -0700
+Subject: media: dvb/frontend.h: document the uAPI file
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Jaedon Shin <jaedon.shin@gmail.com>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-5-florian.fainelli@broadcom.com>
+
+From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+
+commit 8220ead805b6bab4ade2839857a198e9708b07de upstream
+
+Most of the stuff at the Digital TV frontend header file
+are documented only at the Documentation. However, a few
+kernel-doc markups are there, several of them with parsing
+issues.
+
+Add the missing documentation, copying definitions from the
+Documentation when it applies, fixing some bugs.
+
+Please notice that DVBv3 stuff that were deprecated weren't
+commented by purpose. Instead, they were clearly tagged as
+such.
+
+This patch prepares to move part of the documentation from
+Documentation/ to kernel-doc comments.
+
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ include/uapi/linux/dvb/frontend.h | 580 ++++++++++++++++++++++++++++++++------
+ 1 file changed, 498 insertions(+), 82 deletions(-)
+
+--- a/include/uapi/linux/dvb/frontend.h
++++ b/include/uapi/linux/dvb/frontend.h
+@@ -28,13 +28,46 @@
+
+ #include <linux/types.h>
+
+-enum fe_type {
+- FE_QPSK,
+- FE_QAM,
+- FE_OFDM,
+- FE_ATSC
+-};
+-
++/**
++ * enum fe_caps - Frontend capabilities
++ *
++ * @FE_IS_STUPID: There's something wrong at the
++ * frontend, and it can't report its
++ * capabilities.
++ * @FE_CAN_INVERSION_AUTO: Can auto-detect frequency spectral
++ * band inversion
++ * @FE_CAN_FEC_1_2: Supports FEC 1/2
++ * @FE_CAN_FEC_2_3: Supports FEC 2/3
++ * @FE_CAN_FEC_3_4: Supports FEC 3/4
++ * @FE_CAN_FEC_4_5: Supports FEC 4/5
++ * @FE_CAN_FEC_5_6: Supports FEC 5/6
++ * @FE_CAN_FEC_6_7: Supports FEC 6/7
++ * @FE_CAN_FEC_7_8: Supports FEC 7/8
++ * @FE_CAN_FEC_8_9: Supports FEC 8/9
++ * @FE_CAN_FEC_AUTO: Can auto-detect FEC
++ * @FE_CAN_QPSK: Supports QPSK modulation
++ * @FE_CAN_QAM_16: Supports 16-QAM modulation
++ * @FE_CAN_QAM_32: Supports 32-QAM modulation
++ * @FE_CAN_QAM_64: Supports 64-QAM modulation
++ * @FE_CAN_QAM_128: Supports 128-QAM modulation
++ * @FE_CAN_QAM_256: Supports 256-QAM modulation
++ * @FE_CAN_QAM_AUTO: Can auto-detect QAM modulation
++ * @FE_CAN_TRANSMISSION_MODE_AUTO: Can auto-detect transmission mode
++ * @FE_CAN_BANDWIDTH_AUTO: Can auto-detect bandwidth
++ * @FE_CAN_GUARD_INTERVAL_AUTO: Can auto-detect guard interval
++ * @FE_CAN_HIERARCHY_AUTO: Can auto-detect hierarchy
++ * @FE_CAN_8VSB: Supports 8-VSB modulation
++ * @FE_CAN_16VSB: Supporta 16-VSB modulation
++ * @FE_HAS_EXTENDED_CAPS: Unused
++ * @FE_CAN_MULTISTREAM: Supports multistream filtering
++ * @FE_CAN_TURBO_FEC: Supports "turbo FEC" modulation
++ * @FE_CAN_2G_MODULATION: Supports "2nd generation" modulation,
++ * e. g. DVB-S2, DVB-T2, DVB-C2
++ * @FE_NEEDS_BENDING: Unused
++ * @FE_CAN_RECOVER: Can recover from a cable unplug
++ * automatically
++ * @FE_CAN_MUTE_TS: Can stop spurious TS data output
++ */
+ enum fe_caps {
+ FE_IS_STUPID = 0,
+ FE_CAN_INVERSION_AUTO = 0x1,
+@@ -60,15 +93,55 @@ enum fe_caps {
+ FE_CAN_HIERARCHY_AUTO = 0x100000,
+ FE_CAN_8VSB = 0x200000,
+ FE_CAN_16VSB = 0x400000,
+- FE_HAS_EXTENDED_CAPS = 0x800000, /* We need more bitspace for newer APIs, indicate this. */
+- FE_CAN_MULTISTREAM = 0x4000000, /* frontend supports multistream filtering */
+- FE_CAN_TURBO_FEC = 0x8000000, /* frontend supports "turbo fec modulation" */
+- FE_CAN_2G_MODULATION = 0x10000000, /* frontend supports "2nd generation modulation" (DVB-S2) */
+- FE_NEEDS_BENDING = 0x20000000, /* not supported anymore, don't use (frontend requires frequency bending) */
+- FE_CAN_RECOVER = 0x40000000, /* frontend can recover from a cable unplug automatically */
+- FE_CAN_MUTE_TS = 0x80000000 /* frontend can stop spurious TS data output */
++ FE_HAS_EXTENDED_CAPS = 0x800000,
++ FE_CAN_MULTISTREAM = 0x4000000,
++ FE_CAN_TURBO_FEC = 0x8000000,
++ FE_CAN_2G_MODULATION = 0x10000000,
++ FE_NEEDS_BENDING = 0x20000000,
++ FE_CAN_RECOVER = 0x40000000,
++ FE_CAN_MUTE_TS = 0x80000000
++};
++
++/*
++ * DEPRECATED: Should be kept just due to backward compatibility.
++ */
++enum fe_type {
++ FE_QPSK,
++ FE_QAM,
++ FE_OFDM,
++ FE_ATSC
+ };
+
++/**
++ * struct dvb_frontend_info - Frontend properties and capabilities
++ *
++ * @name: Name of the frontend
++ * @type: **DEPRECATED**.
++ * Should not be used on modern programs,
++ * as a frontend may have more than one type.
++ * In order to get the support types of a given
++ * frontend, use :c:type:`DTV_ENUM_DELSYS`
++ * instead.
++ * @frequency_min: Minimal frequency supported by the frontend.
++ * @frequency_max: Minimal frequency supported by the frontend.
++ * @frequency_stepsize: All frequencies are multiple of this value.
++ * @frequency_tolerance: Frequency tolerance.
++ * @symbol_rate_min: Minimal symbol rate, in bauds
++ * (for Cable/Satellite systems).
++ * @symbol_rate_max: Maximal symbol rate, in bauds
++ * (for Cable/Satellite systems).
++ * @symbol_rate_tolerance: Maximal symbol rate tolerance, in ppm
++ * (for Cable/Satellite systems).
++ * @notifier_delay: **DEPRECATED**. Not used by any driver.
++ * @caps: Capabilities supported by the frontend,
++ * as specified in &enum fe_caps.
++ *
++ * .. note:
++ *
++ * #. The frequencies are specified in Hz for Terrestrial and Cable
++ * systems.
++ * #. The frequencies are specified in kHz for Satellite systems.
++ */
+ struct dvb_frontend_info {
+ char name[128];
+ enum fe_type type; /* DEPRECATED. Use DTV_ENUM_DELSYS instead */
+@@ -78,53 +151,102 @@ struct dvb_frontend_info {
+ __u32 frequency_tolerance;
+ __u32 symbol_rate_min;
+ __u32 symbol_rate_max;
+- __u32 symbol_rate_tolerance; /* ppm */
++ __u32 symbol_rate_tolerance;
+ __u32 notifier_delay; /* DEPRECATED */
+ enum fe_caps caps;
+ };
+
+-
+ /**
+- * Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for
+- * the meaning of this struct...
++ * struct dvb_diseqc_master_cmd - DiSEqC master command
++ *
++ * @msg:
++ * DiSEqC message to be sent. It contains a 3 bytes header with:
++ * framing + address + command, and an optional argument
++ * of up to 3 bytes of data.
++ * @msg_len:
++ * Length of the DiSEqC message. Valid values are 3 to 6.
++ *
++ * Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for
++ * the possible messages that can be used.
+ */
+ struct dvb_diseqc_master_cmd {
+- __u8 msg [6]; /* { framing, address, command, data [3] } */
+- __u8 msg_len; /* valid values are 3...6 */
++ __u8 msg[6];
++ __u8 msg_len;
+ };
+
++/**
++ * struct dvb_diseqc_slave_reply - DiSEqC received data
++ *
++ * @msg:
++ * DiSEqC message buffer to store a message received via DiSEqC.
++ * It contains one byte header with: framing and
++ * an optional argument of up to 3 bytes of data.
++ * @msg_len:
++ * Length of the DiSEqC message. Valid values are 0 to 4,
++ * where 0 means no message.
++ * @timeout:
++ * Return from ioctl after timeout ms with errorcode when
++ * no message was received.
++ *
++ * Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for
++ * the possible messages that can be used.
++ */
+ struct dvb_diseqc_slave_reply {
+- __u8 msg [4]; /* { framing, data [3] } */
+- __u8 msg_len; /* valid values are 0...4, 0 means no msg */
+- int timeout; /* return from ioctl after timeout ms with */
+-}; /* errorcode when no message was received */
++ __u8 msg[4];
++ __u8 msg_len;
++ int timeout;
++};
+
++/**
++ * enum fe_sec_voltage - DC Voltage used to feed the LNBf
++ *
++ * @SEC_VOLTAGE_13: Output 13V to the LNBf
++ * @SEC_VOLTAGE_18: Output 18V to the LNBf
++ * @SEC_VOLTAGE_OFF: Don't feed the LNBf with a DC voltage
++ */
+ enum fe_sec_voltage {
+ SEC_VOLTAGE_13,
+ SEC_VOLTAGE_18,
+ SEC_VOLTAGE_OFF
+ };
+
++/**
++ * enum fe_sec_tone_mode - Type of tone to be send to the LNBf.
++ * @SEC_TONE_ON: Sends a 22kHz tone burst to the antenna.
++ * @SEC_TONE_OFF: Don't send a 22kHz tone to the antenna (except
++ * if the ``FE_DISEQC_*`` ioctls are called).
++ */
+ enum fe_sec_tone_mode {
+ SEC_TONE_ON,
+ SEC_TONE_OFF
+ };
+
++/**
++ * enum fe_sec_mini_cmd - Type of mini burst to be sent
++ *
++ * @SEC_MINI_A: Sends a mini-DiSEqC 22kHz '0' Tone Burst to select
++ * satellite-A
++ * @SEC_MINI_B: Sends a mini-DiSEqC 22kHz '1' Data Burst to select
++ * satellite-B
++ */
+ enum fe_sec_mini_cmd {
+ SEC_MINI_A,
+ SEC_MINI_B
+ };
+
+ /**
+- * enum fe_status - enumerates the possible frontend status
+- * @FE_HAS_SIGNAL: found something above the noise level
+- * @FE_HAS_CARRIER: found a DVB signal
+- * @FE_HAS_VITERBI: FEC is stable
+- * @FE_HAS_SYNC: found sync bytes
+- * @FE_HAS_LOCK: everything's working
+- * @FE_TIMEDOUT: no lock within the last ~2 seconds
+- * @FE_REINIT: frontend was reinitialized, application is recommended
+- * to reset DiSEqC, tone and parameters
++ * enum fe_status - Enumerates the possible frontend status.
++ * @FE_NONE: The frontend doesn't have any kind of lock.
++ * That's the initial frontend status
++ * @FE_HAS_SIGNAL: Has found something above the noise level.
++ * @FE_HAS_CARRIER: Has found a DVB signal.
++ * @FE_HAS_VITERBI: FEC inner coding (Viterbi, LDPC or other inner code).
++ * is stable.
++ * @FE_HAS_SYNC: Synchronization bytes was found.
++ * @FE_HAS_LOCK: DVB were locked and everything is working.
++ * @FE_TIMEDOUT: Fo lock within the last about 2 seconds.
++ * @FE_REINIT: Frontend was reinitialized, application is recommended
++ * to reset DiSEqC, tone and parameters.
+ */
+ enum fe_status {
+ FE_NONE = 0x00,
+@@ -137,12 +259,45 @@ enum fe_status {
+ FE_REINIT = 0x40,
+ };
+
++/**
++ * enum fe_spectral_inversion - Type of inversion band
++ *
++ * @INVERSION_OFF: Don't do spectral band inversion.
++ * @INVERSION_ON: Do spectral band inversion.
++ * @INVERSION_AUTO: Autodetect spectral band inversion.
++ *
++ * This parameter indicates if spectral inversion should be presumed or
++ * not. In the automatic setting (``INVERSION_AUTO``) the hardware will try
++ * to figure out the correct setting by itself. If the hardware doesn't
++ * support, the DVB core will try to lock at the carrier first with
++ * inversion off. If it fails, it will try to enable inversion.
++ */
+ enum fe_spectral_inversion {
+ INVERSION_OFF,
+ INVERSION_ON,
+ INVERSION_AUTO
+ };
+
++/**
++ * enum fe_code_rate - Type of Forward Error Correction (FEC)
++ *
++ *
++ * @FEC_NONE: No Forward Error Correction Code
++ * @FEC_1_2: Forward Error Correction Code 1/2
++ * @FEC_2_3: Forward Error Correction Code 2/3
++ * @FEC_3_4: Forward Error Correction Code 3/4
++ * @FEC_4_5: Forward Error Correction Code 4/5
++ * @FEC_5_6: Forward Error Correction Code 5/6
++ * @FEC_6_7: Forward Error Correction Code 6/7
++ * @FEC_7_8: Forward Error Correction Code 7/8
++ * @FEC_8_9: Forward Error Correction Code 8/9
++ * @FEC_AUTO: Autodetect Error Correction Code
++ * @FEC_3_5: Forward Error Correction Code 3/5
++ * @FEC_9_10: Forward Error Correction Code 9/10
++ * @FEC_2_5: Forward Error Correction Code 2/5
++ *
++ * Please note that not all FEC types are supported by a given standard.
++ */
+ enum fe_code_rate {
+ FEC_NONE = 0,
+ FEC_1_2,
+@@ -159,6 +314,26 @@ enum fe_code_rate {
+ FEC_2_5,
+ };
+
++/**
++ * enum fe_modulation - Type of modulation/constellation
++ * @QPSK: QPSK modulation
++ * @QAM_16: 16-QAM modulation
++ * @QAM_32: 32-QAM modulation
++ * @QAM_64: 64-QAM modulation
++ * @QAM_128: 128-QAM modulation
++ * @QAM_256: 256-QAM modulation
++ * @QAM_AUTO: Autodetect QAM modulation
++ * @VSB_8: 8-VSB modulation
++ * @VSB_16: 16-VSB modulation
++ * @PSK_8: 8-PSK modulation
++ * @APSK_16: 16-APSK modulation
++ * @APSK_32: 32-APSK modulation
++ * @DQPSK: DQPSK modulation
++ * @QAM_4_NR: 4-QAM-NR modulation
++ *
++ * Please note that not all modulations are supported by a given standard.
++ *
++ */
+ enum fe_modulation {
+ QPSK,
+ QAM_16,
+@@ -176,6 +351,32 @@ enum fe_modulation {
+ QAM_4_NR,
+ };
+
++/**
++ * enum fe_transmit_mode - Transmission mode
++ *
++ * @TRANSMISSION_MODE_AUTO:
++ * Autodetect transmission mode. The hardware will try to find the
++ * correct FFT-size (if capable) to fill in the missing parameters.
++ * @TRANSMISSION_MODE_1K:
++ * Transmission mode 1K
++ * @TRANSMISSION_MODE_2K:
++ * Transmission mode 2K
++ * @TRANSMISSION_MODE_8K:
++ * Transmission mode 8K
++ * @TRANSMISSION_MODE_4K:
++ * Transmission mode 4K
++ * @TRANSMISSION_MODE_16K:
++ * Transmission mode 16K
++ * @TRANSMISSION_MODE_32K:
++ * Transmission mode 32K
++ * @TRANSMISSION_MODE_C1:
++ * Single Carrier (C=1) transmission mode (DTMB only)
++ * @TRANSMISSION_MODE_C3780:
++ * Multi Carrier (C=3780) transmission mode (DTMB only)
++ *
++ * Please note that not all transmission modes are supported by a given
++ * standard.
++ */
+ enum fe_transmit_mode {
+ TRANSMISSION_MODE_2K,
+ TRANSMISSION_MODE_8K,
+@@ -188,6 +389,23 @@ enum fe_transmit_mode {
+ TRANSMISSION_MODE_C3780,
+ };
+
++/**
++ * enum fe_guard_interval - Guard interval
++ *
++ * @GUARD_INTERVAL_AUTO: Autodetect the guard interval
++ * @GUARD_INTERVAL_1_128: Guard interval 1/128
++ * @GUARD_INTERVAL_1_32: Guard interval 1/32
++ * @GUARD_INTERVAL_1_16: Guard interval 1/16
++ * @GUARD_INTERVAL_1_8: Guard interval 1/8
++ * @GUARD_INTERVAL_1_4: Guard interval 1/4
++ * @GUARD_INTERVAL_19_128: Guard interval 19/128
++ * @GUARD_INTERVAL_19_256: Guard interval 19/256
++ * @GUARD_INTERVAL_PN420: PN length 420 (1/4)
++ * @GUARD_INTERVAL_PN595: PN length 595 (1/6)
++ * @GUARD_INTERVAL_PN945: PN length 945 (1/9)
++ *
++ * Please note that not all guard intervals are supported by a given standard.
++ */
+ enum fe_guard_interval {
+ GUARD_INTERVAL_1_32,
+ GUARD_INTERVAL_1_16,
+@@ -202,6 +420,16 @@ enum fe_guard_interval {
+ GUARD_INTERVAL_PN945,
+ };
+
++/**
++ * enum fe_hierarchy - Hierarchy
++ * @HIERARCHY_NONE: No hierarchy
++ * @HIERARCHY_AUTO: Autodetect hierarchy (if supported)
++ * @HIERARCHY_1: Hierarchy 1
++ * @HIERARCHY_2: Hierarchy 2
++ * @HIERARCHY_4: Hierarchy 4
++ *
++ * Please note that not all hierarchy types are supported by a given standard.
++ */
+ enum fe_hierarchy {
+ HIERARCHY_NONE,
+ HIERARCHY_1,
+@@ -210,6 +438,15 @@ enum fe_hierarchy {
+ HIERARCHY_AUTO
+ };
+
++/**
++ * enum fe_interleaving - Interleaving
++ * @INTERLEAVING_NONE: No interleaving.
++ * @INTERLEAVING_AUTO: Auto-detect interleaving.
++ * @INTERLEAVING_240: Interleaving of 240 symbols.
++ * @INTERLEAVING_720: Interleaving of 720 symbols.
++ *
++ * Please note that, currently, only DTMB uses it.
++ */
+ enum fe_interleaving {
+ INTERLEAVING_NONE,
+ INTERLEAVING_AUTO,
+@@ -217,7 +454,8 @@ enum fe_interleaving {
+ INTERLEAVING_720,
+ };
+
+-/* S2API Commands */
++/* DVBv5 property Commands */
++
+ #define DTV_UNDEFINED 0
+ #define DTV_TUNE 1
+ #define DTV_CLEAR 2
+@@ -310,19 +548,79 @@ enum fe_interleaving {
+
+ #define DTV_MAX_COMMAND DTV_STAT_TOTAL_BLOCK_COUNT
+
++/**
++ * enum fe_pilot - Type of pilot tone
++ *
++ * @PILOT_ON: Pilot tones enabled
++ * @PILOT_OFF: Pilot tones disabled
++ * @PILOT_AUTO: Autodetect pilot tones
++ */
+ enum fe_pilot {
+ PILOT_ON,
+ PILOT_OFF,
+ PILOT_AUTO,
+ };
+
++/**
++ * enum fe_rolloff - Rolloff factor (also known as alpha)
++ * @ROLLOFF_35: Roloff factor: 35%
++ * @ROLLOFF_20: Roloff factor: 20%
++ * @ROLLOFF_25: Roloff factor: 25%
++ * @ROLLOFF_AUTO: Auto-detect the roloff factor.
++ *
++ * .. note:
++ *
++ * Roloff factor of 35% is implied on DVB-S. On DVB-S2, it is default.
++ */
+ enum fe_rolloff {
+- ROLLOFF_35, /* Implied value in DVB-S, default for DVB-S2 */
++ ROLLOFF_35,
+ ROLLOFF_20,
+ ROLLOFF_25,
+ ROLLOFF_AUTO,
+ };
+
++/**
++ * enum fe_delivery_system - Type of the delivery system
++ *
++ * @SYS_UNDEFINED:
++ * Undefined standard. Generally, indicates an error
++ * @SYS_DVBC_ANNEX_A:
++ * Cable TV: DVB-C following ITU-T J.83 Annex A spec
++ * @SYS_DVBC_ANNEX_B:
++ * Cable TV: DVB-C following ITU-T J.83 Annex B spec (ClearQAM)
++ * @SYS_DVBC_ANNEX_C:
++ * Cable TV: DVB-C following ITU-T J.83 Annex C spec
++ * @SYS_ISDBC:
++ * Cable TV: ISDB-C (no drivers yet)
++ * @SYS_DVBT:
++ * Terrestrial TV: DVB-T
++ * @SYS_DVBT2:
++ * Terrestrial TV: DVB-T2
++ * @SYS_ISDBT:
++ * Terrestrial TV: ISDB-T
++ * @SYS_ATSC:
++ * Terrestrial TV: ATSC
++ * @SYS_ATSCMH:
++ * Terrestrial TV (mobile): ATSC-M/H
++ * @SYS_DTMB:
++ * Terrestrial TV: DTMB
++ * @SYS_DVBS:
++ * Satellite TV: DVB-S
++ * @SYS_DVBS2:
++ * Satellite TV: DVB-S2
++ * @SYS_TURBO:
++ * Satellite TV: DVB-S Turbo
++ * @SYS_ISDBS:
++ * Satellite TV: ISDB-S
++ * @SYS_DAB:
++ * Digital audio: DAB (not fully supported)
++ * @SYS_DSS:
++ * Satellite TV: DSS (not fully supported)
++ * @SYS_CMMB:
++ * Terrestrial TV (mobile): CMMB (not fully supported)
++ * @SYS_DVBH:
++ * Terrestrial TV (mobile): DVB-H (standard deprecated)
++ */
+ enum fe_delivery_system {
+ SYS_UNDEFINED,
+ SYS_DVBC_ANNEX_A,
+@@ -345,35 +643,85 @@ enum fe_delivery_system {
+ SYS_DVBC_ANNEX_C,
+ };
+
+-/* backward compatibility */
++/* backward compatibility definitions for delivery systems */
+ #define SYS_DVBC_ANNEX_AC SYS_DVBC_ANNEX_A
+-#define SYS_DMBTH SYS_DTMB /* DMB-TH is legacy name, use DTMB instead */
++#define SYS_DMBTH SYS_DTMB /* DMB-TH is legacy name, use DTMB */
+
+-/* ATSC-MH */
++/* ATSC-MH specific parameters */
+
++/**
++ * enum atscmh_sccc_block_mode - Type of Series Concatenated Convolutional
++ * Code Block Mode.
++ *
++ * @ATSCMH_SCCC_BLK_SEP:
++ * Separate SCCC: the SCCC outer code mode shall be set independently
++ * for each Group Region (A, B, C, D)
++ * @ATSCMH_SCCC_BLK_COMB:
++ * Combined SCCC: all four Regions shall have the same SCCC outer
++ * code mode.
++ * @ATSCMH_SCCC_BLK_RES:
++ * Reserved. Shouldn't be used.
++ */
+ enum atscmh_sccc_block_mode {
+ ATSCMH_SCCC_BLK_SEP = 0,
+ ATSCMH_SCCC_BLK_COMB = 1,
+ ATSCMH_SCCC_BLK_RES = 2,
+ };
+
++/**
++ * enum atscmh_sccc_code_mode - Type of Series Concatenated Convolutional
++ * Code Rate.
++ *
++ * @ATSCMH_SCCC_CODE_HLF:
++ * The outer code rate of a SCCC Block is 1/2 rate.
++ * @ATSCMH_SCCC_CODE_QTR:
++ * The outer code rate of a SCCC Block is 1/4 rate.
++ * @ATSCMH_SCCC_CODE_RES:
++ * Reserved. Should not be used.
++ */
+ enum atscmh_sccc_code_mode {
+ ATSCMH_SCCC_CODE_HLF = 0,
+ ATSCMH_SCCC_CODE_QTR = 1,
+ ATSCMH_SCCC_CODE_RES = 2,
+ };
+
++/**
++ * enum atscmh_rs_frame_ensemble - Reed Solomon(RS) frame ensemble.
++ *
++ * @ATSCMH_RSFRAME_ENS_PRI: Primary Ensemble.
++ * @ATSCMH_RSFRAME_ENS_SEC: Secondary Ensemble.
++ */
+ enum atscmh_rs_frame_ensemble {
+ ATSCMH_RSFRAME_ENS_PRI = 0,
+ ATSCMH_RSFRAME_ENS_SEC = 1,
+ };
+
++/**
++ * enum atscmh_rs_frame_mode - Reed Solomon (RS) frame mode.
++ *
++ * @ATSCMH_RSFRAME_PRI_ONLY:
++ * Single Frame: There is only a primary RS Frame for all Group
++ * Regions.
++ * @ATSCMH_RSFRAME_PRI_SEC:
++ * Dual Frame: There are two separate RS Frames: Primary RS Frame for
++ * Group Region A and B and Secondary RS Frame for Group Region C and
++ * D.
++ * @ATSCMH_RSFRAME_RES:
++ * Reserved. Shouldn't be used.
++ */
+ enum atscmh_rs_frame_mode {
+ ATSCMH_RSFRAME_PRI_ONLY = 0,
+ ATSCMH_RSFRAME_PRI_SEC = 1,
+ ATSCMH_RSFRAME_RES = 2,
+ };
+
++/**
++ * enum atscmh_rs_code_mode
++ * @ATSCMH_RSCODE_211_187: Reed Solomon code (211,187).
++ * @ATSCMH_RSCODE_223_187: Reed Solomon code (223,187).
++ * @ATSCMH_RSCODE_235_187: Reed Solomon code (235,187).
++ * @ATSCMH_RSCODE_RES: Reserved. Shouldn't be used.
++ */
+ enum atscmh_rs_code_mode {
+ ATSCMH_RSCODE_211_187 = 0,
+ ATSCMH_RSCODE_223_187 = 1,
+@@ -385,16 +733,17 @@ enum atscmh_rs_code_mode {
+ #define LNA_AUTO (~0U)
+
+ /**
+- * Scale types for the quality parameters.
++ * enum fecap_scale_params - scale types for the quality parameters.
++ *
+ * @FE_SCALE_NOT_AVAILABLE: That QoS measure is not available. That
+ * could indicate a temporary or a permanent
+ * condition.
+ * @FE_SCALE_DECIBEL: The scale is measured in 0.001 dB steps, typically
+- * used on signal measures.
++ * used on signal measures.
+ * @FE_SCALE_RELATIVE: The scale is a relative percentual measure,
+- * ranging from 0 (0%) to 0xffff (100%).
++ * ranging from 0 (0%) to 0xffff (100%).
+ * @FE_SCALE_COUNTER: The scale counts the occurrence of an event, like
+- * bit error, block error, lapsed time.
++ * bit error, block error, lapsed time.
+ */
+ enum fecap_scale_params {
+ FE_SCALE_NOT_AVAILABLE = 0,
+@@ -406,24 +755,38 @@ enum fecap_scale_params {
+ /**
+ * struct dtv_stats - Used for reading a DTV status property
+ *
+- * @value: value of the measure. Should range from 0 to 0xffff;
+ * @scale: Filled with enum fecap_scale_params - the scale
+ * in usage for that parameter
+ *
++ * The ``{unnamed_union}`` may have either one of the values below:
++ *
++ * %svalue
++ * integer value of the measure, for %FE_SCALE_DECIBEL,
++ * used for dB measures. The unit is 0.001 dB.
++ *
++ * %uvalue
++ * unsigned integer value of the measure, used when @scale is
++ * either %FE_SCALE_RELATIVE or %FE_SCALE_COUNTER.
++ *
+ * For most delivery systems, this will return a single value for each
+ * parameter.
++ *
+ * It should be noticed, however, that new OFDM delivery systems like
+ * ISDB can use different modulation types for each group of carriers.
+ * On such standards, up to 8 groups of statistics can be provided, one
+ * for each carrier group (called "layer" on ISDB).
++ *
+ * In order to be consistent with other delivery systems, the first
+ * value refers to the entire set of carriers ("global").
+- * dtv_status:scale should use the value FE_SCALE_NOT_AVAILABLE when
++ *
++ * @scale should use the value %FE_SCALE_NOT_AVAILABLE when
+ * the value for the entire group of carriers or from one specific layer
+ * is not provided by the hardware.
+- * st.len should be filled with the latest filled status + 1.
+ *
+- * In other words, for ISDB, those values should be filled like:
++ * @len should be filled with the latest filled status + 1.
++ *
++ * In other words, for ISDB, those values should be filled like::
++ *
+ * u.st.stat.svalue[0] = global statistics;
+ * u.st.stat.scale[0] = FE_SCALE_DECIBEL;
+ * u.st.stat.value[1] = layer A statistics;
+@@ -445,11 +808,39 @@ struct dtv_stats {
+
+ #define MAX_DTV_STATS 4
+
++/**
++ * struct dtv_fe_stats - store Digital TV frontend statistics
++ *
++ * @len: length of the statistics - if zero, stats is disabled.
++ * @stat: array with digital TV statistics.
++ *
++ * On most standards, @len can either be 0 or 1. However, for ISDB, each
++ * layer is modulated in separate. So, each layer may have its own set
++ * of statistics. If so, stat[0] carries on a global value for the property.
++ * Indexes 1 to 3 means layer A to B.
++ */
+ struct dtv_fe_stats {
+ __u8 len;
+ struct dtv_stats stat[MAX_DTV_STATS];
+ } __attribute__ ((packed));
+
++/**
++ * struct dtv_property - store one of frontend command and its value
++ *
++ * @cmd: Digital TV command.
++ * @reserved: Not used.
++ * @u: Union with the values for the command.
++ * @result: Result of the command set (currently unused).
++ *
++ * The @u union may have either one of the values below:
++ *
++ * %data
++ * an unsigned 32-bits number.
++ * %st
++ * a &struct dtv_fe_stats array of statistics.
++ * %buffer
++ * a buffer of up to 32 characters (currently unused).
++ */
+ struct dtv_property {
+ __u32 cmd;
+ __u32 reserved[3];
+@@ -469,17 +860,70 @@ struct dtv_property {
+ /* num of properties cannot exceed DTV_IOCTL_MAX_MSGS per ioctl */
+ #define DTV_IOCTL_MAX_MSGS 64
+
++/**
++ * struct dtv_properties - a set of command/value pairs.
++ *
++ * @num: amount of commands stored at the struct.
++ * @props: a pointer to &struct dtv_property.
++ */
+ struct dtv_properties {
+ __u32 num;
+ struct dtv_property *props;
+ };
+
++/*
++ * When set, this flag will disable any zigzagging or other "normal" tuning
++ * behavior. Additionally, there will be no automatic monitoring of the lock
++ * status, and hence no frontend events will be generated. If a frontend device
++ * is closed, this flag will be automatically turned off when the device is
++ * reopened read-write.
++ */
++#define FE_TUNE_MODE_ONESHOT 0x01
++
++/* Digital TV Frontend API calls */
++
++#define FE_GET_INFO _IOR('o', 61, struct dvb_frontend_info)
++
++#define FE_DISEQC_RESET_OVERLOAD _IO('o', 62)
++#define FE_DISEQC_SEND_MASTER_CMD _IOW('o', 63, struct dvb_diseqc_master_cmd)
++#define FE_DISEQC_RECV_SLAVE_REPLY _IOR('o', 64, struct dvb_diseqc_slave_reply)
++#define FE_DISEQC_SEND_BURST _IO('o', 65) /* fe_sec_mini_cmd_t */
++
++#define FE_SET_TONE _IO('o', 66) /* fe_sec_tone_mode_t */
++#define FE_SET_VOLTAGE _IO('o', 67) /* fe_sec_voltage_t */
++#define FE_ENABLE_HIGH_LNB_VOLTAGE _IO('o', 68) /* int */
++
++#define FE_READ_STATUS _IOR('o', 69, fe_status_t)
++#define FE_READ_BER _IOR('o', 70, __u32)
++#define FE_READ_SIGNAL_STRENGTH _IOR('o', 71, __u16)
++#define FE_READ_SNR _IOR('o', 72, __u16)
++#define FE_READ_UNCORRECTED_BLOCKS _IOR('o', 73, __u32)
++
++#define FE_SET_FRONTEND_TUNE_MODE _IO('o', 81) /* unsigned int */
++#define FE_GET_EVENT _IOR('o', 78, struct dvb_frontend_event)
++
++#define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */
++
++#define FE_SET_PROPERTY _IOW('o', 82, struct dtv_properties)
++#define FE_GET_PROPERTY _IOR('o', 83, struct dtv_properties)
++
+ #if defined(__DVB_CORE__) || !defined (__KERNEL__)
+
+ /*
+- * DEPRECATED: The DVBv3 ioctls, structs and enums should not be used on
+- * newer programs, as it doesn't support the second generation of digital
+- * TV standards, nor supports newer delivery systems.
++ * DEPRECATED: Everything below is deprecated in favor of DVBv5 API
++ *
++ * The DVBv3 only ioctls, structs and enums should not be used on
++ * newer programs, as it doesn't support the second generation of
++ * digital TV standards, nor supports newer delivery systems.
++ * They also don't support modern frontends with usually support multiple
++ * delivery systems.
++ *
++ * Drivers shouldn't use them.
++ *
++ * New applications should use DVBv5 delivery system instead
++ */
++
++/*
+ */
+
+ enum fe_bandwidth {
+@@ -492,7 +936,7 @@ enum fe_bandwidth {
+ BANDWIDTH_1_712_MHZ,
+ };
+
+-/* This is needed for legacy userspace support */
++/* This is kept for legacy userspace support */
+ typedef enum fe_sec_voltage fe_sec_voltage_t;
+ typedef enum fe_caps fe_caps_t;
+ typedef enum fe_type fe_type_t;
+@@ -510,6 +954,8 @@ typedef enum fe_pilot fe_pilot_t;
+ typedef enum fe_rolloff fe_rolloff_t;
+ typedef enum fe_delivery_system fe_delivery_system_t;
+
++/* DVBv3 structs */
++
+ struct dvb_qpsk_parameters {
+ __u32 symbol_rate; /* symbol rate in Symbols per second */
+ fe_code_rate_t fec_inner; /* forward error correction (see above) */
+@@ -551,42 +997,12 @@ struct dvb_frontend_event {
+ fe_status_t status;
+ struct dvb_frontend_parameters parameters;
+ };
+-#endif
+-
+-#define FE_SET_PROPERTY _IOW('o', 82, struct dtv_properties)
+-#define FE_GET_PROPERTY _IOR('o', 83, struct dtv_properties)
+-
+-/**
+- * When set, this flag will disable any zigzagging or other "normal" tuning
+- * behaviour. Additionally, there will be no automatic monitoring of the lock
+- * status, and hence no frontend events will be generated. If a frontend device
+- * is closed, this flag will be automatically turned off when the device is
+- * reopened read-write.
+- */
+-#define FE_TUNE_MODE_ONESHOT 0x01
+
+-#define FE_GET_INFO _IOR('o', 61, struct dvb_frontend_info)
+-
+-#define FE_DISEQC_RESET_OVERLOAD _IO('o', 62)
+-#define FE_DISEQC_SEND_MASTER_CMD _IOW('o', 63, struct dvb_diseqc_master_cmd)
+-#define FE_DISEQC_RECV_SLAVE_REPLY _IOR('o', 64, struct dvb_diseqc_slave_reply)
+-#define FE_DISEQC_SEND_BURST _IO('o', 65) /* fe_sec_mini_cmd_t */
+-
+-#define FE_SET_TONE _IO('o', 66) /* fe_sec_tone_mode_t */
+-#define FE_SET_VOLTAGE _IO('o', 67) /* fe_sec_voltage_t */
+-#define FE_ENABLE_HIGH_LNB_VOLTAGE _IO('o', 68) /* int */
+-
+-#define FE_READ_STATUS _IOR('o', 69, fe_status_t)
+-#define FE_READ_BER _IOR('o', 70, __u32)
+-#define FE_READ_SIGNAL_STRENGTH _IOR('o', 71, __u16)
+-#define FE_READ_SNR _IOR('o', 72, __u16)
+-#define FE_READ_UNCORRECTED_BLOCKS _IOR('o', 73, __u32)
++/* DVBv3 API calls */
+
+ #define FE_SET_FRONTEND _IOW('o', 76, struct dvb_frontend_parameters)
+ #define FE_GET_FRONTEND _IOR('o', 77, struct dvb_frontend_parameters)
+-#define FE_SET_FRONTEND_TUNE_MODE _IO('o', 81) /* unsigned int */
+-#define FE_GET_EVENT _IOR('o', 78, struct dvb_frontend_event)
+
+-#define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */
++#endif
+
+ #endif /*_DVBFRONTEND_H_*/
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:00 -0700
+Subject: media: dvb/frontend.h: move out a private internal structure
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Jaedon Shin <jaedon.shin@gmail.com>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-4-florian.fainelli@broadcom.com>
+
+From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+
+commit f35afa4f60c868d7c7811ba747133acbf39410ac upstream
+
+struct dtv_cmds_h is just an ancillary struct used by the
+dvb_frontend.c to internally store frontend commands.
+
+It doesn't belong to the userspace header, nor it is used anywhere,
+except inside the DVB core. So, remove it from the header.
+
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-core/dvb_frontend.c | 11 +++++++++++
+ include/uapi/linux/dvb/frontend.h | 11 -----------
+ 2 files changed, 11 insertions(+), 11 deletions(-)
+
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -998,6 +998,17 @@ static int dvb_frontend_clear_cache(stru
+ .buffer = b \
+ }
+
++struct dtv_cmds_h {
++ char *name; /* A display name for debugging purposes */
++
++ __u32 cmd; /* A unique ID */
++
++ /* Flags */
++ __u32 set:1; /* Either a set or get property */
++ __u32 buffer:1; /* Does this property use the buffer? */
++ __u32 reserved:30; /* Align */
++};
++
+ static struct dtv_cmds_h dtv_cmds[DTV_MAX_COMMAND + 1] = {
+ _DTV_CMD(DTV_TUNE, 1, 0),
+ _DTV_CMD(DTV_CLEAR, 1, 0),
+--- a/include/uapi/linux/dvb/frontend.h
++++ b/include/uapi/linux/dvb/frontend.h
+@@ -384,17 +384,6 @@ enum atscmh_rs_code_mode {
+ #define NO_STREAM_ID_FILTER (~0U)
+ #define LNA_AUTO (~0U)
+
+-struct dtv_cmds_h {
+- char *name; /* A display name for debugging purposes */
+-
+- __u32 cmd; /* A unique ID */
+-
+- /* Flags */
+- __u32 set:1; /* Either a set or get property */
+- __u32 buffer:1; /* Does this property use the buffer? */
+- __u32 reserved:30; /* Align */
+-};
+-
+ /**
+ * Scale types for the quality parameters.
+ * @FE_SCALE_NOT_AVAILABLE: That QoS measure is not available. That
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:16 -0700
+Subject: media: dvb_frontend: Add commands implementation for compat ioct
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Jaedon Shin <jaedon.shin@gmail.com>, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-20-florian.fainelli@broadcom.com>
+
+From: Jaedon Shin <jaedon.shin@gmail.com>
+
+commit 18192a77f0810933ab71a46c1b260d230d7352ee upstream
+
+The dtv_properties structure and the dtv_property structure are
+different sizes in 32-bit and 64-bit system. This patch provides
+FE_SET_PROPERTY and FE_GET_PROPERTY ioctl commands implementation for
+32-bit user space applications.
+
+Signed-off-by: Jaedon Shin <jaedon.shin@gmail.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-core/dvb_frontend.c | 131 ++++++++++++++++++++++++++++++++++
+ 1 file changed, 131 insertions(+)
+
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -1983,9 +1983,140 @@ static long dvb_frontend_ioctl(struct fi
+ }
+
+ #ifdef CONFIG_COMPAT
++struct compat_dtv_property {
++ __u32 cmd;
++ __u32 reserved[3];
++ union {
++ __u32 data;
++ struct dtv_fe_stats st;
++ struct {
++ __u8 data[32];
++ __u32 len;
++ __u32 reserved1[3];
++ compat_uptr_t reserved2;
++ } buffer;
++ } u;
++ int result;
++} __attribute__ ((packed));
++
++struct compat_dtv_properties {
++ __u32 num;
++ compat_uptr_t props;
++};
++
++#define COMPAT_FE_SET_PROPERTY _IOW('o', 82, struct compat_dtv_properties)
++#define COMPAT_FE_GET_PROPERTY _IOR('o', 83, struct compat_dtv_properties)
++
++static int dvb_frontend_handle_compat_ioctl(struct file *file, unsigned int cmd,
++ unsigned long arg)
++{
++ struct dvb_device *dvbdev = file->private_data;
++ struct dvb_frontend *fe = dvbdev->priv;
++ struct dvb_frontend_private *fepriv = fe->frontend_priv;
++ int i, err = 0;
++
++ if (cmd == COMPAT_FE_SET_PROPERTY) {
++ struct compat_dtv_properties prop, *tvps = NULL;
++ struct compat_dtv_property *tvp = NULL;
++
++ if (copy_from_user(&prop, compat_ptr(arg), sizeof(prop)))
++ return -EFAULT;
++
++ tvps = ∝
++
++ /*
++ * Put an arbitrary limit on the number of messages that can
++ * be sent at once
++ */
++ if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
++ return -EINVAL;
++
++ tvp = memdup_user(compat_ptr(tvps->props), tvps->num * sizeof(*tvp));
++ if (IS_ERR(tvp))
++ return PTR_ERR(tvp);
++
++ for (i = 0; i < tvps->num; i++) {
++ err = dtv_property_process_set(fe, file,
++ (tvp + i)->cmd,
++ (tvp + i)->u.data);
++ if (err < 0) {
++ kfree(tvp);
++ return err;
++ }
++ }
++ kfree(tvp);
++ } else if (cmd == COMPAT_FE_GET_PROPERTY) {
++ struct compat_dtv_properties prop, *tvps = NULL;
++ struct compat_dtv_property *tvp = NULL;
++ struct dtv_frontend_properties getp = fe->dtv_property_cache;
++
++ if (copy_from_user(&prop, compat_ptr(arg), sizeof(prop)))
++ return -EFAULT;
++
++ tvps = ∝
++
++ /*
++ * Put an arbitrary limit on the number of messages that can
++ * be sent at once
++ */
++ if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
++ return -EINVAL;
++
++ tvp = memdup_user(compat_ptr(tvps->props), tvps->num * sizeof(*tvp));
++ if (IS_ERR(tvp))
++ return PTR_ERR(tvp);
++
++ /*
++ * Let's use our own copy of property cache, in order to
++ * avoid mangling with DTV zigzag logic, as drivers might
++ * return crap, if they don't check if the data is available
++ * before updating the properties cache.
++ */
++ if (fepriv->state != FESTATE_IDLE) {
++ err = dtv_get_frontend(fe, &getp, NULL);
++ if (err < 0) {
++ kfree(tvp);
++ return err;
++ }
++ }
++ for (i = 0; i < tvps->num; i++) {
++ err = dtv_property_process_get(
++ fe, &getp, (struct dtv_property *)tvp + i, file);
++ if (err < 0) {
++ kfree(tvp);
++ return err;
++ }
++ }
++
++ if (copy_to_user((void __user *)compat_ptr(tvps->props), tvp,
++ tvps->num * sizeof(struct compat_dtv_property))) {
++ kfree(tvp);
++ return -EFAULT;
++ }
++ kfree(tvp);
++ }
++
++ return err;
++}
++
+ static long dvb_frontend_compat_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
+ {
++ struct dvb_device *dvbdev = file->private_data;
++ struct dvb_frontend *fe = dvbdev->priv;
++ struct dvb_frontend_private *fepriv = fe->frontend_priv;
++ int err;
++
++ if (cmd == COMPAT_FE_SET_PROPERTY || cmd == COMPAT_FE_GET_PROPERTY) {
++ if (down_interruptible(&fepriv->sem))
++ return -ERESTARTSYS;
++
++ err = dvb_frontend_handle_compat_ioctl(file, cmd, arg);
++
++ up(&fepriv->sem);
++ return err;
++ }
++
+ return dvb_frontend_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
+ }
+ #endif
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:15 -0700
+Subject: media: dvb_frontend: Add compat_ioctl callback
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Jaedon Shin <jaedon.shin@gmail.com>, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-19-florian.fainelli@broadcom.com>
+
+From: Jaedon Shin <jaedon.shin@gmail.com>
+
+commit c2dfd2276cec63a0c6f6ce18ed83800d96fde542 upstream
+
+Adds compat_ioctl for 32-bit user space applications on a 64-bit system.
+
+[m.chehab@osg.samsung.com: add missing include compat.h]
+Signed-off-by: Jaedon Shin <jaedon.shin@gmail.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-core/dvb_frontend.c | 12 ++++++++++++
+ fs/compat_ioctl.c | 17 -----------------
+ 2 files changed, 12 insertions(+), 17 deletions(-)
+
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -41,6 +41,7 @@
+ #include <linux/jiffies.h>
+ #include <linux/kthread.h>
+ #include <linux/ktime.h>
++#include <linux/compat.h>
+ #include <asm/processor.h>
+
+ #include "dvb_frontend.h"
+@@ -1981,6 +1982,14 @@ static long dvb_frontend_ioctl(struct fi
+ return dvb_usercopy(file, cmd, arg, dvb_frontend_do_ioctl);
+ }
+
++#ifdef CONFIG_COMPAT
++static long dvb_frontend_compat_ioctl(struct file *file, unsigned int cmd,
++ unsigned long arg)
++{
++ return dvb_frontend_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
++}
++#endif
++
+ static int dtv_set_frontend(struct dvb_frontend *fe)
+ {
+ struct dvb_frontend_private *fepriv = fe->frontend_priv;
+@@ -2651,6 +2660,9 @@ static int dvb_frontend_release(struct i
+ static const struct file_operations dvb_frontend_fops = {
+ .owner = THIS_MODULE,
+ .unlocked_ioctl = dvb_frontend_ioctl,
++#ifdef CONFIG_COMPAT
++ .compat_ioctl = dvb_frontend_compat_ioctl,
++#endif
+ .poll = dvb_frontend_poll,
+ .open = dvb_frontend_open,
+ .release = dvb_frontend_release,
+--- a/fs/compat_ioctl.c
++++ b/fs/compat_ioctl.c
+@@ -1340,23 +1340,6 @@ COMPATIBLE_IOCTL(DMX_GET_PES_PIDS)
+ COMPATIBLE_IOCTL(DMX_GET_CAPS)
+ COMPATIBLE_IOCTL(DMX_SET_SOURCE)
+ COMPATIBLE_IOCTL(DMX_GET_STC)
+-COMPATIBLE_IOCTL(FE_GET_INFO)
+-COMPATIBLE_IOCTL(FE_DISEQC_RESET_OVERLOAD)
+-COMPATIBLE_IOCTL(FE_DISEQC_SEND_MASTER_CMD)
+-COMPATIBLE_IOCTL(FE_DISEQC_RECV_SLAVE_REPLY)
+-COMPATIBLE_IOCTL(FE_DISEQC_SEND_BURST)
+-COMPATIBLE_IOCTL(FE_SET_TONE)
+-COMPATIBLE_IOCTL(FE_SET_VOLTAGE)
+-COMPATIBLE_IOCTL(FE_ENABLE_HIGH_LNB_VOLTAGE)
+-COMPATIBLE_IOCTL(FE_READ_STATUS)
+-COMPATIBLE_IOCTL(FE_READ_BER)
+-COMPATIBLE_IOCTL(FE_READ_SIGNAL_STRENGTH)
+-COMPATIBLE_IOCTL(FE_READ_SNR)
+-COMPATIBLE_IOCTL(FE_READ_UNCORRECTED_BLOCKS)
+-COMPATIBLE_IOCTL(FE_SET_FRONTEND)
+-COMPATIBLE_IOCTL(FE_GET_FRONTEND)
+-COMPATIBLE_IOCTL(FE_GET_EVENT)
+-COMPATIBLE_IOCTL(FE_DISHNETWORK_SEND_LEGACY_CMD)
+ COMPATIBLE_IOCTL(VIDEO_STOP)
+ COMPATIBLE_IOCTL(VIDEO_PLAY)
+ COMPATIBLE_IOCTL(VIDEO_FREEZE)
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:14 -0700
+Subject: media: dvb_frontend: Add unlocked_ioctl in dvb_frontend.c
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Jaedon Shin <jaedon.shin@gmail.com>, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-18-florian.fainelli@broadcom.com>
+
+From: Jaedon Shin <jaedon.shin@gmail.com>
+
+commit a2282fd1fe2ebcda480426dbfaaa7c4e87e27399 upstream
+
+Adds unlocked ioctl function directly in dvb_frontend.c instead of using
+dvb_generic_ioctl().
+
+Signed-off-by: Jaedon Shin <jaedon.shin@gmail.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-core/dvb_frontend.c | 17 ++++++++++++++---
+ 1 file changed, 14 insertions(+), 3 deletions(-)
+
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -1926,7 +1926,8 @@ static int dtv_property_process_set(stru
+ return r;
+ }
+
+-static int dvb_frontend_ioctl(struct file *file, unsigned int cmd, void *parg)
++static int dvb_frontend_do_ioctl(struct file *file, unsigned int cmd,
++ void *parg)
+ {
+ struct dvb_device *dvbdev = file->private_data;
+ struct dvb_frontend *fe = dvbdev->priv;
+@@ -1969,6 +1970,17 @@ static int dvb_frontend_ioctl(struct fil
+ return err;
+ }
+
++static long dvb_frontend_ioctl(struct file *file, unsigned int cmd,
++ unsigned long arg)
++{
++ struct dvb_device *dvbdev = file->private_data;
++
++ if (!dvbdev)
++ return -ENODEV;
++
++ return dvb_usercopy(file, cmd, arg, dvb_frontend_do_ioctl);
++}
++
+ static int dtv_set_frontend(struct dvb_frontend *fe)
+ {
+ struct dvb_frontend_private *fepriv = fe->frontend_priv;
+@@ -2638,7 +2650,7 @@ static int dvb_frontend_release(struct i
+
+ static const struct file_operations dvb_frontend_fops = {
+ .owner = THIS_MODULE,
+- .unlocked_ioctl = dvb_generic_ioctl,
++ .unlocked_ioctl = dvb_frontend_ioctl,
+ .poll = dvb_frontend_poll,
+ .open = dvb_frontend_open,
+ .release = dvb_frontend_release,
+@@ -2706,7 +2718,6 @@ int dvb_register_frontend(struct dvb_ada
+ #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
+ .name = fe->ops.info.name,
+ #endif
+- .kernel_ioctl = dvb_frontend_ioctl
+ };
+
+ dev_dbg(dvb->device, "%s:\n", __func__);
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:13 -0700
+Subject: media: dvb_frontend: be sure to init dvb_frontend_handle_ioctl() return code
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Jaedon Shin <jaedon.shin@gmail.com>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-17-florian.fainelli@broadcom.com>
+
+From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+
+commit a9cb97c3e628902e37583d8a40bb28cf76522cf1 upstream
+
+As smatch warned:
+ drivers/media/dvb-core/dvb_frontend.c:2468 dvb_frontend_handle_ioctl() error: uninitialized symbol 'err'.
+
+The ioctl handler actually got a regression here: before changeset
+d73dcf0cdb95 ("media: dvb_frontend: cleanup ioctl handling logic"),
+the code used to return -EOPNOTSUPP if an ioctl handler was not
+implemented on a driver. After the change, it may return a random
+value.
+
+Fixes: d73dcf0cdb95 ("media: dvb_frontend: cleanup ioctl handling logic")
+
+Cc: stable@vger.kernel.org
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Tested-by: Daniel Scheller <d.scheller@gmx.net>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-core/dvb_frontend.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -2113,7 +2113,7 @@ static int dvb_frontend_handle_ioctl(str
+ struct dvb_frontend *fe = dvbdev->priv;
+ struct dvb_frontend_private *fepriv = fe->frontend_priv;
+ struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+- int i, err;
++ int i, err = -EOPNOTSUPP;
+
+ dev_dbg(fe->dvb->device, "%s:\n", __func__);
+
+@@ -2148,6 +2148,7 @@ static int dvb_frontend_handle_ioctl(str
+ }
+ }
+ kfree(tvp);
++ err = 0;
+ break;
+ }
+ case FE_GET_PROPERTY: {
+@@ -2198,6 +2199,7 @@ static int dvb_frontend_handle_ioctl(str
+ return -EFAULT;
+ }
+ kfree(tvp);
++ err = 0;
+ break;
+ }
+
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:10 -0700
+Subject: media: dvb_frontend: better document the -EPERM condition
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Jaedon Shin <jaedon.shin@gmail.com>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-14-florian.fainelli@broadcom.com>
+
+From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+
+commit da5516b5e81d45a96291823620f6c820178dc055 upstream
+
+Two readonly ioctls can't be allowed if the frontend device
+is opened in read only mode. Explain why.
+
+Reviewed by: Shuah Khan <shuahkh@osg.samsung.com>
+
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-core/dvb_frontend.c | 20 +++++++++++++++++---
+ 1 file changed, 17 insertions(+), 3 deletions(-)
+
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -1925,9 +1925,23 @@ static int dvb_frontend_ioctl(struct fil
+ return -ENODEV;
+ }
+
+- if ((file->f_flags & O_ACCMODE) == O_RDONLY &&
+- (_IOC_DIR(cmd) != _IOC_READ || cmd == FE_GET_EVENT ||
+- cmd == FE_DISEQC_RECV_SLAVE_REPLY)) {
++ /*
++ * If the frontend is opened in read-only mode, only the ioctls
++ * that don't interfere with the tune logic should be accepted.
++ * That allows an external application to monitor the DVB QoS and
++ * statistics parameters.
++ *
++ * That matches all _IOR() ioctls, except for two special cases:
++ * - FE_GET_EVENT is part of the tuning logic on a DVB application;
++ * - FE_DISEQC_RECV_SLAVE_REPLY is part of DiSEqC 2.0
++ * setup
++ * So, those two ioctls should also return -EPERM, as otherwise
++ * reading from them would interfere with a DVB tune application
++ */
++ if ((file->f_flags & O_ACCMODE) == O_RDONLY
++ && (_IOC_DIR(cmd) != _IOC_READ
++ || cmd == FE_GET_EVENT
++ || cmd == FE_DISEQC_RECV_SLAVE_REPLY)) {
+ up(&fepriv->sem);
+ return -EPERM;
+ }
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:07 -0700
+Subject: media: dvb_frontend: cleanup dvb_frontend_ioctl_properties()
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Jaedon Shin <jaedon.shin@gmail.com>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-11-florian.fainelli@broadcom.com>
+
+From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+
+commit 2b5df42b8dec69fb926a242007fd462343db4408 upstream
+
+Use a switch() on this function, just like on other ioctl
+handlers and handle parameters inside each part of the
+switch.
+
+That makes it easier to integrate with the already existing
+ioctl handler function.
+
+Reviewed-by: Shuah Khan <shuahkh@osg.samsung.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-core/dvb_frontend.c | 85 ++++++++++++++++++++--------------
+ 1 file changed, 52 insertions(+), 33 deletions(-)
+
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -1956,21 +1956,25 @@ static int dvb_frontend_ioctl_properties
+ struct dvb_frontend *fe = dvbdev->priv;
+ struct dvb_frontend_private *fepriv = fe->frontend_priv;
+ struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+- int err = 0;
+-
+- struct dtv_properties *tvps = parg;
+- struct dtv_property *tvp = NULL;
+- int i;
++ int err, i;
+
+ dev_dbg(fe->dvb->device, "%s:\n", __func__);
+
+- if (cmd == FE_SET_PROPERTY) {
+- dev_dbg(fe->dvb->device, "%s: properties.num = %d\n", __func__, tvps->num);
+- dev_dbg(fe->dvb->device, "%s: properties.props = %p\n", __func__, tvps->props);
+-
+- /* Put an arbitrary limit on the number of messages that can
+- * be sent at once */
+- if ((tvps->num == 0) || (tvps->num > DTV_IOCTL_MAX_MSGS))
++ switch(cmd) {
++ case FE_SET_PROPERTY: {
++ struct dtv_properties *tvps = parg;
++ struct dtv_property *tvp = NULL;
++
++ dev_dbg(fe->dvb->device, "%s: properties.num = %d\n",
++ __func__, tvps->num);
++ dev_dbg(fe->dvb->device, "%s: properties.props = %p\n",
++ __func__, tvps->props);
++
++ /*
++ * Put an arbitrary limit on the number of messages that can
++ * be sent at once
++ */
++ if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
+ return -EINVAL;
+
+ tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
+@@ -1979,23 +1983,34 @@ static int dvb_frontend_ioctl_properties
+
+ for (i = 0; i < tvps->num; i++) {
+ err = dtv_property_process_set(fe, tvp + i, file);
+- if (err < 0)
+- goto out;
++ if (err < 0) {
++ kfree(tvp);
++ return err;
++ }
+ (tvp + i)->result = err;
+ }
+
+ if (c->state == DTV_TUNE)
+ dev_dbg(fe->dvb->device, "%s: Property cache is full, tuning\n", __func__);
+
+- } else if (cmd == FE_GET_PROPERTY) {
++ kfree(tvp);
++ break;
++ }
++ case FE_GET_PROPERTY: {
++ struct dtv_properties *tvps = parg;
++ struct dtv_property *tvp = NULL;
+ struct dtv_frontend_properties getp = fe->dtv_property_cache;
+
+- dev_dbg(fe->dvb->device, "%s: properties.num = %d\n", __func__, tvps->num);
+- dev_dbg(fe->dvb->device, "%s: properties.props = %p\n", __func__, tvps->props);
++ dev_dbg(fe->dvb->device, "%s: properties.num = %d\n",
++ __func__, tvps->num);
++ dev_dbg(fe->dvb->device, "%s: properties.props = %p\n",
++ __func__, tvps->props);
+
+- /* Put an arbitrary limit on the number of messages that can
+- * be sent at once */
+- if ((tvps->num == 0) || (tvps->num > DTV_IOCTL_MAX_MSGS))
++ /*
++ * Put an arbitrary limit on the number of messages that can
++ * be sent at once
++ */
++ if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
+ return -EINVAL;
+
+ tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
+@@ -2010,28 +2025,32 @@ static int dvb_frontend_ioctl_properties
+ */
+ if (fepriv->state != FESTATE_IDLE) {
+ err = dtv_get_frontend(fe, &getp, NULL);
+- if (err < 0)
+- goto out;
++ if (err < 0) {
++ kfree(tvp);
++ return err;
++ }
+ }
+ for (i = 0; i < tvps->num; i++) {
+ err = dtv_property_process_get(fe, &getp, tvp + i, file);
+- if (err < 0)
+- goto out;
++ if (err < 0) {
++ kfree(tvp);
++ return err;
++ }
+ (tvp + i)->result = err;
+ }
+
+ if (copy_to_user((void __user *)tvps->props, tvp,
+ tvps->num * sizeof(struct dtv_property))) {
+- err = -EFAULT;
+- goto out;
++ kfree(tvp);
++ return -EFAULT;
+ }
+-
+- } else
+- err = -EOPNOTSUPP;
+-
+-out:
+- kfree(tvp);
+- return err;
++ kfree(tvp);
++ break;
++ }
++ default:
++ return -ENOTSUPP;
++ } /* switch */
++ return 0;
+ }
+
+ static int dtv_set_frontend(struct dvb_frontend *fe)
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:08 -0700
+Subject: media: dvb_frontend: cleanup ioctl handling logic
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Jaedon Shin <jaedon.shin@gmail.com>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-12-florian.fainelli@broadcom.com>
+
+From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+
+commit d73dcf0cdb95a47f7e4e991ab63dd30f6eb67b4e upstream
+
+Currently, there are two handlers for ioctls:
+ - dvb_frontend_ioctl_properties()
+ - dvb_frontend_ioctl_legacy()
+
+Despite their names, both handles non-legacy DVB ioctls.
+
+Besides that, there's no reason why to not handle all ioctls
+on a single handler function.
+
+So, merge them into a single function (dvb_frontend_handle_ioctl)
+and reorganize the ioctl's to indicate what's the current DVB
+API and what's deprecated.
+
+Despite the big diff, the handling logic for each ioctl is the
+same as before.
+
+Reviewed-by: Shuah Khan <shuahkh@osg.samsung.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-core/dvb_frontend.c | 328 ++++++++++++++++------------------
+ 1 file changed, 158 insertions(+), 170 deletions(-)
+
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -1296,10 +1296,8 @@ static int dtv_get_frontend(struct dvb_f
+ return 0;
+ }
+
+-static int dvb_frontend_ioctl_legacy(struct file *file,
+- unsigned int cmd, void *parg);
+-static int dvb_frontend_ioctl_properties(struct file *file,
+- unsigned int cmd, void *parg);
++static int dvb_frontend_handle_ioctl(struct file *file,
++ unsigned int cmd, void *parg);
+
+ static int dtv_property_process_get(struct dvb_frontend *fe,
+ const struct dtv_frontend_properties *c,
+@@ -1801,12 +1799,12 @@ static int dtv_property_process_set(stru
+ break;
+ case DTV_VOLTAGE:
+ c->voltage = tvp->u.data;
+- r = dvb_frontend_ioctl_legacy(file, FE_SET_VOLTAGE,
++ r = dvb_frontend_handle_ioctl(file, FE_SET_VOLTAGE,
+ (void *)c->voltage);
+ break;
+ case DTV_TONE:
+ c->sectone = tvp->u.data;
+- r = dvb_frontend_ioctl_legacy(file, FE_SET_TONE,
++ r = dvb_frontend_handle_ioctl(file, FE_SET_TONE,
+ (void *)c->sectone);
+ break;
+ case DTV_CODE_RATE_HP:
+@@ -1913,14 +1911,13 @@ static int dtv_property_process_set(stru
+ return r;
+ }
+
+-static int dvb_frontend_ioctl(struct file *file,
+- unsigned int cmd, void *parg)
++static int dvb_frontend_ioctl(struct file *file, unsigned int cmd, void *parg)
+ {
+ struct dvb_device *dvbdev = file->private_data;
+ struct dvb_frontend *fe = dvbdev->priv;
+ struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+ struct dvb_frontend_private *fepriv = fe->frontend_priv;
+- int err = -EOPNOTSUPP;
++ int err;
+
+ dev_dbg(fe->dvb->device, "%s: (%d)\n", __func__, _IOC_NR(cmd));
+ if (down_interruptible(&fepriv->sem))
+@@ -1938,121 +1935,13 @@ static int dvb_frontend_ioctl(struct fil
+ return -EPERM;
+ }
+
+- if ((cmd == FE_SET_PROPERTY) || (cmd == FE_GET_PROPERTY))
+- err = dvb_frontend_ioctl_properties(file, cmd, parg);
+- else {
+- c->state = DTV_UNDEFINED;
+- err = dvb_frontend_ioctl_legacy(file, cmd, parg);
+- }
++ c->state = DTV_UNDEFINED;
++ err = dvb_frontend_handle_ioctl(file, cmd, parg);
+
+ up(&fepriv->sem);
+ return err;
+ }
+
+-static int dvb_frontend_ioctl_properties(struct file *file,
+- unsigned int cmd, void *parg)
+-{
+- struct dvb_device *dvbdev = file->private_data;
+- struct dvb_frontend *fe = dvbdev->priv;
+- struct dvb_frontend_private *fepriv = fe->frontend_priv;
+- struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+- int err, i;
+-
+- dev_dbg(fe->dvb->device, "%s:\n", __func__);
+-
+- switch(cmd) {
+- case FE_SET_PROPERTY: {
+- struct dtv_properties *tvps = parg;
+- struct dtv_property *tvp = NULL;
+-
+- dev_dbg(fe->dvb->device, "%s: properties.num = %d\n",
+- __func__, tvps->num);
+- dev_dbg(fe->dvb->device, "%s: properties.props = %p\n",
+- __func__, tvps->props);
+-
+- /*
+- * Put an arbitrary limit on the number of messages that can
+- * be sent at once
+- */
+- if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
+- return -EINVAL;
+-
+- tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
+- if (IS_ERR(tvp))
+- return PTR_ERR(tvp);
+-
+- for (i = 0; i < tvps->num; i++) {
+- err = dtv_property_process_set(fe, tvp + i, file);
+- if (err < 0) {
+- kfree(tvp);
+- return err;
+- }
+- (tvp + i)->result = err;
+- }
+-
+- if (c->state == DTV_TUNE)
+- dev_dbg(fe->dvb->device, "%s: Property cache is full, tuning\n", __func__);
+-
+- kfree(tvp);
+- break;
+- }
+- case FE_GET_PROPERTY: {
+- struct dtv_properties *tvps = parg;
+- struct dtv_property *tvp = NULL;
+- struct dtv_frontend_properties getp = fe->dtv_property_cache;
+-
+- dev_dbg(fe->dvb->device, "%s: properties.num = %d\n",
+- __func__, tvps->num);
+- dev_dbg(fe->dvb->device, "%s: properties.props = %p\n",
+- __func__, tvps->props);
+-
+- /*
+- * Put an arbitrary limit on the number of messages that can
+- * be sent at once
+- */
+- if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
+- return -EINVAL;
+-
+- tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
+- if (IS_ERR(tvp))
+- return PTR_ERR(tvp);
+-
+- /*
+- * Let's use our own copy of property cache, in order to
+- * avoid mangling with DTV zigzag logic, as drivers might
+- * return crap, if they don't check if the data is available
+- * before updating the properties cache.
+- */
+- if (fepriv->state != FESTATE_IDLE) {
+- err = dtv_get_frontend(fe, &getp, NULL);
+- if (err < 0) {
+- kfree(tvp);
+- return err;
+- }
+- }
+- for (i = 0; i < tvps->num; i++) {
+- err = dtv_property_process_get(fe, &getp, tvp + i, file);
+- if (err < 0) {
+- kfree(tvp);
+- return err;
+- }
+- (tvp + i)->result = err;
+- }
+-
+- if (copy_to_user((void __user *)tvps->props, tvp,
+- tvps->num * sizeof(struct dtv_property))) {
+- kfree(tvp);
+- return -EFAULT;
+- }
+- kfree(tvp);
+- break;
+- }
+- default:
+- return -ENOTSUPP;
+- } /* switch */
+- return 0;
+-}
+-
+ static int dtv_set_frontend(struct dvb_frontend *fe)
+ {
+ struct dvb_frontend_private *fepriv = fe->frontend_priv;
+@@ -2190,16 +2079,105 @@ static int dtv_set_frontend(struct dvb_f
+ }
+
+
+-static int dvb_frontend_ioctl_legacy(struct file *file,
+- unsigned int cmd, void *parg)
++static int dvb_frontend_handle_ioctl(struct file *file,
++ unsigned int cmd, void *parg)
+ {
+ struct dvb_device *dvbdev = file->private_data;
+ struct dvb_frontend *fe = dvbdev->priv;
+ struct dvb_frontend_private *fepriv = fe->frontend_priv;
+ struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+- int err = -EOPNOTSUPP;
++ int i, err;
++
++ dev_dbg(fe->dvb->device, "%s:\n", __func__);
++
++ switch(cmd) {
++ case FE_SET_PROPERTY: {
++ struct dtv_properties *tvps = parg;
++ struct dtv_property *tvp = NULL;
++
++ dev_dbg(fe->dvb->device, "%s: properties.num = %d\n",
++ __func__, tvps->num);
++ dev_dbg(fe->dvb->device, "%s: properties.props = %p\n",
++ __func__, tvps->props);
++
++ /*
++ * Put an arbitrary limit on the number of messages that can
++ * be sent at once
++ */
++ if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
++ return -EINVAL;
++
++ tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
++ if (IS_ERR(tvp))
++ return PTR_ERR(tvp);
++
++ for (i = 0; i < tvps->num; i++) {
++ err = dtv_property_process_set(fe, tvp + i, file);
++ if (err < 0) {
++ kfree(tvp);
++ return err;
++ }
++ (tvp + i)->result = err;
++ }
++
++ if (c->state == DTV_TUNE)
++ dev_dbg(fe->dvb->device, "%s: Property cache is full, tuning\n", __func__);
++
++ kfree(tvp);
++ break;
++ }
++ case FE_GET_PROPERTY: {
++ struct dtv_properties *tvps = parg;
++ struct dtv_property *tvp = NULL;
++ struct dtv_frontend_properties getp = fe->dtv_property_cache;
++
++ dev_dbg(fe->dvb->device, "%s: properties.num = %d\n",
++ __func__, tvps->num);
++ dev_dbg(fe->dvb->device, "%s: properties.props = %p\n",
++ __func__, tvps->props);
++
++ /*
++ * Put an arbitrary limit on the number of messages that can
++ * be sent at once
++ */
++ if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
++ return -EINVAL;
++
++ tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
++ if (IS_ERR(tvp))
++ return PTR_ERR(tvp);
++
++ /*
++ * Let's use our own copy of property cache, in order to
++ * avoid mangling with DTV zigzag logic, as drivers might
++ * return crap, if they don't check if the data is available
++ * before updating the properties cache.
++ */
++ if (fepriv->state != FESTATE_IDLE) {
++ err = dtv_get_frontend(fe, &getp, NULL);
++ if (err < 0) {
++ kfree(tvp);
++ return err;
++ }
++ }
++ for (i = 0; i < tvps->num; i++) {
++ err = dtv_property_process_get(fe, &getp, tvp + i, file);
++ if (err < 0) {
++ kfree(tvp);
++ return err;
++ }
++ (tvp + i)->result = err;
++ }
++
++ if (copy_to_user((void __user *)tvps->props, tvp,
++ tvps->num * sizeof(struct dtv_property))) {
++ kfree(tvp);
++ return -EFAULT;
++ }
++ kfree(tvp);
++ break;
++ }
+
+- switch (cmd) {
+ case FE_GET_INFO: {
+ struct dvb_frontend_info* info = parg;
+
+@@ -2263,42 +2241,6 @@ static int dvb_frontend_ioctl_legacy(str
+ break;
+ }
+
+- case FE_READ_BER:
+- if (fe->ops.read_ber) {
+- if (fepriv->thread)
+- err = fe->ops.read_ber(fe, (__u32 *) parg);
+- else
+- err = -EAGAIN;
+- }
+- break;
+-
+- case FE_READ_SIGNAL_STRENGTH:
+- if (fe->ops.read_signal_strength) {
+- if (fepriv->thread)
+- err = fe->ops.read_signal_strength(fe, (__u16 *) parg);
+- else
+- err = -EAGAIN;
+- }
+- break;
+-
+- case FE_READ_SNR:
+- if (fe->ops.read_snr) {
+- if (fepriv->thread)
+- err = fe->ops.read_snr(fe, (__u16 *) parg);
+- else
+- err = -EAGAIN;
+- }
+- break;
+-
+- case FE_READ_UNCORRECTED_BLOCKS:
+- if (fe->ops.read_ucblocks) {
+- if (fepriv->thread)
+- err = fe->ops.read_ucblocks(fe, (__u32 *) parg);
+- else
+- err = -EAGAIN;
+- }
+- break;
+-
+ case FE_DISEQC_RESET_OVERLOAD:
+ if (fe->ops.diseqc_reset_overload) {
+ err = fe->ops.diseqc_reset_overload(fe);
+@@ -2350,6 +2292,23 @@ static int dvb_frontend_ioctl_legacy(str
+ }
+ break;
+
++ case FE_DISEQC_RECV_SLAVE_REPLY:
++ if (fe->ops.diseqc_recv_slave_reply)
++ err = fe->ops.diseqc_recv_slave_reply(fe, (struct dvb_diseqc_slave_reply*) parg);
++ break;
++
++ case FE_ENABLE_HIGH_LNB_VOLTAGE:
++ if (fe->ops.enable_high_lnb_voltage)
++ err = fe->ops.enable_high_lnb_voltage(fe, (long) parg);
++ break;
++
++ case FE_SET_FRONTEND_TUNE_MODE:
++ fepriv->tune_mode_flags = (unsigned long) parg;
++ err = 0;
++ break;
++
++ /* DEPRECATED dish control ioctls */
++
+ case FE_DISHNETWORK_SEND_LEGACY_CMD:
+ if (fe->ops.dishnetwork_send_legacy_command) {
+ err = fe->ops.dishnetwork_send_legacy_command(fe,
+@@ -2414,16 +2373,46 @@ static int dvb_frontend_ioctl_legacy(str
+ }
+ break;
+
+- case FE_DISEQC_RECV_SLAVE_REPLY:
+- if (fe->ops.diseqc_recv_slave_reply)
+- err = fe->ops.diseqc_recv_slave_reply(fe, (struct dvb_diseqc_slave_reply*) parg);
++ /* DEPRECATED statistics ioctls */
++
++ case FE_READ_BER:
++ if (fe->ops.read_ber) {
++ if (fepriv->thread)
++ err = fe->ops.read_ber(fe, (__u32 *) parg);
++ else
++ err = -EAGAIN;
++ }
+ break;
+
+- case FE_ENABLE_HIGH_LNB_VOLTAGE:
+- if (fe->ops.enable_high_lnb_voltage)
+- err = fe->ops.enable_high_lnb_voltage(fe, (long) parg);
++ case FE_READ_SIGNAL_STRENGTH:
++ if (fe->ops.read_signal_strength) {
++ if (fepriv->thread)
++ err = fe->ops.read_signal_strength(fe, (__u16 *) parg);
++ else
++ err = -EAGAIN;
++ }
++ break;
++
++ case FE_READ_SNR:
++ if (fe->ops.read_snr) {
++ if (fepriv->thread)
++ err = fe->ops.read_snr(fe, (__u16 *) parg);
++ else
++ err = -EAGAIN;
++ }
++ break;
++
++ case FE_READ_UNCORRECTED_BLOCKS:
++ if (fe->ops.read_ucblocks) {
++ if (fepriv->thread)
++ err = fe->ops.read_ucblocks(fe, (__u32 *) parg);
++ else
++ err = -EAGAIN;
++ }
+ break;
+
++ /* DEPRECATED DVBv3 ioctls */
++
+ case FE_SET_FRONTEND:
+ err = dvbv3_set_delivery_system(fe);
+ if (err)
+@@ -2450,11 +2439,10 @@ static int dvb_frontend_ioctl_legacy(str
+ err = dtv_get_frontend(fe, &getp, parg);
+ break;
+ }
+- case FE_SET_FRONTEND_TUNE_MODE:
+- fepriv->tune_mode_flags = (unsigned long) parg;
+- err = 0;
+- break;
+- }
++
++ default:
++ return -ENOTSUPP;
++ } /* switch */
+
+ return err;
+ }
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:12 -0700
+Subject: media: dvb_frontend: dtv_property_process_set() cleanups
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Satendra Singh Thakur <satendra.t@samsung.com>, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Jaedon Shin <jaedon.shin@gmail.com>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-16-florian.fainelli@broadcom.com>
+
+From: Satendra Singh Thakur <satendra.t@samsung.com>
+
+commit media: dvb_frontend: dtv_property_process_set() cleanups upstream
+
+Since all properties in the func dtv_property_process_set() use
+at most 4 bytes arguments, change the code to pass
+u32 cmd and u32 data as function arguments, instead of passing a
+pointer to the entire struct dtv_property *tvp.
+
+Instead of having a generic dtv_property_dump(), added its own
+properties debug logic in the dtv_property_process_set().
+
+Signed-off-by: Satendra Singh Thakur <satendra.t@samsung.com>
+Reviewed-by: Shuah Khan <shuahkh@osg.samsung.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-core/dvb_frontend.c | 125 +++++++++++++++++++---------------
+ 1 file changed, 72 insertions(+), 53 deletions(-)
+
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -1088,22 +1088,19 @@ static struct dtv_cmds_h dtv_cmds[DTV_MA
+ _DTV_CMD(DTV_STAT_TOTAL_BLOCK_COUNT, 0, 0),
+ };
+
+-static void dtv_property_dump(struct dvb_frontend *fe,
+- bool is_set,
++static void dtv_get_property_dump(struct dvb_frontend *fe,
+ struct dtv_property *tvp)
+ {
+ int i;
+
+ if (tvp->cmd <= 0 || tvp->cmd > DTV_MAX_COMMAND) {
+- dev_warn(fe->dvb->device, "%s: %s tvp.cmd = 0x%08x undefined\n",
+- __func__,
+- is_set ? "SET" : "GET",
++ dev_warn(fe->dvb->device, "%s: GET tvp.cmd = 0x%08x undefined\n"
++ , __func__,
+ tvp->cmd);
+ return;
+ }
+
+- dev_dbg(fe->dvb->device, "%s: %s tvp.cmd = 0x%08x (%s)\n", __func__,
+- is_set ? "SET" : "GET",
++ dev_dbg(fe->dvb->device, "%s: GET tvp.cmd = 0x%08x (%s)\n", __func__,
+ tvp->cmd,
+ dtv_cmds[tvp->cmd].name);
+
+@@ -1513,7 +1510,7 @@ static int dtv_property_process_get(stru
+ return -EINVAL;
+ }
+
+- dtv_property_dump(fe, false, tvp);
++ dtv_get_property_dump(fe, tvp);
+
+ return 0;
+ }
+@@ -1740,16 +1737,36 @@ static int dvbv3_set_delivery_system(str
+ return emulate_delivery_system(fe, delsys);
+ }
+
++/**
++ * dtv_property_process_set - Sets a single DTV property
++ * @fe: Pointer to &struct dvb_frontend
++ * @file: Pointer to &struct file
++ * @cmd: Digital TV command
++ * @data: An unsigned 32-bits number
++ *
++ * This routine assigns the property
++ * value to the corresponding member of
++ * &struct dtv_frontend_properties
++ *
++ * Returns:
++ * Zero on success, negative errno on failure.
++ */
+ static int dtv_property_process_set(struct dvb_frontend *fe,
+- struct dtv_property *tvp,
+- struct file *file)
++ struct file *file,
++ u32 cmd, u32 data)
+ {
+ int r = 0;
+ struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+
+- dtv_property_dump(fe, true, tvp);
+-
+- switch(tvp->cmd) {
++ /** Dump DTV command name and value*/
++ if (!cmd || cmd > DTV_MAX_COMMAND)
++ dev_warn(fe->dvb->device, "%s: SET cmd 0x%08x undefined\n",
++ __func__, cmd);
++ else
++ dev_dbg(fe->dvb->device,
++ "%s: SET cmd 0x%08x (%s) to 0x%08x\n",
++ __func__, cmd, dtv_cmds[cmd].name, data);
++ switch (cmd) {
+ case DTV_CLEAR:
+ /*
+ * Reset a cache of data specific to the frontend here. This does
+@@ -1769,133 +1786,133 @@ static int dtv_property_process_set(stru
+ r = dtv_set_frontend(fe);
+ break;
+ case DTV_FREQUENCY:
+- c->frequency = tvp->u.data;
++ c->frequency = data;
+ break;
+ case DTV_MODULATION:
+- c->modulation = tvp->u.data;
++ c->modulation = data;
+ break;
+ case DTV_BANDWIDTH_HZ:
+- c->bandwidth_hz = tvp->u.data;
++ c->bandwidth_hz = data;
+ break;
+ case DTV_INVERSION:
+- c->inversion = tvp->u.data;
++ c->inversion = data;
+ break;
+ case DTV_SYMBOL_RATE:
+- c->symbol_rate = tvp->u.data;
++ c->symbol_rate = data;
+ break;
+ case DTV_INNER_FEC:
+- c->fec_inner = tvp->u.data;
++ c->fec_inner = data;
+ break;
+ case DTV_PILOT:
+- c->pilot = tvp->u.data;
++ c->pilot = data;
+ break;
+ case DTV_ROLLOFF:
+- c->rolloff = tvp->u.data;
++ c->rolloff = data;
+ break;
+ case DTV_DELIVERY_SYSTEM:
+- r = dvbv5_set_delivery_system(fe, tvp->u.data);
++ r = dvbv5_set_delivery_system(fe, data);
+ break;
+ case DTV_VOLTAGE:
+- c->voltage = tvp->u.data;
++ c->voltage = data;
+ r = dvb_frontend_handle_ioctl(file, FE_SET_VOLTAGE,
+ (void *)c->voltage);
+ break;
+ case DTV_TONE:
+- c->sectone = tvp->u.data;
++ c->sectone = data;
+ r = dvb_frontend_handle_ioctl(file, FE_SET_TONE,
+ (void *)c->sectone);
+ break;
+ case DTV_CODE_RATE_HP:
+- c->code_rate_HP = tvp->u.data;
++ c->code_rate_HP = data;
+ break;
+ case DTV_CODE_RATE_LP:
+- c->code_rate_LP = tvp->u.data;
++ c->code_rate_LP = data;
+ break;
+ case DTV_GUARD_INTERVAL:
+- c->guard_interval = tvp->u.data;
++ c->guard_interval = data;
+ break;
+ case DTV_TRANSMISSION_MODE:
+- c->transmission_mode = tvp->u.data;
++ c->transmission_mode = data;
+ break;
+ case DTV_HIERARCHY:
+- c->hierarchy = tvp->u.data;
++ c->hierarchy = data;
+ break;
+ case DTV_INTERLEAVING:
+- c->interleaving = tvp->u.data;
++ c->interleaving = data;
+ break;
+
+ /* ISDB-T Support here */
+ case DTV_ISDBT_PARTIAL_RECEPTION:
+- c->isdbt_partial_reception = tvp->u.data;
++ c->isdbt_partial_reception = data;
+ break;
+ case DTV_ISDBT_SOUND_BROADCASTING:
+- c->isdbt_sb_mode = tvp->u.data;
++ c->isdbt_sb_mode = data;
+ break;
+ case DTV_ISDBT_SB_SUBCHANNEL_ID:
+- c->isdbt_sb_subchannel = tvp->u.data;
++ c->isdbt_sb_subchannel = data;
+ break;
+ case DTV_ISDBT_SB_SEGMENT_IDX:
+- c->isdbt_sb_segment_idx = tvp->u.data;
++ c->isdbt_sb_segment_idx = data;
+ break;
+ case DTV_ISDBT_SB_SEGMENT_COUNT:
+- c->isdbt_sb_segment_count = tvp->u.data;
++ c->isdbt_sb_segment_count = data;
+ break;
+ case DTV_ISDBT_LAYER_ENABLED:
+- c->isdbt_layer_enabled = tvp->u.data;
++ c->isdbt_layer_enabled = data;
+ break;
+ case DTV_ISDBT_LAYERA_FEC:
+- c->layer[0].fec = tvp->u.data;
++ c->layer[0].fec = data;
+ break;
+ case DTV_ISDBT_LAYERA_MODULATION:
+- c->layer[0].modulation = tvp->u.data;
++ c->layer[0].modulation = data;
+ break;
+ case DTV_ISDBT_LAYERA_SEGMENT_COUNT:
+- c->layer[0].segment_count = tvp->u.data;
++ c->layer[0].segment_count = data;
+ break;
+ case DTV_ISDBT_LAYERA_TIME_INTERLEAVING:
+- c->layer[0].interleaving = tvp->u.data;
++ c->layer[0].interleaving = data;
+ break;
+ case DTV_ISDBT_LAYERB_FEC:
+- c->layer[1].fec = tvp->u.data;
++ c->layer[1].fec = data;
+ break;
+ case DTV_ISDBT_LAYERB_MODULATION:
+- c->layer[1].modulation = tvp->u.data;
++ c->layer[1].modulation = data;
+ break;
+ case DTV_ISDBT_LAYERB_SEGMENT_COUNT:
+- c->layer[1].segment_count = tvp->u.data;
++ c->layer[1].segment_count = data;
+ break;
+ case DTV_ISDBT_LAYERB_TIME_INTERLEAVING:
+- c->layer[1].interleaving = tvp->u.data;
++ c->layer[1].interleaving = data;
+ break;
+ case DTV_ISDBT_LAYERC_FEC:
+- c->layer[2].fec = tvp->u.data;
++ c->layer[2].fec = data;
+ break;
+ case DTV_ISDBT_LAYERC_MODULATION:
+- c->layer[2].modulation = tvp->u.data;
++ c->layer[2].modulation = data;
+ break;
+ case DTV_ISDBT_LAYERC_SEGMENT_COUNT:
+- c->layer[2].segment_count = tvp->u.data;
++ c->layer[2].segment_count = data;
+ break;
+ case DTV_ISDBT_LAYERC_TIME_INTERLEAVING:
+- c->layer[2].interleaving = tvp->u.data;
++ c->layer[2].interleaving = data;
+ break;
+
+ /* Multistream support */
+ case DTV_STREAM_ID:
+ case DTV_DVBT2_PLP_ID_LEGACY:
+- c->stream_id = tvp->u.data;
++ c->stream_id = data;
+ break;
+
+ /* ATSC-MH */
+ case DTV_ATSCMH_PARADE_ID:
+- fe->dtv_property_cache.atscmh_parade_id = tvp->u.data;
++ fe->dtv_property_cache.atscmh_parade_id = data;
+ break;
+ case DTV_ATSCMH_RS_FRAME_ENSEMBLE:
+- fe->dtv_property_cache.atscmh_rs_frame_ensemble = tvp->u.data;
++ fe->dtv_property_cache.atscmh_rs_frame_ensemble = data;
+ break;
+
+ case DTV_LNA:
+- c->lna = tvp->u.data;
++ c->lna = data;
+ if (fe->ops.set_lna)
+ r = fe->ops.set_lna(fe);
+ if (r < 0)
+@@ -2122,7 +2139,9 @@ static int dvb_frontend_handle_ioctl(str
+ return PTR_ERR(tvp);
+
+ for (i = 0; i < tvps->num; i++) {
+- err = dtv_property_process_set(fe, tvp + i, file);
++ err = dtv_property_process_set(fe, file,
++ (tvp + i)->cmd,
++ (tvp + i)->u.data);
+ if (err < 0) {
+ kfree(tvp);
+ return err;
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:18 -0700
+Subject: media: dvb_frontend: fix return error code
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Jaedon Shin <jaedon.shin@gmail.com>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-22-florian.fainelli@broadcom.com>
+
+From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+
+commit 330dada5957e3ca0c8811b14c45e3ac42c694651 upstream
+
+The correct error code when a function is not defined is
+-ENOTSUPP. It was typoed wrong as -EOPNOTSUPP, with,
+unfortunately, exists, but it is not used by the DVB core.
+
+Thanks-to: Geert Uytterhoeven <geert@linux-m68k.org>
+Thanks-to: Arnd Bergmann <arnd@arndb.de>
+
+To make me revisit this code.
+
+Fixes: a9cb97c3e628 ("media: dvb_frontend: be sure to init dvb_frontend_handle_ioctl() return code")
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-core/dvb_frontend.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -2265,7 +2265,7 @@ static int dvb_frontend_handle_ioctl(str
+ struct dvb_frontend *fe = dvbdev->priv;
+ struct dvb_frontend_private *fepriv = fe->frontend_priv;
+ struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+- int i, err = -EOPNOTSUPP;
++ int i, err = -ENOTSUPP;
+
+ dev_dbg(fe->dvb->device, "%s:\n", __func__);
+
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:11 -0700
+Subject: media: dvb_frontend: fix return values for FE_SET_PROPERTY
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Jaedon Shin <jaedon.shin@gmail.com>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-15-florian.fainelli@broadcom.com>
+
+From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+
+commit 259a41d9ae8f3689742267f340ad2b159d00b302 upstream
+
+There are several problems with regards to the return of
+FE_SET_PROPERTY. The original idea were to return per-property
+return codes via tvp->result field, and to return an updated
+set of values.
+
+However, that never worked. What's actually implemented is:
+
+- the FE_SET_PROPERTY implementation doesn't call .get_frontend
+ callback in order to get the actual parameters after return;
+
+- the tvp->result field is only filled if there's no error.
+ So, it is always filled with zero;
+
+- FE_SET_PROPERTY doesn't call memdup_user() nor any other
+ copy_to_user() function. So, any changes to the properties
+ will be lost;
+
+- FE_SET_PROPERTY is declared as a write-only ioctl (IOW).
+
+While we could fix the above, it could cause regressions.
+
+So, let's just assume what the code really does, updating
+the documentation accordingly and removing the logic that
+would update the discarded tvp->result.
+
+Reviewed-by: Shuah Khan <shuahkh@osg.samsung.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Documentation/media/uapi/dvb/fe-get-property.rst | 7 +++++--
+ drivers/media/dvb-core/dvb_frontend.c | 2 --
+ include/uapi/linux/dvb/frontend.h | 2 +-
+ 3 files changed, 6 insertions(+), 5 deletions(-)
+
+--- a/Documentation/media/uapi/dvb/fe-get-property.rst
++++ b/Documentation/media/uapi/dvb/fe-get-property.rst
+@@ -48,8 +48,11 @@ depends on the delivery system and on th
+
+ - This call requires read/write access to the device.
+
+- - At return, the values are updated to reflect the actual parameters
+- used.
++.. note::
++
++ At return, the values aren't updated to reflect the actual
++ parameters used. If the actual parameters are needed, an explicit
++ call to ``FE_GET_PROPERTY`` is needed.
+
+ - ``FE_GET_PROPERTY:``
+
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -2127,7 +2127,6 @@ static int dvb_frontend_handle_ioctl(str
+ kfree(tvp);
+ return err;
+ }
+- (tvp + i)->result = err;
+ }
+ kfree(tvp);
+ break;
+@@ -2172,7 +2171,6 @@ static int dvb_frontend_handle_ioctl(str
+ kfree(tvp);
+ return err;
+ }
+- (tvp + i)->result = err;
+ }
+
+ if (copy_to_user((void __user *)tvps->props, tvp,
+--- a/include/uapi/linux/dvb/frontend.h
++++ b/include/uapi/linux/dvb/frontend.h
+@@ -830,7 +830,7 @@ struct dtv_fe_stats {
+ * @cmd: Digital TV command.
+ * @reserved: Not used.
+ * @u: Union with the values for the command.
+- * @result: Result of the command set (currently unused).
++ * @result: Unused
+ *
+ * The @u union may have either one of the values below:
+ *
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:17 -0700
+Subject: media: dvb_frontend: fix wrong cast in compat_ioctl
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Jaedon Shin <jaedon.shin@gmail.com>, Colin Ian King <colin.king@canonical.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-21-florian.fainelli@broadcom.com>
+
+From: Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>
+
+commit 5c6c9c4830b76d851d38829611b3c3e4be0f5cdf upstream
+
+FE_GET_PROPERTY has always failed as following situations:
+ - Use compatible ioctl
+ - The array of 'struct dtv_property' has 2 or more items
+
+This patch fixes wrong cast to a pointer 'struct dtv_property' from a
+pointer of 2nd or after item of 'struct compat_dtv_property' array.
+
+Signed-off-by: Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-core/dvb_frontend.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -2081,7 +2081,7 @@ static int dvb_frontend_handle_compat_io
+ }
+ for (i = 0; i < tvps->num; i++) {
+ err = dtv_property_process_get(
+- fe, &getp, (struct dtv_property *)tvp + i, file);
++ fe, &getp, (struct dtv_property *)(tvp + i), file);
+ if (err < 0) {
+ kfree(tvp);
+ return err;
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:02 -0700
+Subject: [PATCH stable 4.9 05/21] media: dvb_frontend: get rid of get_property() callback
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Jaedon Shin <jaedon.shin@gmail.com>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-6-florian.fainelli@broadcom.com>
+
+From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+
+commit 8f8a19fcc1a89b83d0ab6d7cf2bcdd272dbd4334 upstream
+
+Only lg2160 implement gets_property, but there's no need for that,
+as no other driver calls this callback, as get_frontend() does the
+same, and set_frontend() also calls lg2160 get_frontend().
+
+So, get rid of it.
+
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-core/dvb_frontend.c | 9 +--------
+ drivers/media/dvb-core/dvb_frontend.h | 3 ---
+ drivers/media/dvb-frontends/lg2160.c | 14 --------------
+ 3 files changed, 1 insertion(+), 25 deletions(-)
+
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -1306,7 +1306,7 @@ static int dtv_property_process_get(stru
+ struct dtv_property *tvp,
+ struct file *file)
+ {
+- int r, ncaps;
++ int ncaps;
+
+ switch(tvp->cmd) {
+ case DTV_ENUM_DELSYS:
+@@ -1517,13 +1517,6 @@ static int dtv_property_process_get(stru
+ return -EINVAL;
+ }
+
+- /* Allow the frontend to override outgoing properties */
+- if (fe->ops.get_property) {
+- r = fe->ops.get_property(fe, tvp);
+- if (r < 0)
+- return r;
+- }
+-
+ dtv_property_dump(fe, false, tvp);
+
+ return 0;
+--- a/drivers/media/dvb-core/dvb_frontend.h
++++ b/drivers/media/dvb-core/dvb_frontend.h
+@@ -399,8 +399,6 @@ struct dtv_frontend_properties;
+ * @analog_ops: pointer to struct analog_demod_ops
+ * @set_property: callback function to allow the frontend to validade
+ * incoming properties. Should not be used on new drivers.
+- * @get_property: callback function to allow the frontend to override
+- * outcoming properties. Should not be used on new drivers.
+ */
+ struct dvb_frontend_ops {
+
+@@ -463,7 +461,6 @@ struct dvb_frontend_ops {
+ struct analog_demod_ops analog_ops;
+
+ int (*set_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
+- int (*get_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
+ };
+
+ #ifdef __DVB_CORE__
+--- a/drivers/media/dvb-frontends/lg2160.c
++++ b/drivers/media/dvb-frontends/lg2160.c
+@@ -1052,16 +1052,6 @@ fail:
+ return ret;
+ }
+
+-static int lg216x_get_property(struct dvb_frontend *fe,
+- struct dtv_property *tvp)
+-{
+- struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+-
+- return (DTV_ATSCMH_FIC_VER == tvp->cmd) ?
+- lg216x_get_frontend(fe, c) : 0;
+-}
+-
+-
+ static int lg2160_set_frontend(struct dvb_frontend *fe)
+ {
+ struct lg216x_state *state = fe->demodulator_priv;
+@@ -1372,8 +1362,6 @@ static struct dvb_frontend_ops lg2160_op
+ .init = lg216x_init,
+ .sleep = lg216x_sleep,
+ #endif
+- .get_property = lg216x_get_property,
+-
+ .set_frontend = lg2160_set_frontend,
+ .get_frontend = lg216x_get_frontend,
+ .get_tune_settings = lg216x_get_tune_settings,
+@@ -1400,8 +1388,6 @@ static struct dvb_frontend_ops lg2161_op
+ .init = lg216x_init,
+ .sleep = lg216x_sleep,
+ #endif
+- .get_property = lg216x_get_property,
+-
+ .set_frontend = lg2160_set_frontend,
+ .get_frontend = lg216x_get_frontend,
+ .get_tune_settings = lg216x_get_tune_settings,
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:09 -0700
+Subject: media: dvb_frontend: get rid of property cache's state
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Jaedon Shin <jaedon.shin@gmail.com>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-13-florian.fainelli@broadcom.com>
+
+From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+
+commit ef2cc27cf860b79874e9fde1419dd67c3372e41c upstream
+
+In the past, I guess the idea was to use state in order to
+allow an autofush logic. However, in the current code, it is
+used only for debug messages, on a poor man's solution, as
+there's already a debug message to indicate when the properties
+got flushed.
+
+So, just get rid of it for good.
+
+Reviewed-by: Shuah Khan <shuahkg@osg.samsung.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-core/dvb_frontend.c | 20 ++++++--------------
+ drivers/media/dvb-core/dvb_frontend.h | 5 -----
+ 2 files changed, 6 insertions(+), 19 deletions(-)
+
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -932,8 +932,6 @@ static int dvb_frontend_clear_cache(stru
+ memset(c, 0, offsetof(struct dtv_frontend_properties, strength));
+ c->delivery_system = delsys;
+
+- c->state = DTV_CLEAR;
+-
+ dev_dbg(fe->dvb->device, "%s: Clearing cache for delivery system %d\n",
+ __func__, c->delivery_system);
+
+@@ -1760,13 +1758,13 @@ static int dtv_property_process_set(stru
+ dvb_frontend_clear_cache(fe);
+ break;
+ case DTV_TUNE:
+- /* interpret the cache of data, build either a traditional frontend
+- * tunerequest so we can pass validation in the FE_SET_FRONTEND
+- * ioctl.
++ /*
++ * Use the cached Digital TV properties to tune the
++ * frontend
+ */
+- c->state = tvp->cmd;
+- dev_dbg(fe->dvb->device, "%s: Finalised property cache\n",
+- __func__);
++ dev_dbg(fe->dvb->device,
++ "%s: Setting the frontend from property cache\n",
++ __func__);
+
+ r = dtv_set_frontend(fe);
+ break;
+@@ -1915,7 +1913,6 @@ static int dvb_frontend_ioctl(struct fil
+ {
+ struct dvb_device *dvbdev = file->private_data;
+ struct dvb_frontend *fe = dvbdev->priv;
+- struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+ struct dvb_frontend_private *fepriv = fe->frontend_priv;
+ int err;
+
+@@ -1935,7 +1932,6 @@ static int dvb_frontend_ioctl(struct fil
+ return -EPERM;
+ }
+
+- c->state = DTV_UNDEFINED;
+ err = dvb_frontend_handle_ioctl(file, cmd, parg);
+
+ up(&fepriv->sem);
+@@ -2119,10 +2115,6 @@ static int dvb_frontend_handle_ioctl(str
+ }
+ (tvp + i)->result = err;
+ }
+-
+- if (c->state == DTV_TUNE)
+- dev_dbg(fe->dvb->device, "%s: Property cache is full, tuning\n", __func__);
+-
+ kfree(tvp);
+ break;
+ }
+--- a/drivers/media/dvb-core/dvb_frontend.h
++++ b/drivers/media/dvb-core/dvb_frontend.h
+@@ -615,11 +615,6 @@ struct dtv_frontend_properties {
+ struct dtv_fe_stats post_bit_count;
+ struct dtv_fe_stats block_error;
+ struct dtv_fe_stats block_count;
+-
+- /* private: */
+- /* Cache State */
+- u32 state;
+-
+ };
+
+ #define DVB_FE_NO_EXIT 0
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:06 -0700
+Subject: media: dvb_frontend: get rid of set_property() callback
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Jaedon Shin <jaedon.shin@gmail.com>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-10-florian.fainelli@broadcom.com>
+
+From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+
+commit 6680e73b5226114992acfc11f9cf5730f706fb01 upstream
+
+Now that all clients of set_property() were removed, get rid
+of this callback.
+
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-core/dvb_frontend.c | 7 -------
+ drivers/media/dvb-core/dvb_frontend.h | 5 -----
+ 2 files changed, 12 deletions(-)
+
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -1751,13 +1751,6 @@ static int dtv_property_process_set(stru
+ int r = 0;
+ struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+
+- /* Allow the frontend to validate incoming properties */
+- if (fe->ops.set_property) {
+- r = fe->ops.set_property(fe, tvp);
+- if (r < 0)
+- return r;
+- }
+-
+ dtv_property_dump(fe, true, tvp);
+
+ switch(tvp->cmd) {
+--- a/drivers/media/dvb-core/dvb_frontend.h
++++ b/drivers/media/dvb-core/dvb_frontend.h
+@@ -397,11 +397,8 @@ struct dtv_frontend_properties;
+ * @search: callback function used on some custom algo search algos.
+ * @tuner_ops: pointer to struct dvb_tuner_ops
+ * @analog_ops: pointer to struct analog_demod_ops
+- * @set_property: callback function to allow the frontend to validade
+- * incoming properties. Should not be used on new drivers.
+ */
+ struct dvb_frontend_ops {
+-
+ struct dvb_frontend_info info;
+
+ u8 delsys[MAX_DELSYS];
+@@ -459,8 +456,6 @@ struct dvb_frontend_ops {
+
+ struct dvb_tuner_ops tuner_ops;
+ struct analog_demod_ops analog_ops;
+-
+- int (*set_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
+ };
+
+ #ifdef __DVB_CORE__
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:05 -0700
+Subject: media: friio-fe: get rid of set_property()
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Jaedon Shin <jaedon.shin@gmail.com>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-9-florian.fainelli@broadcom.com>
+
+From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+
+commit b2c41ca9632e686e79f6c9db9c5f75666d37926e upstream
+
+This callback is not actually doing anything but making it to
+return an error depending on the DTV frontend command. Well,
+that could break userspace for no good reason, and, if needed,
+should be implemented, instead, at set_frontend() callback.
+
+So, get rid of it.
+
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/usb/dvb-usb/friio-fe.c | 24 ------------------------
+ 1 file changed, 24 deletions(-)
+
+--- a/drivers/media/usb/dvb-usb/friio-fe.c
++++ b/drivers/media/usb/dvb-usb/friio-fe.c
+@@ -261,28 +261,6 @@ static int jdvbt90502_read_signal_streng
+ return 0;
+ }
+
+-
+-/* filter out un-supported properties to notify users */
+-static int jdvbt90502_set_property(struct dvb_frontend *fe,
+- struct dtv_property *tvp)
+-{
+- int r = 0;
+-
+- switch (tvp->cmd) {
+- case DTV_DELIVERY_SYSTEM:
+- if (tvp->u.data != SYS_ISDBT)
+- r = -EINVAL;
+- break;
+- case DTV_CLEAR:
+- case DTV_TUNE:
+- case DTV_FREQUENCY:
+- break;
+- default:
+- r = -EINVAL;
+- }
+- return r;
+-}
+-
+ static int jdvbt90502_set_frontend(struct dvb_frontend *fe)
+ {
+ struct dtv_frontend_properties *p = &fe->dtv_property_cache;
+@@ -457,8 +435,6 @@ static struct dvb_frontend_ops jdvbt9050
+ .init = jdvbt90502_init,
+ .write = _jdvbt90502_write,
+
+- .set_property = jdvbt90502_set_property,
+-
+ .set_frontend = jdvbt90502_set_frontend,
+
+ .read_status = jdvbt90502_read_status,
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:03 -0700
+Subject: media: stv0288: get rid of set_property boilerplate
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Jaedon Shin <jaedon.shin@gmail.com>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-7-florian.fainelli@broadcom.com>
+
+From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+
+commit 473e4b4c1cf3046fc6b3437be9a9f3c89c2e61ef upstream
+
+This driver doesn't implement support for set_property(). Yet,
+it implements a boilerplate for it. Get rid of it.
+
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-frontends/stv0288.c | 7 -------
+ 1 file changed, 7 deletions(-)
+
+--- a/drivers/media/dvb-frontends/stv0288.c
++++ b/drivers/media/dvb-frontends/stv0288.c
+@@ -447,12 +447,6 @@ static int stv0288_read_ucblocks(struct
+ return 0;
+ }
+
+-static int stv0288_set_property(struct dvb_frontend *fe, struct dtv_property *p)
+-{
+- dprintk("%s(..)\n", __func__);
+- return 0;
+-}
+-
+ static int stv0288_set_frontend(struct dvb_frontend *fe)
+ {
+ struct stv0288_state *state = fe->demodulator_priv;
+@@ -568,7 +562,6 @@ static struct dvb_frontend_ops stv0288_o
+ .set_tone = stv0288_set_tone,
+ .set_voltage = stv0288_set_voltage,
+
+- .set_property = stv0288_set_property,
+ .set_frontend = stv0288_set_frontend,
+ };
+
--- /dev/null
+From foo@baz Tue 23 Jun 2020 09:03:02 PM CEST
+From: Florian Fainelli <f.fainelli@gmail.com>
+Date: Fri, 5 Jun 2020 09:25:04 -0700
+Subject: media: stv6110: get rid of a srate dead code
+To: linux-kernel@vger.kernel.org
+Cc: stable@vger.kernel.org, Mauro Carvalho Chehab <mchehab@s-opensource.com>, Florian Fainelli <f.fainelli@gmail.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Krufky <mkrufky@linuxtv.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Shuah Khan <shuah@kernel.org>, Jaedon Shin <jaedon.shin@gmail.com>, Colin Ian King <colin.king@canonical.com>, Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>, Satendra Singh Thakur <satendra.t@samsung.com>, linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure))
+Message-ID: <20200605162518.28099-8-florian.fainelli@broadcom.com>
+
+From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+
+commit 282996925b4d78f9795d176f7fb409281c98d56d upstream
+
+The stv6110 has a weird code that checks if get_property
+and set_property ioctls are defined. If they're, it initializes
+a "srate" var from properties cache. Otherwise, it sets to
+15MBaud, with won't make any sense.
+
+Thankfully, it seems that someone else discovered the issue in
+the past, as "srate" is currently not used anywhere!
+
+So, get rid of that really weird dead code logic.
+
+Reported-by: Honza Petrous <jpetrous@gmail.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
+Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/dvb-frontends/stv6110.c | 9 ---------
+ 1 file changed, 9 deletions(-)
+
+--- a/drivers/media/dvb-frontends/stv6110.c
++++ b/drivers/media/dvb-frontends/stv6110.c
+@@ -263,11 +263,9 @@ static int stv6110_get_frequency(struct
+ static int stv6110_set_frequency(struct dvb_frontend *fe, u32 frequency)
+ {
+ struct stv6110_priv *priv = fe->tuner_priv;
+- struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+ u8 ret = 0x04;
+ u32 divider, ref, p, presc, i, result_freq, vco_freq;
+ s32 p_calc, p_calc_opt = 1000, r_div, r_div_opt = 0, p_val;
+- s32 srate;
+
+ dprintk("%s, freq=%d kHz, mclk=%d Hz\n", __func__,
+ frequency, priv->mclk);
+@@ -278,13 +276,6 @@ static int stv6110_set_frequency(struct
+ ((((priv->mclk / 1000000) - 16) & 0x1f) << 3);
+
+ /* BB_GAIN = db/2 */
+- if (fe->ops.set_property && fe->ops.get_property) {
+- srate = c->symbol_rate;
+- dprintk("%s: Get Frontend parameters: srate=%d\n",
+- __func__, srate);
+- } else
+- srate = 15000000;
+-
+ priv->regs[RSTV6110_CTRL2] &= ~0x0f;
+ priv->regs[RSTV6110_CTRL2] |= (priv->gain & 0x0f);
+
sched-rt-net-use-config_preemption.patch.patch
net-core-device_rename-use-rwsem-instead-of-a-seqcou.patch
media-dvb_frontend-initialize-variable-s-with-fe_none-instead-of-0.patch
+media-dvb-frontend.h-move-out-a-private-internal-structure.patch
+media-dvb-frontend.h-document-the-uapi-file.patch
+media-dvb_frontend-get-rid-of-get_property-callback.patch
+media-stv0288-get-rid-of-set_property-boilerplate.patch
+media-stv6110-get-rid-of-a-srate-dead-code.patch
+media-friio-fe-get-rid-of-set_property.patch
+media-dvb_frontend-get-rid-of-set_property-callback.patch
+media-dvb_frontend-cleanup-dvb_frontend_ioctl_properties.patch
+media-dvb_frontend-cleanup-ioctl-handling-logic.patch
+media-dvb_frontend-get-rid-of-property-cache-s-state.patch
+media-dvb_frontend-better-document-the-eperm-condition.patch
+media-dvb_frontend-fix-return-values-for-fe_set_property.patch
+media-dvb_frontend-dtv_property_process_set-cleanups.patch
+media-dvb_frontend-be-sure-to-init-dvb_frontend_handle_ioctl-return-code.patch
+media-dvb_frontend-add-unlocked_ioctl-in-dvb_frontend.c.patch
+media-dvb_frontend-add-compat_ioctl-callback.patch
+media-dvb_frontend-add-commands-implementation-for-compat-ioct.patch
+media-dvb_frontend-fix-wrong-cast-in-compat_ioctl.patch
+media-dvb_frontend-fix-return-error-code.patch